blob: eb08eadd28f9a591ea36a6f3a70b00bd83f6cec4 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005import os
6import shutil
7import unittest
8
9from oeqa.core.utils.path import remove_safe
10from oeqa.sdk.case import OESDKTestCase
11
Brad Bishop19323692019-04-05 15:28:33 -040012from oeqa.utils.subprocesstweak import errors_have_output
13errors_have_output()
14
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015class GccCompileTest(OESDKTestCase):
16 td_vars = ['MACHINE']
17
18 @classmethod
19 def setUpClass(self):
20 files = {'test.c' : self.tc.files_dir, 'test.cpp' : self.tc.files_dir,
21 'testsdkmakefile' : self.tc.sdk_files_dir}
22 for f in files:
23 shutil.copyfile(os.path.join(files[f], f),
24 os.path.join(self.tc.sdk_dir, f))
25
26 def setUp(self):
27 machine = self.td.get("MACHINE")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028 if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
29 self.tc.hasHostPackage("^gcc-", regex=True)):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030 raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a cross-canadian toolchain")
31
32 def test_gcc_compile(self):
33 self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
34
35 def test_gpp_compile(self):
36 self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
37
38 def test_gpp2_compile(self):
39 self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
40
41 def test_make(self):
42 self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir)
43
44 @classmethod
45 def tearDownClass(self):
46 files = [os.path.join(self.tc.sdk_dir, f) \
47 for f in ['test.c', 'test.cpp', 'test.o', 'test',
48 'testsdkmakefile']]
49 for f in files:
50 remove_safe(f)