Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: Maciej Borzecki <maciej.borzecki@rndity.com>
Cc: Paul Eggleton <paul.eggleton@linux.intel.com>,
	Maciej Borzecki <maciek.borzecki@gmail.com>,
	openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v4 7/7] wic: selftest: add tests for --fixed-size partition flags
Date: Wed, 23 Nov 2016 13:36:30 +0200	[thread overview]
Message-ID: <20161123113630.GB12545@linux.intel.com> (raw)
In-Reply-To: <7c765b6d3940a7b7dc9daeb32f712809a4b5464e.1479887010.git.maciej.borzecki@rndity.com>

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@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?

> +
> +    def test_fixed_size(self):
> +        """
> +        Test creation of a simple image with partition size controlled through
> +        --fixed-size flag
> +        """
> +        wkspath, wksname = self._make_fixed_size_wks(200)
> +
> +        wic_cmd_vars = {
> +            'wks': wkspath,
> +            'image': self.OE_IMAGE,
> +        }
> +        self.assertEqual(0, runCmd("wic create %(wks)s -e %(image)s" \
> +                                   % wic_cmd_vars).status)
> +        os.remove(wkspath)
> +        wicout = glob(self.resultdir + "%s-*direct" % wksname)
> +        self.assertEqual(1, len(wicout))
> +
> +        wicimg = wicout[0]
> +
> +        # verify partition size with wic
> +        res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg,
> +                     ignore_status=True,
> +                     native_sysroot=self.native_sysroot)
> +        self.assertEqual(0, res.status)
> +
> +        # parse parted output which looks like this:
> +        # BYT;\n
> +        # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
> +        # 1:0.00MiB:200MiB:200MiB:ext4::;\n
> +        partlns = res.output.splitlines()[2:]
> +
> +        self.assertEqual(1, len(partlns))
> +        self.assertEqual("1:0.00MiB:200MiB:200MiB:ext4::;", partlns[0])
> +
> +    def test_fixed_size_error(self):
> +        """
> +        Test creation of a simple image with partition size controlled through
> +        --fixed-size flag. The size of partition is intentionally set to 1MiB
> +        in order to trigger an error in wic.
> +        """
> +        wkspath, wksname = self._make_fixed_size_wks(1)
> +
> +        wic_cmd_vars = {
> +            'wks': wkspath,
> +            'image': self.OE_IMAGE,
> +        }
> +        self.assertEqual(1, runCmd("wic create %(wks)s -e %(image)s" \
> +                                   % wic_cmd_vars, ignore_status=True).status)
> +        os.remove(wkspath)
> +        wicout = glob(self.resultdir + "%s-*direct" % wksname)
> +        self.assertEqual(0, len(wicout))

--
Regards,
Ed


  reply	other threads:[~2016-11-23 11:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23  7:46 [PATCH v4 0/7] wic: bugfixes & --fixed-size support, tests, oe-selftest: minor fixes Maciej Borzecki
2016-11-23  7:46 ` [PATCH v4 1/7] oe-selftest: enforce en_US.UTF-8 locale Maciej Borzecki
2016-11-23  7:46 ` [PATCH v4 2/7] oeqa/utils/commands.py: allow use of binaries from native sysroot Maciej Borzecki
2016-11-23  7:46 ` [PATCH v4 3/7] wic: add --fixed-size wks option Maciej Borzecki
2016-11-23  7:46 ` [PATCH v4 4/7] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
2016-11-23  7:46 ` [PATCH v4 5/7] wic: selftest: do not repeat core-image-minimal Maciej Borzecki
2016-11-23 11:23   ` Ed Bartosh
2016-11-23 11:39     ` Maciej Borzęcki
2016-11-23 13:26       ` Ed Bartosh
2016-11-23  7:46 ` [PATCH v4 6/7] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
2016-11-23  7:46 ` [PATCH v4 7/7] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
2016-11-23 11:36   ` Ed Bartosh [this message]
2016-11-23 11:47     ` Maciej Borzęcki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161123113630.GB12545@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=maciej.borzecki@rndity.com \
    --cc=maciek.borzecki@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=paul.eggleton@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox