Skip to contentSkip to conversation

oeqa/sdk: rename test cases

PATCH In review Ross Burton 2 participants 7 messages May 20, 2024 – May 21, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 oeqa/sdk: rename test cases

Instead of having a test called eg "assimp", rename it to "cmake" as the point of the test is to verify that CMake works. This should make it clearer what the tests are actually exercising.

---
 meta/lib/oeqa/sdk/cases/{buildcpio.py => autotools.py}  | 2 +-
 meta/lib/oeqa/sdk/cases/{assimp.py => cmake.py}         | 4 ++--
 meta/lib/oeqa/sdk/cases/{buildgalculator.py => gtk3.py} | 2 +-
 meta/lib/oeqa/sdk/cases/{buildlzip.py => makefile.py}   | 2 +-
 meta/lib/oeqa/sdk/cases/{buildepoxy.py => meson.py}     | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename meta/lib/oeqa/sdk/cases/{buildcpio.py => autotools.py} (97%)
 rename meta/lib/oeqa/sdk/cases/{assimp.py => cmake.py} (95%)
 rename meta/lib/oeqa/sdk/cases/{buildgalculator.py => gtk3.py} (98%)
 rename meta/lib/oeqa/sdk/cases/{buildlzip.py => makefile.py} (97%)
 rename meta/lib/oeqa/sdk/cases/{buildepoxy.py => meson.py} (93%)
meta/lib/oeqa/sdk/cases/autotools.py renamed from meta/lib/oeqa/sdk/cases/buildcpio.py +1 -1
similarity index 97%
rename from meta/lib/oeqa/sdk/cases/buildcpio.py
rename to meta/lib/oeqa/sdk/cases/autotools.py
index 51003b19cd0..a711353791c 100644
@@ -13,7 +13,7 @@ from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 errors_have_output()
 
-class BuildCpioTest(OESDKTestCase):
+class AutotoolsTest(OESDKTestCase):
     """
     Check that autotools will cross-compile correctly.
     """
meta/lib/oeqa/sdk/cases/cmake.py renamed from meta/lib/oeqa/sdk/cases/assimp.py +2 -2
similarity index 95%
rename from meta/lib/oeqa/sdk/cases/assimp.py
rename to meta/lib/oeqa/sdk/cases/cmake.py
index e986838aea7..4886435ddf1 100644
@@ -13,7 +13,7 @@ from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 errors_have_output()
 
-class BuildAssimp(OESDKTestCase):
+class CMakeTest(OESDKTestCase):
     """
     Test case to build a project using cmake.
     """
@@ -21,7 +21,7 @@ class BuildAssimp(OESDKTestCase):
     def setUp(self):
         if not (self.tc.hasHostPackage("nativesdk-cmake") or
                 self.tc.hasHostPackage("cmake-native")):
-            raise unittest.SkipTest("Needs cmake")
+            raise unittest.SkipTest("CMakeTest: needs cmake")
 
     def test_assimp(self):
         with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
meta/lib/oeqa/sdk/cases/gtk3.py renamed from meta/lib/oeqa/sdk/cases/buildgalculator.py +1 -1
similarity index 98%
rename from meta/lib/oeqa/sdk/cases/buildgalculator.py
rename to meta/lib/oeqa/sdk/cases/gtk3.py
index 178f07472d5..c329c4bb86c 100644
@@ -13,7 +13,7 @@ from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 errors_have_output()
 
-class GalculatorTest(OESDKTestCase):
+class GTK3Test(OESDKTestCase):
     """
     Test that autotools and GTK+ 3 compiles correctly.
     """
meta/lib/oeqa/sdk/cases/makefile.py renamed from meta/lib/oeqa/sdk/cases/buildlzip.py +1 -1
similarity index 97%
rename from meta/lib/oeqa/sdk/cases/buildlzip.py
rename to meta/lib/oeqa/sdk/cases/makefile.py
index b4b7d85b882..c0b40f1f728 100644
@@ -9,7 +9,7 @@ from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 errors_have_output()
 
-class BuildLzipTest(OESDKTestCase):
+class MakefileTest(OESDKTestCase):
     """
     Test that "plain" compilation works, using just $CC $CFLAGS etc.
     """
meta/lib/oeqa/sdk/cases/meson.py renamed from meta/lib/oeqa/sdk/cases/buildepoxy.py +2 -2
similarity index 93%
rename from meta/lib/oeqa/sdk/cases/buildepoxy.py
rename to meta/lib/oeqa/sdk/cases/meson.py
index 147ee3e0eee..be53df204a5 100644
@@ -13,14 +13,14 @@ from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 errors_have_output()
 
-class EpoxyTest(OESDKTestCase):
+class MesonTest(OESDKTestCase):
     """
     Test that Meson builds correctly.
     """
     def setUp(self):
         if not (self.tc.hasHostPackage("nativesdk-meson") or
                 self.tc.hasHostPackage("meson-native")):
-            raise unittest.SkipTest("EpoxyTest class: SDK doesn't contain Meson")
+            raise unittest.SkipTest("MesonTest: needs meson")
 
     def test_epoxy(self):
         with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir:
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/6 oeqa/sdk: remove unused imports from test cases

Remove redundant imports.

---
 meta/lib/oeqa/sdk/cases/autotools.py | 1 -
 meta/lib/oeqa/sdk/cases/makefile.py  | 2 +-
 meta/lib/oeqa/sdk/cases/maturin.py   | 1 -
 meta/lib/oeqa/sdk/cases/python.py    | 2 +-
 meta/lib/oeqa/sdk/cases/rust.py      | 1 -
 5 files changed, 2 insertions(+), 5 deletions(-)
meta/lib/oeqa/sdk/cases/autotools.py +0 -1
index a711353791c..848e9392ec0 100644
@@ -7,7 +7,6 @@
 import os
 import tempfile
 import subprocess
-import unittest
 
 from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
meta/lib/oeqa/sdk/cases/makefile.py +1 -1
index c0b40f1f728..2ff54ce25ff 100644
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier: MIT
 #
 
-import os, tempfile, subprocess, unittest
+import os, tempfile, subprocess
 from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 errors_have_output()
meta/lib/oeqa/sdk/cases/maturin.py +0 -1
index ea10f568b27..20f6b553d0b 100644
@@ -8,7 +8,6 @@ import os
 import shutil
 import unittest
 
-from oeqa.core.utils.path import remove_safe
 from oeqa.sdk.case import OESDKTestCase
 from oeqa.utils.subprocesstweak import errors_have_output
 
meta/lib/oeqa/sdk/cases/python.py +1 -1
index 5ea992b9f33..51284949f50 100644
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier: MIT
 #
 
-import subprocess, unittest
+import unittest
 from oeqa.sdk.case import OESDKTestCase
 
 from oeqa.utils.subprocesstweak import errors_have_output
meta/lib/oeqa/sdk/cases/rust.py +0 -1
index f5d437bb19d..a54245851b4 100644
@@ -8,7 +8,6 @@ import os
 import shutil
 import unittest
 
-from oeqa.core.utils.path import remove_safe
 from oeqa.sdk.case import OESDKTestCase
 
 from oeqa.utils.subprocesstweak import errors_have_output
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/6 meson: don't use deprecated pkgconfig variable

In reply to Ross Burton

As with a previous change to the class[1], the "pkgconfig" entry is now deprecated and "pkg-config" should be used instead.

[1] oe-core d64b307891422e290bbe821d4303b3af526bbe17

---
 meta/recipes-devtools/meson/meson_1.3.1.bb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-devtools/meson/meson_1.3.1.bb +2 -2
index 3d2eedca10a..5b0d82fe9f5 100644
@@ -86,7 +86,7 @@ ar = ${@meson_array('BUILD_AR', d)}
 nm = ${@meson_array('BUILD_NM', d)}
 strip = ${@meson_array('BUILD_STRIP', d)}
 readelf = ${@meson_array('BUILD_READELF', d)}
-pkgconfig = 'pkg-config-native'
+pkg-config = 'pkg-config-native'
 
 [built-in options]
 c_args = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
@@ -104,7 +104,7 @@ cpp = @CXX
 ar = @AR
 nm = @NM
 strip = @STRIP
-pkgconfig = 'pkg-config'
+pkg-config = 'pkg-config'
 
 [built-in options]
 c_args = @CFLAGS
Signature · 1 line
2.34.1
#3 lore raw

PATCH 4/6 toolchain-scripts: export the target endianism and word size

In reply to Ross Burton

Some build systems (notably, Meson) like to be told when cross-compiling what the target endian and word size is. We don't have these exported via the variables, so add them using siteinfo as a source of data.

---
 meta/classes-recipe/toolchain-scripts.bbclass | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/classes-recipe/toolchain-scripts.bbclass +9 -0
index 6bfe0b6de0d..cbef412e796 100644
@@ -16,6 +16,13 @@ DEBUG_PREFIX_MAP = ""
 
 EXPORT_SDK_PS1 = "${@ 'export PS1=\\"%s\\"' % d.getVar('SDK_PS1') if d.getVar('SDK_PS1') else ''}"
 
+def siteinfo_with_prefix(d, prefix):
+    # Return a prefixed value from siteinfo
+    for item in siteinfo_data_for_machine(d.getVar("TARGET_ARCH"), d.getVar("TARGET_OS"), d):
+        if item.startswith(prefix):
+            return item.replace(prefix, "")
+    raise KeyError
+
 # This function creates an environment-setup-script for use in a deployable SDK
 toolchain_create_sdk_env_script () {
 	# Create environment setup script.  Remember that $SDKTARGETSYSROOT should
@@ -63,6 +70,8 @@ toolchain_create_sdk_env_script () {
 	echo 'export OECORE_BASELIB="${baselib}"' >> $script
 	echo 'export OECORE_TARGET_ARCH="${TARGET_ARCH}"' >>$script
 	echo 'export OECORE_TARGET_OS="${TARGET_OS}"' >>$script
+	echo 'export OECORE_TARGET_BITS="${@siteinfo_with_prefix(d, 'bit-')}"' >>$script
+	echo 'export OECORE_TARGET_ENDIAN="${@siteinfo_with_prefix(d, 'endian-')}"' >>$script
 
 	echo 'unset command_not_found_handle' >> $script
 
Signature · 1 line
2.34.1
#4 lore raw

PATCH 5/6 meson: correct the host machine definition in SDKs

In reply to Ross Burton

The SDK_ARCH is not the correct definiton for the host machine definition inside the SDK, but because a nativesdk recipe doesn't know what the final target will be these values should be set up at SDK installation time via the environment script.

Put placeholders in the installed meson.cross file instead, and replace them at SDK installation time with the correct values.

---
 .../meson/meson/meson-setup.py                | 37 +++++++++++++++++++
 meta/recipes-devtools/meson/meson_1.3.1.bb    | 16 ++------
 2 files changed, 41 insertions(+), 12 deletions(-)
meta/recipes-devtools/meson/meson/meson-setup.py +37 -0
index daaa551de2d..74579ecca6b 100755
@@ -1,9 +1,42 @@
 #!/usr/bin/env python3
 
 import os
+import re
 import string
 import sys
 
+# Keep these in sync with the logic in meson-routines.bbclass
+def meson_cpu_family():
+    arch = os.environ["OECORE_TARGET_ARCH"]
+    if arch == 'powerpc':
+        return 'ppc'
+    elif arch == 'powerpc64' or arch == 'powerpc64le':
+        return 'ppc64'
+    elif arch == 'armeb':
+        return 'arm'
+    elif arch == 'aarch64_be':
+        return 'aarch64'
+    elif arch == 'mipsel':
+        return 'mips'
+    elif arch == 'mips64el':
+        return 'mips64'
+    elif re.match(r"i[3-6]86", arch):
+        return "x86"
+    elif arch == "microblazeel":
+        return "microblaze"
+    else:
+        return arch
+
+def meson_operating_system():
+    opersys = os.environ["OECORE_TARGET_ARCH"]
+    if "mingw" in opersys:
+        return "windows"
+    # avoid e.g 'linux-gnueabi'
+    elif "linux" in opersys:
+        return "linux"
+    else:
+        return opersys
+
 class Template(string.Template):
     delimiter = "@"
 
@@ -30,6 +63,10 @@ cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ[
 native_template_file = os.path.join(sysroot, 'usr/share/meson/meson.native.template')
 native_file = os.path.join(sysroot, 'usr/share/meson/meson.native')
 
+# Inject transformed values
+os.environ["OECORE_MESON_TARGET_FAMILY"] = meson_cpu_family()
+os.environ["OECORE_MESON_TARGET_OS"] = meson_operating_system()
+
 with open(template_file) as in_file:
     template = in_file.read()
     output = Template(template).substitute(Environ())
meta/recipes-devtools/meson/meson_1.3.1.bb +4 -12
index 5b0d82fe9f5..f8085f369bf 100644
@@ -117,18 +117,14 @@ needs_exe_wrapper = true
 sys_root = @OECORE_TARGET_SYSROOT
 
 [host_machine]
-system = '$host_system'
-cpu_family = '$host_cpu_family'
-cpu = '$host_cpu'
-endian = '$host_endian'
+system = @OECORE_MESON_TARGET_OS
+cpu_family = @OECORE_MESON_TARGET_FAMILY
+cpu = @OECORE_TARGET_ARCH
+endian = @OECORE_TARGET_ENDIAN
 EOF
 }
 
 do_install:append:class-nativesdk() {
-    host_system=${SDK_OS}
-    host_cpu_family=${@meson_cpu_family("SDK_ARCH", d)}
-    host_cpu=${SDK_ARCH}
-    host_endian=${@meson_endian("SDK", d)}
     install_templates
 
     install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
@@ -142,10 +138,6 @@ do_install:append:class-nativesdk() {
 FILES:${PN}:append:class-nativesdk = "${datadir}/meson ${SDKPATHNATIVE}"
 
 do_install:append:class-native() {
-    host_system=${HOST_OS}
-    host_cpu_family=${@meson_cpu_family("HOST_ARCH", d)}
-    host_cpu=${HOST_ARCH}
-    host_endian=${@meson_endian("HOST", d)}
     install_templates
 
     install -d ${D}${datadir}/post-relocate-setup.d
Signature · 1 line
2.34.1
#5 lore raw

Re: [OE-core] [PATCH 5/6] meson: correct the host machine definition in SDKs

I believe this causes the following failure:

https://autobuilder.yoctoproject.org/typhoon/#/builders/146/builds/1733/steps/12/logs/stdio

Quoted 123 lines · Ross Burton

The SDK_ARCH is not the correct definiton for the host machine definition inside the SDK, but because a nativesdk recipe doesn't know what the final target will be these values should be set up at SDK installation time via the environment script.

Put placeholders in the installed meson.cross file instead, and replace them at SDK installation time with the correct values.

---
 .../meson/meson/meson-setup.py                | 37 +++++++++++++++++++
 meta/recipes-devtools/meson/meson_1.3.1.bb    | 16 ++------
 2 files changed, 41 insertions(+), 12 deletions(-)
meta/recipes-devtools/meson/meson/meson-setup.py +37 -0
index daaa551de2d..74579ecca6b 100755
@@ -1,9 +1,42 @@
 #!/usr/bin/env python3
 
 import os
+import re
 import string
 import sys
 
+# Keep these in sync with the logic in meson-routines.bbclass
+def meson_cpu_family():
+    arch = os.environ["OECORE_TARGET_ARCH"]
+    if arch == 'powerpc':
+        return 'ppc'
+    elif arch == 'powerpc64' or arch == 'powerpc64le':
+        return 'ppc64'
+    elif arch == 'armeb':
+        return 'arm'
+    elif arch == 'aarch64_be':
+        return 'aarch64'
+    elif arch == 'mipsel':
+        return 'mips'
+    elif arch == 'mips64el':
+        return 'mips64'
+    elif re.match(r"i[3-6]86", arch):
+        return "x86"
+    elif arch == "microblazeel":
+        return "microblaze"
+    else:
+        return arch
+
+def meson_operating_system():
+    opersys = os.environ["OECORE_TARGET_ARCH"]
+    if "mingw" in opersys:
+        return "windows"
+    # avoid e.g 'linux-gnueabi'
+    elif "linux" in opersys:
+        return "linux"
+    else:
+        return opersys
+
 class Template(string.Template):
     delimiter = "@"
 
@@ -30,6 +63,10 @@ cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ[
 native_template_file = os.path.join(sysroot, 'usr/share/meson/meson.native.template')
 native_file = os.path.join(sysroot, 'usr/share/meson/meson.native')
 
+# Inject transformed values
+os.environ["OECORE_MESON_TARGET_FAMILY"] = meson_cpu_family()
+os.environ["OECORE_MESON_TARGET_OS"] = meson_operating_system()
+
 with open(template_file) as in_file:
     template = in_file.read()
     output = Template(template).substitute(Environ())
meta/recipes-devtools/meson/meson_1.3.1.bb +4 -12
index 5b0d82fe9f5..f8085f369bf 100644
@@ -117,18 +117,14 @@ needs_exe_wrapper = true
 sys_root = @OECORE_TARGET_SYSROOT
 
 [host_machine]
-system = '$host_system'
-cpu_family = '$host_cpu_family'
-cpu = '$host_cpu'
-endian = '$host_endian'
+system = @OECORE_MESON_TARGET_OS
+cpu_family = @OECORE_MESON_TARGET_FAMILY
+cpu = @OECORE_TARGET_ARCH
+endian = @OECORE_TARGET_ENDIAN
 EOF
 }
 
 do_install:append:class-nativesdk() {
-    host_system=${SDK_OS}
-    host_cpu_family=${@meson_cpu_family("SDK_ARCH", d)}
-    host_cpu=${SDK_ARCH}
-    host_endian=${@meson_endian("SDK", d)}
     install_templates
 
     install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
@@ -142,10 +138,6 @@ do_install:append:class-nativesdk() {
 FILES:${PN}:append:class-nativesdk = "${datadir}/meson ${SDKPATHNATIVE}"
 
 do_install:append:class-native() {
-    host_system=${HOST_OS}
-    host_cpu_family=${@meson_cpu_family("HOST_ARCH", d)}
-    host_cpu=${HOST_ARCH}
-    host_endian=${@meson_endian("HOST", d)}
     install_templates
 
     install -d ${D}${datadir}/post-relocate-setup.d
Signature · 11 lines
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199567): https://lists.openembedded.org/g/openembedded-core/message/199567
Mute This Topic: https://lists.openembedded.org/mt/106200491/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

PATCH 6/6 oeqa/sdk/meson: improve test to validate host/build target assignments

In reply to Ross Burton

Use 'meson introspect' to dump JSON describing the build configuration and validate that the build and host architectures are correctly set in the meson.cross file.

Also instead of calling ninja directly, call the relevant meson commands.

---
 meta/lib/oeqa/sdk/cases/meson.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
meta/lib/oeqa/sdk/cases/meson.py +13 -5
index be53df204a5..5b53668c958 100644
@@ -4,6 +4,7 @@
 # SPDX-License-Identifier: MIT
 #
 
+import json
 import os
 import subprocess
 import tempfile
@@ -35,10 +36,17 @@ class MesonTest(OESDKTestCase):
             self.assertTrue(os.path.isdir(dirs["source"]))
             os.makedirs(dirs["build"])
 
-            log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
-            # Check that Meson thinks we're doing a cross build and not a native
-            self.assertIn("Build type: cross build", log)
-            self._run("ninja -C {build} -v".format(**dirs))
-            self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs))
+            log = self._run("meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
+
+            # Check that the host (gcc) and build (cross-gcc) compilers are different
+            data = json.loads(self._run("meson introspect --compilers {build}".format(**dirs)))
+            self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
+            # Check that the system architectures were set correctly
+            data = json.loads(self._run("meson introspect --machines {build}".format(**dirs)))
+            self.assertEqual(data["build"]["cpu"], self.td["SDK_ARCH"])
+            self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"])
+
+            self._run("meson compile -C {build} -v".format(**dirs))
+            self._run("meson install -C {build} --destdir {install}".format(**dirs))
 
             self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so"))
Signature · 1 line
2.34.1