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 | |
| 13 | def parse(self, s): |
| 14 | """ |
| 15 | Parse the output of readelf -h and return the binary class, or fail. |
| 16 | """ |
| 17 | l = [l.split()[1] for l in s.split('\n') if "Class:" in l] |
| 18 | if l: |
| 19 | return l[0] |
| 20 | else: |
| 21 | self.fail("Cannot parse readelf output\n" + s) |
| 22 | |
| 23 | @skipUnlessPassed('test_ssh') |
| 24 | def test_check_multilib_libc(self): |
| 25 | """ |
| 26 | Check that a multilib image has both 32-bit and 64-bit libc in. |
| 27 | """ |
| 28 | |
| 29 | (status, output) = self.target.run("readelf -h /lib/libc.so.6") |
| 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 | |
| 40 | @testcase('279') |
| 41 | @skipUnlessPassed('test_check_multilib_libc') |
| 42 | def test_file_connman(self): |
| 43 | self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman-gnome'), msg="This test assumes lib32-connman-gnome is installed") |
| 44 | |
| 45 | (status, output) = self.target.run("readelf -h /usr/bin/connman-applet") |
| 46 | self.assertEqual(status, 0, "Failed to readelf /usr/bin/connman-applet") |
| 47 | theclass = self.parse(output) |
| 48 | self.assertEqual(theclass, "ELF32", msg="connman-applet isn't ELF32 (is %s)" % theclass) |