diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/cases/meson.py')
-rw-r--r-- | meta/lib/oeqa/sdk/cases/meson.py | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/meta/lib/oeqa/sdk/cases/meson.py b/meta/lib/oeqa/sdk/cases/meson.py index be53df204a..a809ca3a53 100644 --- a/meta/lib/oeqa/sdk/cases/meson.py +++ b/meta/lib/oeqa/sdk/cases/meson.py | |||
@@ -4,41 +4,69 @@ | |||
4 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
5 | # | 5 | # |
6 | 6 | ||
7 | import json | ||
7 | import os | 8 | import os |
8 | import subprocess | 9 | import subprocess |
9 | import tempfile | 10 | import tempfile |
10 | import unittest | 11 | import unittest |
11 | 12 | ||
12 | from oeqa.sdk.case import OESDKTestCase | 13 | from oeqa.sdk.case import OESDKTestCase |
14 | from oeqa.sdkext.context import OESDKExtTestContext | ||
13 | from oeqa.utils.subprocesstweak import errors_have_output | 15 | from oeqa.utils.subprocesstweak import errors_have_output |
14 | errors_have_output() | 16 | errors_have_output() |
15 | 17 | ||
16 | class MesonTest(OESDKTestCase): | 18 | class MesonTestBase(OESDKTestCase): |
19 | def setUp(self): | ||
20 | libc = self.td.get("TCLIBC") | ||
21 | if libc in [ 'newlib' ]: | ||
22 | raise unittest.SkipTest("MesonTest class: SDK doesn't contain a supported C library") | ||
23 | |||
24 | if isinstance(self.tc, OESDKExtTestContext): | ||
25 | self.skipTest(f"{self.id()} does not support eSDK (https://bugzilla.yoctoproject.org/show_bug.cgi?id=15854)") | ||
26 | |||
27 | self.ensure_host_package("meson") | ||
28 | self.ensure_host_package("pkgconfig") | ||
29 | |||
30 | def build_meson(self, sourcedir, builddir, installdir=None, options=""): | ||
31 | """ | ||
32 | Given a source tree in sourcedir, configure it to build in builddir with | ||
33 | the specified options, and if installdir is set also install. | ||
34 | """ | ||
35 | log = self._run(f"meson setup --warnlevel 1 {builddir} {sourcedir} {options}") | ||
36 | |||
37 | # Check that Meson thinks we're doing a cross build and not a native | ||
38 | self.assertIn("Build type: cross build", log) | ||
39 | |||
40 | # Check that the cross-compiler used is the one we set. | ||
41 | data = json.loads(self._run(f"meson introspect --compilers {builddir}")) | ||
42 | self.assertIn(self.td.get("CC").split()[0], data["host"]["c"]["exelist"]) | ||
43 | |||
44 | # Check that the target architectures was set correctly. | ||
45 | data = json.loads(self._run(f"meson introspect --machines {builddir}")) | ||
46 | self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"]) | ||
47 | |||
48 | self._run(f"meson compile -C {builddir} -v") | ||
49 | |||
50 | if installdir: | ||
51 | self._run(f"meson install -C {builddir} --destdir {installdir}") | ||
52 | |||
53 | class MesonTest(MesonTestBase): | ||
17 | """ | 54 | """ |
18 | Test that Meson builds correctly. | 55 | Test that Meson builds correctly. |
19 | """ | 56 | """ |
20 | def setUp(self): | ||
21 | if not (self.tc.hasHostPackage("nativesdk-meson") or | ||
22 | self.tc.hasHostPackage("meson-native")): | ||
23 | raise unittest.SkipTest("MesonTest: needs meson") | ||
24 | 57 | ||
25 | def test_epoxy(self): | 58 | def test_epoxy(self): |
26 | with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir: | 59 | with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir: |
27 | tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/anholt/libepoxy/releases/download/1.5.3/libepoxy-1.5.3.tar.xz") | 60 | tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/anholt/libepoxy/releases/download/1.5.3/libepoxy-1.5.3.tar.xz") |
28 | 61 | ||
29 | dirs = {} | 62 | sourcedir = os.path.join(testdir, "libepoxy-1.5.3") |
30 | dirs["source"] = os.path.join(testdir, "libepoxy-1.5.3") | 63 | builddir = os.path.join(testdir, "build") |
31 | dirs["build"] = os.path.join(testdir, "build") | 64 | installdir = os.path.join(testdir, "install") |
32 | dirs["install"] = os.path.join(testdir, "install") | ||
33 | 65 | ||
34 | subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) | 66 | subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) |
35 | self.assertTrue(os.path.isdir(dirs["source"])) | 67 | self.assertTrue(os.path.isdir(sourcedir)) |
36 | os.makedirs(dirs["build"]) | ||
37 | |||
38 | log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs)) | ||
39 | # Check that Meson thinks we're doing a cross build and not a native | ||
40 | self.assertIn("Build type: cross build", log) | ||
41 | self._run("ninja -C {build} -v".format(**dirs)) | ||
42 | self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs)) | ||
43 | 68 | ||
44 | self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so")) | 69 | os.makedirs(builddir) |
70 | self.build_meson(sourcedir, builddir, installdir, "-Degl=no -Dglx=no -Dx11=false") | ||
71 | self.assertTrue(os.path.isdir(installdir)) | ||
72 | self.check_elf(os.path.join(installdir, "usr", "local", "lib", "libepoxy.so")) | ||