Openembedded Core Discussions
 help / color / mirror / Atom feed
From: "Paul Barker" <pbarker@konsulko.com>
To: Ricardo Ribalda Delgado <ricardo@ribalda.com>
Cc: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH v6 10/10] oeqa: wic: Add more tests for include_path
Date: Sat, 18 Apr 2020 21:10:46 +0100	[thread overview]
Message-ID: <20200418211046.01deeb05@ub1910> (raw)
In-Reply-To: <20200414133614.1830058-11-ricardo@ribalda.com>

On Tue, 14 Apr 2020 15:36:14 +0200
Ricardo Ribalda Delgado <ricardo@ribalda.com> wrote:

> Make sure permissions are respected.
> 
> Add new test for orig/destination option.
> 
> Cc: Paul Barker <pbarker@konsulko.com>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com>
> ---
>  meta/lib/oeqa/selftest/cases/wic.py | 64 ++++++++++++++++++++++++++++-
>  1 file changed, 63 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
> index 8ef08c3d77..1036269b64 100644
> --- a/meta/lib/oeqa/selftest/cases/wic.py
> +++ b/meta/lib/oeqa/selftest/cases/wic.py
> @@ -486,15 +486,77 @@ part /part2 --source rootfs --ondisk mmcblk0 --fstype=ext4 --include-path %s"""
>              res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part1))
>              files = extract_files(res.output)
>              self.assertNotIn('test-file', files)
> +            self.assertEqual(True, files_own_by_root(res.output))
>  
> -            # Test partition 2, should not contain 'test-file'
> +            # Test partition 2, should contain 'test-file'
>              res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part2))
>              files = extract_files(res.output)
>              self.assertIn('test-file', files)
> +            self.assertEqual(True, files_own_by_root(res.output))
>  
>          finally:
>              os.environ['PATH'] = oldpath
>  
> +    def test_include_path_embeded(self):
> +        """Test --include-path wks option."""
> +
> +        oldpath = os.environ['PATH']
> +        os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
> +
> +        try:
> +            include_path = os.path.join(self.resultdir, 'test-include')
> +            os.makedirs(include_path)
> +            with open(os.path.join(include_path, 'test-file'), 'w') as t:
> +                t.write("test\n")
> +            wks_file = os.path.join(include_path, 'temp.wks')
> +            with open(wks_file, 'w') as wks:
> +                rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
> +                wks.write("""
> +part / --source rootfs  --fstype=ext4 --include-path %s --include-path core-image-minimal-mtdutils export/"""
> +                          % (include_path))
> +            runCmd("wic create %s -e core-image-minimal -o %s" \
> +                                       % (wks_file, self.resultdir))
> +
> +            part1 = glob(os.path.join(self.resultdir, 'temp-*.direct.p1'))[0]
> +
> +            res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part1))
> +            files = extract_files(res.output)
> +            self.assertIn('test-file', files)
> +            self.assertEqual(True, files_own_by_root(res.output))
> +
> +            res = runCmd("debugfs -R 'ls -p /export/etc/' %s 2>/dev/null" % (part1))
> +            files = extract_files(res.output)
> +            self.assertIn('shadow', files)

This fails if `shadow` isn't part of the image:

2020-04-18 21:00:01,411 - oe-selftest - INFO - test_include_path_embeded (wic.Wic)
2020-04-18 21:00:14,102 - oe-selftest - INFO -  ... FAIL
2020-04-18 21:00:14,103 - oe-selftest - INFO - Traceback (most recent call last):
  File "/home/pbarker/Projects/Yocto/poky/meta/lib/oeqa/selftest/cases/wic.py", line 529, in test_include_path_embeded
    self.assertIn('shadow', files)
AssertionError: 'shadow' not found in [...]

> +            self.assertEqual(True, files_own_by_root(res.output))
> +
> +        finally:
> +            os.environ['PATH'] = oldpath
> +
> +    def test_include_path_errors(self):
> +        """Test --include-path wks option error handling."""
> +        wks_file = 'temp.wks'
> +
> +        # Absolute argument.
> +        with open(wks_file, 'w') as wks:
> +            wks.write("part / --source rootfs --fstype=ext4 --include-path core-image-minimal-mtdutils /export")
> +        self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
> +                                      % (wks_file, self.resultdir), ignore_status=True).status)
> +        os.remove(wks_file)
> +
> +        # Argument pointing to parent directory.
> +        with open(wks_file, 'w') as wks:
> +            wks.write("part / --source rootfs --fstype=ext4 --include-path core-image-minimal-mtdutils ././..")
> +        self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
> +                                      % (wks_file, self.resultdir), ignore_status=True).status)
> +        os.remove(wks_file)
> +
> +        # 3 Argument pointing to parent directory.
> +        with open(wks_file, 'w') as wks:
> +            wks.write("part / --source rootfs --fstype=ext4 --include-path core-image-minimal-mtdutils export/ dummy")
> +        self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
> +                                      % (wks_file, self.resultdir), ignore_status=True).status)
> +        os.remove(wks_file)
> +
>      def test_exclude_path_errors(self):
>          """Test --exclude-path wks option error handling."""
>          wks_file = 'temp.wks'



-- 
Paul Barker
Konsulko Group

  reply	other threads:[~2020-04-18 20:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 13:36 [PATCH v6 00/10] Fix permissions and embed-rotofs Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 01/10] wic: Fix permissions when using exclude or include path Ricardo Ribalda
2020-04-18 19:03   ` Paul Barker
2020-04-14 13:36 ` [PATCH v6 02/10] wic: Fix multi images .wks with bitbake Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 03/10] wic: Add --change-directory argument Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 04/10] wic: Continue if excluded_path does not exist Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 05/10] wic: Avoid creating invalid pseudo directory Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 06/10] oeqa: wic: Add tests for permissions and change-directory Ricardo Ribalda
2020-04-18 20:07   ` Paul Barker
2020-04-14 13:36 ` [PATCH v6 07/10] wic: misc: Do not find for executables in ALREADY_PROVIDED Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 08/10] wic: root: Add an opt. destination on include-path Ricardo Ribalda
2020-04-18 19:02   ` Paul Barker
2020-04-14 13:36 ` [PATCH v6 09/10] wic: rootfs: Combine path_validation in one function Ricardo Ribalda
2020-04-14 13:36 ` [PATCH v6 10/10] oeqa: wic: Add more tests for include_path Ricardo Ribalda
2020-04-18 20:10   ` Paul Barker [this message]
2020-04-18 20:16     ` [OE-core] " Ricardo Ribalda
     [not found]     ` <1607034A6B86A480.2683@lists.openembedded.org>
2020-04-18 21:39       ` Ricardo Ribalda

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=20200418211046.01deeb05@ub1910 \
    --to=pbarker@konsulko.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=ricardo@ribalda.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