[OE-core] [PATCH v4 7/7] wic: selftest: add tests for --fixed-size partition flags

Maciej Borzęcki maciej.borzecki at rndity.com
Wed Nov 23 11:47:31 UTC 2016


On Wed, Nov 23, 2016 at 12:36 PM, Ed Bartosh <ed.bartosh at linux.intel.com> wrote:
> Hi Maciej,
>
> Thank you for the patchset!
> The changes and the tests look good to me.
> I have little suggestions, but most of them just a matter of taste, so
> feel free to ignore them.
>
> On Wed, Nov 23, 2016 at 08:46:33AM +0100, Maciej Borzecki wrote:
>> wic has a new flag for setting a fixed parition size --fixed-size. Add
>> tests that verify if partition is indeed sized properly and that errors
>> are signaled when there is not enough space to fit partition data.
>>
>> Signed-off-by: Maciej Borzecki <maciej.borzecki at rndity.com>
>> ---
>>  meta/lib/oeqa/selftest/wic.py | 69 +++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 69 insertions(+)
>>
>> diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
>> index ad783043b92130a023fd70120becec479c6253a7..45f68df1e74828e11401f57dd732a88a50dd1f00 100644
>> --- a/meta/lib/oeqa/selftest/wic.py
>> +++ b/meta/lib/oeqa/selftest/wic.py
>> @@ -29,6 +29,7 @@ import unittest
>>  from glob import glob
>>  from shutil import rmtree
>>  from functools import wraps
>> +from tempfile import NamedTemporaryFile
>>
>>  from oeqa.selftest.base import oeSelfTest
>>  from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
>> @@ -61,6 +62,8 @@ class Wic(oeSelfTest):
>>
>>      def setUpLocal(self):
>>          """This code is executed before each test method."""
>> +        self.native_sysroot = get_bb_var('STAGING_DIR_NATIVE', 'core-image-minimal')
>> +
>>          arch = get_bb_var('HOST_ARCH', 'core-image-minimal')
>>          is_x86 = arch in ['i586', 'i686', 'x86_64']
>>          if is_x86:
>> @@ -378,3 +381,69 @@ class Wic(oeSelfTest):
>>          self.assertEqual(0, runCmd("wic create %(wks)s -e %(image)s" \
>>                                     % wic_cmd_vars).status)
>>          self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
>> +
>> +    def _make_fixed_size_wks(self, size):
>> +        """
>> +        Create a wks of an image with a single partition. Size of the partition is set
>> +        using --fixed-size flag. Returns a tuple: (path to wks file, wks image name)
>> +        """
>> +        with NamedTemporaryFile("w", suffix=".wks", delete=False) as tf:
>> +            wkspath = tf.name
>> +            tf.write("part " \
>> +                     "--source rootfs --ondisk hda --align 4 --fixed-size %d "
>> +                     "--fstype=ext4\n" % size)
>> +        wksname = os.path.splitext(os.path.basename(wkspath))[0]
>> +
>> +        return (wkspath, wksname)
> Would 'return wkspath, wksname' be a bit more readable?

Agreed.

-- 
Maciej Borzecki
RnDity



More information about the Openembedded-core mailing list