blob: e4c5c730037990a76f601beb01bcd20221470add [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop19323692019-04-05 15:28:33 -04007import os
8import subprocess
9import tempfile
10import unittest
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011from oeqa.sdk.case import OESDKTestCase
12
13from oeqa.utils.subprocesstweak import errors_have_output
14errors_have_output()
15
16class BuildAssimp(OESDKTestCase):
17 """
18 Test case to build a project using cmake.
19 """
20
Brad Bishop19323692019-04-05 15:28:33 -040021 def setUp(self):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022 if not (self.tc.hasHostPackage("nativesdk-cmake") or
23 self.tc.hasHostPackage("cmake-native")):
24 raise unittest.SkipTest("Needs cmake")
Andrew Geissler028142b2023-05-05 11:29:21 -050025 if not (self.tc.hasTargetPackage("zlib", multilib=True) or \
26 self.tc.hasTargetPackage("libz1", multilib=True)):
27 raise unittest.SkipTest("Assimp test needs zlib in the SDK")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080029 def test_assimp(self):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030 with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
Brad Bishop19323692019-04-05 15:28:33 -040031 tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz")
32
33 dirs = {}
34 dirs["source"] = os.path.join(testdir, "assimp-4.1.0")
35 dirs["build"] = os.path.join(testdir, "build")
36 dirs["install"] = os.path.join(testdir, "install")
37
Andrew Geisslerc9f78652020-09-18 14:11:35 -050038 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040039 self.assertTrue(os.path.isdir(dirs["source"]))
40 os.makedirs(dirs["build"])
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080041
Brad Bishop19323692019-04-05 15:28:33 -040042 self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON {source}".format(**dirs))
43 self._run("cmake --build {build} -- -j".format(**dirs))
44 self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs))
45 self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.4.1.0"))