From: Martin Quinson Date: Sun, 29 Oct 2023 14:05:54 +0000 (+0100) Subject: tesh: rerun the command in valgrind if it segfaults X-Git-Tag: v3.35~89^2~39 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f575793ee1442b9e9bf32b561d5f9f230a258d62?hp=732fa298b5797e83b27340837332cce4384d157a tesh: rerun the command in valgrind if it segfaults This is particuly useful when experiencing segfaults in our test suite on some exotic OS that has valgrind (say hello to FreeBSD here) --- diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index bec45335a4..1a6d8f33b1 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -237,6 +237,7 @@ class Cmd: self.output_display = False self.sort = -1 + self.rerun_with_valgrind = False self.ignore_regexps = TeshState().ignore_regexps_common @@ -302,6 +303,12 @@ class Cmd: _thread.start_new_thread(Cmd._run, (self, lock)) else: self._run() + if self.rerun_with_valgrind: + print('\n\n\nXXXXXXXXX Rerunning this test with valgrind to help debugging it XXXXXXXXX') + print('(this will fail if valgrind is not installed, of course)\n\n\n') + + self.args = "valgrind " + self.args + self._run() return True def _run(self, lock=None): @@ -470,6 +477,8 @@ class Cmd: else: logs.append("In addition, <{cmd}> got signal {sig}.".format(cmd=cmd_name, sig=SIGNALS_TO_NAMES_DICT[-proc.returncode])) + if proc.returncode == -signal.SIGSEGV: + self.rerun_with_valgrind = True if lock is not None: lock.release() @@ -505,6 +514,10 @@ class Cmd: logs.append("Test suite `{file}': NOK (<{cmd}> got signal {sig})".format( file=FileReader().filename, cmd=cmd_name, sig=SIGNALS_TO_NAMES_DICT[-proc.returncode])) + + if proc.returncode == -signal.SIGSEGV: + self.rerun_with_valgrind = True + if lock is not None: lock.release() TeshState().set_return_code(max(-proc.returncode, 1))