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