summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorKristian Amlie <kristian.amlie@mender.io>2017-02-06 17:16:47 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-15 20:06:44 -0800
commit47ee6c2153db204a9fda718b92616d4bf851057e (patch)
tree6577aa92019f090bc9641d8550d869128f0bc7db /meta/lib/oeqa
parentf6a064d969f4149b2152ed2e851828acaaec07ca (diff)
downloadpoky-47ee6c2153db204a9fda718b92616d4bf851057e.tar.gz
selftest/wic: Add tests for --exclude-dir option.
Based partially on an earlier patch by Maciej Borzecki. Note that because tools now reside in recipe specific sysroots, we need to import the path from bitbake and apply it during the test. (From OE-Core rev: c826233ad08ee5a4b9943a05d4e73f3fb3281588) Signed-off-by: Kristian Amlie <kristian.amlie@mender.io> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/wic.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 417ba3d26f..0144d77a6f 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -339,6 +339,110 @@ class Wic(oeSelfTest):
339 self.assertEqual(0, status) 339 self.assertEqual(0, status)
340 self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars))) 340 self.assertEqual(1, len(glob(self.resultdir + "%(wks)s-*.direct" % bbvars)))
341 341
342 def test_exclude_path(self):
343 """Test --exclude-path wks option."""
344
345 oldpath = os.environ['PATH']
346 os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
347
348 try:
349 wks_file = 'temp.wks'
350 with open(wks_file, 'w') as wks:
351 rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
352 wks.write("""part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path usr
353part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr
354part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr"""
355 % (rootfs_dir, rootfs_dir))
356 self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
357 % (wks_file, self.resultdir)).status)
358
359 os.remove(wks_file)
360 wicout = glob(self.resultdir + "%s-*direct" % 'temp')
361 self.assertEqual(1, len(wicout))
362
363 wicimg = wicout[0]
364
365 # verify partition size with wic
366 res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg)
367 self.assertEqual(0, res.status)
368
369 # parse parted output which looks like this:
370 # BYT;\n
371 # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
372 # 1:0.00MiB:200MiB:200MiB:ext4::;\n
373 partlns = res.output.splitlines()[2:]
374
375 self.assertEqual(3, len(partlns))
376
377 for part in [1, 2, 3]:
378 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part)
379 partln = partlns[part-1].split(":")
380 self.assertEqual(7, len(partln))
381 start = int(partln[1].rstrip("B")) / 512
382 length = int(partln[3].rstrip("B")) / 512
383 self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" %
384 (wicimg, part_file, start, length)).status)
385
386 # Test partition 1, should contain the normal root directories, except
387 # /usr.
388 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part1"))
389 self.assertEqual(0, res.status)
390 files = [line.split('/')[5] for line in res.output.split('\n')]
391 self.assertIn("etc", files)
392 self.assertNotIn("usr", files)
393
394 # Partition 2, should contain common directories for /usr, not root
395 # directories.
396 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part2"))
397 self.assertEqual(0, res.status)
398 files = [line.split('/')[5] for line in res.output.split('\n')]
399 self.assertNotIn("etc", files)
400 self.assertNotIn("usr", files)
401 self.assertIn("share", files)
402
403 # Partition 3, should contain the same as partition 2, including the bin
404 # directory, but not the files inside it.
405 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
406 self.assertEqual(0, res.status)
407 files = [line.split('/')[5] for line in res.output.split('\n')]
408 self.assertNotIn("etc", files)
409 self.assertNotIn("usr", files)
410 self.assertIn("share", files)
411 self.assertIn("bin", files)
412 res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
413 self.assertEqual(0, res.status)
414 files = [line.split('/')[5] for line in res.output.split('\n')]
415 self.assertIn(".", files)
416 self.assertIn("..", files)
417 self.assertEqual(2, len(files))
418
419 for part in [1, 2, 3]:
420 part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part)
421 os.remove(part_file)
422
423 finally:
424 os.environ['PATH'] = oldpath
425
426 def test_exclude_path_errors(self):
427 """Test --exclude-path wks option error handling."""
428 wks_file = 'temp.wks'
429
430 rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
431
432 # Absolute argument.
433 with open(wks_file, 'w') as wks:
434 wks.write("part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path /usr")
435 self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
436 % (wks_file, self.resultdir), ignore_status=True).status)
437 os.remove(wks_file)
438
439 # Argument pointing to parent directory.
440 with open(wks_file, 'w') as wks:
441 wks.write("part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path ././..")
442 self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
443 % (wks_file, self.resultdir), ignore_status=True).status)
444 os.remove(wks_file)
445
342 @testcase(1496) 446 @testcase(1496)
343 def test_bmap_short(self): 447 def test_bmap_short(self):
344 """Test generation of .bmap file -m option""" 448 """Test generation of .bmap file -m option"""