Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | import os |
| 2 | |
| 3 | from oeqa.runtime.case import OERuntimeTestCase |
| 4 | from oeqa.core.decorator.depends import OETestDepends |
| 5 | from oeqa.core.decorator.oeid import OETestID |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 6 | from oeqa.runtime.decorator.package import OEHasPackage |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 7 | |
| 8 | class GccCompileTest(OERuntimeTestCase): |
| 9 | |
| 10 | @classmethod |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 11 | def setUp(cls): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 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 |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 23 | def tearDown(cls): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 24 | files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile' |
| 25 | cls.tc.target.run('rm %s' % files) |
| 26 | |
| 27 | @OETestID(203) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 28 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 29 | @OEHasPackage(['gcc']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 30 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 40 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 41 | @OEHasPackage(['g++']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 42 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 53 | @OEHasPackage(['g++']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 64 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 65 | @OEHasPackage(['gcc']) |
| 66 | @OEHasPackage(['make']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 67 | 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) |