aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_runner.py
diff options
context:
space:
mode:
authorS3RK <1466284+S3RK@users.noreply.github.com>2021-06-14 09:44:11 +0200
committerS3RK <1466284+S3RK@users.noreply.github.com>2021-06-15 09:37:58 +0200
commit451b96f7d2796d00eabaec56d831f9e9b1a569cc (patch)
treeed74d34ea415368dc5aa4d2f4dcdf3bfd0af976e /test/functional/test_runner.py
parentde5512e28df220990ad123b914167aadd6f50979 (diff)
downloadbitcoin-451b96f7d2796d00eabaec56d831f9e9b1a569cc.tar.xz
test: kill process group to avoid dangling processes
Diffstat (limited to 'test/functional/test_runner.py')
-rwxr-xr-xtest/functional/test_runner.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index c9a8cc5611..76347b052d 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -19,6 +19,7 @@ import datetime
import os
import time
import shutil
+import signal
import subprocess
import sys
import tempfile
@@ -548,9 +549,11 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
all_passed = all(map(lambda test_result: test_result.was_successful, test_results)) and coverage_passed
- # This will be a no-op unless failfast is True in which case there may be dangling
- # processes which need to be killed.
- job_queue.kill_and_join()
+ # Clean up dangling processes if any. This may only happen with --failfast option.
+ # Killing the process group will also terminate the current process but that is
+ # not an issue
+ if len(job_queue.jobs):
+ os.killpg(os.getpgid(0), signal.SIGKILL)
sys.exit(not all_passed)
@@ -647,16 +650,6 @@ class TestHandler:
print('.', end='', flush=True)
dot_count += 1
- def kill_and_join(self):
- """Send SIGKILL to all jobs and block until all have ended."""
- procs = [i[2] for i in self.jobs]
-
- for proc in procs:
- proc.kill()
-
- for proc in procs:
- proc.wait()
-
class TestResult():
def __init__(self, name, status, time):