Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 7 | from oeqa.runtime.case import OERuntimeTestCase |
| 8 | from oeqa.core.decorator.depends import OETestDepends |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9 | from oeqa.core.decorator.data import skipIfNotInDataVar |
| 10 | from oeqa.runtime.decorator.package import OEHasPackage |
| 11 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 12 | import subprocess |
| 13 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 14 | class MultilibTest(OERuntimeTestCase): |
| 15 | |
| 16 | def archtest(self, binary, arch): |
| 17 | """ |
| 18 | Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64). |
| 19 | """ |
| 20 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 21 | dest = "{}/test_binary".format(self.td.get('T', '')) |
| 22 | self.target.copyFrom(binary, dest) |
| 23 | output = subprocess.check_output("readelf -h {}".format(dest), shell=True).decode() |
| 24 | os.remove(dest) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | |
| 26 | l = [l.split()[1] for l in output.split('\n') if "Class:" in l] |
| 27 | if l: |
| 28 | theclass = l[0] |
| 29 | else: |
| 30 | self.fail('Cannot parse readelf. Output:\n%s' % output) |
| 31 | |
| 32 | msg = "%s isn't %s (is %s)" % (binary, arch, theclass) |
| 33 | self.assertEqual(theclass, arch, msg=msg) |
| 34 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 35 | @skipIfNotInDataVar('MULTILIBS', 'multilib:lib32', |
| 36 | "This isn't a multilib:lib32 image") |
| 37 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 38 | @OEHasPackage(['lib32-libc6']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 39 | def test_check_multilib_libc(self): |
| 40 | """ |
| 41 | Check that a multilib image has both 32-bit and 64-bit libc in. |
| 42 | """ |
| 43 | self.archtest("/lib/libc.so.6", "ELF32") |
| 44 | self.archtest("/lib64/libc.so.6", "ELF64") |
| 45 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 46 | @OETestDepends(['multilib.MultilibTest.test_check_multilib_libc']) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 47 | @OEHasPackage(['lib32-connman']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 48 | def test_file_connman(self): |
| 49 | self.archtest("/usr/sbin/connmand", "ELF32") |