diff options
-rwxr-xr-x | util/twister_launcher.py | 1 | ||||
-rwxr-xr-x | util/zephyr_to_resultdb.py | 29 |
2 files changed, 28 insertions, 2 deletions
diff --git a/util/twister_launcher.py b/util/twister_launcher.py index c67d15d97d..f0e49c5298 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -185,6 +185,7 @@ def upload_results(ec_base, outdir): "-realm", "chromium:public", "--", + "vpython3", str(ec_base / "util/zephyr_to_resultdb.py"), "--result=" + str(json_path), "--upload=True", diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 48bfe151e4..683cf98eb5 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -11,6 +11,7 @@ import argparse import base64 +import datetime import json import os @@ -82,7 +83,7 @@ def testcase_artifact(testcase): return base64.b64encode(artifact.encode()) -def testcase_to_result(testsuite, testcase): +def testcase_to_result(testsuite, testcase, base_tags): """Translates ZTEST testcase to ResultDB format""" result = { "testId": testcase["identifier"], @@ -103,19 +104,43 @@ def testcase_to_result(testsuite, testcase): "testMetadata": {"name": testcase["identifier"]}, } + for (key, value) in base_tags: + result["tags"].append({"key": key, "value": value}) + return result +def create_base_tags(data): + """Creates base tags needed for Testhaus""" + base_tags = [] + + queued_time = datetime.datetime.fromisoformat( + data["environment"]["run_date"] + ) + base_tags.append( + ("queued_time", queued_time.strftime("%Y-%m-%d %H:%M:%S.%f UTC")) + ) + + base_tags.append(("zephyr_version", data["environment"]["zephyr_version"])) + base_tags.append(("board", data["environment"]["os"])) + base_tags.append(("toolchain", data["environment"]["toolchain"])) + + return base_tags + + def json_to_resultdb(result_file): """Translates Twister json test report to ResultDB format""" with open(result_file) as file: data = json.load(file) results = [] + base_tags = create_base_tags(data) for testsuite in data["testsuites"]: for testcase in testsuite["testcases"]: if testcase["status"]: - results.append(testcase_to_result(testsuite, testcase)) + results.append( + testcase_to_result(testsuite, testcase, base_tags) + ) file.close() |