oeqa/sdk: Simplify test specification and discovery

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`

(From OE-Core rev: bde94c128c0b4e7e1ebea40f582b4dd6dcc965ff)

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>
This commit is contained in:
Thune Tran 2025-06-26 20:57:21 +00:00 committed by Richard Purdie
parent ece7bb5490
commit 041ba867db
11 changed files with 29 additions and 20 deletions

View 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

View 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())

View 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"

View 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"