summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2025-05-10 09:43:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-12 22:01:55 +0100
commitfa6d138447ce72835b2f9ab0a4932f60bca64488 (patch)
tree70d063fb983141ffef592ed4ed9a67f1526d6c72 /meta
parentff06a1b4257a98d3003a4a23660cbbd96b0d11d4 (diff)
downloadpoky-fa6d138447ce72835b2f9ab0a4932f60bca64488.tar.gz
oeqa/sdk/meson: generalise test case
Refactor this test case so the generic "build a meson project" code is separated out and can be reused. Also currently meson inside eSDKs only works with fully populated eSDKs, but our testing uses minimal eSDKS, so skip the test if the eSDK is a minimal build. A bug has been filed to resolve this. (From OE-Core rev: 575e0bf52db0467d88af4b5fe467b682f10ca62a) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/sdk/cases/meson.py51
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
10import unittest 10import unittest
11 11
12from oeqa.sdk.case import OESDKTestCase 12from oeqa.sdk.case import OESDKTestCase
13from oeqa.sdkext.context import OESDKExtTestContext
13from oeqa.utils.subprocesstweak import errors_have_output 14from oeqa.utils.subprocesstweak import errors_have_output
14errors_have_output() 15errors_have_output()
15 16
16class MesonTest(OESDKTestCase): 17class 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
44class 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"))