diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
| commit | 8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch) | |
| tree | efdc32587159d0050a69009bdf2330a531727d95 /meta/lib/oeqa/sdk/testsdk.py | |
| parent | d412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff) | |
| download | poky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz | |
The poky repository master branch is no longer being updated.
You can either:
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
b) use the new bitbake-setup
You can find information about either approach in our documentation:
https://docs.yoctoproject.org/
Note that "poky" the distro setting is still available in meta-yocto as
before and we continue to use and maintain that.
Long live Poky!
Some further information on the background of this change can be found
in: https://lists.openembedded.org/g/openembedded-architecture/message/2179
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/sdk/testsdk.py')
| -rw-r--r-- | meta/lib/oeqa/sdk/testsdk.py | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py deleted file mode 100644 index cffcf9f49a..0000000000 --- a/meta/lib/oeqa/sdk/testsdk.py +++ /dev/null | |||
| @@ -1,164 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Copyright 2018 by Garmin Ltd. or its subsidiaries | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: MIT | ||
| 5 | # | ||
| 6 | |||
| 7 | from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor | ||
| 8 | |||
| 9 | class TestSDKBase(object): | ||
| 10 | @staticmethod | ||
| 11 | def get_sdk_configuration(d, test_type): | ||
| 12 | import platform | ||
| 13 | import oe.lsb | ||
| 14 | from oeqa.utils.metadata import get_layers | ||
| 15 | configuration = {'TEST_TYPE': test_type, | ||
| 16 | 'MACHINE': d.getVar("MACHINE"), | ||
| 17 | 'SDKMACHINE': d.getVar("SDKMACHINE"), | ||
| 18 | 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"), | ||
| 19 | 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"), | ||
| 20 | 'STARTTIME': d.getVar("DATETIME"), | ||
| 21 | 'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'), | ||
| 22 | 'LAYERS': get_layers(d.getVar("BBLAYERS"))} | ||
| 23 | return configuration | ||
| 24 | |||
| 25 | @staticmethod | ||
| 26 | def get_sdk_result_id(configuration): | ||
| 27 | return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) | ||
| 28 | |||
| 29 | class TestSDK(TestSDKBase): | ||
| 30 | context_executor_class = OESDKTestContextExecutor | ||
| 31 | context_class = OESDKTestContext | ||
| 32 | test_type = 'sdk' | ||
| 33 | |||
| 34 | def sdk_dir_names(self, d): | ||
| 35 | """Return list from TESTSDK_CASE_DIRS.""" | ||
| 36 | testdirs = d.getVar("TESTSDK_CASE_DIRS") | ||
| 37 | if testdirs: | ||
| 38 | return testdirs.split() | ||
| 39 | |||
| 40 | bb.fatal("TESTSDK_CASE_DIRS unset, can't find SDK test directories.") | ||
| 41 | |||
| 42 | def get_sdk_paths(self, d): | ||
| 43 | """ | ||
| 44 | Return a list of paths where SDK test cases reside. | ||
| 45 | |||
| 46 | SDK tests are expected in <LAYER_DIR>/lib/oeqa/<dirname>/cases | ||
| 47 | """ | ||
| 48 | paths = [] | ||
| 49 | for layer in d.getVar("BBLAYERS").split(): | ||
| 50 | for dirname in self.sdk_dir_names(d): | ||
| 51 | case_path = os.path.join(layer, "lib", "oeqa", dirname, "cases") | ||
| 52 | if os.path.isdir(case_path): | ||
| 53 | paths.append(case_path) | ||
| 54 | return paths | ||
| 55 | |||
| 56 | def get_tcname(self, d): | ||
| 57 | """ | ||
| 58 | Get the name of the SDK file | ||
| 59 | """ | ||
| 60 | return d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") | ||
| 61 | |||
| 62 | def extract_sdk(self, tcname, sdk_dir, d): | ||
| 63 | """ | ||
| 64 | Extract the SDK to the specified location | ||
| 65 | """ | ||
| 66 | import subprocess | ||
| 67 | |||
| 68 | try: | ||
| 69 | subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True) | ||
| 70 | except subprocess.CalledProcessError as e: | ||
| 71 | bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) | ||
| 72 | |||
| 73 | def setup_context(self, d): | ||
| 74 | """ | ||
| 75 | Return a dictionary of additional arguments that should be passed to | ||
| 76 | the context_class on construction | ||
| 77 | """ | ||
| 78 | return dict() | ||
| 79 | |||
| 80 | def run(self, d): | ||
| 81 | |||
| 82 | import os | ||
| 83 | import subprocess | ||
| 84 | import json | ||
| 85 | import logging | ||
| 86 | |||
| 87 | from bb.utils import export_proxies | ||
| 88 | from oeqa.utils import make_logger_bitbake_compatible | ||
| 89 | from oeqa.utils import get_json_result_dir | ||
| 90 | |||
| 91 | pn = d.getVar("PN") | ||
| 92 | logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) | ||
| 93 | |||
| 94 | # sdk use network for download projects for build | ||
| 95 | export_proxies(d) | ||
| 96 | |||
| 97 | # We need the original PATH for testing the eSDK, not with our manipulations | ||
| 98 | os.environ['PATH'] = d.getVar("BB_ORIGENV", False).getVar("PATH") | ||
| 99 | |||
| 100 | tcname = self.get_tcname(d) | ||
| 101 | |||
| 102 | if not os.path.exists(tcname): | ||
| 103 | bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) | ||
| 104 | |||
| 105 | tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") | ||
| 106 | test_data = json.load(open(tdname, "r")) | ||
| 107 | |||
| 108 | target_pkg_manifest = self.context_executor_class._load_manifest( | ||
| 109 | d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) | ||
| 110 | host_pkg_manifest = self.context_executor_class._load_manifest( | ||
| 111 | d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest")) | ||
| 112 | |||
| 113 | processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS") | ||
| 114 | if processes: | ||
| 115 | try: | ||
| 116 | import testtools, subunit | ||
| 117 | except ImportError: | ||
| 118 | bb.warn("Failed to import testtools or subunit, the testcases will run serially") | ||
| 119 | processes = None | ||
| 120 | |||
| 121 | sdk_dir = d.expand("${WORKDIR}/testimage-sdk/") | ||
| 122 | bb.utils.remove(sdk_dir, True) | ||
| 123 | bb.utils.mkdirhier(sdk_dir) | ||
| 124 | |||
| 125 | context_args = self.setup_context(d) | ||
| 126 | |||
| 127 | self.extract_sdk(tcname, sdk_dir, d) | ||
| 128 | |||
| 129 | fail = False | ||
| 130 | sdk_envs = self.context_executor_class._get_sdk_environs(sdk_dir) | ||
| 131 | for s in sdk_envs: | ||
| 132 | sdk_env = sdk_envs[s] | ||
| 133 | bb.plain("SDK testing environment: %s" % s) | ||
| 134 | tc = self.context_class(td=test_data, logger=logger, sdk_dir=sdk_dir, | ||
| 135 | sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, | ||
| 136 | host_pkg_manifest=host_pkg_manifest, **context_args) | ||
| 137 | |||
| 138 | try: | ||
| 139 | modules = (d.getVar("TESTSDK_SUITES") or "").split() | ||
| 140 | tc.loadTests(self.get_sdk_paths(d), modules) | ||
| 141 | except Exception as e: | ||
| 142 | import traceback | ||
| 143 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | ||
| 144 | |||
| 145 | if processes: | ||
| 146 | result = tc.runTests(processes=int(processes)) | ||
| 147 | else: | ||
| 148 | result = tc.runTests() | ||
| 149 | |||
| 150 | component = "%s %s" % (pn, self.context_executor_class.name) | ||
| 151 | context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) | ||
| 152 | configuration = self.get_sdk_configuration(d, self.test_type) | ||
| 153 | result.logDetails(get_json_result_dir(d), | ||
| 154 | configuration, | ||
| 155 | self.get_sdk_result_id(configuration)) | ||
| 156 | result.logSummary(component, context_msg) | ||
| 157 | |||
| 158 | if not result.wasSuccessful(): | ||
| 159 | fail = True | ||
| 160 | |||
| 161 | if fail: | ||
| 162 | bb.fatal("%s - FAILED - check the task log and the commands log" % pn) | ||
| 163 | |||
| 164 | |||
