summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/bbconfigbuild/configfragments.py7
-rw-r--r--meta/lib/oeqa/selftest/cases/bblayers.py20
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py124
3 files changed, 108 insertions, 43 deletions
diff --git a/meta/lib/bbconfigbuild/configfragments.py b/meta/lib/bbconfigbuild/configfragments.py
index fce3301bac..34c6a3b4bc 100644
--- a/meta/lib/bbconfigbuild/configfragments.py
+++ b/meta/lib/bbconfigbuild/configfragments.py
@@ -104,8 +104,11 @@ class ConfigFragmentsPlugin(LayerPlugin):
104 return True 104 return True
105 return False 105 return False
106 106
107 def fragment_prefix(self, fragmentname):
108 return fragmentname.split("/",1)[0]
109
107 def builtin_fragment_exists(self, fragmentname): 110 def builtin_fragment_exists(self, fragmentname):
108 fragment_prefix = fragmentname.split("/",1)[0] 111 fragment_prefix = self.fragment_prefix(fragmentname)
109 fragment_prefix_defs = set([f.split(':')[0] for f in self.tinfoil.config_data.getVar('OE_FRAGMENTS_BUILTIN').split()]) 112 fragment_prefix_defs = set([f.split(':')[0] for f in self.tinfoil.config_data.getVar('OE_FRAGMENTS_BUILTIN').split()])
110 return fragment_prefix in fragment_prefix_defs 113 return fragment_prefix in fragment_prefix_defs
111 114
@@ -128,6 +131,8 @@ class ConfigFragmentsPlugin(LayerPlugin):
128 if f in enabled_fragments: 131 if f in enabled_fragments:
129 print("Fragment {} already included in {}".format(f, args.confpath)) 132 print("Fragment {} already included in {}".format(f, args.confpath))
130 else: 133 else:
134 # first filter out all built-in fragments with the same prefix as the one that is being enabled
135 enabled_fragments = [fragment for fragment in enabled_fragments if not(self.builtin_fragment_exists(fragment) and self.fragment_prefix(fragment) == self.fragment_prefix(f))]
131 enabled_fragments.append(f) 136 enabled_fragments.append(f)
132 return " ".join(enabled_fragments), None, 0, True 137 return " ".join(enabled_fragments), None, 0, True
133 138
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py
index d82c5aaf37..08bc1d1e44 100644
--- a/meta/lib/oeqa/selftest/cases/bblayers.py
+++ b/meta/lib/oeqa/selftest/cases/bblayers.py
@@ -157,7 +157,10 @@ class BitbakeLayers(OESelftestTestCase):
157 with open(jsonfile) as f: 157 with open(jsonfile) as f:
158 data = json.load(f) 158 data = json.load(f)
159 for s in data['sources']: 159 for s in data['sources']:
160 data['sources'][s]['git-remote']['rev'] = '5200799866b92259e855051112520006e1aaaac0' 160 if s == 'meta-yocto':
161 data['sources'][s]['git-remote']['rev'] = '913bd8ba4dd1d5d2a38261bde985b64a36e36281'
162 else:
163 data['sources'][s]['git-remote']['rev'] = '744a2277844ec9a384a9ca7dae2a634d5a0d3590'
161 with open(jsonfile, 'w') as f: 164 with open(jsonfile, 'w') as f:
162 json.dump(data, f) 165 json.dump(data, f)
163 166
@@ -281,11 +284,11 @@ class BitbakeConfigBuild(OESelftestTestCase):
281 2. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting 284 2. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting
282 the fragment. 285 the fragment.
283 3. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting 286 3. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting
284 the fragment with another value that overrides the first one. 287 the fragment with another value that replaces the first one.
285 4. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set to the previous 288 4. Repeat steps 2 and 3 to verify that going back and forth between values
286 value after removing the second assignment (from step 3). 289 works.
287 5. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is not set after 290 5. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is not set after
288 removing the original assignment. 291 removing the final assignment.
289 """ 292 """
290 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None) 293 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None)
291 294
@@ -295,10 +298,13 @@ class BitbakeConfigBuild(OESelftestTestCase):
295 runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue') 298 runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue')
296 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue') 299 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue')
297 300
298 runCmd('bitbake-config-build disable-fragment selftest-fragment/someothervalue') 301 runCmd('bitbake-config-build enable-fragment selftest-fragment/somevalue')
299 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'somevalue') 302 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'somevalue')
300 303
301 runCmd('bitbake-config-build disable-fragment selftest-fragment/somevalue') 304 runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue')
305 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue')
306
307 runCmd('bitbake-config-build disable-fragment selftest-fragment/someothervalue')
302 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None) 308 self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None)
303 309
304 def test_show_fragment(self): 310 def test_show_fragment(self):
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index b1c318bd4e..bb4ac23ebf 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -18,6 +18,7 @@ from glob import glob
18from shutil import rmtree, copy 18from shutil import rmtree, copy
19from tempfile import NamedTemporaryFile 19from tempfile import NamedTemporaryFile
20from tempfile import TemporaryDirectory 20from tempfile import TemporaryDirectory
21from textwrap import dedent
21 22
22from oeqa.selftest.case import OESelftestTestCase 23from oeqa.selftest.case import OESelftestTestCase
23from oeqa.core.decorator import OETestTag 24from oeqa.core.decorator import OETestTag
@@ -1021,7 +1022,7 @@ class Wic2(WicTestCase):
1021 wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES', 1022 wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES',
1022 'INITRD', 'INITRD_LIVE', 'ISODIR','INITRAMFS_IMAGE', 1023 'INITRD', 'INITRD_LIVE', 'ISODIR','INITRAMFS_IMAGE',
1023 'INITRAMFS_IMAGE_BUNDLE', 'INITRAMFS_LINK_NAME', 1024 'INITRAMFS_IMAGE_BUNDLE', 'INITRAMFS_LINK_NAME',
1024 'APPEND', 'IMAGE_EFI_BOOT_FILES')) 1025 'APPEND', 'IMAGE_EFI_BOOT_FILES', 'IMAGE_EXTRA_PARTITION_FILES'))
1025 with open(path) as envfile: 1026 with open(path) as envfile:
1026 content = dict(line.split("=", 1) for line in envfile) 1027 content = dict(line.split("=", 1) for line in envfile)
1027 # test if variables used by wic present in the .env file 1028 # test if variables used by wic present in the .env file
@@ -1329,41 +1330,47 @@ run_wic_cmd() {
1329 def test_extra_partition_space(self): 1330 def test_extra_partition_space(self):
1330 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 1331 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
1331 1332
1332 with NamedTemporaryFile("w", suffix=".wks") as tempf: 1333 oldpath = os.environ['PATH']
1333 tempf.write("bootloader --ptable gpt\n" \ 1334 os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
1334 "part --ondisk hda --size 10M --extra-partition-space 10M --fstype=ext4\n" \
1335 "part --ondisk hda --fixed-size 20M --extra-partition-space 10M --fstype=ext4\n" \
1336 "part --source rootfs --ondisk hda --extra-partition-space 10M --fstype=ext4\n" \
1337 "part --source rootfs --ondisk hda --fixed-size 200M --extra-partition-space 10M --fstype=ext4\n")
1338 tempf.flush()
1339
1340 _, wicimg = self._get_wic(tempf.name)
1341
1342 res = runCmd("parted -m %s unit b p" % wicimg,
1343 native_sysroot=native_sysroot, stderr=subprocess.PIPE)
1344
1345 # parse parted output which looks like this:
1346 # BYT;\n
1347 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
1348 # 1:0.00MiB:200MiB:200MiB:ext4::;\n
1349 partlns = res.output.splitlines()[2:]
1350
1351 self.assertEqual(4, len(partlns))
1352 1335
1353 # Test for each partitions that the extra part space exists 1336 try:
1354 for part in range(0, len(partlns)): 1337 with NamedTemporaryFile("w", suffix=".wks") as tempf:
1355 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % (part + 1)) 1338 tempf.write("bootloader --ptable gpt\n" \
1356 partln = partlns[part].split(":") 1339 "part --ondisk hda --size 10M --extra-partition-space 10M --fstype=ext4\n" \
1357 self.assertEqual(7, len(partln)) 1340 "part --ondisk hda --fixed-size 20M --extra-partition-space 10M --fstype=ext4\n" \
1358 self.assertRegex(partln[3], r'^[0-9]+B$') 1341 "part --source rootfs --ondisk hda --extra-partition-space 10M --fstype=ext4\n" \
1359 part_size = int(partln[3].rstrip("B")) 1342 "part --source rootfs --ondisk hda --fixed-size 200M --extra-partition-space 10M --fstype=ext4\n")
1360 start = int(partln[1].rstrip("B")) / 512 1343 tempf.flush()
1361 length = part_size / 512 1344
1362 runCmd("dd if=%s of=%s skip=%d count=%d" % 1345 _, wicimg = self._get_wic(tempf.name)
1363 (wicimg, part_file, start, length)) 1346
1364 res = runCmd("dumpe2fs %s -h | grep \"^Block count\"" % part_file) 1347 res = runCmd("parted -m %s unit b p" % wicimg,
1365 fs_size = int(res.output.split(":")[1].strip()) * 1024 1348 native_sysroot=native_sysroot, stderr=subprocess.PIPE)
1366 self.assertLessEqual(fs_size + 10485760, part_size, "part file: %s" % part_file) 1349
1350 # parse parted output which looks like this:
1351 # BYT;\n
1352 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
1353 # 1:0.00MiB:200MiB:200MiB:ext4::;\n
1354 partlns = res.output.splitlines()[2:]
1355
1356 self.assertEqual(4, len(partlns))
1357
1358 # Test for each partitions that the extra part space exists
1359 for part in range(0, len(partlns)):
1360 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % (part + 1))
1361 partln = partlns[part].split(":")
1362 self.assertEqual(7, len(partln))
1363 self.assertRegex(partln[3], r'^[0-9]+B$')
1364 part_size = int(partln[3].rstrip("B"))
1365 start = int(partln[1].rstrip("B")) / 512
1366 length = part_size / 512
1367 runCmd("dd if=%s of=%s skip=%d count=%d" %
1368 (wicimg, part_file, start, length))
1369 res = runCmd("dumpe2fs %s -h | grep \"^Block count\"" % part_file)
1370 fs_size = int(res.output.split(":")[1].strip()) * 1024
1371 self.assertLessEqual(fs_size + 10485760, part_size, "part file: %s" % part_file)
1372 finally:
1373 os.environ['PATH'] = oldpath
1367 1374
1368 # TODO this test could also work on aarch64 1375 # TODO this test could also work on aarch64
1369 @skipIfNotArch(['i586', 'i686', 'x86_64']) 1376 @skipIfNotArch(['i586', 'i686', 'x86_64'])
@@ -1647,6 +1654,53 @@ INITRAMFS_IMAGE = "core-image-initramfs-boot"
1647 status, output = qemu.run_serial(cmd) 1654 status, output = qemu.run_serial(cmd)
1648 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 1655 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
1649 1656
1657 def test_extra_partition_plugin(self):
1658 """Test extra partition plugin"""
1659 config = dedent("""\
1660 IMAGE_EXTRA_PARTITION_FILES_label-foo = "bar.conf;foo.conf"
1661 IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "bar.conf;foobar.conf"
1662 IMAGE_EXTRA_PARTITION_FILES = "foo/*"
1663 WICVARS:append = "\
1664 IMAGE_EXTRA_PARTITION_FILES_label-foo \
1665 IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \
1666 "
1667 """)
1668 self.append_config(config)
1669
1670 deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE')
1671
1672 testfile = open(os.path.join(deploy_dir, "bar.conf"), "w")
1673 testfile.write("test")
1674 testfile.close()
1675
1676 os.mkdir(os.path.join(deploy_dir, "foo"))
1677 testfile = open(os.path.join(deploy_dir, "foo", "bar.conf"), "w")
1678 testfile.write("test")
1679 testfile.close()
1680
1681 oldpath = os.environ['PATH']
1682 os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
1683
1684 try:
1685 with NamedTemporaryFile("w", suffix=".wks") as wks:
1686 wks.writelines(['part / --source extra_partition --ondisk sda --fstype=ext4 --label foo --align 4 --size 5M\n',
1687 'part / --source extra_partition --ondisk sda --fstype=ext4 --uuid e7d0824e-cda3-4bed-9f54-9ef5312d105d --align 4 --size 5M\n',
1688 'part / --source extra_partition --ondisk sda --fstype=ext4 --label bar --align 4 --size 5M\n'])
1689 wks.flush()
1690 _, wicimg = self._get_wic(wks.name)
1691
1692 result = runCmd("wic ls %s | wc -l" % wicimg)
1693 self.assertEqual('4', result.output, msg="Expect 3 partitions, not %s" % result.output)
1694
1695 for part, file in enumerate(["foo.conf", "foobar.conf", "bar.conf"]):
1696 result = runCmd("wic ls %s:%d | grep -q \"%s\"" % (wicimg, part + 1, file))
1697 self.assertEqual(0, result.status, msg="File '%s' not found in the partition #%d" % (file, part))
1698
1699 self.remove_config(config)
1700
1701 finally:
1702 os.environ['PATH'] = oldpath
1703
1650 def test_fs_types(self): 1704 def test_fs_types(self):
1651 """Test filesystem types for empty and not empty partitions""" 1705 """Test filesystem types for empty and not empty partitions"""
1652 img = 'core-image-minimal' 1706 img = 'core-image-minimal'