diff options
Diffstat (limited to 'meta/lib/oeqa/sdk')
22 files changed, 368 insertions, 41 deletions
diff --git a/meta/lib/oeqa/sdk/buildtools-cases/README b/meta/lib/oeqa/sdk/buildtools-cases/README new file mode 100644 index 0000000000..d4f20faa9f --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-cases/README @@ -0,0 +1,2 @@ +These test cases are used by buildtools-tarball, and are not used by the testsdk +class. diff --git a/meta/lib/oeqa/sdk/buildtools-cases/build.py b/meta/lib/oeqa/sdk/buildtools-cases/build.py new file mode 100644 index 0000000000..c85c32496b --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-cases/build.py @@ -0,0 +1,32 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import os, tempfile +import time +from oeqa.sdk.case import OESDKTestCase +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() + +class BuildTests(OESDKTestCase): + """ + Verify that bitbake can build virtual/libc inside the buildtools. + """ + def test_libc(self): + with tempfile.TemporaryDirectory(prefix='bitbake-build-', dir=self.tc.sdk_dir) as testdir: + corebase = self.td['COREBASE'] + + self._run('. %s/oe-init-build-env %s' % (corebase, testdir)) + with open(os.path.join(testdir, 'conf', 'local.conf'), 'ta') as conf: + conf.write('\n') + conf.write('DL_DIR = "%s"\n' % self.td['DL_DIR']) + + try: + self._run('. %s/oe-init-build-env %s && bitbake virtual/libc' % (corebase, testdir)) + finally: + delay = 10 + while delay and (os.path.exists(testdir + "/bitbake.lock") or os.path.exists(testdir + "/cache/hashserv.db-wal")): + time.sleep(1) + delay = delay - 1 diff --git a/meta/lib/oeqa/sdk/buildtools-cases/gcc.py b/meta/lib/oeqa/sdk/buildtools-cases/gcc.py new file mode 100644 index 0000000000..a62c4d0bc4 --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-cases/gcc.py @@ -0,0 +1,31 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import os.path +from oeqa.sdk.case import OESDKTestCase + +class GccTests(OESDKTestCase): + def test_verify_specs(self): + """ + Verify that the compiler has been relocated successfully and isn't + looking in the hard-coded prefix. + """ + # Canonicalise the SDK root + sdk_base = os.path.realpath(self.tc.sdk_dir) + # Canonicalise the location of GCC + gcc_path = os.path.realpath(self._run("command -v gcc").strip()) + # Skip the test if the GCC didn't come from the buildtools, as it only + # comes with buildtools-extended-tarball. + if os.path.commonprefix((sdk_base, gcc_path)) != sdk_base: + self.skipTest("Buildtools does not provide GCC") + + # This is the prefix that GCC is build with, and should be replaced at + # installation time. + sdkpath = self.td.get("SDKPATH") + self.assertTrue(sdkpath) + + for line in self._run('gcc -dumpspecs').splitlines(): + self.assertNotIn(sdkpath, line) diff --git a/meta/lib/oeqa/sdk/buildtools-cases/https.py b/meta/lib/oeqa/sdk/buildtools-cases/https.py new file mode 100644 index 0000000000..4525e3d758 --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-cases/https.py @@ -0,0 +1,22 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +from oeqa.sdk.case import OESDKTestCase +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() + +class HTTPTests(OESDKTestCase): + """ + Verify that HTTPS certificates are working correctly, as this depends on + environment variables being set correctly. + """ + + def test_wget(self): + self._run('env -i wget --debug --output-document /dev/null https://yoctoproject.org/connectivity.html') + + def test_python(self): + # urlopen() returns a file-like object on success and throws an exception otherwise + self._run('python3 -c \'import urllib.request; urllib.request.urlopen("https://yoctoproject.org/connectivity.html")\'') diff --git a/meta/lib/oeqa/sdk/buildtools-cases/sanity.py b/meta/lib/oeqa/sdk/buildtools-cases/sanity.py new file mode 100644 index 0000000000..a55d456656 --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-cases/sanity.py @@ -0,0 +1,24 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import shutil +import os.path +from oeqa.sdk.case import OESDKTestCase + +class SanityTests(OESDKTestCase): + def test_tools(self): + """ + Test that wget and tar come from the buildtools, not the host. This + verifies that the buildtools have installed correctly. We can't check + for gcc as that is only installed by buildtools-extended. + """ + for command in ("tar", "wget"): + # Canonicalise the SDK root + sdk_base = os.path.realpath(self.tc.sdk_dir) + # Canonicalise the location of this command + tool_path = os.path.realpath(self._run("command -v %s" % command).strip()) + # Assert that the tool was found inside the SDK root + self.assertEqual(os.path.commonprefix((sdk_base, tool_path)), sdk_base) diff --git a/meta/lib/oeqa/sdk/buildtools-docs-cases/README b/meta/lib/oeqa/sdk/buildtools-docs-cases/README new file mode 100644 index 0000000000..f8edbc7dad --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-docs-cases/README @@ -0,0 +1,2 @@ +These test cases are used by build-docs-tarball, and are not used by the testsdk +class. diff --git a/meta/lib/oeqa/sdk/buildtools-docs-cases/build.py b/meta/lib/oeqa/sdk/buildtools-docs-cases/build.py new file mode 100644 index 0000000000..6e3ee94292 --- /dev/null +++ b/meta/lib/oeqa/sdk/buildtools-docs-cases/build.py @@ -0,0 +1,19 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import tempfile +from oeqa.sdk.case import OESDKTestCase +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() + +class BuildTests(OESDKTestCase): + """ + Verify that our docs can build using our docs tools tarball. + """ + def test_docs_build(self): + with tempfile.TemporaryDirectory(prefix='docs-tarball-build-', dir=self.tc.sdk_dir) as testdir: + self._run('git clone git://git.yoctoproject.org/yocto-docs %s' % testdir) + self._run('cd %s/documentation && make html' % testdir) diff --git a/meta/lib/oeqa/sdk/cases/buildcpio.py b/meta/lib/oeqa/sdk/cases/autotools.py index e7fc211a47..848e9392ec 100644 --- a/meta/lib/oeqa/sdk/cases/buildcpio.py +++ b/meta/lib/oeqa/sdk/cases/autotools.py @@ -1,26 +1,27 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # import os import tempfile import subprocess -import unittest 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. """ def test_cpio(self): with tempfile.TemporaryDirectory(prefix="cpio-", dir=self.tc.sdk_dir) as testdir: - tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.13.tar.gz") + tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.15.tar.gz") dirs = {} - dirs["source"] = os.path.join(testdir, "cpio-2.13") + dirs["source"] = os.path.join(testdir, "cpio-2.15") dirs["build"] = os.path.join(testdir, "build") dirs["install"] = os.path.join(testdir, "install") @@ -28,8 +29,7 @@ class BuildCpioTest(OESDKTestCase): self.assertTrue(os.path.isdir(dirs["source"])) os.makedirs(dirs["build"]) - self._run("sed -i -e '/char.*program_name/d' {source}/src/global.c".format(**dirs)) - self._run("cd {build} && {source}/configure --disable-maintainer-mode $CONFIGURE_FLAGS".format(**dirs)) + self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs)) self._run("cd {build} && make -j".format(**dirs)) self._run("cd {build} && make install DESTDIR={install}".format(**dirs)) diff --git a/meta/lib/oeqa/sdk/cases/assimp.py b/meta/lib/oeqa/sdk/cases/cmake.py index f166758e49..db7d826a38 100644 --- a/meta/lib/oeqa/sdk/cases/assimp.py +++ b/meta/lib/oeqa/sdk/cases/cmake.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -11,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. """ @@ -19,22 +21,25 @@ 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: - tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz") + tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v5.4.1.tar.gz") dirs = {} - dirs["source"] = os.path.join(testdir, "assimp-4.1.0") + dirs["source"] = os.path.join(testdir, "assimp-5.4.1") dirs["build"] = os.path.join(testdir, "build") dirs["install"] = os.path.join(testdir, "install") subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) self.assertTrue(os.path.isdir(dirs["source"])) + # Apply the zlib patch https://github.com/madler/zlib/commit/a566e156b3fa07b566ddbf6801b517a9dba04fa3 + # this sed wont be needed once assimp moves its zlib copy to v1.3.1+ + self._run("sed -i '/# ifdef _FILE_OFFSET_BITS/I,+2 d' {source}/contrib/zlib/gzguts.h".format(**dirs)) os.makedirs(dirs["build"]) - self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON {source}".format(**dirs)) + self._run("cd {build} && cmake -DASSIMP_WARNINGS_AS_ERRORS=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DASSIMP_BUILD_ZLIB=ON {source}".format(**dirs)) self._run("cmake --build {build} -- -j".format(**dirs)) self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs)) - self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.4.1.0")) + self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.5.4.1")) diff --git a/meta/lib/oeqa/sdk/cases/gcc.py b/meta/lib/oeqa/sdk/cases/gcc.py index eb08eadd28..fc28b9c3d4 100644 --- a/meta/lib/oeqa/sdk/cases/gcc.py +++ b/meta/lib/oeqa/sdk/cases/gcc.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/sdk/cases/buildgalculator.py b/meta/lib/oeqa/sdk/cases/gtk3.py index eb3c8ddf39..c329c4bb86 100644 --- a/meta/lib/oeqa/sdk/cases/buildgalculator.py +++ b/meta/lib/oeqa/sdk/cases/gtk3.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -11,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. """ @@ -19,7 +21,8 @@ class GalculatorTest(OESDKTestCase): if not (self.tc.hasTargetPackage("gtk+3", multilib=True) or \ self.tc.hasTargetPackage("libgtk-3.0", multilib=True)): raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3") - if not (self.tc.hasHostPackage("nativesdk-gettext-dev")): + if not (self.tc.hasHostPackage("nativesdk-gettext-dev") or + self.tc.hasHostPackage("gettext-native")): raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext") def test_galculator(self): diff --git a/meta/lib/oeqa/sdk/cases/buildlzip.py b/meta/lib/oeqa/sdk/cases/makefile.py index 49ae756bf3..2ff54ce25f 100644 --- a/meta/lib/oeqa/sdk/cases/buildlzip.py +++ b/meta/lib/oeqa/sdk/cases/makefile.py @@ -1,13 +1,15 @@ # +# Copyright OpenEmbedded Contributors +# # 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() -class BuildLzipTest(OESDKTestCase): +class MakefileTest(OESDKTestCase): """ Test that "plain" compilation works, using just $CC $CFLAGS etc. """ diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py new file mode 100644 index 0000000000..20f6b553d0 --- /dev/null +++ b/meta/lib/oeqa/sdk/cases/maturin.py @@ -0,0 +1,78 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import os +import shutil +import unittest + +from oeqa.sdk.case import OESDKTestCase +from oeqa.utils.subprocesstweak import errors_have_output + +errors_have_output() + + +class MaturinTest(OESDKTestCase): + def setUp(self): + if not ( + self.tc.hasHostPackage("nativesdk-python3-maturin") + or self.tc.hasHostPackage("python3-maturin-native") + ): + raise unittest.SkipTest("No python3-maturin package in the SDK") + + def test_maturin_list_python(self): + py_major = self._run("python3 -c 'import sys; print(sys.version_info.major)'") + py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'") + python_version = "%s.%s" % (py_major.strip(), py_minor.strip()) + cmd = "maturin list-python" + output = self._run(cmd) + self.assertRegex(output, r"^🐍 1 python interpreter found:\n") + self.assertRegex( + output, + r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), + ) + + +class MaturinDevelopTest(OESDKTestCase): + @classmethod + def setUpClass(self): + targetdir = os.path.join(self.tc.sdk_dir, "guessing-game") + try: + shutil.rmtree(targetdir) + except FileNotFoundError: + pass + shutil.copytree( + os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir + ) + + def setUp(self): + machine = self.td.get("MACHINE") + if not ( + self.tc.hasHostPackage("nativesdk-python3-maturin") + or self.tc.hasHostPackage("python3-maturin-native") + ): + raise unittest.SkipTest("No python3-maturin package in the SDK") + if not ( + self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine) + ): + raise unittest.SkipTest( + "Testing 'maturin develop' requires Rust cross-canadian in the SDK" + ) + + def test_maturin_develop(self): + """ + This test case requires: + (1) that a .venv can been created. + (2) a functional 'rustc' and 'cargo' + """ + self._run("cd %s/guessing-game; python3 -m venv .venv" % self.tc.sdk_dir) + cmd = "cd %s/guessing-game; maturin develop" % self.tc.sdk_dir + output = self._run(cmd) + self.assertRegex(output, r"🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8") + self.assertRegex(output, r"🐍 Not using a specific python interpreter") + self.assertRegex(output, r"📡 Using build options features from pyproject.toml") + self.assertRegex(output, r"Compiling guessing-game v0.1.0") + self.assertRegex(output, r"📦 Built wheel for abi3 Python ≥ 3.8") + self.assertRegex(output, r"🛠 Installed guessing-game-0.1.0") diff --git a/meta/lib/oeqa/sdk/cases/buildepoxy.py b/meta/lib/oeqa/sdk/cases/meson.py index 385f8ccca8..be53df204a 100644 --- a/meta/lib/oeqa/sdk/cases/buildepoxy.py +++ b/meta/lib/oeqa/sdk/cases/meson.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # @@ -11,13 +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")): - raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain Meson") + if not (self.tc.hasHostPackage("nativesdk-meson") or + self.tc.hasHostPackage("meson-native")): + raise unittest.SkipTest("MesonTest: needs meson") def test_epoxy(self): with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir: @@ -32,7 +35,7 @@ class EpoxyTest(OESDKTestCase): self.assertTrue(os.path.isdir(dirs["source"])) os.makedirs(dirs["build"]) - log = self._run("meson -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs)) + 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)) diff --git a/meta/lib/oeqa/sdk/cases/perl.py b/meta/lib/oeqa/sdk/cases/perl.py index 14d76d820f..8eab4442e8 100644 --- a/meta/lib/oeqa/sdk/cases/perl.py +++ b/meta/lib/oeqa/sdk/cases/perl.py @@ -1,4 +1,6 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # diff --git a/meta/lib/oeqa/sdk/cases/python.py b/meta/lib/oeqa/sdk/cases/python.py index a334abce5f..51284949f5 100644 --- a/meta/lib/oeqa/sdk/cases/python.py +++ b/meta/lib/oeqa/sdk/cases/python.py @@ -1,24 +1,15 @@ # +# Copyright OpenEmbedded Contributors +# # SPDX-License-Identifier: MIT # -import subprocess, unittest +import unittest from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output errors_have_output() -class Python2Test(OESDKTestCase): - def setUp(self): - if not (self.tc.hasHostPackage("nativesdk-python-core") or - self.tc.hasHostPackage("python-core-native")): - raise unittest.SkipTest("No python package in the SDK") - - def test_python2(self): - cmd = "python -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" - output = self._run(cmd) - self.assertEqual(output, "Hello, world\n") - class Python3Test(OESDKTestCase): def setUp(self): if not (self.tc.hasHostPackage("nativesdk-python3-core") or diff --git a/meta/lib/oeqa/sdk/cases/rust.py b/meta/lib/oeqa/sdk/cases/rust.py new file mode 100644 index 0000000000..a54245851b --- /dev/null +++ b/meta/lib/oeqa/sdk/cases/rust.py @@ -0,0 +1,56 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import os +import shutil +import unittest + +from oeqa.sdk.case import OESDKTestCase + +from oeqa.utils.subprocesstweak import errors_have_output +errors_have_output() + +class RustCompileTest(OESDKTestCase): + td_vars = ['MACHINE'] + + @classmethod + def setUpClass(self): + targetdir = os.path.join(self.tc.sdk_dir, "hello") + try: + shutil.rmtree(targetdir) + except FileNotFoundError: + pass + shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir) + + def setUp(self): + machine = self.td.get("MACHINE") + if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine): + raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain") + + def test_cargo_build(self): + self._run('cd %s/hello; cargo build' % self.tc.sdk_dir) + +class RustHostCompileTest(OESDKTestCase): + td_vars = ['MACHINE', 'SDK_SYS'] + + @classmethod + def setUpClass(self): + targetdir = os.path.join(self.tc.sdk_dir, "hello") + try: + shutil.rmtree(targetdir) + except FileNotFoundError: + pass + shutil.copytree(os.path.join(self.tc.sdk_files_dir, "rust/hello"), targetdir) + + def setUp(self): + machine = self.td.get("MACHINE") + if not self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine): + raise unittest.SkipTest("RustCompileTest class: SDK doesn't contain a Rust cross-canadian toolchain") + + def test_cargo_build(self): + sdksys = self.td.get("SDK_SYS") + self._run('cd %s/hello; cargo build --target %s-gnu' % (self.tc.sdk_dir, sdksys)) + self._run('cd %s/hello; cargo run --target %s-gnu' % (self.tc.sdk_dir, sdksys)) diff --git a/meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml b/meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml new file mode 100644 index 0000000000..fe619478a6 --- /dev/null +++ b/meta/lib/oeqa/sdk/files/rust/hello/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/meta/lib/oeqa/sdk/files/rust/hello/build.rs b/meta/lib/oeqa/sdk/files/rust/hello/build.rs new file mode 100644 index 0000000000..b1a533d5df --- /dev/null +++ b/meta/lib/oeqa/sdk/files/rust/hello/build.rs @@ -0,0 +1,3 @@ +/* This is the simplest build script just to invoke host compiler + in the build process. */ +fn main() {} diff --git a/meta/lib/oeqa/sdk/files/rust/hello/src/main.rs b/meta/lib/oeqa/sdk/files/rust/hello/src/main.rs new file mode 100644 index 0000000000..a06c03f82a --- /dev/null +++ b/meta/lib/oeqa/sdk/files/rust/hello/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, OpenEmbedded world!"); +} diff --git a/meta/lib/oeqa/sdk/testmetaidesupport.py b/meta/lib/oeqa/sdk/testmetaidesupport.py new file mode 100644 index 0000000000..00ef30e82e --- /dev/null +++ b/meta/lib/oeqa/sdk/testmetaidesupport.py @@ -0,0 +1,45 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +class TestSDK(object): + def run(self, d): + import json + import logging + from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor + from oeqa.utils import make_logger_bitbake_compatible + + pn = d.getVar("PN") + + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + sdk_dir = d.expand("${WORKDIR}/testsdk/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + + sdk_envs = OESDKTestContextExecutor._get_sdk_environs(d.getVar("DEPLOY_DIR_IMAGE")) + tdname = d.expand("${DEPLOY_DIR_IMAGE}/${PN}.testdata.json") + test_data = json.load(open(tdname, "r")) + + host_pkg_manifest = {"cmake-native":"", "gcc-cross":"", "gettext-native":"", "meson-native":"", "perl-native":"", "python3-core-native":"", } + target_pkg_manifest = {"gtk+3":""} + + for s in sdk_envs: + bb.plain("meta-ide-support based SDK testing environment: %s" % s) + + sdk_env = sdk_envs[s] + + tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest) + + tc.loadTests(OESDKTestContextExecutor.default_cases) + + results = tc.runTests() + if results: + results.logSummary(pn) + + if (not results) or (not results.wasSuccessful()): + bb.fatal('%s - FAILED' % (pn,), forcelog=True) diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py index 35e40187bc..518b09febb 100644 --- a/meta/lib/oeqa/sdk/testsdk.py +++ b/meta/lib/oeqa/sdk/testsdk.py @@ -23,14 +23,6 @@ class TestSDKBase(object): return configuration @staticmethod - def get_sdk_json_result_dir(d): - json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') - custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") - if custom_json_result_dir: - json_result_dir = custom_json_result_dir - return json_result_dir - - @staticmethod def get_sdk_result_id(configuration): return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) @@ -72,6 +64,7 @@ class TestSDK(TestSDKBase): from bb.utils import export_proxies from oeqa.utils import make_logger_bitbake_compatible + from oeqa.utils import get_json_result_dir pn = d.getVar("PN") logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) @@ -79,6 +72,9 @@ class TestSDK(TestSDKBase): # sdk use network for download projects for build export_proxies(d) + # We need the original PATH for testing the eSDK, not with our manipulations + os.environ['PATH'] = d.getVar("BB_ORIGENV", False).getVar("PATH") + tcname = self.get_tcname(d) if not os.path.exists(tcname): @@ -131,7 +127,7 @@ class TestSDK(TestSDKBase): component = "%s %s" % (pn, self.context_executor_class.name) context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) configuration = self.get_sdk_configuration(d, self.test_type) - result.logDetails(self.get_sdk_json_result_dir(d), + result.logDetails(get_json_result_dir(d), configuration, self.get_sdk_result_id(configuration)) result.logSummary(component, context_msg) |