Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | import unittest |
| 2 | from oeqa.oetest import oeRuntimeTest, skipModule |
| 3 | from oeqa.utils.decorators import * |
| 4 | |
| 5 | def 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 | |
| 11 | class MultilibTest(oeRuntimeTest): |
| 12 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 13 | def archtest(self, binary, arch): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15 | Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | if l: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 23 | theclass = l[0] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | else: |
| 25 | self.fail("Cannot parse readelf output\n" + s) |
| 26 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 27 | self.assertEqual(theclass, arch, msg="%s isn't %s (is %s)" % (binary, arch, theclass)) |
| 28 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | @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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 34 | self.archtest("/lib/libc.so.6", "ELF32") |
| 35 | self.archtest("/lib64/libc.so.6", "ELF64") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | |
| 37 | @testcase('279') |
| 38 | @skipUnlessPassed('test_check_multilib_libc') |
| 39 | def test_file_connman(self): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 40 | self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 42 | self.archtest("/usr/sbin/connmand", "ELF32") |