Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | import unittest |
| 2 | import os |
| 3 | from oeqa.oetest import oeRuntimeTest, skipModule |
| 4 | from oeqa.utils.decorators import * |
| 5 | |
| 6 | def setUpModule(): |
| 7 | if not oeRuntimeTest.hasFeature("tools-sdk"): |
| 8 | skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES") |
| 9 | |
| 10 | |
| 11 | class GccCompileTest(oeRuntimeTest): |
| 12 | |
| 13 | @classmethod |
| 14 | def setUpClass(self): |
| 15 | oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.c"), "/tmp/test.c") |
| 16 | oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "testmakefile"), "/tmp/testmakefile") |
| 17 | oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.cpp"), "/tmp/test.cpp") |
| 18 | |
| 19 | @testcase(203) |
| 20 | def test_gcc_compile(self): |
| 21 | (status, output) = self.target.run('gcc /tmp/test.c -o /tmp/test -lm') |
| 22 | self.assertEqual(status, 0, msg="gcc compile failed, output: %s" % output) |
| 23 | (status, output) = self.target.run('/tmp/test') |
| 24 | self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output) |
| 25 | |
| 26 | @testcase(200) |
| 27 | def test_gpp_compile(self): |
| 28 | (status, output) = self.target.run('g++ /tmp/test.c -o /tmp/test -lm') |
| 29 | self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output) |
| 30 | (status, output) = self.target.run('/tmp/test') |
| 31 | self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output) |
| 32 | |
| 33 | @testcase(1142) |
| 34 | def test_gpp2_compile(self): |
| 35 | (status, output) = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm') |
| 36 | self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output) |
| 37 | (status, output) = self.target.run('/tmp/test') |
| 38 | self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output) |
| 39 | |
| 40 | @testcase(204) |
| 41 | def test_make(self): |
| 42 | (status, output) = self.target.run('cd /tmp; make -f testmakefile') |
| 43 | self.assertEqual(status, 0, msg="running make failed, output %s" % output) |
| 44 | |
| 45 | @classmethod |
| 46 | def tearDownClass(self): |
| 47 | oeRuntimeTest.tc.target.run("rm /tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile") |