blob: 17b1483e8d388f6c16161f20085b38ecfbdb2036 [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
8
9from oeqa.runtime.case import OERuntimeTestCase
10from oeqa.core.decorator.depends import OETestDepends
Brad Bishop977dc1a2019-02-06 16:01:43 -050011from oeqa.runtime.decorator.package import OEHasPackage
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012
13class GccCompileTest(OERuntimeTestCase):
14
15 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050016 def setUp(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017 dst = '/tmp/'
18 src = os.path.join(cls.tc.files_dir, 'test.c')
19 cls.tc.target.copyTo(src, dst)
20
21 src = os.path.join(cls.tc.runtime_files_dir, 'testmakefile')
22 cls.tc.target.copyTo(src, dst)
23
24 src = os.path.join(cls.tc.files_dir, 'test.cpp')
25 cls.tc.target.copyTo(src, dst)
26
27 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050028 def tearDown(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
30 cls.tc.target.run('rm %s' % files)
31
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050033 @OEHasPackage(['gcc'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034 def test_gcc_compile(self):
35 status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
36 msg = 'gcc compile failed, output: %s' % output
37 self.assertEqual(status, 0, msg=msg)
38
39 status, output = self.target.run('/tmp/test')
40 msg = 'running compiled file failed, output: %s' % output
41 self.assertEqual(status, 0, msg=msg)
42
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050044 @OEHasPackage(['g++'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045 def test_gpp_compile(self):
46 status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
47 msg = 'g++ compile failed, output: %s' % output
48 self.assertEqual(status, 0, msg=msg)
49
50 status, output = self.target.run('/tmp/test')
51 msg = 'running compiled file failed, output: %s' % output
52 self.assertEqual(status, 0, msg=msg)
53
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050055 @OEHasPackage(['g++'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 def test_gpp2_compile(self):
57 status, output = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
58 msg = 'g++ compile failed, output: %s' % output
59 self.assertEqual(status, 0, msg=msg)
60
61 status, output = self.target.run('/tmp/test')
62 msg = 'running compiled file failed, output: %s' % output
63 self.assertEqual(status, 0, msg=msg)
64
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050066 @OEHasPackage(['gcc'])
67 @OEHasPackage(['make'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068 def test_make(self):
69 status, output = self.target.run('cd /tmp; make -f testmakefile')
70 msg = 'running make failed, output %s' % output
71 self.assertEqual(status, 0, msg=msg)