pySim-shell_test/utils: enumerate pySim-shell logs

When pySim-shell is called by a testcase, a logfile is createted. The logfile
filename contains the testcase name. However, a testcase may run pySim-shell
multiple times. In this case we overwrite the log from previous run. Let's use a
counter to generate unique file names for each run, so that we won't lose logs
from previous runs.

Related: OS#6601
Change-Id: Ib2195d9b2231f74d0a6c4fb28f4889b6c45efb1e
This commit is contained in:
Philipp Maier
2024-10-25 10:44:01 +02:00
committed by laforge
parent d8d52bdf77
commit 32d6a9ab5f

View File

@@ -170,6 +170,7 @@ class UnittestUtils(unittest.TestCase):
testcasepath = inspect.getfile(self.__class__) testcasepath = inspect.getfile(self.__class__)
testcasename = testcasepath.split("/")[-2] + "." + self._testMethodName testcasename = testcasepath.split("/")[-2] + "." + self._testMethodName
print(boxed_heading_str("testcase: " + testcasename)) print(boxed_heading_str("testcase: " + testcasename))
self.pysim_shell_log_counter = 0
# Find directories # Find directories
self.test_dir = os.path.dirname(testcasepath) self.test_dir = os.path.dirname(testcasepath)
@@ -240,7 +241,8 @@ class UnittestUtils(unittest.TestCase):
no_exceptions : fail the testcase in case any exceptions occurred while running pySim_shell no_exceptions : fail the testcase in case any exceptions occurred while running pySim_shell
""" """
logfile_name = "pySim-shell_" + self._testMethodName + ".log" logfile_name = "pySim-shell_" + self._testMethodName + "_" + str(self.pysim_shell_log_counter) + ".log"
self.pysim_shell_log_counter+=1
# Make sure the script file is available # Make sure the script file is available
if not os.access(script, os.R_OK): if not os.access(script, os.R_OK):