summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py74
1 files changed, 40 insertions, 34 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index e7e5dcb7e7..78de2fcfd0 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1330,41 +1330,47 @@ run_wic_cmd() {
1330 def test_extra_partition_space(self): 1330 def test_extra_partition_space(self):
1331 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools") 1331 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "wic-tools")
1332 1332
1333 with NamedTemporaryFile("w", suffix=".wks") as tempf: 1333 oldpath = os.environ['PATH']
1334 tempf.write("bootloader --ptable gpt\n" \ 1334 os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
1335 "part --ondisk hda --size 10M --extra-partition-space 10M --fstype=ext4\n" \
1336 "part --ondisk hda --fixed-size 20M --extra-partition-space 10M --fstype=ext4\n" \
1337 "part --source rootfs --ondisk hda --extra-partition-space 10M --fstype=ext4\n" \
1338 "part --source rootfs --ondisk hda --fixed-size 200M --extra-partition-space 10M --fstype=ext4\n")
1339 tempf.flush()
1340
1341 _, wicimg = self._get_wic(tempf.name)
1342
1343 res = runCmd("parted -m %s unit b p" % wicimg,
1344 native_sysroot=native_sysroot, stderr=subprocess.PIPE)
1345
1346 # parse parted output which looks like this:
1347 # BYT;\n
1348 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
1349 # 1:0.00MiB:200MiB:200MiB:ext4::;\n
1350 partlns = res.output.splitlines()[2:]
1351
1352 self.assertEqual(4, len(partlns))
1353 1335
1354 # Test for each partitions that the extra part space exists 1336 try:
1355 for part in range(0, len(partlns)): 1337 with NamedTemporaryFile("w", suffix=".wks") as tempf:
1356 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % (part + 1)) 1338 tempf.write("bootloader --ptable gpt\n" \
1357 partln = partlns[part].split(":") 1339 "part --ondisk hda --size 10M --extra-partition-space 10M --fstype=ext4\n" \
1358 self.assertEqual(7, len(partln)) 1340 "part --ondisk hda --fixed-size 20M --extra-partition-space 10M --fstype=ext4\n" \
1359 self.assertRegex(partln[3], r'^[0-9]+B$') 1341 "part --source rootfs --ondisk hda --extra-partition-space 10M --fstype=ext4\n" \
1360 part_size = int(partln[3].rstrip("B")) 1342 "part --source rootfs --ondisk hda --fixed-size 200M --extra-partition-space 10M --fstype=ext4\n")
1361 start = int(partln[1].rstrip("B")) / 512 1343 tempf.flush()
1362 length = part_size / 512 1344
1363 runCmd("dd if=%s of=%s skip=%d count=%d" % 1345 _, wicimg = self._get_wic(tempf.name)
1364 (wicimg, part_file, start, length)) 1346
1365 res = runCmd("dumpe2fs %s -h | grep \"^Block count\"" % part_file) 1347 res = runCmd("parted -m %s unit b p" % wicimg,
1366 fs_size = int(res.output.split(":")[1].strip()) * 1024 1348 native_sysroot=native_sysroot, stderr=subprocess.PIPE)
1367 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
1368 1374
1369 # TODO this test could also work on aarch64 1375 # TODO this test could also work on aarch64
1370 @skipIfNotArch(['i586', 'i686', 'x86_64']) 1376 @skipIfNotArch(['i586', 'i686', 'x86_64'])