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