Skip to content

Commit 92db453

Browse files
Tim Tianyang Chenrostedt
authored andcommitted
Ktest: Add SigInt handling
User can cancel tests and specify handler's behavior using option 'EMAIL_WHEN_CANCELED'. Link: http://lkml.kernel.org/r/1522094884-22718-3-git-send-email-tianyang.chen@oracle.com Suggested-by: Dhaval Giani <dhaval.giani@oracle.com> Signed-off-by: Tim Tianyang Chen <tianyang.chen@oracle.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 2ceb2d8 commit 92db453

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎tools/testing/ktest/ktest.pl‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,6 +4144,16 @@ sub send_email {
41444144
}
41454145
}
41464146

4147+
sub cancel_test {
4148+
if ($email_when_canceled) {
4149+
send_email("KTEST: Your [$test_type] test was cancelled",
4150+
"Your test started at $script_start_time was cancelled: sig int");
4151+
}
4152+
die "\nCaught Sig Int, test interrupted: $!\n"
4153+
}
4154+
4155+
$SIG{INT} = qw(cancel_test);
4156+
41474157
# First we need to do is the builds
41484158
for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
41494159

0 commit comments

Comments
 (0)