Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | import os |
| 6 | |
| 7 | from oeqa.runtime.case import OERuntimeTestCase |
| 8 | from oeqa.core.decorator.depends import OETestDepends |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 9 | from oeqa.runtime.decorator.package import OEHasPackage |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10 | |
| 11 | class GccCompileTest(OERuntimeTestCase): |
| 12 | |
| 13 | @classmethod |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 14 | def setUp(cls): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 15 | 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 Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 26 | def tearDown(cls): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 27 | files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile' |
| 28 | cls.tc.target.run('rm %s' % files) |
| 29 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 30 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 31 | @OEHasPackage(['gcc']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 42 | @OEHasPackage(['g++']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 43 | 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 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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 63 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 64 | @OEHasPackage(['gcc']) |
| 65 | @OEHasPackage(['make']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | 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) |