aboutsummaryrefslogtreecommitdiff
path: root/zephyr-upstream
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2020-02-06 16:17:02 +0700
committerPaul Sokolovskyy <paul.sokolovsky@linaro.org>2020-02-07 05:18:32 +0000
commit4214c484187f28c3a8cd36897b6261aaff856afa (patch)
treebad865020293d5328e5ff5d07b4730c9cd878515 /zephyr-upstream
parent11b05499f15c99e16368b6fc8f6d8ae8fc30da34 (diff)
zephyr-upstream: submit_for_testing: Safer parsing of Zephyr's testcase.yaml
For "harness: console", don't assume that "harness_config" dict and any sub-keys exist. While they should, and used to, we now get more or less random changes which add "harness: console", but not "harness_config". E.g. https://github.com/zephyrproject-rtos/zephyr/commit/39ad5937c57349f29070cf200b050b75f35c2272#r37148637 Change-Id: I576e91fd447e7eddefb066398dee4d5b52be7d27 Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Diffstat (limited to 'zephyr-upstream')
-rw-r--r--zephyr-upstream/submit_for_testing.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/zephyr-upstream/submit_for_testing.py b/zephyr-upstream/submit_for_testing.py
index 8003c8dfab..4c55a3cb95 100644
--- a/zephyr-upstream/submit_for_testing.py
+++ b/zephyr-upstream/submit_for_testing.py
@@ -163,18 +163,19 @@ def permutations_of_regexes(regexes):
def parse_yaml_harness_config(yaml_node):
# Return a string with the actual regular expression to look for in the LAVA job.
# We can then use LAVA's interactive test action to look for it.
- if "harness" in yaml_node.keys() and yaml_node["harness"] == "console":
- if yaml_node["harness_config"]["type"] == "one_line":
- return yaml_node["harness_config"]["regex"][0]
- elif yaml_node["harness_config"]["type"] == "multi_line":
- if "ordered" not in yaml_node["harness_config"].keys() or yaml_node["harness_config"]["ordered"] == "true":
+ if yaml_node.get("harness") == "console":
+ config = yaml_node.get("harness_config", {})
+ if config.get("type") == "one_line":
+ return config["regex"][0]
+ elif config.get("type") == "multi_line":
+ if "ordered" not in config or config["ordered"] == "true":
# For ordered regular expressions, we can simply join them into one,
# while allowing any character in between via (.*)
- return ".*".join(yaml_node["harness_config"]["regex"])
+ return ".*".join(config["regex"])
else:
# For non-ordered case, we need to look for all permutations of
# the regexes, since they can occur in any order.
- return permutations_of_regexes(yaml_node["harness_config"]["regex"])
+ return permutations_of_regexes(config["regex"])
else:
return None