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 | |
| 8 | class GccCompileTest(OESDKTestCase): |
| 9 | td_vars = ['MACHINE'] |
| 10 | |
| 11 | @classmethod |
| 12 | def setUpClass(self): |
| 13 | files = {'test.c' : self.tc.files_dir, 'test.cpp' : self.tc.files_dir, |
| 14 | 'testsdkmakefile' : self.tc.sdk_files_dir} |
| 15 | for f in files: |
| 16 | shutil.copyfile(os.path.join(files[f], f), |
| 17 | os.path.join(self.tc.sdk_dir, f)) |
| 18 | |
| 19 | def setUp(self): |
| 20 | machine = self.td.get("MACHINE") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | if not (self.tc.hasTargetPackage("packagegroup-cross-canadian-%s" % machine) or |
| 22 | self.tc.hasTargetPackage("gcc")): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 23 | raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a cross-canadian toolchain") |
| 24 | |
| 25 | def test_gcc_compile(self): |
| 26 | self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir)) |
| 27 | |
| 28 | def test_gpp_compile(self): |
| 29 | self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir)) |
| 30 | |
| 31 | def test_gpp2_compile(self): |
| 32 | self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir)) |
| 33 | |
| 34 | def test_make(self): |
| 35 | self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir) |
| 36 | |
| 37 | @classmethod |
| 38 | def tearDownClass(self): |
| 39 | files = [os.path.join(self.tc.sdk_dir, f) \ |
| 40 | for f in ['test.c', 'test.cpp', 'test.o', 'test', |
| 41 | 'testsdkmakefile']] |
| 42 | for f in files: |
| 43 | remove_safe(f) |