blob: 68556e45c5a0439b063cfc8876f4e0bd65ddaa05 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007from oeqa.runtime.case import OERuntimeTestCase
8from oeqa.core.decorator.depends import OETestDepends
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009from oeqa.core.decorator.data import skipIfNotInDataVar
10from oeqa.runtime.decorator.package import OEHasPackage
11
Andrew Geisslerc9f78652020-09-18 14:11:35 -050012import subprocess
13
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014class 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 Geisslerc9f78652020-09-18 14:11:35 -050021 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 Bishop6e60e8b2018-02-01 10:27:11 -050025
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 Bishop6e60e8b2018-02-01 10:27:11 -050035 @skipIfNotInDataVar('MULTILIBS', 'multilib:lib32',
36 "This isn't a multilib:lib32 image")
37 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishopd5ae7d92018-06-14 09:52:03 -070038 @OEHasPackage(['lib32-libc6'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039 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 Bishop6e60e8b2018-02-01 10:27:11 -050046 @OETestDepends(['multilib.MultilibTest.test_check_multilib_libc'])
Andrew Geisslerc9f78652020-09-18 14:11:35 -050047 @OEHasPackage(['lib32-connman'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 def test_file_connman(self):
49 self.archtest("/usr/sbin/connmand", "ELF32")