blob: d90cd1799a549c600b0c735945b086fb1016e71a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import unittest
2import os
3from oeqa.oetest import oeRuntimeTest, skipModule
4from oeqa.utils.decorators import *
5
6def setUpModule():
7 if not oeRuntimeTest.hasFeature("tools-sdk"):
8 skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
9
10
11class 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")