Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: Kristian Amlie <kristian.amlie@mender.io>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v2 3/3] selftest/wic: Add tests for --exclude-dir option.
Date: Fri, 16 Dec 2016 16:44:23 +0200	[thread overview]
Message-ID: <20161216144423.GB6398@linux.intel.com> (raw)
In-Reply-To: <1481732934-5128-4-git-send-email-kristian.amlie@mender.io>

On Wed, Dec 14, 2016 at 05:28:54PM +0100, Kristian Amlie wrote:
> Based partially on an earlier patch by Maciej Borzecki.
> 
> Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
> ---
>  meta/lib/oeqa/selftest/wic.py | 106 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 105 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
> index faac11e..b2b0fe8 100644
> --- a/meta/lib/oeqa/selftest/wic.py
> +++ b/meta/lib/oeqa/selftest/wic.py
> @@ -49,7 +49,8 @@ class Wic(oeSelfTest):
>          # setUpClass being unavailable.
>          if not Wic.image_is_ready:
>              bitbake('syslinux syslinux-native parted-native gptfdisk-native '
> -                    'dosfstools-native mtools-native bmap-tools-native')
> +                    'dosfstools-native mtools-native bmap-tools-native '
> +                    'e2tools-native')
>              bitbake('core-image-minimal')
>              Wic.image_is_ready = True
>  
> @@ -299,3 +300,106 @@ class Wic(oeSelfTest):
>          self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
>                                     % image).status)
>          self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
> +
> +    def test_exclude_path(self):
> +        """Test --exclude-path wks option."""
> +
> +        # For using 'e2ls'.
> +        old_path = os.environ['PATH']
> +        os.environ['PATH'] = get_bb_var('PATH', 'core-image-minimal')
> +
> +        wks_file = 'temp.wks'
> +        ks = open(wks_file, 'w')
I'd use more pythonic 'with open(wks_file, 'w') as wks:' here.

> +        rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
> +        ks.write("""part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path usr
> +part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr
> +part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr"""
> +                 % (rootfs_dir, rootfs_dir))
> +        ks.close()
> +        self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \
> +                                   % wks_file).status)
> +
> +        os.remove(wks_file)
> +        wicout = glob(self.resultdir + "%s-*direct" % 'temp')
> +        self.assertEqual(1, len(wicout))
> +
> +        wicimg = wicout[0]
> +
> +        # verify partition size with wic
> +        res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg)
> +        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(3, len(partlns))
> +
> +        for part in [1, 2, 3]:
> +            part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part)
> +            partln = partlns[part-1].split(":")
> +            self.assertEqual(7, len(partln))
> +            start = int(partln[1].rstrip("B")) / 512
> +            length = int(partln[3].rstrip("B")) / 512
> +            self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" %
> +                                       (wicimg, part_file, start, length)).status)
> +
> +        # Test partition 1, should contain the normal root directories, except
> +        # /usr.
> +        res = runCmd("e2ls %s" % os.path.join(self.resultdir, "selftest_img.part1"))
> +        self.assertEqual(0, res.status)
> +        files = res.output.split()
> +        self.assertIn("etc", files)
> +        self.assertNotIn("usr", files)
> +
> +        # Partition 2, should contain common directories for /usr, not root
> +        # directories.
> +        res = runCmd("e2ls %s" % os.path.join(self.resultdir, "selftest_img.part2"))
> +        self.assertEqual(0, res.status)
> +        files = res.output.split()
> +        self.assertNotIn("etc", files)
> +        self.assertNotIn("usr", files)
> +        self.assertIn("share", files)
> +
> +        # Partition 3, should contain the same as partition 2, including the bin
> +        # directory, but not the files inside it.
> +        res = runCmd("e2ls %s" % os.path.join(self.resultdir, "selftest_img.part3"))
> +        self.assertEqual(0, res.status)
> +        files = res.output.split()
> +        self.assertNotIn("etc", files)
> +        self.assertNotIn("usr", files)
> +        self.assertIn("share", files)
> +        self.assertIn("bin", files)
> +        res = runCmd("e2ls %s:bin" % os.path.join(self.resultdir, "selftest_img.part3"))
> +        self.assertEqual(0, res.status)
> +        self.assertEqual("No files found!", res.output.strip())
> +
> +        for part in [1, 2, 3]:
> +            part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part)
> +            os.remove(part_file)
> +
> +        os.environ['PATH'] = old_path
> +
> +    def test_exclude_path_errors(self):
> +        """Test --exclude-path wks option error handling."""
> +        wks_file = 'temp.wks'
> +
> +        rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
> +
> +        # Absolute argument.
> +        ks = open(wks_file, 'w')
and here
> +        ks.write("part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path /usr")
> +        ks.close()
> +        self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal" \
> +                                      % wks_file, ignore_status=True).status)
> +        os.remove(wks_file)
> +
> +        # Argument pointing to parent directory.
> +        ks = open(wks_file, 'w')
and here
> +        ks.write("part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path ././..")
> +        ks.close()
> +        self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal" \
> +                                      % wks_file, ignore_status=True).status)
> +        os.remove(wks_file)

--
Regards,
Ed


  reply	other threads:[~2016-12-16 14:44 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 10:15 [PATCH v1] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-11-25 10:33 ` Patrick Ohly
2016-11-25 12:07   ` Kristian Amlie
2016-11-25 16:31     ` Ed Bartosh
2016-11-28  7:15       ` Kristian Amlie
2016-11-28 10:52         ` Ed Bartosh
2016-11-28 11:01           ` Kristian Amlie
2016-11-28 11:18             ` Ed Bartosh
2016-11-30 13:30               ` Kristian Amlie
2016-11-30 13:37                 ` Maciej Borzęcki
2016-11-30 15:29                 ` Ed Bartosh
2016-11-30 19:29                   ` Paul Eggleton
2016-12-02 14:36                   ` Kristian Amlie
2016-12-02 15:05                     ` Ed Bartosh
2016-12-05 10:23                       ` Kristian Amlie
2016-12-14 16:28               ` [PATCH v2] " Kristian Amlie
2016-12-14 16:28                 ` [PATCH v2 1/3] " Kristian Amlie
2016-12-14 16:28                 ` [PATCH v2 2/3] Add e2tools recipe, in order to test contents of images Kristian Amlie
2016-12-14 16:28                 ` [PATCH v2 3/3] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2016-12-16 14:44                   ` Ed Bartosh [this message]
2016-12-19  9:09                     ` Kristian Amlie
2016-12-19  9:09                       ` [PATCH v3 1/3] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-12-19  9:09                       ` [PATCH v3 2/3] Add e2tools recipe, in order to test contents of images Kristian Amlie
2016-12-19  9:09                       ` [PATCH v3 3/3] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2016-12-19 20:49                         ` Burton, Ross
2016-12-20  9:20                           ` Kristian Amlie
2016-12-29 10:05                           ` Kristian Amlie
2016-12-29 10:05                             ` [PATCH v4 1/2] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-12-29 10:05                             ` [PATCH v4 2/2] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2016-12-29 10:23                               ` Kristian Amlie
2016-12-29 14:03                                 ` Kristian Amlie
2016-12-29 14:03                                   ` [PATCH v5 1/2] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-12-29 14:03                                   ` [PATCH v5 2/2] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2017-01-16  9:05                                   ` [PATCH v4 " Kristian Amlie
2017-02-06 16:16                                     ` Kristian Amlie
2017-02-06 16:16                                       ` [PATCH 1/2] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2017-02-06 16:16                                       ` [PATCH 2/2] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2017-02-06 16:38                                       ` [PATCH v4 " Ed Bartosh
2016-12-19 11:57                       ` [PATCH v2 3/3] " Ed Bartosh
2016-11-25 12:28 ` [PATCH v1] wic: Add --exclude-path option to rootfs source plugin Maciej Borzęcki
2016-11-25 12:35   ` Kristian Amlie
2016-11-25 16:33     ` Ed Bartosh
2016-11-28  7:07       ` Kristian Amlie
2016-11-28 10:46         ` Ed Bartosh
2016-11-28 11:00           ` Kristian Amlie
2017-02-06 16:29 ` ✗ patchtest: failure for wic: Add --exclude-path option to rootfs source plugin. (rev10) Patchwork
2017-02-06 16:29 ` ✗ patchtest: failure for wic: Add --exclude-path option to rootfs source plugin. (rev11) Patchwork
2017-02-07  7:23   ` Kristian Amlie

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=20161216144423.GB6398@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=kristian.amlie@mender.io \
    --cc=openembedded-core@lists.openembedded.org \
    /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