]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
oeqa/sdk: Simplify test specification and discovery
authorThune Tran <thune.a.tran@boeing.com>
Thu, 26 Jun 2025 20:57:21 +0000 (20:57 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 1 Jul 2025 07:47:23 +0000 (08:47 +0100)
Simplify how tests are specified and discovered for different SDK configurations
to allow per-layer customization.

* Introduce `TESTSDK_CASE_DIRS` variable to specify test directory types,
  replacing the need to modify the default_cases class member

* Discover tests from configured layers using a common discovery pattern
  (`<LAYER_DIR>/lib/oeqa/<dirname>/cases`) where `<dirname>` is specified in `TESTSDK_CASE_DIRS`

* The buildtools directories were renamed to follow the common discovery pattern
(`<LAYER_DIR>/lib/oeqa/<dirname>/cases`) for consistency across all SDK configurations.

  meta/lib/oeqa/
  ├── sdk/cases/              # Standard SDK: dirname="sdk"
  ├── buildtools/cases/       # Buildtools: dirname="buildtools"
  └── buildtools-docs/cases/  # Buildtools-docs: dirname="buildtools-docs"

  meta-mingw/lib/oeqa/
  └── sdkmingw/cases/         # MinGW: dirname="sdkmingw"

  meta-foo/lib/oeqa/
  └── sdk/cases/              # Standard SDK: dirname="sdk"

Tested by:

1. Adding new tests using the default discovery pattern `<LAYER_DIR>/lib/oeqa/sdk/cases` and
   verifying they are discovered and executed.

2. Verifying existing SDK configuration tests work (requires -c populate_sdk first):
   * Standard SDK: `bitbake core-image-minimal -c testsdk`
   * Buildtools tarball: `bitbake buildtools-tarball -c testsdk`
   * Buildtools docs tarball: `bitbake buildtools-docs-tarball -c testsdk`
   * Mingw SDK: (SDKMACHINE = "x86_64-mingw32") `bitbake core-image-minimal -c testsdk`

Signed-off-by: Thune Tran <thune.a.tran@boeing.com>
Signed-off-by: Chuck Wolber <chuck.wolber@boeing.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/testsdk.bbclass
meta/lib/oeqa/buildtools-docs/cases/README [moved from meta/lib/oeqa/sdk/buildtools-docs-cases/README with 100% similarity]
meta/lib/oeqa/buildtools-docs/cases/build.py [moved from meta/lib/oeqa/sdk/buildtools-docs-cases/build.py with 100% similarity]
meta/lib/oeqa/buildtools/cases/README [moved from meta/lib/oeqa/sdk/buildtools-cases/README with 100% similarity]
meta/lib/oeqa/buildtools/cases/build.py [moved from meta/lib/oeqa/sdk/buildtools-cases/build.py with 100% similarity]
meta/lib/oeqa/buildtools/cases/gcc.py [moved from meta/lib/oeqa/sdk/buildtools-cases/gcc.py with 100% similarity]
meta/lib/oeqa/buildtools/cases/https.py [moved from meta/lib/oeqa/sdk/buildtools-cases/https.py with 100% similarity]
meta/lib/oeqa/buildtools/cases/sanity.py [moved from meta/lib/oeqa/sdk/buildtools-cases/sanity.py with 100% similarity]
meta/lib/oeqa/sdk/testsdk.py
meta/recipes-core/meta/buildtools-docs-tarball.bb
meta/recipes-core/meta/buildtools-tarball.bb

index 59d2834c9929a900f3607469b97b9a0d9346106f..b1c4fa67e65b659b9eca623992c93fcec76003c5 100644 (file)
@@ -19,6 +19,7 @@ TESTSDK_SUITES ?= ""
 
 TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK"
 TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt"
+TESTSDK_CASE_DIRS ?= "sdk"
 
 def import_and_run(name, d):
     import importlib
index 52b702b6a2806294b8c84cc849a577284e4d30bc..cffcf9f49a9ccc4963483ce7995f81aceebb3201 100644 (file)
@@ -31,6 +31,28 @@ class TestSDK(TestSDKBase):
     context_class = OESDKTestContext
     test_type = 'sdk'
 
+    def sdk_dir_names(self, d):
+        """Return list from TESTSDK_CASE_DIRS."""
+        testdirs = d.getVar("TESTSDK_CASE_DIRS")
+        if testdirs:
+            return testdirs.split()
+
+        bb.fatal("TESTSDK_CASE_DIRS unset, can't find SDK test directories.")
+
+    def get_sdk_paths(self, d):
+        """
+        Return a list of paths where SDK test cases reside.
+
+        SDK tests are expected in <LAYER_DIR>/lib/oeqa/<dirname>/cases
+        """
+        paths = []
+        for layer in d.getVar("BBLAYERS").split():
+            for dirname in self.sdk_dir_names(d):
+                case_path = os.path.join(layer, "lib", "oeqa", dirname, "cases")
+                if os.path.isdir(case_path):
+                    paths.append(case_path)
+        return paths
+
     def get_tcname(self, d):
         """
         Get the name of the SDK file
@@ -115,7 +137,7 @@ class TestSDK(TestSDKBase):
 
             try:
                 modules = (d.getVar("TESTSDK_SUITES") or "").split()
-                tc.loadTests(self.context_executor_class.default_cases, modules)
+                tc.loadTests(self.get_sdk_paths(d), modules)
             except Exception as e:
                 import traceback
                 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
index 24fbc3300045927bc6b544b9e73b6f400312bf87..98d47f7b719bfe51263442cf22d8edd912484fb1 100644 (file)
@@ -18,4 +18,5 @@ TOOLCHAIN_OUTPUTNAME = "${SDK_ARCH}-buildtools-docs-nativesdk-standalone-${DISTR
 
 SDK_TITLE = "Docs Build tools tarball"
 
-TESTSDK_CASES = "buildtools-docs-cases"
+# Directory that contains testcases
+TESTSDK_CASE_DIRS = "buildtools-docs"
\ No newline at end of file
index 6fa6d93a3d3d1e3d8553e504a19dab516b9293ec..02117ab84d22526e737edd6d8f66ec8f03712d1f 100644 (file)
@@ -124,22 +124,7 @@ TOOLCHAIN_NEED_CONFIGSITE_CACHE = ""
 # The recipe doesn't need any default deps
 INHIBIT_DEFAULT_DEPS = "1"
 
-# Directory in testsdk that contains testcases
-TESTSDK_CASES = "buildtools-cases"
+inherit testsdk
 
-# We have our own code, avoid deferred inherit
-SDK_CLASSES:remove = "testsdk"
-
-python do_testsdk() {
-    import oeqa.sdk.testsdk
-    testsdk = oeqa.sdk.testsdk.TestSDK()
-
-    cases_path = os.path.join(os.path.abspath(os.path.dirname(oeqa.sdk.testsdk.__file__)), d.getVar("TESTSDK_CASES"))
-    testsdk.context_executor_class.default_cases = [cases_path,]
-
-    testsdk.run(d)
-}
-addtask testsdk
-do_testsdk[nostamp] = "1"
-do_testsdk[network] = "1"
-do_testsdk[depends] += "xz-native:do_populate_sysroot"
+# Directory that contains testcases
+TESTSDK_CASE_DIRS = "buildtools"
\ No newline at end of file