multilib.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #
  2. # SPDX-License-Identifier: MIT
  3. #
  4. from oeqa.runtime.case import OERuntimeTestCase
  5. from oeqa.core.decorator.depends import OETestDepends
  6. from oeqa.core.decorator.data import skipIfNotInDataVar
  7. from oeqa.runtime.decorator.package import OEHasPackage
  8. class MultilibTest(OERuntimeTestCase):
  9. def archtest(self, binary, arch):
  10. """
  11. Check that ``binary`` has the ELF class ``arch`` (e.g. ELF32/ELF64).
  12. """
  13. status, output = self.target.run('readelf -h %s' % binary)
  14. self.assertEqual(status, 0, 'Failed to readelf %s' % binary)
  15. l = [l.split()[1] for l in output.split('\n') if "Class:" in l]
  16. if l:
  17. theclass = l[0]
  18. else:
  19. self.fail('Cannot parse readelf. Output:\n%s' % output)
  20. msg = "%s isn't %s (is %s)" % (binary, arch, theclass)
  21. self.assertEqual(theclass, arch, msg=msg)
  22. @skipIfNotInDataVar('MULTILIBS', 'multilib:lib32',
  23. "This isn't a multilib:lib32 image")
  24. @OETestDepends(['ssh.SSHTest.test_ssh'])
  25. @OEHasPackage(['binutils'])
  26. @OEHasPackage(['lib32-libc6'])
  27. def test_check_multilib_libc(self):
  28. """
  29. Check that a multilib image has both 32-bit and 64-bit libc in.
  30. """
  31. self.archtest("/lib/libc.so.6", "ELF32")
  32. self.archtest("/lib64/libc.so.6", "ELF64")
  33. @OETestDepends(['multilib.MultilibTest.test_check_multilib_libc'])
  34. @OEHasPackage(['lib32-connman', '!connman'])
  35. def test_file_connman(self):
  36. self.archtest("/usr/sbin/connmand", "ELF32")