summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/multilib.py
blob: fe11a21903e92847521e93f37081a095deace27a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import unittest
from oeqa.oetest import oeRuntimeTest, skipModule
from oeqa.utils.decorators import *

def setUpModule():
    multilibs = oeRuntimeTest.tc.d.getVar("MULTILIBS", True) or ""
    if "multilib:lib32" not in multilibs:
        skipModule("this isn't a multilib:lib32 image")


class MultilibTest(oeRuntimeTest):

    def parse(self, s):
        """
        Parse the output of readelf -h and return the binary class, or fail.
        """
        l = [l.split()[1] for l in s.split('\n') if "Class:" in l]
        if l:
            return l[0]
        else:
            self.fail("Cannot parse readelf output\n" + s)

    @skipUnlessPassed('test_ssh')
    def test_check_multilib_libc(self):
        """
        Check that a multilib image has both 32-bit and 64-bit libc in.
        """

        (status, output) = self.target.run("readelf -h /lib/libc.so.6")
        self.assertEqual(status, 0, "Failed to readelf /lib/libc.so.6")
        class32 = self.parse(output)

        (status, output) = self.target.run("readelf -h /lib64/libc.so.6")
        self.assertEqual(status, 0, "Failed to readelf /lib64/libc.so.6")
        class64 = self.parse(output)

        self.assertEqual(class32, "ELF32", msg="/lib/libc.so.6 isn't ELF32 (is %s)" % class32)
        self.assertEqual(class64, "ELF64", msg="/lib64/libc.so.6 isn't ELF64 (is %s)" % class64)

    @testcase('279')
    @skipUnlessPassed('test_check_multilib_libc')
    def test_file_connman(self):
        self.assertTrue(oeRuntimeTest.hasPackage('lib32-connman'), msg="This test assumes lib32-connman is installed")

        (status, output) = self.target.run("readelf -h /usr/sbin/connmand")
        self.assertEqual(status, 0, "Failed to readelf /usr/sbin/connmand")
        theclass = self.parse(output)
        self.assertEqual(theclass, "ELF32", msg="connmand isn't ELF32 (is %s)" % theclass)