summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2013-06-28 11:55:50 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-07-09 10:53:45 +0100
commit4285e856aa073979bf046168a75188ccf5a1e7d4 (patch)
tree1a146b3d4545cfd683e4d71588060d917af24a06 /meta/lib
parent06d6f9d52e9cb636d007f35db38819eebf1f4000 (diff)
downloadast2050-yocto-poky-4285e856aa073979bf046168a75188ccf5a1e7d4.zip
ast2050-yocto-poky-4285e856aa073979bf046168a75188ccf5a1e7d4.tar.gz
lib/oeqa/runtime: add gcc test
gcc compile test and support files. (From OE-Core rev: ccbce75335971abf5098a492755e92ca60cf67bd) Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/runtime/files/test.c26
-rw-r--r--meta/lib/oeqa/runtime/files/testmakefile5
-rw-r--r--meta/lib/oeqa/runtime/gcc.py36
3 files changed, 67 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/files/test.c b/meta/lib/oeqa/runtime/files/test.c
new file mode 100644
index 0000000..2d8389c
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/test.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+
+double convert(long long l)
+{
+ return (double)l;
+}
+
+int main(int argc, char * argv[]) {
+
+ long long l = 10;
+ double f;
+ double check = 10.0;
+
+ f = convert(l);
+ printf("convert: %lld => %f\n", l, f);
+ if ( f != check ) exit(1);
+
+ f = 1234.67;
+ check = 1234.0;
+ printf("floorf(%f) = %f\n", f, floorf(f));
+ if ( floorf(f) != check) exit(1);
+
+ return 0;
+}
diff --git a/meta/lib/oeqa/runtime/files/testmakefile b/meta/lib/oeqa/runtime/files/testmakefile
new file mode 100644
index 0000000..ca1844e
--- /dev/null
+++ b/meta/lib/oeqa/runtime/files/testmakefile
@@ -0,0 +1,5 @@
+test: test.o
+ gcc -o test test.o -lm
+test.o: test.c
+ gcc -c test.c
+
diff --git a/meta/lib/oeqa/runtime/gcc.py b/meta/lib/oeqa/runtime/gcc.py
new file mode 100644
index 0000000..b63badd
--- /dev/null
+++ b/meta/lib/oeqa/runtime/gcc.py
@@ -0,0 +1,36 @@
+import unittest
+import os
+from oeqa.oetest import oeRuntimeTest, skipModule
+from oeqa.utils.decorators import *
+
+def setUpModule():
+ if not oeRuntimeTest.hasFeature("tools-sdk"):
+ skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES")
+
+
+class GccCompileTest(oeRuntimeTest):
+
+ @classmethod
+ def setUpClass(self):
+ oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.c"), "/tmp/test.c")
+ oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "testmakefile"), "/tmp/testmakefile")
+
+ def test_gcc_compile(self):
+ (status, output) = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
+ self.assertEqual(status, 0, msg="gcc compile failed, output: %s" % output)
+ (status, output) = self.target.run('/tmp/test')
+ self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
+
+ def test_gpp_compile(self):
+ (status, output) = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
+ self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output)
+ (status, output) = self.target.run('/tmp/test')
+ self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output)
+
+ def test_make(self):
+ (status, output) = self.target.run('cd /tmp; make -f testmakefile')
+ self.assertEqual(status, 0, msg="running make failed, output %s" % output)
+
+ @classmethod
+ def tearDownClass(self):
+ oeRuntimeTest.tc.target.run("rm /tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile")
OpenPOWER on IntegriCloud