From 8e68e73c43b94e265810592c1ab881de91ce8575 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 19 May 2021 14:14:46 -0500 Subject: [PATCH] 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. --- tools/test-runner | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/test-runner b/tools/test-runner index 892e63ff..86419e88 100755 --- a/tools/test-runner +++ b/tools/test-runner @@ -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')])