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