diff options
author | Ross Burton <ross.burton@intel.com> | 2015-12-01 09:38:57 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-01 21:32:05 +0000 |
commit | d39192a8488667da33fdcb86e36856df158643d0 (patch) | |
tree | 5f265d88481566f0dca7fcf91ac61e1fc37a799e /meta/lib/oeqa/runtime/multilib.py | |
parent | cc34104561cd67dd4e4b3534abc59e3e3f1aa0e2 (diff) | |
download | poky-d39192a8488667da33fdcb86e36856df158643d0.tar.gz |
oeqa/runtime/multilib: refactor ELF class extraction
Instead of duplicating the same code over and over, split it out to a separate
function.
(From OE-Core rev: 4f870f020bbf908ab87990803f3c278bf4e44843)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime/multilib.py')
-rw-r--r-- | meta/lib/oeqa/runtime/multilib.py | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py index fe11a21903..593d385021 100644 --- a/meta/lib/oeqa/runtime/multilib.py +++ b/meta/lib/oeqa/runtime/multilib.py | |||
@@ -10,39 +10,33 @@ def setUpModule(): | |||
10 | 10 | ||
11 | class MultilibTest(oeRuntimeTest): | 11 | class MultilibTest(oeRuntimeTest): |
12 | 12 | ||
13 | def parse(self, s): | 13 | def archtest(self, binary, arch): |
14 | """ | 14 | """ |
15 | Parse the output of readelf -h and return the binary class, or fail. | 15 | Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64). |
16 | """ | 16 | """ |
17 | l = [l.split()[1] for l in s.split('\n') if "Class:" in l] | 17 | |
18 | (status, output) = self.target.run("readelf -h %s" % binary) | ||
19 | self.assertEqual(status, 0, "Failed to readelf %s" % binary) | ||
20 | |||
21 | l = [l.split()[1] for l in output.split('\n') if "Class:" in l] | ||
18 | if l: | 22 | if l: |
19 | return l[0] | 23 | theclass = l[0] |
20 | else: | 24 | else: |
21 | self.fail("Cannot parse readelf output\n" + s) | 25 | self.fail("Cannot parse readelf output\n" + s) |
22 | 26 | ||
27 | self.assertEqual(theclass, arch, msg="%s isn't %s (is %s)" % (binary, arch, theclass)) | ||
28 | |||
23 | @skipUnlessPassed('test_ssh') | 29 | @skipUnlessPassed('test_ssh') |
24 | def test_check_multilib_libc(self): | 30 | def test_check_multilib_libc(self): |
25 | """ | 31 | """ |
26 | Check that a multilib image has both 32-bit and 64-bit libc in. | 32 | Check that a multilib image has both 32-bit and 64-bit libc in. |
27 | """ | 33 | """ |
28 | 34 | self.archtest("/lib/libc.so.6", "ELF32") | |
29 | (status, output) = self.target.run("readelf -h /lib/libc.so.6") | 35 | self.archtest("/lib64/libc.so.6", "ELF64") |
30 | self.assertEqual(status, 0, "Failed to readelf /lib/libc.so.6") | ||
31 | class32 = self.parse(output) | ||
32 | |||
33 | (status, output) = self.target.run("readelf -h /lib64/libc.so.6") | ||
34 | self.assertEqual(status, 0, "Failed to readelf /lib64/libc.so.6") | ||
35 | class64 = self.parse(output) | ||
36 | |||
37 | self.assertEqual(class32, "ELF32", msg="/lib/libc.so.6 isn't ELF32 (is %s)" % class32) | ||
38 | self.assertEqual(class64, "ELF64", msg="/lib64/libc.so.6 isn't ELF64 (is %s)" % class64) | ||
39 | 36 | ||
40 | @testcase('279') | 37 | @testcase('279') |
41 | @skipUnlessPassed('test_check_multilib_libc') | 38 | @skipUnlessPassed('test_check_multilib_libc') |
42 | def test_file_connman(self): | 39 | def test_file_connman(self): |
43 | self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed") | 40 | self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed") |
44 | 41 | ||
45 | (status, output) = self.target.run("readelf -h /usr/sbin/connmand") | 42 | self.archtest("/usr/sbin/connmand", "ELF32") |
46 | self.assertEqual(status, 0, "Failed to readelf /usr/sbin/connmand") | ||
47 | theclass = self.parse(output) | ||
48 | self.assertEqual(theclass, "ELF32", msg="connmand isn't ELF32 (is %s)" % theclass) | ||