* [PATCH] wic: selftest: account for occasional newline in debugfs file names
@ 2017-03-13 10:19 Maciej Borzecki
2017-03-13 10:37 ` Kristian Amlie
0 siblings, 1 reply; 2+ messages in thread
From: Maciej Borzecki @ 2017-03-13 10:19 UTC (permalink / raw)
To: openembedded-core; +Cc: Maciek Borzecki
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
Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
meta/lib/oeqa/selftest/wic.py | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index dcb88bacad13a2da4c725abf1c986b39ea70f0fc..825312e5a55639129d88246e7335174484260fc1 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
self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" %
(wicimg, part_file, start, length)).status)
+ 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" % os.path.join(self.resultdir, "selftest_img.part1"))
self.assertEqual(0, res.status)
- files = [line.split('/')[5] for line in res.output.split('\n')]
+ files = extract_files(res.output)
self.assertIn("etc", files)
self.assertNotIn("usr", files)
@@ -393,7 +410,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
# directories.
res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part2"))
self.assertEqual(0, res.status)
- files = [line.split('/')[5] for line in res.output.split('\n')]
+ files = extract_files(res.output)
self.assertNotIn("etc", files)
self.assertNotIn("usr", files)
self.assertIn("share", files)
@@ -402,14 +419,14 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
# directory, but not the files inside it.
res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
self.assertEqual(0, res.status)
- files = [line.split('/')[5] for line in res.output.split('\n')]
+ files = extract_files(res.output)
self.assertNotIn("etc", files)
self.assertNotIn("usr", files)
self.assertIn("share", files)
self.assertIn("bin", files)
res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
self.assertEqual(0, res.status)
- files = [line.split('/')[5] for line in res.output.split('\n')]
+ files = extract_files(res.output)
self.assertIn(".", files)
self.assertIn("..", files)
self.assertEqual(2, len(files))
--
2.5.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] wic: selftest: account for occasional newline in debugfs file names
2017-03-13 10:19 [PATCH] wic: selftest: account for occasional newline in debugfs file names Maciej Borzecki
@ 2017-03-13 10:37 ` Kristian Amlie
0 siblings, 0 replies; 2+ messages in thread
From: Kristian Amlie @ 2017-03-13 10:37 UTC (permalink / raw)
To: Maciej Borzecki, openembedded-core; +Cc: Maciek Borzecki
On 13/03/17 11:19, Maciej Borzecki wrote:
> 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
>
> Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
> ---
> meta/lib/oeqa/selftest/wic.py | 25 +++++++++++++++++++++----
> 1 file changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
> index dcb88bacad13a2da4c725abf1c986b39ea70f0fc..825312e5a55639129d88246e7335174484260fc1 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
> self.assertEqual(0, runCmd("dd if=%s of=%s skip=%d count=%d" %
> (wicimg, part_file, start, length)).status)
>
> + 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" % os.path.join(self.resultdir, "selftest_img.part1"))
> self.assertEqual(0, res.status)
> - files = [line.split('/')[5] for line in res.output.split('\n')]
> + files = extract_files(res.output)
> self.assertIn("etc", files)
> self.assertNotIn("usr", files)
>
> @@ -393,7 +410,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
> # directories.
> res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part2"))
> self.assertEqual(0, res.status)
> - files = [line.split('/')[5] for line in res.output.split('\n')]
> + files = extract_files(res.output)
> self.assertNotIn("etc", files)
> self.assertNotIn("usr", files)
> self.assertIn("share", files)
> @@ -402,14 +419,14 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
> # directory, but not the files inside it.
> res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
> self.assertEqual(0, res.status)
> - files = [line.split('/')[5] for line in res.output.split('\n')]
> + files = extract_files(res.output)
> self.assertNotIn("etc", files)
> self.assertNotIn("usr", files)
> self.assertIn("share", files)
> self.assertIn("bin", files)
> res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % os.path.join(self.resultdir, "selftest_img.part3"))
> self.assertEqual(0, res.status)
> - files = [line.split('/')[5] for line in res.output.split('\n')]
> + files = extract_files(res.output)
> self.assertIn(".", files)
> self.assertIn("..", files)
> self.assertEqual(2, len(files))
Looks good to me.
--
Kristian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-13 10:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 10:19 [PATCH] wic: selftest: account for occasional newline in debugfs file names Maciej Borzecki
2017-03-13 10:37 ` Kristian Amlie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.