From f56b8b220c6cab3d3309ec34637a289e9a45cdea Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Thu, 23 Feb 2023 09:46:43 -0700 Subject: zephyr: Handle scenario where an assert is not found in the log Sometimes the assert occurs in the setup of a test which is outside of the `START` and `FAIL` markers of a test leaving the test with no valid assertion marker. BUG=None BRANCH=NONE TEST=Add failing assert in setup, ./twister -T zephyr/test Change-Id: I96999fe2eb40b33390df8c7ac24a48f8050b5767 Signed-off-by: Al Semjonovs Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4287588 Reviewed-by: Simon Glass Commit-Queue: Simon Glass --- util/zephyr_to_resultdb.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 5d5edc6c99..e9cc191b43 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -2,6 +2,7 @@ # Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. + """ Upload twister results to ResultDB Usage: @@ -135,7 +136,12 @@ def testcase_to_result(testsuite, testcase, base_tags, config_tags): assert_msg = re.findall( r"Assertion failed.*$", testcase["log"], re.MULTILINE ) - result["failureReason"] = {"primaryErrorMessage": assert_msg[0]} + if assert_msg: + result["failureReason"] = {"primaryErrorMessage": assert_msg[0]} + else: + result["failureReason"] = { + "primaryErrorMessage": "Assert not found - possibly occurred in test setup" + } return result -- cgit v1.2.1