Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | import os |
| 2 | import subprocess |
| 3 | import tempfile |
| 4 | import unittest |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5 | from oeqa.sdk.case import OESDKTestCase |
| 6 | |
| 7 | from oeqa.utils.subprocesstweak import errors_have_output |
| 8 | errors_have_output() |
| 9 | |
| 10 | class BuildAssimp(OESDKTestCase): |
| 11 | """ |
| 12 | Test case to build a project using cmake. |
| 13 | """ |
| 14 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 15 | def setUp(self): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 16 | if not (self.tc.hasHostPackage("nativesdk-cmake") or |
| 17 | self.tc.hasHostPackage("cmake-native")): |
| 18 | raise unittest.SkipTest("Needs cmake") |
| 19 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 20 | def test_assimp(self): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 21 | with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 22 | tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz") |
| 23 | |
| 24 | dirs = {} |
| 25 | dirs["source"] = os.path.join(testdir, "assimp-4.1.0") |
| 26 | dirs["build"] = os.path.join(testdir, "build") |
| 27 | dirs["install"] = os.path.join(testdir, "install") |
| 28 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 29 | subprocess.check_output(["tar", "xf", tarball, "-C", testdir]) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 30 | self.assertTrue(os.path.isdir(dirs["source"])) |
| 31 | os.makedirs(dirs["build"]) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 33 | self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON {source}".format(**dirs)) |
| 34 | self._run("cmake --build {build} -- -j".format(**dirs)) |
| 35 | self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs)) |
| 36 | self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.4.1.0")) |