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