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