[meta-mingw,v2,5/5] oeqa/sdkmingw: Add test cases

Submitted by Joshua Watt on Nov. 19, 2018, 9:17 p.m. | Patch ID: 156409

Details

Message ID 20181119211752.18963-6-JPEWhacker@gmail.com
State New
Headers show

Commit Message

Joshua Watt Nov. 19, 2018, 9:17 p.m.
Adds test cases to verify that gcc, binutils, gdb, and pkg-config are
functioning in the MinGW SDK

[YOCTO #13020]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 lib/oeqa/sdkmingw/cases/binutils.py     | 55 +++++++++++++++++++++++++
 lib/oeqa/sdkmingw/cases/gcc.py          | 47 +++++++++++++++++++++
 lib/oeqa/sdkmingw/cases/gdb.py          | 20 +++++++++
 lib/oeqa/sdkmingw/cases/pkgconfig.py    | 18 ++++++++
 lib/oeqa/sdkmingw/files/testsdkmakefile |  4 ++
 5 files changed, 144 insertions(+)
 create mode 100644 lib/oeqa/sdkmingw/cases/binutils.py
 create mode 100644 lib/oeqa/sdkmingw/cases/gcc.py
 create mode 100644 lib/oeqa/sdkmingw/cases/gdb.py
 create mode 100644 lib/oeqa/sdkmingw/cases/pkgconfig.py
 create mode 100644 lib/oeqa/sdkmingw/files/testsdkmakefile

Patch hide | download patch | download mbox

diff --git a/lib/oeqa/sdkmingw/cases/binutils.py b/lib/oeqa/sdkmingw/cases/binutils.py
new file mode 100644
index 0000000..fdd5a47
--- /dev/null
+++ b/lib/oeqa/sdkmingw/cases/binutils.py
@@ -0,0 +1,55 @@ 
+# Copyright 2018 by Garmin Ltd. or its subsidiaries
+# Released under the MIT license (see COPYING.MIT)
+
+import os
+import unittest
+
+from oeqa.sdkmingw.case import OESDKMinGWTestCase
+
+class BinutilsTest(OESDKMinGWTestCase):
+    td_vars = ['MACHINE']
+
+    def setUp(self):
+        super().setUp()
+
+        self.copyTestFile(os.path.join(self.tc.files_dir, 'test.c'))
+
+        machine = self.td.get("MACHINE")
+        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
+                self.tc.hasHostPackage("^gcc-", regex=True)):
+            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain a cross-canadian toolchain")
+        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
+                self.tc.hasHostPackage('binutils-cross-canadian-%s' % machine)):
+            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain a binutils")
+
+        self._run('%CC% -c -g test.c -o test.o')
+        self._run('%CC% -o test test.o -lm')
+
+    def test_strip(self):
+        self._run('%STRIP% -s test')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_ar(self):
+        self._run('%AR% -rcs lib.a test.o')
+        self._run('%CC% -o test lib.a -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_ranlib(self):
+        self._run('%AR% -rc lib.a test.o')
+        self._run('%RANLIB% lib.a')
+        self._run('%CC% -o test lib.a -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_objcopy(self):
+        self._run('%OBJCOPY% -g test.o test_no_debug.o')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test_no_debug.o'))
+        self._run('%CC% -o test test_no_debug.o -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_objdump(self):
+        self._run('%OBJDUMP% -S test.o')
+
+    def test_nm(self):
+        self._run('%NM% test.o')
+
+
diff --git a/lib/oeqa/sdkmingw/cases/gcc.py b/lib/oeqa/sdkmingw/cases/gcc.py
new file mode 100644
index 0000000..7294bf5
--- /dev/null
+++ b/lib/oeqa/sdkmingw/cases/gcc.py
@@ -0,0 +1,47 @@ 
+# Copyright 2018 by Garmin Ltd. or its subsidiaries
+# Released under the MIT license (see COPYING.MIT)
+
+import os
+import unittest
+
+from oeqa.sdkmingw.case import OESDKMinGWTestCase
+
+class GccCompileTest(OESDKMinGWTestCase):
+    td_vars = ['MACHINE']
+
+    def setUp(self):
+        super().setUp()
+
+        self.copyTestFile(os.path.join(self.tc.files_dir, 'test.c'))
+        self.copyTestFile(os.path.join(self.tc.files_dir, 'test.cpp'))
+        self.copyTestFile(os.path.join(self.tc.sdk_files_dir, 'testsdkmakefile'))
+
+        machine = self.td.get("MACHINE")
+        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
+                self.tc.hasHostPackage("^gcc-", regex=True)):
+            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain a cross-canadian toolchain")
+
+    def test_gcc_compile(self):
+        self._run('%CC% %CFLAGS% %LDFLAGS% test.c -o test -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_gcc_compile_and_link(self):
+        self._run('%CC% %CFLAGS% -c test.c -o test.o')
+        self._run('%CC% %LDFLAGS% -o test test.o -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test.o'))
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_gpp_compile(self):
+        self._run('%CXX% %CXXFLAGS% %LDFLAGS% test.c -o test -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_gpp2_compile(self):
+        self._run('%CXX% %CXXFLAGS% %LDFLAGS% test.cpp -o test -lm')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
+    def test_make(self):
+        if not self.tc.hasHostPackage('nativesdk-make'):
+            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain make")
+        self._run('make -f testsdkmakefile')
+        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))
+
diff --git a/lib/oeqa/sdkmingw/cases/gdb.py b/lib/oeqa/sdkmingw/cases/gdb.py
new file mode 100644
index 0000000..f1bde7a
--- /dev/null
+++ b/lib/oeqa/sdkmingw/cases/gdb.py
@@ -0,0 +1,20 @@ 
+# Copyright 2018 by Garmin Ltd. or its subsidiaries
+# Released under the MIT license (see COPYING.MIT)
+
+import unittest
+
+from oeqa.sdkmingw.case import OESDKMinGWTestCase
+
+class GdbTest(OESDKMinGWTestCase):
+    td_vars = ['MACHINE']
+
+    def setUp(self):
+        super().setUp()
+
+        machine = self.td.get("MACHINE")
+        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
+                self.tc.hasHostPackage("^gdb-", regex=True)):
+            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain a cross-canadian toolchain")
+
+    def test_gdb(self):
+        self._run('%GDB% -ex quit')
diff --git a/lib/oeqa/sdkmingw/cases/pkgconfig.py b/lib/oeqa/sdkmingw/cases/pkgconfig.py
new file mode 100644
index 0000000..24185a0
--- /dev/null
+++ b/lib/oeqa/sdkmingw/cases/pkgconfig.py
@@ -0,0 +1,18 @@ 
+# Copyright 2018 by Garmin Ltd. or its subsidiaries
+# Released under the MIT license (see COPYING.MIT)
+
+import os
+import unittest
+
+from oeqa.sdkmingw.case import OESDKMinGWTestCase
+
+class PkgConfigTest(OESDKMinGWTestCase):
+    def setUp(self):
+        super().setUp()
+
+        if not self.tc.hasHostPackage("nativesdk-pkgconfig"):
+            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain nativesdk-pkgconfig")
+
+    def test_pkg_config(self):
+        self._run('pkg-config --list-all')
+
diff --git a/lib/oeqa/sdkmingw/files/testsdkmakefile b/lib/oeqa/sdkmingw/files/testsdkmakefile
new file mode 100644
index 0000000..b5cac86
--- /dev/null
+++ b/lib/oeqa/sdkmingw/files/testsdkmakefile
@@ -0,0 +1,4 @@ 
+test: test.o
+	$(CC) -o test test.o -lm
+test.o: test.c
+	$(CC) -c test.c