blob: 8265c59f239a8d87671f328ff02f3d2a577a1c94 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
Brad Bishop977dc1a2019-02-06 16:01:43 -05006from oeqa.runtime.decorator.package import OEHasPackage
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007
8class GccCompileTest(OERuntimeTestCase):
9
10 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050011 def setUp(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012 dst = '/tmp/'
13 src = os.path.join(cls.tc.files_dir, 'test.c')
14 cls.tc.target.copyTo(src, dst)
15
16 src = os.path.join(cls.tc.runtime_files_dir, 'testmakefile')
17 cls.tc.target.copyTo(src, dst)
18
19 src = os.path.join(cls.tc.files_dir, 'test.cpp')
20 cls.tc.target.copyTo(src, dst)
21
22 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050023 def tearDown(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024 files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
25 cls.tc.target.run('rm %s' % files)
26
27 @OETestID(203)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050029 @OEHasPackage(['gcc'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030 def test_gcc_compile(self):
31 status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
32 msg = 'gcc compile failed, output: %s' % output
33 self.assertEqual(status, 0, msg=msg)
34
35 status, output = self.target.run('/tmp/test')
36 msg = 'running compiled file failed, output: %s' % output
37 self.assertEqual(status, 0, msg=msg)
38
39 @OETestID(200)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050041 @OEHasPackage(['g++'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050042 def test_gpp_compile(self):
43 status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
44 msg = 'g++ compile failed, output: %s' % output
45 self.assertEqual(status, 0, msg=msg)
46
47 status, output = self.target.run('/tmp/test')
48 msg = 'running compiled file failed, output: %s' % output
49 self.assertEqual(status, 0, msg=msg)
50
51 @OETestID(1142)
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
63 @OETestID(204)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 @OETestDepends(['ssh.SSHTest.test_ssh'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050065 @OEHasPackage(['gcc'])
66 @OEHasPackage(['make'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067 def test_make(self):
68 status, output = self.target.run('cd /tmp; make -f testmakefile')
69 msg = 'running make failed, output %s' % output
70 self.assertEqual(status, 0, msg=msg)