diff options
author | Bill Randle <william.c.randle@intel.com> | 2016-04-13 10:17:42 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-04-18 16:28:21 +0100 |
commit | 8beb671843f1f8b6613e286c17e746f64c33ffa5 (patch) | |
tree | 5aac97730679d98e6a2cc8dc6ea20e96aada638c /meta | |
parent | 0262bc51cdad5e88b14bdce634fe08ab4401de8b (diff) | |
download | poky-8beb671843f1f8b6613e286c17e746f64c33ffa5.tar.gz |
ext-sdk-prepare.py: exclude do_rm_work from unexpected output; create unit test
When installing the esdk with INHERIT += "rm_work", the script complains
about do_rm_work as unexpected output from the bitbake run. This patch
ignores any output lines with do_rm_work and further refactors the
output comparison into its own function creates a new unit test to
verify the fix. The unit test can be run direct from the command line or
via oe-selftest.
[YOCTO #9019]
(From OE-Core rev: d41930e1daa933cf4bf063fa79a2e8fc9129e1b1)
Signed-off-by: Bill Randle <william.c.randle@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/files/ext-sdk-prepare.py | 27 | ||||
-rwxr-xr-x | meta/lib/oeqa/selftest/esdk_prepare.py | 75 |
2 files changed, 91 insertions, 11 deletions
diff --git a/meta/files/ext-sdk-prepare.py b/meta/files/ext-sdk-prepare.py index 80db8bb16a..605e2ebefa 100644 --- a/meta/files/ext-sdk-prepare.py +++ b/meta/files/ext-sdk-prepare.py | |||
@@ -27,6 +27,21 @@ def exec_watch(cmd, **options): | |||
27 | 27 | ||
28 | return process.returncode, buf | 28 | return process.returncode, buf |
29 | 29 | ||
30 | def check_unexpected(lines, recipes): | ||
31 | """Check for unexpected output lines from dry run""" | ||
32 | unexpected = [] | ||
33 | for line in lines.splitlines(): | ||
34 | if 'Running task' in line: | ||
35 | for recipe in recipes: | ||
36 | if recipe in line: | ||
37 | break | ||
38 | else: | ||
39 | line = line.split('Running', 1)[-1] | ||
40 | if 'do_rm_work' not in line: | ||
41 | unexpected.append(line.rstrip()) | ||
42 | elif 'Running setscene' in line: | ||
43 | unexpected.append(line.rstrip()) | ||
44 | return unexpected | ||
30 | 45 | ||
31 | def main(): | 46 | def main(): |
32 | if len(sys.argv) < 2: | 47 | if len(sys.argv) < 2: |
@@ -67,17 +82,7 @@ def main(): | |||
67 | 82 | ||
68 | try: | 83 | try: |
69 | out = subprocess.check_output('bitbake %s -n' % ' '.join(sdk_targets), stderr=subprocess.STDOUT, shell=True) | 84 | out = subprocess.check_output('bitbake %s -n' % ' '.join(sdk_targets), stderr=subprocess.STDOUT, shell=True) |
70 | unexpected = [] | 85 | unexpected = check_unexpected(out, recipes) |
71 | for line in out.splitlines(): | ||
72 | if 'Running task' in line: | ||
73 | for recipe in recipes: | ||
74 | if recipe in line: | ||
75 | break | ||
76 | else: | ||
77 | line = line.split('Running', 1)[-1] | ||
78 | unexpected.append(line.rstrip()) | ||
79 | elif 'Running setscene' in line: | ||
80 | unexpected.append(line.rstrip()) | ||
81 | except subprocess.CalledProcessError as e: | 86 | except subprocess.CalledProcessError as e: |
82 | print('ERROR: Failed to execute dry-run:\n%s' % e.output) | 87 | print('ERROR: Failed to execute dry-run:\n%s' % e.output) |
83 | return 1 | 88 | return 1 |
diff --git a/meta/lib/oeqa/selftest/esdk_prepare.py b/meta/lib/oeqa/selftest/esdk_prepare.py new file mode 100755 index 0000000000..1b36a0d682 --- /dev/null +++ b/meta/lib/oeqa/selftest/esdk_prepare.py | |||
@@ -0,0 +1,75 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | import shutil, tempfile | ||
4 | import sys | ||
5 | import os | ||
6 | import imp | ||
7 | import unittest | ||
8 | try: | ||
9 | from oeqa.utils.commands import get_bb_var | ||
10 | except ImportError: | ||
11 | pass | ||
12 | |||
13 | # module under test | ||
14 | module_file_name = "ext-sdk-prepare.py" | ||
15 | module_path = "" | ||
16 | |||
17 | class ExtSdkPrepareTest(unittest.TestCase): | ||
18 | |||
19 | """ unit test for fix for Yocto #9019 """ | ||
20 | |||
21 | @classmethod | ||
22 | def setUpClass(self): | ||
23 | # copy module under test to temp dir | ||
24 | self.test_dir = tempfile.mkdtemp() | ||
25 | module_dest_path = os.path.join(self.test_dir, module_file_name) | ||
26 | try: | ||
27 | shutil.copy(module_path, self.test_dir) | ||
28 | # load module under test | ||
29 | self.test_mod = imp.load_source("", module_dest_path) | ||
30 | except: | ||
31 | print "error: unable to copy or load %s [src: %s, dst: %s]" % \ | ||
32 | (module_file_name, module_path, module_dest_path) | ||
33 | sys.exit(1) | ||
34 | |||
35 | def test_prepare_unexpected(self): | ||
36 | # test data | ||
37 | # note: pathnames have been truncated from the actual bitbake | ||
38 | # output as they are not important for the test. | ||
39 | test_data = ( | ||
40 | 'NOTE: Running noexec task 9 of 6539 (ID: 28, quilt/quilt-native_0.64.bb, do_build)\n' | ||
41 | 'NOTE: Running task 10 of 6539 (ID: 29, quilt/quilt-native_0.64.bb, do_package)\n' | ||
42 | 'NOTE: Running task 11 of 6539 (ID: 30, quilt/quilt-native_0.64.bb, do_rm_work)\n' | ||
43 | 'NOTE: Running noexec task 6402 of 6539 (ID: 1, images/core-image-sato.bb, do_patch)\n' | ||
44 | 'NOTE: Running task 6538 of 6539 (ID: 14, images/core-image-sato.bb, do_rm_work)\n' | ||
45 | ) | ||
46 | # expected warning output | ||
47 | expected = [ (' task 10 of 6539 (ID: 29, quilt/quilt-native_0.64.bb, do_package)') ] | ||
48 | # recipe to test, matching test input data | ||
49 | recipes = [ "core-image-sato.bb" ] | ||
50 | |||
51 | # run the test | ||
52 | output = self.test_mod.check_unexpected(test_data, recipes) | ||
53 | self.assertEqual(output, expected) | ||
54 | |||
55 | @classmethod | ||
56 | def tearDownClass(self): | ||
57 | # remove temp dir | ||
58 | shutil.rmtree(self.test_dir) | ||
59 | |||
60 | if __name__ == '__main__': | ||
61 | # running from command line - i.e., not under oe-selftest | ||
62 | # directory containing module under test comes from command line | ||
63 | if len(sys.argv) == 2 and os.path.isdir(sys.argv[1]): | ||
64 | module_path = os.path.join(sys.argv[1], module_file_name) | ||
65 | suite = unittest.TestLoader().loadTestsFromTestCase(ExtSdkPrepareTest) | ||
66 | unittest.TextTestRunner().run(suite) | ||
67 | else: | ||
68 | progname = os.path.basename(sys.argv[0]) | ||
69 | print "%s: missing directory path" % progname | ||
70 | print "usage: %s /path/to/directory-of(ext-sdk-prepare.py)" % progname | ||
71 | sys.exit(1) | ||
72 | else: | ||
73 | # running under oe-selftest | ||
74 | # determine module source dir from COREBASE and expected path | ||
75 | module_path = os.path.join(get_bb_var("COREBASE"), "meta", "files", module_file_name) | ||