xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/runtime/cases/x32lib.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#
2# SPDX-License-Identifier: MIT
3#
4
5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.core.decorator.data import skipIfNotInDataVar
8
9import subprocess
10
11class X32libTest(OERuntimeTestCase):
12
13    @skipIfNotInDataVar('DEFAULTTUNE', 'x86-64-x32',
14                        'DEFAULTTUNE is not set to x86-64-x32')
15    @OETestDepends(['ssh.SSHTest.test_ssh'])
16    def test_x32_file(self):
17        dest = self.td.get('T', '') + "/ls.x32test"
18        self.target.copyFrom("/bin/ls", dest)
19        cmd = 'readelf -h {} | grep Class | grep ELF32'.format(dest)
20        status1 = subprocess.call(cmd, shell=True)
21        cmd = 'readelf -h {} | grep Machine | grep X86-64'.format(dest)
22        status2 = subprocess.call(cmd, shell=True)
23        msg = ("/bin/ls isn't an X86-64 ELF32 binary. readelf says:\n{}".format(
24                subprocess.check_output("readelf -h {}".format(dest), shell=True).decode()))
25        os.remove(dest)
26        self.assertTrue(status1 == 0 and status2 == 0, msg=msg)
27