summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Semjonovs <asemjonovs@google.com>2022-11-16 14:09:55 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-18 22:36:49 +0000
commit4c1230c1e6e4d4884c7aa110ebb72b5d14e7b614 (patch)
tree8f79208e2e5f48bb6b232d7afe2157d857b01fc4
parenteccb0c71b575e461dd7b3c54af368bf95365a5de (diff)
downloadchrome-ec-4c1230c1e6e4d4884c7aa110ebb72b5d14e7b614.tar.gz
twister: Add tags to enable Testhaus
Add queued_time and board tags to test results Example twister.json format -- go/paste/5260283562950656 BUG=b:247857971 BRANCH=None TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs <asemjonovs@google.com> Change-Id: Ia252aa72fa433e13ec45e4d9470d96370888ad00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032325 Reviewed-by: Zhihui Xie <zhihuixie@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rwxr-xr-xutil/twister_launcher.py1
-rwxr-xr-xutil/zephyr_to_resultdb.py29
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()