summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMaciej Borzecki <maciej.borzecki@rndity.com>2017-03-13 11:19:23 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-14 14:42:18 +0000
commit6e20b31d5d17133e0fca086e12a0ad06ab5c4cc8 (patch)
treede5b33b63f8ff96f3196e62645c44d98d285673a /meta/lib
parent49c4fb941ebe8fca69402675d079149837104640 (diff)
downloadpoky-6e20b31d5d17133e0fca086e12a0ad06ab5c4cc8.tar.gz
wic: selftest: account for occasional newline in debugfs file names
Debugfs output may contain a newline in file names in 'ls -p' output. Make sure that output is correctly split into lines by matching '/\n' and newlines are removed from file names. Fixes the following error appearing in AB tests: Traceback (most recent call last): File "/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-oe-selftest/build/meta/lib/oeqa/selftest/wic.py", line 388, in test_exclude_path files = [line.split('/')[5] for line in res.output.split('\n')] File "/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-oe-selftest/build/meta/lib/oeqa/selftest/wic.py", line 388, in <listcomp> files = [line.split('/')[5] for line in res.output.split('\n')] IndexError: list index out of range (From OE-Core rev: 477805b913a6c4b4b630e42f08cd9e59f1e4e254) Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/wic.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index dcb88bacad..825312e5a5 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -381,11 +381,28 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
381 self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" % 381 self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" %
382 (wicimg, part_file, start, length)).status) 382 (wicimg, part_file, start, length)).status)
383 383
384 def extract_files(debugfs_output):
385 # extract file names from the output of debugfs -R 'ls -p',
386 # which looks like this:
387 #
388 # /2/040755/0/0/.//\n
389 # /2/040755/0/0/..//\n
390 # /11/040700/0/0/lost+found^M//\n
391 # /12/040755/1002/1002/run//\n
392 # /13/040755/1002/1002/sys//\n
393 # /14/040755/1002/1002/bin//\n
394 # /80/040755/1002/1002/var//\n
395 # /92/040755/1002/1002/tmp//\n
396 #
397 # NOTE the occasional ^M in file names
398 return [line.split('/')[5].strip() for line in \
399 debugfs_output.strip().split('/\n')]
400
384 # Test partition 1, should contain the normal root directories, except 401 # Test partition 1, should contain the normal root directories, except
385 # /usr. 402 # /usr.
386 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part1")) 403 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part1"))
387 self.assertEqual(0, res.status) 404 self.assertEqual(0, res.status)
388 files = [line.split('/')[5] for line in res.output.split('\n')] 405 files = extract_files(res.output)
389 self.assertIn("etc", files) 406 self.assertIn("etc", files)
390 self.assertNotIn("usr", files) 407 self.assertNotIn("usr", files)
391 408
@@ -393,7 +410,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
393 # directories. 410 # directories.
394 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part2")) 411 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part2"))
395 self.assertEqual(0, res.status) 412 self.assertEqual(0, res.status)
396 files = [line.split('/')[5] for line in res.output.split('\n')] 413 files = extract_files(res.output)
397 self.assertNotIn("etc", files) 414 self.assertNotIn("etc", files)
398 self.assertNotIn("usr", files) 415 self.assertNotIn("usr", files)
399 self.assertIn("share", files) 416 self.assertIn("share", files)
@@ -402,14 +419,14 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
402 # directory, but not the files inside it. 419 # directory, but not the files inside it.
403 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3")) 420 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
404 self.assertEqual(0, res.status) 421 self.assertEqual(0, res.status)
405 files = [line.split('/')[5] for line in res.output.split('\n')] 422 files = extract_files(res.output)
406 self.assertNotIn("etc", files) 423 self.assertNotIn("etc", files)
407 self.assertNotIn("usr", files) 424 self.assertNotIn("usr", files)
408 self.assertIn("share", files) 425 self.assertIn("share", files)
409 self.assertIn("bin", files) 426 self.assertIn("bin", files)
410 res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3")) 427 res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
411 self.assertEqual(0, res.status) 428 self.assertEqual(0, res.status)
412 files = [line.split('/')[5] for line in res.output.split('\n')] 429 files = extract_files(res.output)
413 self.assertIn(".", files) 430 self.assertIn(".", files)
414 self.assertIn("..", files) 431 self.assertIn("..", files)
415 self.assertEqual(2, len(files)) 432 self.assertEqual(2, len(files))