blob: fc28b9c3d43f201778d7f48c924d2a2fa4de48d6 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007import os
8import shutil
9import unittest
10
11from oeqa.core.utils.path import remove_safe
12from oeqa.sdk.case import OESDKTestCase
13
Brad Bishop19323692019-04-05 15:28:33 -040014from oeqa.utils.subprocesstweak import errors_have_output
15errors_have_output()
16
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017class GccCompileTest(OESDKTestCase):
18 td_vars = ['MACHINE']
19
20 @classmethod
21 def setUpClass(self):
22 files = {'test.c' : self.tc.files_dir, 'test.cpp' : self.tc.files_dir,
23 'testsdkmakefile' : self.tc.sdk_files_dir}
24 for f in files:
25 shutil.copyfile(os.path.join(files[f], f),
26 os.path.join(self.tc.sdk_dir, f))
27
28 def setUp(self):
29 machine = self.td.get("MACHINE")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030 if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
31 self.tc.hasHostPackage("^gcc-", regex=True)):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a cross-canadian toolchain")
33
34 def test_gcc_compile(self):
35 self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
36
37 def test_gpp_compile(self):
38 self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
39
40 def test_gpp2_compile(self):
41 self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
42
43 def test_make(self):
44 self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir)
45
46 @classmethod
47 def tearDownClass(self):
48 files = [os.path.join(self.tc.sdk_dir, f) \
49 for f in ['test.c', 'test.cpp', 'test.o', 'test',
50 'testsdkmakefile']]
51 for f in files:
52 remove_safe(f)