summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2015-12-01 09:38:57 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:05 +0000
commitd39192a8488667da33fdcb86e36856df158643d0 (patch)
tree5f265d88481566f0dca7fcf91ac61e1fc37a799e
parentcc34104561cd67dd4e4b3534abc59e3e3f1aa0e2 (diff)
downloadpoky-contrib-d39192a8488667da33fdcb86e36856df158643d0.tar.gz
poky-contrib-d39192a8488667da33fdcb86e36856df158643d0.tar.bz2
poky-contrib-d39192a8488667da33fdcb86e36856df158643d0.zip
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>
-rw-r--r--meta/lib/oeqa/runtime/multilib.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py
index fe11a21903e..593d3850216 100644
--- a/meta/lib/oeqa/runtime/multilib.py
+++ b/meta/lib/oeqa/runtime/multilib.py
@@ -10,39 +10,33 @@ def setUpModule():
class MultilibTest(oeRuntimeTest):
- def parse(self, s):
+ def archtest(self, binary, arch):
"""
- Parse the output of readelf -h and return the binary class, or fail.
+ Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
"""
- l = [l.split()[1] for l in s.split('\n') if "Class:" in l]
+
+ (status, output) = self.target.run("readelf -h %s" % binary)
+ self.assertEqual(status, 0, "Failed to readelf %s" % binary)
+
+ l = [l.split()[1] for l in output.split('\n') if "Class:" in l]
if l:
- return l[0]
+ theclass = l[0]
else:
self.fail("Cannot parse readelf output\n" + s)
+ self.assertEqual(theclass, arch, msg="%s isn't %s (is %s)" % (binary, arch, theclass))
+
@skipUnlessPassed('test_ssh')
def test_check_multilib_libc(self):
"""
Check that a multilib image has both 32-bit and 64-bit libc in.
"""
-
- (status, output) = self.target.run("readelf -h /lib/libc.so.6")
- self.assertEqual(status, 0, "Failed to readelf /lib/libc.so.6")
- class32 = self.parse(output)
-
- (status, output) = self.target.run("readelf -h /lib64/libc.so.6")
- self.assertEqual(status, 0, "Failed to readelf /lib64/libc.so.6")
- class64 = self.parse(output)
-
- self.assertEqual(class32, "ELF32", msg="/lib/libc.so.6 isn't ELF32 (is %s)" % class32)
- self.assertEqual(class64, "ELF64", msg="/lib64/libc.so.6 isn't ELF64 (is %s)" % class64)
+ self.archtest("/lib/libc.so.6", "ELF32")
+ self.archtest("/lib64/libc.so.6", "ELF64")
@testcase('279')
@skipUnlessPassed('test_check_multilib_libc')
def test_file_connman(self):
self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed")
- (status, output) = self.target.run("readelf -h /usr/sbin/connmand")
- self.assertEqual(status, 0, "Failed to readelf /usr/sbin/connmand")
- theclass = self.parse(output)
- self.assertEqual(theclass, "ELF32", msg="connmand isn't ELF32 (is %s)" % theclass)
+ self.archtest("/usr/sbin/connmand", "ELF32")