[oe-commits] [openembedded-core] 11/13: oeqa: enable testresults.json for testexport
git at git.openembedded.org
git at git.openembedded.org
Thu Mar 12 00:28:32 UTC 2020
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit c9ff467288563d21cccfd8fd0507aa05f319677b
Author: Stefan Kral <sk at typedivision.de>
AuthorDate: Wed Mar 11 17:37:30 2020 +0100
oeqa: enable testresults.json for testexport
Add the option --json-result-dir to oeqa core context to enable
testresults.json creation for test runs via testexport.
Eg. oe-test runtime --json-result-dir .
Signed-off-by: Stefan Kral <sk at typedivision.de>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/lib/oeqa/core/context.py | 30 +++++++++++++++++++++++++++++-
meta/lib/oeqa/core/runner.py | 13 ++++++++++---
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index 16320af..b9a28ce 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -116,6 +116,9 @@ class OETestContextExecutor(object):
default=self.default_output_log,
help="results output log, default: %s" % self.default_output_log)
+ self.parser.add_argument('--json-result-dir', action='store',
+ help="json result output dir, create testresults.json here if set")
+
group = self.parser.add_mutually_exclusive_group()
group.add_argument('--run-tests', action='store', nargs='+',
default=self.default_tests,
@@ -178,6 +181,22 @@ class OETestContextExecutor(object):
self.module_paths = args.CASES_PATHS
+ def _get_json_result_dir(self, args):
+ return args.json_result_dir
+
+ def _get_configuration(self):
+ td = self.tc_kwargs['init']['td']
+ configuration = {'TEST_TYPE': self.name,
+ 'MACHINE': td.get("MACHINE"),
+ 'DISTRO': td.get("DISTRO"),
+ 'IMAGE_BASENAME': td.get("IMAGE_BASENAME"),
+ 'DATETIME': td.get("DATETIME")}
+ return configuration
+
+ def _get_result_id(self, configuration):
+ return '%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'],
+ configuration['MACHINE'], configuration['DATETIME'])
+
def _pre_run(self):
pass
@@ -196,7 +215,16 @@ class OETestContextExecutor(object):
else:
self._pre_run()
rc = self.tc.runTests(**self.tc_kwargs['run'])
- rc.logDetails()
+
+ json_result_dir = self._get_json_result_dir(args)
+ if json_result_dir:
+ configuration = self._get_configuration()
+ rc.logDetails(json_result_dir,
+ configuration,
+ self._get_result_id(configuration))
+ else:
+ rc.logDetails()
+
rc.logSummary(self.name)
output_link = os.path.join(os.path.dirname(args.output_log),
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index f656e1a..fc3872a 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -319,10 +319,17 @@ class OETestResultJSONHelper(object):
the_file.write(file_content)
def dump_testresult_file(self, write_dir, configuration, result_id, test_result):
- bb.utils.mkdirhier(write_dir)
- lf = bb.utils.lockfile(os.path.join(write_dir, 'jsontestresult.lock'))
+ try:
+ import bb
+ has_bb = True
+ lf = bb.utils.lockfile(os.path.join(write_dir, 'jsontestresult.lock'))
+ bb.utils.mkdirhier(write_dir, exist_ok=True)
+ except ImportError:
+ has_bb = False
+ os.makedirs(write_dir)
test_results = self._get_existing_testresults_if_available(write_dir)
test_results[result_id] = {'configuration': configuration, 'result': test_result}
json_testresults = json.dumps(test_results, sort_keys=True, indent=4)
self._write_file(write_dir, self.testresult_filename, json_testresults)
- bb.utils.unlockfile(lf)
+ if has_bb:
+ bb.utils.unlockfile(lf)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list