blob: 593d385021621656c138b4b19d80ee76d8953df8 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 multilibs = oeRuntimeTest.tc.d.getVar("MULTILIBS", True) or ""
7 if "multilib:lib32" not in multilibs:
8 skipModule("this isn't a multilib:lib32 image")
9
10
11class MultilibTest(oeRuntimeTest):
12
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050013 def archtest(self, binary, arch):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050015 Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050017
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]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 if l:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050023 theclass = l[0]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 else:
25 self.fail("Cannot parse readelf output\n" + s)
26
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027 self.assertEqual(theclass, arch, msg="%s isn't %s (is %s)" % (binary, arch, theclass))
28
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 @skipUnlessPassed('test_ssh')
30 def test_check_multilib_libc(self):
31 """
32 Check that a multilib image has both 32-bit and 64-bit libc in.
33 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050034 self.archtest("/lib/libc.so.6", "ELF32")
35 self.archtest("/lib64/libc.so.6", "ELF64")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
37 @testcase('279')
38 @skipUnlessPassed('test_check_multilib_libc')
39 def test_file_connman(self):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050040 self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042 self.archtest("/usr/sbin/connmand", "ELF32")