blob: d11f4b63fbf5bd854138ff819170bf1b5bcc07d8 [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
8class 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 Bishopd7bf8c12018-02-25 22:55:05 -050021 if not (self.tc.hasTargetPackage("packagegroup-cross-canadian-%s" % machine) or
22 self.tc.hasTargetPackage("gcc")):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 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)