Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | import os |
| 2 | import shutil |
| 3 | import unittest |
| 4 | |
| 5 | from oeqa.core.utils.path import remove_safe |
| 6 | from oeqa.sdk.case import OESDKTestCase |
| 7 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 8 | from oeqa.utils.subprocesstweak import errors_have_output |
| 9 | errors_have_output() |
| 10 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 11 | class 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or |
| 25 | self.tc.hasHostPackage("^gcc-", regex=True)): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 26 | 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) |