auto-t: Do not remove valgrind.log

Right now the --valgrind option logs to a static file named
'valgrind.log'.  This means that for any test that run multiple
instances of iwd, output is lost for all invocations except the last.
Fix that by using a per-process log file and making sure that all log
files are printed to stdout when the test ends.

This approach isn't perfect since it is possible for the pid to be
reused, but better than the current behavior.
This commit is contained in:
Denis Kenzior 2021-05-19 14:14:46 -05:00
parent edf7294c06
commit 8e68e73c43
1 changed files with 10 additions and 6 deletions

View File

@ -672,7 +672,7 @@ class Namespace:
if self.args.valgrind:
args.extend(['valgrind', '--leak-check=full', '--track-origins=yes',
'--log-file=/tmp/valgrind.log'])
'--log-file=/tmp/valgrind.log.%p'])
args.extend(['iwd', '-p', iwd_radios])
@ -1183,16 +1183,20 @@ def post_test(ctx, to_copy):
finally:
ctx.stop_test_processes()
if ctx.args.valgrind:
for f in os.listdir('/tmp'):
if f.startswith("valgrind.log."):
dbg(f)
with open('/tmp/' + f, 'r') as v:
dbg(v.read())
dbg("\n")
os.remove('/tmp/' + f)
allowed = ['phonesim.conf', 'certs', 'secrets', 'iwd']
for f in [f for f in os.listdir('/tmp') if f not in allowed]:
dbg("File %s was not cleaned up!" % f)
os.remove('/tmp/' + f)
if ctx.args.valgrind:
with open('/tmp/valgrind.log', 'r') as f:
dbg(f.read())
dbg("\n")
def print_results(results):
table = PrettyTable(['Test', colored('Passed', 'green'), colored('Failed', 'red'), \
colored('Skipped', 'cyan'), colored('Time', 'yellow')])