1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# SPDX-License-Identifier: MIT 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun 5*4882a593Smuzhiyunimport os 6*4882a593Smuzhiyun 7*4882a593Smuzhiyunfrom oeqa.runtime.case import OERuntimeTestCase 8*4882a593Smuzhiyunfrom oeqa.core.decorator.depends import OETestDepends 9*4882a593Smuzhiyunfrom oeqa.runtime.decorator.package import OEHasPackage 10*4882a593Smuzhiyun 11*4882a593Smuzhiyunclass SconsCompileTest(OERuntimeTestCase): 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun @classmethod 14*4882a593Smuzhiyun def setUp(cls): 15*4882a593Smuzhiyun dst = '/tmp/' 16*4882a593Smuzhiyun src = os.path.join(cls.tc.runtime_files_dir, 'hello.c') 17*4882a593Smuzhiyun cls.tc.target.copyTo(src, dst) 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun src = os.path.join(cls.tc.runtime_files_dir, 'SConstruct') 20*4882a593Smuzhiyun cls.tc.target.copyTo(src, dst) 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun @classmethod 23*4882a593Smuzhiyun def tearDown(cls): 24*4882a593Smuzhiyun files = '/tmp/hello.c /tmp/hello.o /tmp/hello /tmp/SConstruct' 25*4882a593Smuzhiyun cls.tc.target.run('rm %s' % files) 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun @OETestDepends(['ssh.SSHTest.test_ssh']) 28*4882a593Smuzhiyun @OEHasPackage(['gcc']) 29*4882a593Smuzhiyun @OEHasPackage(['python3-scons']) 30*4882a593Smuzhiyun def test_scons_compile(self): 31*4882a593Smuzhiyun status, output = self.target.run('cd /tmp/ && scons') 32*4882a593Smuzhiyun msg = 'scons compile failed, output: %s' % output 33*4882a593Smuzhiyun self.assertEqual(status, 0, msg=msg) 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun status, output = self.target.run('/tmp/hello') 36*4882a593Smuzhiyun msg = 'running compiled file failed, output: %s' % output 37*4882a593Smuzhiyun self.assertEqual(status, 0, msg=msg) 38