From 540ed23255eb686dac706f33ad99a339659bc64c Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Sat, 9 Nov 2024 17:29:48 +0100 Subject: [PATCH] Increase test stability again. --- test/tests/openwrt_docker_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/tests/openwrt_docker_test.py b/test/tests/openwrt_docker_test.py index e17d1d3..9479545 100644 --- a/test/tests/openwrt_docker_test.py +++ b/test/tests/openwrt_docker_test.py @@ -107,8 +107,15 @@ def run_openwrt_shell_command(command, *arg): if process.stdout == "": return None + # Sometime it happens that also the previous command return is included which results in two or more json strings. + jsons = process.stdout.split('\n') + + # Search for 'return' and give back the last occurrence index + idx = next((i for i, s in reversed(list(enumerate(jsons))) if 'return' in s), -1) + # Assume json here, parse it - ret = json.loads(process.stdout) + ret = json.loads(jsons[idx]) + data = ret['return'] # decode output