blob: 1b6e431bf4be89d9c14cebdf8a31b66883a6df87 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005import os
6
7from oeqa.runtime.case import OERuntimeTestCase
8from oeqa.core.decorator.depends import OETestDepends
Brad Bishop977dc1a2019-02-06 16:01:43 -05009from oeqa.runtime.decorator.package import OEHasPackage
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010
11class GccCompileTest(OERuntimeTestCase):
12
13 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050014 def setUp(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015 dst = '/tmp/'
16 src = os.path.join(cls.tc.files_dir, 'test.c')
17 cls.tc.target.copyTo(src, dst)
18
19 src = os.path.join(cls.tc.runtime_files_dir, 'testmakefile')
20 cls.tc.target.copyTo(src, dst)
21
22 src = os.path.join(cls.tc.files_dir, 'test.cpp')
23 cls.tc.target.copyTo(src, dst)
24
25 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050026 def tearDown(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027 files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
28 cls.tc.target.run('rm %s' % files)
29
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050031 @OEHasPackage(['gcc'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 def test_gcc_compile(self):
33 status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
34 msg = 'gcc compile failed, output: %s' % output
35 self.assertEqual(status, 0, msg=msg)
36
37 status, output = self.target.run('/tmp/test')
38 msg = 'running compiled file failed, output: %s' % output
39 self.assertEqual(status, 0, msg=msg)
40
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050042 @OEHasPackage(['g++'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043 def test_gpp_compile(self):
44 status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
45 msg = 'g++ compile failed, output: %s' % output
46 self.assertEqual(status, 0, msg=msg)
47
48 status, output = self.target.run('/tmp/test')
49 msg = 'running compiled file failed, output: %s' % output
50 self.assertEqual(status, 0, msg=msg)
51
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050053 @OEHasPackage(['g++'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 def test_gpp2_compile(self):
55 status, output = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
56 msg = 'g++ compile failed, output: %s' % output
57 self.assertEqual(status, 0, msg=msg)
58
59 status, output = self.target.run('/tmp/test')
60 msg = 'running compiled file failed, output: %s' % output
61 self.assertEqual(status, 0, msg=msg)
62
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050064 @OEHasPackage(['gcc'])
65 @OEHasPackage(['make'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 def test_make(self):
67 status, output = self.target.run('cd /tmp; make -f testmakefile')
68 msg = 'running make failed, output %s' % output
69 self.assertEqual(status, 0, msg=msg)