diff options
| author | Alexis Lothoré <alexis.lothore@bootlin.com> | 2024-02-26 10:19:18 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-27 11:35:43 +0000 |
| commit | fec128bd625dbbb5a239d6ff6999e1e4a41a5a9b (patch) | |
| tree | b0e556d80ad837575227a7c83d447dfa48da4136 | |
| parent | 031099c417a61d6e7db2cf7bf02f69650179b7e8 (diff) | |
| download | poky-fec128bd625dbbb5a239d6ff6999e1e4a41a5a9b.tar.gz | |
lib/oeqa: share get_json_result_dir helper
Multiple places in oeqa need to get the log output path, and redefine a
small helper to accomplish this
Define this helper in lib/oeqa/utils/__init__.py and import it wherever
needed to allow using it.
(From OE-Core rev: 01b1a6a5a4e7cede4d23a981b5144ae9c8306274)
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/classes-recipe/testimage.bbclass | 12 | ||||
| -rw-r--r-- | meta/lib/oeqa/sdk/testsdk.py | 11 | ||||
| -rw-r--r-- | meta/lib/oeqa/sdkext/testsdk.py | 3 | ||||
| -rw-r--r-- | meta/lib/oeqa/utils/__init__.py | 7 |
4 files changed, 14 insertions, 19 deletions
diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index d076102f96..959c226072 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass | |||
| @@ -149,13 +149,6 @@ def get_testimage_configuration(d, test_type, machine): | |||
| 149 | return configuration | 149 | return configuration |
| 150 | get_testimage_configuration[vardepsexclude] = "DATETIME" | 150 | get_testimage_configuration[vardepsexclude] = "DATETIME" |
| 151 | 151 | ||
| 152 | def get_testimage_json_result_dir(d): | ||
| 153 | json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') | ||
| 154 | custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") | ||
| 155 | if custom_json_result_dir: | ||
| 156 | json_result_dir = custom_json_result_dir | ||
| 157 | return json_result_dir | ||
| 158 | |||
| 159 | def get_testimage_result_id(configuration): | 152 | def get_testimage_result_id(configuration): |
| 160 | return '%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['MACHINE'], configuration['STARTTIME']) | 153 | return '%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['MACHINE'], configuration['STARTTIME']) |
| 161 | 154 | ||
| @@ -224,6 +217,7 @@ def testimage_main(d): | |||
| 224 | from oeqa.core.target.qemu import supported_fstypes | 217 | from oeqa.core.target.qemu import supported_fstypes |
| 225 | from oeqa.core.utils.test import getSuiteCases | 218 | from oeqa.core.utils.test import getSuiteCases |
| 226 | from oeqa.utils import make_logger_bitbake_compatible | 219 | from oeqa.utils import make_logger_bitbake_compatible |
| 220 | from oeqa.utils import get_json_result_dir | ||
| 227 | 221 | ||
| 228 | def sigterm_exception(signum, stackframe): | 222 | def sigterm_exception(signum, stackframe): |
| 229 | """ | 223 | """ |
| @@ -426,14 +420,14 @@ def testimage_main(d): | |||
| 426 | # Show results (if we have them) | 420 | # Show results (if we have them) |
| 427 | if results: | 421 | if results: |
| 428 | configuration = get_testimage_configuration(d, 'runtime', machine) | 422 | configuration = get_testimage_configuration(d, 'runtime', machine) |
| 429 | results.logDetails(get_testimage_json_result_dir(d), | 423 | results.logDetails(get_json_result_dir(d), |
| 430 | configuration, | 424 | configuration, |
| 431 | get_testimage_result_id(configuration), | 425 | get_testimage_result_id(configuration), |
| 432 | dump_streams=d.getVar('TESTREPORT_FULLLOGS')) | 426 | dump_streams=d.getVar('TESTREPORT_FULLLOGS')) |
| 433 | results.logSummary(pn) | 427 | results.logSummary(pn) |
| 434 | 428 | ||
| 435 | # Copy additional logs to tmp/log/oeqa so it's easier to find them | 429 | # Copy additional logs to tmp/log/oeqa so it's easier to find them |
| 436 | targetdir = os.path.join(get_testimage_json_result_dir(d), d.getVar("PN")) | 430 | targetdir = os.path.join(get_json_result_dir(d), d.getVar("PN")) |
| 437 | os.makedirs(targetdir, exist_ok=True) | 431 | os.makedirs(targetdir, exist_ok=True) |
| 438 | os.symlink(bootlog, os.path.join(targetdir, os.path.basename(bootlog))) | 432 | os.symlink(bootlog, os.path.join(targetdir, os.path.basename(bootlog))) |
| 439 | os.symlink(d.getVar("BB_LOGFILE"), os.path.join(targetdir, os.path.basename(d.getVar("BB_LOGFILE") + "." + d.getVar('DATETIME')))) | 433 | os.symlink(d.getVar("BB_LOGFILE"), os.path.join(targetdir, os.path.basename(d.getVar("BB_LOGFILE") + "." + d.getVar('DATETIME')))) |
diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py index b4719110ed..518b09febb 100644 --- a/meta/lib/oeqa/sdk/testsdk.py +++ b/meta/lib/oeqa/sdk/testsdk.py | |||
| @@ -23,14 +23,6 @@ class TestSDKBase(object): | |||
| 23 | return configuration | 23 | return configuration |
| 24 | 24 | ||
| 25 | @staticmethod | 25 | @staticmethod |
| 26 | def get_sdk_json_result_dir(d): | ||
| 27 | json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') | ||
| 28 | custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") | ||
| 29 | if custom_json_result_dir: | ||
| 30 | json_result_dir = custom_json_result_dir | ||
| 31 | return json_result_dir | ||
| 32 | |||
| 33 | @staticmethod | ||
| 34 | def get_sdk_result_id(configuration): | 26 | def get_sdk_result_id(configuration): |
| 35 | return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) | 27 | return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) |
| 36 | 28 | ||
| @@ -72,6 +64,7 @@ class TestSDK(TestSDKBase): | |||
| 72 | 64 | ||
| 73 | from bb.utils import export_proxies | 65 | from bb.utils import export_proxies |
| 74 | from oeqa.utils import make_logger_bitbake_compatible | 66 | from oeqa.utils import make_logger_bitbake_compatible |
| 67 | from oeqa.utils import get_json_result_dir | ||
| 75 | 68 | ||
| 76 | pn = d.getVar("PN") | 69 | pn = d.getVar("PN") |
| 77 | logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) | 70 | logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) |
| @@ -134,7 +127,7 @@ class TestSDK(TestSDKBase): | |||
| 134 | component = "%s %s" % (pn, self.context_executor_class.name) | 127 | component = "%s %s" % (pn, self.context_executor_class.name) |
| 135 | context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) | 128 | context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) |
| 136 | configuration = self.get_sdk_configuration(d, self.test_type) | 129 | configuration = self.get_sdk_configuration(d, self.test_type) |
| 137 | result.logDetails(self.get_sdk_json_result_dir(d), | 130 | result.logDetails(get_json_result_dir(d), |
| 138 | configuration, | 131 | configuration, |
| 139 | self.get_sdk_result_id(configuration)) | 132 | self.get_sdk_result_id(configuration)) |
| 140 | result.logSummary(component, context_msg) | 133 | result.logSummary(component, context_msg) |
diff --git a/meta/lib/oeqa/sdkext/testsdk.py b/meta/lib/oeqa/sdkext/testsdk.py index 159f0d135b..9d5a99d900 100644 --- a/meta/lib/oeqa/sdkext/testsdk.py +++ b/meta/lib/oeqa/sdkext/testsdk.py | |||
| @@ -16,6 +16,7 @@ class TestSDKExt(TestSDKBase): | |||
| 16 | from bb.utils import export_proxies | 16 | from bb.utils import export_proxies |
| 17 | from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak | 17 | from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak |
| 18 | from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor | 18 | from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor |
| 19 | from oeqa.utils import get_json_result_dir | ||
| 19 | 20 | ||
| 20 | pn = d.getVar("PN") | 21 | pn = d.getVar("PN") |
| 21 | logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) | 22 | logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) |
| @@ -91,7 +92,7 @@ class TestSDKExt(TestSDKBase): | |||
| 91 | component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) | 92 | component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) |
| 92 | context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) | 93 | context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) |
| 93 | configuration = self.get_sdk_configuration(d, 'sdkext') | 94 | configuration = self.get_sdk_configuration(d, 'sdkext') |
| 94 | result.logDetails(self.get_sdk_json_result_dir(d), | 95 | result.logDetails(get_json_result_dir(d), |
| 95 | configuration, | 96 | configuration, |
| 96 | self.get_sdk_result_id(configuration)) | 97 | self.get_sdk_result_id(configuration)) |
| 97 | result.logSummary(component, context_msg) | 98 | result.logSummary(component, context_msg) |
diff --git a/meta/lib/oeqa/utils/__init__.py b/meta/lib/oeqa/utils/__init__.py index fbc7f7d525..53bdcbf266 100644 --- a/meta/lib/oeqa/utils/__init__.py +++ b/meta/lib/oeqa/utils/__init__.py | |||
| @@ -90,3 +90,10 @@ def load_test_components(logger, executor): | |||
| 90 | "_executor_class defined." % (comp_name, comp_context)) | 90 | "_executor_class defined." % (comp_name, comp_context)) |
| 91 | 91 | ||
| 92 | return components | 92 | return components |
| 93 | |||
| 94 | def get_json_result_dir(d): | ||
| 95 | json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') | ||
| 96 | custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") | ||
| 97 | if custom_json_result_dir: | ||
| 98 | json_result_dir = custom_json_result_dir | ||
| 99 | return json_result_dir \ No newline at end of file | ||
