Commit f7eaafa8 authored by Robert Schmidt's avatar Robert Schmidt

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.
parent 19c6d20b
...@@ -296,8 +296,16 @@ def test_in_list(test, list): ...@@ -296,8 +296,16 @@ def test_in_list(test, list):
return True return True
return False return False
test_runner_abort = False
def receive_signal(signum, frame): 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): def ShowTestID(ctx, desc):
logging.info(f'\u001B[1m----------------------------------------\u001B[0m') logging.info(f'\u001B[1m----------------------------------------\u001B[0m')
...@@ -488,7 +496,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -488,7 +496,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
#logging.info('test will be run: ' + test) #logging.info('test will be run: ' + test)
todo_tests.append(test) todo_tests.append(test)
signal.signal(signal.SIGUSR1, receive_signal) signal.signal(signal.SIGINT, receive_signal)
HTML.CreateHtmlTabHeader() HTML.CreateHtmlTabHeader()
...@@ -498,6 +506,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -498,6 +506,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
i = 0 i = 0
for test_case_id in todo_tests: for test_case_id in todo_tests:
for test in all_tests: for test in all_tests:
if test_runner_abort:
task_set_succeeded = False
id = test.get('id') id = test.get('id')
if test_case_id != id: if test_case_id != id:
continue continue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment