poky/meta/classes-recipe/testsdk.bbclass
Thune Tran 041ba867db 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>
2025-07-01 08:49:37 +01:00

57 lines
1.5 KiB
Plaintext

# Copyright (C) 2013 - 2016 Intel Corporation
#
# SPDX-License-Identifier: MIT
# testsdk.bbclass enables testing for SDK and Extensible SDK
#
# To run SDK tests, run the commands:
# $ bitbake <image-name> -c populate_sdk
# $ bitbake <image-name> -c testsdk
#
# To run eSDK tests, run the commands:
# $ bitbake <image-name> -c populate_sdk_ext
# $ bitbake <image-name> -c testsdkext
#
# where "<image-name>" is an image like core-image-sato.
# List of test modules to run, or run all that can be found if unset
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
class_name = d.getVar(name)
if class_name:
module, cls = class_name.rsplit('.', 1)
m = importlib.import_module(module)
c = getattr(m, cls)()
c.run(d)
else:
bb.warn('No tests were run because %s did not define a class' % name)
import_and_run[vardepsexclude] = "DATETIME BB_ORIGENV"
python do_testsdk() {
import_and_run('TESTSDK_CLASS_NAME', d)
}
addtask testsdk
do_testsdk[nostamp] = "1"
do_testsdk[network] = "1"
python do_testsdkext() {
import_and_run('TESTSDKEXT_CLASS_NAME', d)
}
addtask testsdkext
do_testsdkext[nostamp] = "1"
do_testsdkext[network] = "1"
python () {
if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"):
bb.build.addtask("testsdk", None, "do_populate_sdk", d)
bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d)
}