From f7eaafa8358b3825a0b8953047bd630696b20e2b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 3 Nov 2025 19:03:03 +0100 Subject: [PATCH] CI test runner: handle SIGINT Handle SIGINT and mark any subsequent steps as failed. Receiving SIGINT a second time will abort the script immediately (as is the case before this commit). Note that Python seems to relay the signal to the "controlled" process (e.g., Ping), which would return immediately with an error. So some steps like Ping will abort immediately, others (e.g., IdleSleep) will finish their step, and then the present logic will mark subsequent steps as failed. --- ci-scripts/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ci-scripts/main.py b/ci-scripts/main.py index b56d8d7b87..99500fff12 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -296,8 +296,16 @@ def test_in_list(test, list): return True return False +test_runner_abort = False def receive_signal(signum, frame): - sys.exit(1) + global test_runner_abort + if not test_runner_abort: + logging.warning("received signal, canceling steps") + logging.info("send signal again to exit immediately") + test_runner_abort = True + else: + logging.warning("received signal again, exiting") + sys.exit(1) def ShowTestID(ctx, desc): logging.info(f'\u001B[1m----------------------------------------\u001B[0m') @@ -488,7 +496,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re #logging.info('test will be run: ' + test) todo_tests.append(test) - signal.signal(signal.SIGUSR1, receive_signal) + signal.signal(signal.SIGINT, receive_signal) HTML.CreateHtmlTabHeader() @@ -498,6 +506,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re i = 0 for test_case_id in todo_tests: for test in all_tests: + if test_runner_abort: + task_set_succeeded = False id = test.get('id') if test_case_id != id: continue