blob: 74ad2a2f2b989d45e641b25f001a05fd65d6837f [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")
21 if not self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine):
22 raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a cross-canadian toolchain")
23
24 def test_gcc_compile(self):
25 self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
26
27 def test_gpp_compile(self):
28 self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
29
30 def test_gpp2_compile(self):
31 self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
32
33 def test_make(self):
34 self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir)
35
36 @classmethod
37 def tearDownClass(self):
38 files = [os.path.join(self.tc.sdk_dir, f) \
39 for f in ['test.c', 'test.cpp', 'test.o', 'test',
40 'testsdkmakefile']]
41 for f in files:
42 remove_safe(f)