From 882e24677ff0532d4967b1480c826cad2d0ec1f5 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Tue, 29 Oct 2024 13:14:23 +0100 Subject: [PATCH] pySim-shell_test/utils: print logfile on all types of errors When pySim-shell has problems starting up, it exits with an error code. This is detected by the testsuite, but it also causes an early exit, so that the log file content are not printed. Change-Id: Ic0f34eda32a7c557810abcb05a84e343741fdb8a --- tests/pySim-shell_test/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/pySim-shell_test/utils.py b/tests/pySim-shell_test/utils.py index 348c9b16..c3cf7a26 100644 --- a/tests/pySim-shell_test/utils.py +++ b/tests/pySim-shell_test/utils.py @@ -265,11 +265,9 @@ class UnittestUtils(unittest.TestCase): # Execute commandline cmdline += " > " + logfile_name + " 2>&1" print("Executing: " + cmdline) - rc = os.system(cmdline) - if rc: - raise RuntimeError("pySim-shell exits with error code %u" % rc) + py_sim_shell_rc = os.system(cmdline) - # Check for exceptions + # Read logfile logfile = open(logfile_name) logfile_content = logfile.read() if self.print_content: @@ -278,6 +276,12 @@ class UnittestUtils(unittest.TestCase): print(logfile_content) print("-----------------------8<-----------------------") logfile.close() + + # Exit early in case pySim-shell ran into a fundamental error + if py_sim_shell_rc: + raise RuntimeError("pySim-shell exits with error code %u" % py_sim_shell_rc) + + # Check log for exceptions exception_regex_compiled = re.compile('.*EXCEPTION.*') exceptions_strings = re.findall(exception_regex_compiled, logfile_content) if exceptions_strings != []: