Skip to content

Commit

Permalink
ktest: Added force stop after success and failure
Browse files Browse the repository at this point in the history
Added the options STOP_AFTER_SUCCESS and STOP_AFTER_FAILURE to
allow the user to give a time (in seconds) to stop the monitor
after a stack trace or login has been detected. Sometimes the
kernel constantly prints out to the console and this may cause
the test to run indefinitely.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Nov 18, 2010
1 parent cccae1a commit 1c8a617
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
$default{"SSH_EXEC"} = "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND";
$default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE";
$default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot";
$default{"STOP_AFTER_SUCCESS"} = 10;
$default{"STOP_AFTER_FAILURE"} = 60;

my $version;
my $machine;
Expand Down Expand Up @@ -94,6 +96,8 @@
my $booted_timeout;
my $console;
my $success_line;
my $stop_after_success;
my $stop_after_failure;
my $build_target;
my $target_image;
my $localversion;
Expand Down Expand Up @@ -601,6 +605,9 @@ sub monitor {

reboot_to;

my $success_start;
my $failure_start;

for (;;) {

if ($booted) {
Expand All @@ -619,14 +626,36 @@ sub monitor {

if ($full_line =~ /$success_line/) {
$booted = 1;
$success_start = time;
}

if ($booted && defined($stop_after_success) &&
$stop_after_success >= 0) {
my $now = time;
if ($now - $success_start >= $stop_after_success) {
doprint "Test forced to stop after $stop_after_success seconds after success\n";
last;
}
}

if ($full_line =~ /\[ backtrace testing \]/) {
$skip_call_trace = 1;
}

if ($full_line =~ /call trace:/i) {
$bug = 1 if (!$skip_call_trace);
if (!$skip_call_trace) {
$bug = 1;
$failure_start = time;
}
}

if ($bug && defined($stop_after_failure) &&
$stop_after_failure >= 0) {
my $now = time;
if ($now - $failure_start >= $stop_after_failure) {
doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
last;
}
}

if ($full_line =~ /\[ end of backtrace testing \]/) {
Expand Down Expand Up @@ -1687,6 +1716,8 @@ sub set_test_option {
$booted_timeout = set_test_option("BOOTED_TIMEOUT", $i);
$console = set_test_option("CONSOLE", $i);
$success_line = set_test_option("SUCCESS_LINE", $i);
$stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i);
$stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i);
$build_target = set_test_option("BUILD_TARGET", $i);
$ssh_exec = set_test_option("SSH_EXEC", $i);
$scp_to_target = set_test_option("SCP_TO_TARGET", $i);
Expand Down
12 changes: 12 additions & 0 deletions tools/testing/ktest/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@
# (default "login:")
#SUCCESS_LINE = login:

# In case the console constantly fills the screen, having
# a specified time to stop the test after success is recommended.
# (in seconds)
# (default 10)
#STOP_AFTER_SUCCESS = 10

# In case the console constantly fills the screen, having
# a specified time to stop the test after failure is recommended.
# (in seconds)
# (default 60)
#STOP_AFTER_FAILURE = 60

# Stop testing if a build fails. If set, the script will end if
# a failure is detected, otherwise it will save off the .config,
# dmesg and bootlog in a directory called
Expand Down

0 comments on commit 1c8a617

Please sign in to comment.