dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/38603?usp=email )
Change subject: pySim-shell_test/utils: print logfile on all types of errors ......................................................................
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 --- M tests/pySim-shell_test/utils.py 1 file changed, 9 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/03/38603/1
diff --git a/tests/pySim-shell_test/utils.py b/tests/pySim-shell_test/utils.py index 348c9b1..b93424e 100644 --- a/tests/pySim-shell_test/utils.py +++ b/tests/pySim-shell_test/utils.py @@ -265,11 +265,9 @@ # 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 @@ 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" % rc) + + # Check log for exceptions exception_regex_compiled = re.compile('.*EXCEPTION.*') exceptions_strings = re.findall(exception_regex_compiled, logfile_content) if exceptions_strings != []: @@ -288,7 +292,7 @@ self.assertTrue(False, "Unexpected exceptions occurred!") else: print("Note: the occurrence of exceptions may be expected, the sheer presence of exceptions is not necessarly an error.") - + def __filter_lines(self, text:str, ignore_regex_list:list[str], mask_regex_list:list[str], interesting_regex_list:list[str]): """ Filter data from text lines using regex_lists """