From 3b3281c114c69277f4fc303164aeeb653e98e4b1 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Thu, 30 Nov 2023 10:00:00 +0100 Subject: [PATCH] test framework: add checking the exit code of test commands Signed-off-by: Bernhard Kaindl --- tests/integration/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 5f516046..26bac7bf 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -11,10 +11,11 @@ from lxml import etree +# pyright: ignore[reportMissingImports] if sys.version_info.major == 2: - from commands import getoutput # type:ignore[import-not-found] # pyright: ignore[reportMissingImports] + from commands import getstatusoutput # type:ignore[import-not-found] else: - from subprocess import getoutput + from subprocess import getstatusoutput BUGTOOL_OUTPUT_DIR = "/var/opt/xen/bug-report/" BUGTOOL_DOM0_TEMPL = "tests/integration/dom0-template/" @@ -97,7 +98,10 @@ def run_bugtool_entry(archive_type, test_entries): # For case the default python interpreter of the user is python3, we must use python2(for now): command = "python2 ./xen-bugtool -y --output=%s --entries=%s" % (archive_type, test_entries) print("# " + command) - print(getoutput(command)) + error_code, output = getstatusoutput(command) + print(output) + if error_code: + raise RuntimeError(output) srcdir = os.getcwd() os.chdir(BUGTOOL_OUTPUT_DIR) output_file = test_entries + "." + archive_type