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