summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/wic.py
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2020-01-08 11:25:46 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-01-10 20:32:04 +0000
commitd4cd27a9837426e809190548a83c6c7c76505114 (patch)
tree27203bd06cc01655ea6c33ed596bce4eea4136a2 /meta/lib/oeqa/selftest/cases/wic.py
parent07b6b284204e912b5d08bdd0ca51b766ab7dd9c1 (diff)
downloadopenembedded-core-contrib-d4cd27a9837426e809190548a83c6c7c76505114.tar.gz
wic: Add --include-path argument
This option adds the contents of the given path to a partition built with the rootfs source plugin. The path is relative to the directory in which wic is running not the rootfs itself so use of an absolute path is recommended. This option is most useful when multiple copies of the rootfs are added to an image and it is required to add extra content to only one of these copies. This option only has an effect with the rootfs source plugin. Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/wic.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py73
1 files changed, 55 insertions, 18 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 3c5be2f501..46cd98b193 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -44,6 +44,24 @@ def only_for_arch(archs, image='core-image-minimal'):
return wrapped_f
return wrapper
+def extract_files(debugfs_output):
+ """
+ extract file names from the output of debugfs -R 'ls -p',
+ which looks like this:
+
+ /2/040755/0/0/.//\n
+ /2/040755/0/0/..//\n
+ /11/040700/0/0/lost+found^M//\n
+ /12/040755/1002/1002/run//\n
+ /13/040755/1002/1002/sys//\n
+ /14/040755/1002/1002/bin//\n
+ /80/040755/1002/1002/var//\n
+ /92/040755/1002/1002/tmp//\n
+ """
+ # NOTE the occasional ^M in file names
+ return [line.split('/')[5].strip() for line in \
+ debugfs_output.strip().split('/\n')]
+
class WicTestCase(OESelftestTestCase):
"""Wic test class."""
@@ -393,24 +411,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
runCmd("dd if=%s of=%s skip=%d count=%d" %
(wicimg, part_file, start, length))
- def extract_files(debugfs_output):
- """
- extract file names from the output of debugfs -R 'ls -p',
- which looks like this:
-
- /2/040755/0/0/.//\n
- /2/040755/0/0/..//\n
- /11/040700/0/0/lost+found^M//\n
- /12/040755/1002/1002/run//\n
- /13/040755/1002/1002/sys//\n
- /14/040755/1002/1002/bin//\n
- /80/040755/1002/1002/var//\n
- /92/040755/1002/1002/tmp//\n
- """
- # NOTE the occasional ^M in file names
- return [line.split('/')[5].strip() for line in \
- debugfs_output.strip().split('/\n')]
-
# Test partition 1, should contain the normal root directories, except
# /usr.
res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
@@ -451,6 +451,43 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
finally:
os.environ['PATH'] = oldpath
+ def test_include_path(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 /part1 --source rootfs --ondisk mmcblk0 --fstype=ext4
+part /part2 --source rootfs --ondisk mmcblk0 --fstype=ext4 --include-path %s"""
+ % (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]
+ part2 = glob(os.path.join(self.resultdir, 'temp-*.direct.p2'))[0]
+
+ # Test partition 1, should not contain 'test-file'
+ res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part1))
+ files = extract_files(res.output)
+ self.assertNotIn('test-file', files)
+
+ # Test partition 2, should not contain 'test-file'
+ res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part2))
+ files = extract_files(res.output)
+ self.assertIn('test-file', files)
+
+ finally:
+ os.environ['PATH'] = oldpath
+
def test_exclude_path_errors(self):
"""Test --exclude-path wks option error handling."""
wks_file = 'temp.wks'