blob: 26c1df089cec98095b8e6520878e9ceede639020 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001import os, subprocess, unittest
2import bb
3from oeqa.sdk.case import OESDKTestCase
4
5from oeqa.utils.subprocesstweak import errors_have_output
6errors_have_output()
7
8class BuildAssimp(OESDKTestCase):
9 """
10 Test case to build a project using cmake.
11 """
12
13 td_vars = ['DATETIME', 'TARGET_OS', 'TARGET_ARCH']
14
15 @classmethod
16 def setUpClass(self):
17 if not (self.tc.hasHostPackage("nativesdk-cmake") or
18 self.tc.hasHostPackage("cmake-native")):
19 raise unittest.SkipTest("Needs cmake")
20
21 def fetch(self, workdir, dl_dir, url, archive=None):
22 if not archive:
23 from urllib.parse import urlparse
24 archive = os.path.basename(urlparse(url).path)
25
26 if dl_dir:
27 tarball = os.path.join(dl_dir, archive)
28 if os.path.exists(tarball):
29 return tarball
30
31 tarball = os.path.join(workdir, archive)
32 subprocess.check_output(["wget", "-O", tarball, url])
33 return tarball
34
35 def test_assimp(self):
36 import tempfile
37 import oe.qa, oe.elf
38
39 with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
40 dl_dir = self.td.get('DL_DIR', None)
41 tarball = self.fetch(testdir, dl_dir, "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz")
42 subprocess.check_output(["tar", "xf", tarball, "-C", testdir])
43
44 sourcedir = os.path.join(testdir, "assimp-4.1.0")
45 builddir = os.path.join(testdir, "build")
46 installdir = os.path.join(testdir, "install")
47 bb.utils.mkdirhier(builddir)
48
49 self._run("cd %s && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON %s " % (builddir, sourcedir))
50 self._run("cmake --build %s -- -j" % builddir)
51 self._run("cmake --build %s --target install -- DESTDIR=%s" % (builddir, installdir))
52
53 elf = oe.qa.ELFFile(os.path.join(installdir, "usr", "local", "lib", "libassimp.so.4.1.0"))
54 elf.open()
55
56 output = self._run("echo $OECORE_TARGET_OS:$OECORE_TARGET_ARCH")
57 target_os, target_arch = output.strip().split(":")
58 machine_data = oe.elf.machine_dict(None)[target_os][target_arch]
59 (machine, osabi, abiversion, endian, bits) = machine_data
60
61 self.assertEqual(machine, elf.machine())
62 self.assertEqual(bits, elf.abiSize())
63 self.assertEqual(endian, elf.isLittleEndian())