summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/sdk
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2018-08-03 15:01:14 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-07 12:13:03 +0100
commitb152f84a73e4ae9b8440bb3df849f4dea1130466 (patch)
tree067e5555652435d16d756b482d37793a7ec8aaf6 /meta/lib/oeqa/sdk
parent481833a6934461b9a926222fc32c5f654e19da02 (diff)
downloadpoky-b152f84a73e4ae9b8440bb3df849f4dea1130466.tar.gz
oeqa/sdk: add test that CMake works
Add a new SDK testcase that builds assimp, a project that uses cmake. Using TARGET_ARCH and TARGET_OS which is now exported into the environment, check that the generated binaries match the ELF headers we expect. (From OE-Core rev: b4acfa11b35b47c86d2d83d7b0693284a8dc7495) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/sdk')
-rw-r--r--meta/lib/oeqa/sdk/cases/assimp.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/meta/lib/oeqa/sdk/cases/assimp.py b/meta/lib/oeqa/sdk/cases/assimp.py
new file mode 100644
index 0000000000..7251bdf34e
--- /dev/null
+++ b/meta/lib/oeqa/sdk/cases/assimp.py
@@ -0,0 +1,68 @@
1import os, subprocess, unittest
2import bb
3from oeqa.sdk.case import OESDKTestCase
4from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
5
6from oeqa.utils.subprocesstweak import errors_have_output
7errors_have_output()
8
9class BuildAssimp(OESDKTestCase):
10 """
11 Test case to build a project using cmake.
12 """
13
14 td_vars = ['DATETIME', 'TARGET_OS', 'TARGET_ARCH']
15
16 @classmethod
17 def setUpClass(self):
18 if not (self.tc.hasHostPackage("nativesdk-cmake") or
19 self.tc.hasHostPackage("cmake-native")):
20 raise unittest.SkipTest("Needs cmake")
21
22 def fetch(self, workdir, dl_dir, url, archive=None):
23 if not archive:
24 from urllib.parse import urlparse
25 archive = os.path.basename(urlparse(url).path)
26
27 if dl_dir:
28 tarball = os.path.join(dl_dir, archive)
29 if os.path.exists(tarball):
30 return tarball
31
32 tarball = os.path.join(workdir, archive)
33 subprocess.check_output(["wget", "-O", tarball, url])
34 return tarball
35
36 def test_assimp(self):
37 import tempfile
38 import oe.qa, oe.elf
39
40 with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
41 dl_dir = self.td.get('DL_DIR', None)
42 tarball = self.fetch(testdir, dl_dir, "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz")
43 subprocess.check_output(["tar", "xf", tarball, "-C", testdir])
44
45 sourcedir = os.path.join(testdir, "assimp-4.1.0")
46 builddir = os.path.join(testdir, "build")
47 installdir = os.path.join(testdir, "install")
48 bb.utils.mkdirhier(builddir)
49
50 self._run("cd %s && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON %s " % (builddir, sourcedir))
51 self._run("cmake --build %s -- -j" % builddir)
52 self._run("cmake --build %s --target install -- DESTDIR=%s" % (builddir, installdir))
53
54 elf = oe.qa.ELFFile(os.path.join(installdir, "usr", "local", "lib", "libassimp.so.4.1.0"))
55 elf.open()
56
57 output = self._run("echo $OECORE_TARGET_OS:$OECORE_TARGET_ARCH")
58 target_os, target_arch = output.strip().split(":")
59 machine_data = oe.elf.machine_dict(None)[target_os][target_arch]
60 (machine, osabi, abiversion, endian, bits) = machine_data
61
62 self.assertEqual(machine, elf.machine())
63 self.assertEqual(bits, elf.abiSize())
64 self.assertEqual(endian, elf.isLittleEndian())
65
66 @classmethod
67 def tearDownClass(self):
68 self.project.clean()