Fixed issue with test.py/bench.py -f/--fail not killing runners

While the -f/--fail logic was correctly terminating the test.py/bench.py
runner thread, it was not terminating the actual underlying test
process. This was causing test.py/bench.py to hang until the test runner
completed all pending tests, which could take quite some time.

This wasn't noticed earlier because test.py/bench.py still reports the
test as failed, and most uses of -f/--fail involve specifying a specific
test case, which usually terminates quite quickly.

What's more interesting is this termination logic was copied from the
handling of ctrl-C/SIGINT/KeyboardInterrupt, but this issue is not
present there because SIGINT would be sent to all processes in the
process tree, terminating the child process anyways.

Fixed by adding an explicit proc.kill() to test.py/bench.py before
tearing down the runner thread.
This commit is contained in:
Christopher Haster
2024-03-26 12:40:37 -05:00
parent 74f4ad8669
commit 2dcde5579b
2 changed files with 4 additions and 0 deletions

View File

@@ -1005,6 +1005,7 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
elif op == 'finished':
# force a failure?
if args.get('fail'):
proc.kill()
raise TestFailure(last_id, 0, list(last_stdout))
# passed
case = m.group('case')
@@ -1032,6 +1033,7 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
if args.get('keep_going'):
proc.kill()
except KeyboardInterrupt:
proc.kill()
raise TestFailure(last_id, 0, list(last_stdout))
finally:
children.remove(proc)