Skip to content

Commit 396cb0f

Browse files
Thune Tranrpurdie
authored andcommitted
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/ # (default) Standard SDK: dirname="sdk" ├── sdkbuildtools/cases/ # Buildtools: dirname="sdkbuildtools" └── sdkbuildtools-docs/cases/ # Buildtools-docs: dirname="sdkbuildtools-docs" meta-mingw/lib/oeqa/ └── sdkmingw/cases/ # MinGW: dirname="sdkmingw" meta-foo/lib/oeqa/ └── sdk/cases/ # (default) Standard SDK: dirname="sdk" * Add mingw sdk compatibility until meta-mingw migrates to TESTSDK_CASE_DIRS 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>
1 parent 29cd5ac commit 396cb0f

File tree

11 files changed

+40
-20
lines changed

11 files changed

+40
-20
lines changed

meta/classes-recipe/testsdk.bbclass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ TESTSDK_SUITES ?= ""
1919

2020
TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK"
2121
TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt"
22+
TESTSDK_CASE_DIRS ?= "sdk"
2223

2324
def import_and_run(name, d):
2425
import importlib

meta/lib/oeqa/sdk/testsdk.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor
88

9+
# TODO: drop once the meta-mingw layer migrates to TESTSDK_CASE_DIRS
10+
def mingw_default_dir(d):
11+
sdkmach = d.getVar("SDKMACHINE") or ""
12+
if sdkmach.endswith("mingw32"):
13+
return "sdkmingw"
14+
return ""
15+
916
class TestSDKBase(object):
1017
@staticmethod
1118
def get_sdk_configuration(d, test_type):
@@ -31,6 +38,32 @@ class TestSDK(TestSDKBase):
3138
context_class = OESDKTestContext
3239
test_type = 'sdk'
3340

41+
def sdk_dir_names(self, d):
42+
"""Return list from TESTSDK_CASE_DIRS."""
43+
mingw_dir = mingw_default_dir(d)
44+
if mingw_dir:
45+
return mingw_dir.split()
46+
47+
testdirs = d.getVar("TESTSDK_CASE_DIRS")
48+
if testdirs:
49+
return testdirs.split()
50+
51+
bb.fatal("TESTSDK_CASE_DIRS unset, can't find SDK test directories.")
52+
53+
def get_sdk_paths(self, d):
54+
"""
55+
Return a list of paths where SDK test cases reside.
56+
57+
SDK tests are expected in <LAYER_DIR>/lib/oeqa/<dirname>/cases
58+
"""
59+
paths = []
60+
for layer in d.getVar("BBLAYERS").split():
61+
for dirname in self.sdk_dir_names(d):
62+
case_path = os.path.join(layer, "lib", "oeqa", dirname, "cases")
63+
if os.path.isdir(case_path):
64+
paths.append(case_path)
65+
return paths
66+
3467
def get_tcname(self, d):
3568
"""
3669
Get the name of the SDK file
@@ -115,7 +148,7 @@ def run(self, d):
115148

116149
try:
117150
modules = (d.getVar("TESTSDK_SUITES") or "").split()
118-
tc.loadTests(self.context_executor_class.default_cases, modules)
151+
tc.loadTests(self.get_sdk_paths(d), modules)
119152
except Exception as e:
120153
import traceback
121154
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())

meta/recipes-core/meta/buildtools-docs-tarball.bb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ TOOLCHAIN_OUTPUTNAME = "${SDK_ARCH}-buildtools-docs-nativesdk-standalone-${DISTR
1616

1717
SDK_TITLE = "Docs Build tools tarball"
1818

19-
TESTSDK_CASES = "buildtools-docs-cases"
19+
# Directory that contains testcases
20+
TESTSDK_CASE_DIRS = "sdkbuildtools-docs"

0 commit comments

Comments
 (0)