blob: 911083156fbd4da9484398f604cb0b35067d5ce2 [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
6from oeqa.core.decorator.data import skipIfNotFeature
7
8class GccCompileTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 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
23 def tearDownClass(cls):
24 files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
25 cls.tc.target.run('rm %s' % files)
26
27 @OETestID(203)
28 @skipIfNotFeature('tools-sdk',
29 'Test requires tools-sdk to be in IMAGE_FEATURES')
30 @OETestDepends(['ssh.SSHTest.test_ssh'])
31 def test_gcc_compile(self):
32 status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
33 msg = 'gcc compile failed, output: %s' % output
34 self.assertEqual(status, 0, msg=msg)
35
36 status, output = self.target.run('/tmp/test')
37 msg = 'running compiled file failed, output: %s' % output
38 self.assertEqual(status, 0, msg=msg)
39
40 @OETestID(200)
41 @skipIfNotFeature('tools-sdk',
42 'Test requires tools-sdk to be in IMAGE_FEATURES')
43 @OETestDepends(['ssh.SSHTest.test_ssh'])
44 def test_gpp_compile(self):
45 status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
46 msg = 'g++ compile failed, output: %s' % output
47 self.assertEqual(status, 0, msg=msg)
48
49 status, output = self.target.run('/tmp/test')
50 msg = 'running compiled file failed, output: %s' % output
51 self.assertEqual(status, 0, msg=msg)
52
53 @OETestID(1142)
54 @skipIfNotFeature('tools-sdk',
55 'Test requires tools-sdk to be in IMAGE_FEATURES')
56 @OETestDepends(['ssh.SSHTest.test_ssh'])
57 def test_gpp2_compile(self):
58 status, output = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
59 msg = 'g++ compile failed, output: %s' % output
60 self.assertEqual(status, 0, msg=msg)
61
62 status, output = self.target.run('/tmp/test')
63 msg = 'running compiled file failed, output: %s' % output
64 self.assertEqual(status, 0, msg=msg)
65
66 @OETestID(204)
67 @skipIfNotFeature('tools-sdk',
68 'Test requires tools-sdk to be in IMAGE_FEATURES')
69 @OETestDepends(['ssh.SSHTest.test_ssh'])
70 def test_make(self):
71 status, output = self.target.run('cd /tmp; make -f testmakefile')
72 msg = 'running make failed, output %s' % output
73 self.assertEqual(status, 0, msg=msg)