Skip to content

fix: Ctrl+C now properly kills running tests and stops immediately#12

Merged
haugoug merged 1 commit intogvsoc:mainfrom
germainh512:fix-ctrlc
Mar 10, 2026
Merged

fix: Ctrl+C now properly kills running tests and stops immediately#12
haugoug merged 1 commit intogvsoc:mainfrom
germainh512:fix-ctrlc

Conversation

@germainh512
Copy link

Problem

Pressing Ctrl+C during a test run would only clear the pending_tests list, but:

  • Tests already dispatched to the worker queue kept running
  • Currently running test processes were not killed
  • This caused many tests to show as KO before eventually stopping

Fix

On Ctrl+C the signal handler now:

  1. Clears pending_tests — tests not yet dispatched
  2. Drains the worker queue — tests dispatched but not yet started
  3. Kills all running processes — sends SIGKILL to all active test process trees

Workers also check _interrupted before starting a test, so any test pulled from the queue after the interrupt is silently dropped.

The command execution loop checks _interrupted between commands, so multi-command tests abort quickly.

Also initializes status, output, timeout_reached in TestRun.__init__ so stats collection never crashes on runs that were created but never executed.

Tested

  • Manual test: 20 tests with sleep 30, 4 threads. Ctrl+C kills everything in <1s.
  • 122 automated tests passing.

The previous Ctrl+C implementation only cleared pending_tests but:
- Tests already in the worker queue continued to run
- Currently running processes were not killed
- TestRun objects without status caused crashes in stats collection

Now on Ctrl+C:
1. Clears pending_tests (tests not yet dispatched)
2. Drains the worker queue (tests queued but not started)
3. Kills all currently running test processes via SIGKILL
4. Workers check _interrupted flag before starting new tests
5. Command loop checks _interrupted between commands

Also initializes status/output/timeout_reached in TestRun.__init__
so stats collection never crashes on uninitialized runs.

122 tests passing.
@haugoug haugoug merged commit 75064b4 into gvsoc:main Mar 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants