MCPcopy Create free account
hub / github.com/FastLED/FastLED / run_test_with_deadlock_detection

Function run_test_with_deadlock_detection

tests/test_wrapper.py:40–136  ·  view source on GitHub ↗

Run a test with deadlock detection. Args: runner_exe: Path to runner.exe (loads test DLLs) test_dll: Path to test DLL timeout_seconds: Timeout in seconds (default: 20) Returns: Exit code (0 = success, non-zero = failure/timeout)

(
    runner_exe: str,
    test_dll: str,
    timeout_seconds: float = DEFAULT_TIMEOUT,
)

Source from the content-addressed store, hash-verified

38
39
40def run_test_with_deadlock_detection(
41 runner_exe: str,
42 test_dll: str,
43 timeout_seconds: float = DEFAULT_TIMEOUT,
44) -> int:
45 """
46 Run a test with deadlock detection.
47
48 Args:
49 runner_exe: Path to runner.exe (loads test DLLs)
50 test_dll: Path to test DLL
51 timeout_seconds: Timeout in seconds (default: 20)
52
53 Returns:
54 Exit code (0 = success, non-zero = failure/timeout)
55 """
56 test_name = Path(test_dll).stem
57
58 print(f"Running test: {test_name} (timeout: {timeout_seconds}s)")
59
60 start_time = time.time()
61
62 # Start the test process (runner.exe loads the test DLL)
63 try:
64 proc = subprocess.Popen(
65 [runner_exe, test_dll],
66 stdout=subprocess.PIPE,
67 stderr=subprocess.STDOUT,
68 text=True,
69 bufsize=1, # Line buffered
70 )
71 except KeyboardInterrupt as ki:
72 handle_keyboard_interrupt(ki)
73 raise
74 except Exception as e:
75 print(f"Failed to start test: {e}", file=sys.stderr)
76 return 1
77
78 # Start background thread to read output without blocking
79 output_lines = []
80 reader_thread = threading.Thread(
81 target=_output_reader, args=(proc, output_lines), daemon=True
82 )
83 reader_thread.start()
84
85 # Monitor the process - just poll() and check timeout
86 try:
87 while True:
88 # Check if process has finished
89 returncode = proc.poll()
90 if returncode is not None:
91 # Process finished - wait for reader thread to drain remaining output
92 reader_thread.join(timeout=2.0)
93
94 elapsed = time.time() - start_time
95 if returncode == 0:
96 print(f"✓ Test passed in {elapsed:.2f}s")
97 else:

Callers 1

mainFunction · 0.85

Calls 8

handle_hung_testFunction · 0.90
timeMethod · 0.80
killMethod · 0.80
printFunction · 0.50
startMethod · 0.45
pollMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected