From 32d6a9ab5fab4407c0d4aca72b2e41496ffe56a5 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 25 Oct 2024 10:44:01 +0200 Subject: [PATCH] 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 --- tests/pySim-shell_test/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/pySim-shell_test/utils.py b/tests/pySim-shell_test/utils.py index 943eb480..6acbd702 100644 --- a/tests/pySim-shell_test/utils.py +++ b/tests/pySim-shell_test/utils.py @@ -170,6 +170,7 @@ class UnittestUtils(unittest.TestCase): testcasepath = inspect.getfile(self.__class__) testcasename = testcasepath.split("/")[-2] + "." + self._testMethodName print(boxed_heading_str("testcase: " + testcasename)) + self.pysim_shell_log_counter = 0 # Find directories 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 """ - 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 if not os.access(script, os.R_OK):