diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-11-09 12:55:40 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-18 11:23:12 -0500 |
commit | 1c8a617a274c4065681d964cd5a5afb921de4a87 (patch) | |
tree | ac0ed54d6d2a8db807f3a096d7df9fa35b600a31 /tools/testing | |
parent | cccae1a62a81dc8e32bf787024fdcf7ef71f1285 (diff) |
ktest: Added force stop after success and failure
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>
Diffstat (limited to 'tools/testing')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 33 | ||||
-rw-r--r-- | tools/testing/ktest/sample.conf | 12 |
2 files changed, 44 insertions, 1 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 52e45b8551e8..6e8597398468 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -45,6 +45,8 @@ $default{"DIE_ON_FAILURE"} = 1; | |||
45 | $default{"SSH_EXEC"} = "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND"; | 45 | $default{"SSH_EXEC"} = "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND"; |
46 | $default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE"; | 46 | $default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE"; |
47 | $default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot"; | 47 | $default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot"; |
48 | $default{"STOP_AFTER_SUCCESS"} = 10; | ||
49 | $default{"STOP_AFTER_FAILURE"} = 60; | ||
48 | 50 | ||
49 | my $version; | 51 | my $version; |
50 | my $machine; | 52 | my $machine; |
@@ -94,6 +96,8 @@ my $timeout; | |||
94 | my $booted_timeout; | 96 | my $booted_timeout; |
95 | my $console; | 97 | my $console; |
96 | my $success_line; | 98 | my $success_line; |
99 | my $stop_after_success; | ||
100 | my $stop_after_failure; | ||
97 | my $build_target; | 101 | my $build_target; |
98 | my $target_image; | 102 | my $target_image; |
99 | my $localversion; | 103 | my $localversion; |
@@ -601,6 +605,9 @@ sub monitor { | |||
601 | 605 | ||
602 | reboot_to; | 606 | reboot_to; |
603 | 607 | ||
608 | my $success_start; | ||
609 | my $failure_start; | ||
610 | |||
604 | for (;;) { | 611 | for (;;) { |
605 | 612 | ||
606 | if ($booted) { | 613 | if ($booted) { |
@@ -619,6 +626,16 @@ sub monitor { | |||
619 | 626 | ||
620 | if ($full_line =~ /$success_line/) { | 627 | if ($full_line =~ /$success_line/) { |
621 | $booted = 1; | 628 | $booted = 1; |
629 | $success_start = time; | ||
630 | } | ||
631 | |||
632 | if ($booted && defined($stop_after_success) && | ||
633 | $stop_after_success >= 0) { | ||
634 | my $now = time; | ||
635 | if ($now - $success_start >= $stop_after_success) { | ||
636 | doprint "Test forced to stop after $stop_after_success seconds after success\n"; | ||
637 | last; | ||
638 | } | ||
622 | } | 639 | } |
623 | 640 | ||
624 | if ($full_line =~ /\[ backtrace testing \]/) { | 641 | if ($full_line =~ /\[ backtrace testing \]/) { |
@@ -626,7 +643,19 @@ sub monitor { | |||
626 | } | 643 | } |
627 | 644 | ||
628 | if ($full_line =~ /call trace:/i) { | 645 | if ($full_line =~ /call trace:/i) { |
629 | $bug = 1 if (!$skip_call_trace); | 646 | if (!$skip_call_trace) { |
647 | $bug = 1; | ||
648 | $failure_start = time; | ||
649 | } | ||
650 | } | ||
651 | |||
652 | if ($bug && defined($stop_after_failure) && | ||
653 | $stop_after_failure >= 0) { | ||
654 | my $now = time; | ||
655 | if ($now - $failure_start >= $stop_after_failure) { | ||
656 | doprint "Test forced to stop after $stop_after_failure seconds after failure\n"; | ||
657 | last; | ||
658 | } | ||
630 | } | 659 | } |
631 | 660 | ||
632 | if ($full_line =~ /\[ end of backtrace testing \]/) { | 661 | if ($full_line =~ /\[ end of backtrace testing \]/) { |
@@ -1687,6 +1716,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
1687 | $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); | 1716 | $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); |
1688 | $console = set_test_option("CONSOLE", $i); | 1717 | $console = set_test_option("CONSOLE", $i); |
1689 | $success_line = set_test_option("SUCCESS_LINE", $i); | 1718 | $success_line = set_test_option("SUCCESS_LINE", $i); |
1719 | $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i); | ||
1720 | $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i); | ||
1690 | $build_target = set_test_option("BUILD_TARGET", $i); | 1721 | $build_target = set_test_option("BUILD_TARGET", $i); |
1691 | $ssh_exec = set_test_option("SSH_EXEC", $i); | 1722 | $ssh_exec = set_test_option("SSH_EXEC", $i); |
1692 | $scp_to_target = set_test_option("SCP_TO_TARGET", $i); | 1723 | $scp_to_target = set_test_option("SCP_TO_TARGET", $i); |
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index e1272746ce8c..3408c594b2de 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf | |||
@@ -294,6 +294,18 @@ | |||
294 | # (default "login:") | 294 | # (default "login:") |
295 | #SUCCESS_LINE = login: | 295 | #SUCCESS_LINE = login: |
296 | 296 | ||
297 | # In case the console constantly fills the screen, having | ||
298 | # a specified time to stop the test after success is recommended. | ||
299 | # (in seconds) | ||
300 | # (default 10) | ||
301 | #STOP_AFTER_SUCCESS = 10 | ||
302 | |||
303 | # In case the console constantly fills the screen, having | ||
304 | # a specified time to stop the test after failure is recommended. | ||
305 | # (in seconds) | ||
306 | # (default 60) | ||
307 | #STOP_AFTER_FAILURE = 60 | ||
308 | |||
297 | # Stop testing if a build fails. If set, the script will end if | 309 | # Stop testing if a build fails. If set, the script will end if |
298 | # a failure is detected, otherwise it will save off the .config, | 310 | # a failure is detected, otherwise it will save off the .config, |
299 | # dmesg and bootlog in a directory called | 311 | # dmesg and bootlog in a directory called |