Skip to content

Commit 2b80336

Browse files
Steven Rostedtrostedt
authored andcommitted
ktest: Add option REBOOT_SUCCESS_LINE to stop waiting after a reboot
When ktest.pl reboots, it will usuall wait SLEEP_TIME seconds of idle console before starting the next test. By setting the REBOOT_SUCCESS_LINE, ktest will not wait SLEEP_TIME when it detects the line while rebooting to a new kernel. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent e0a8742 commit 2b80336

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

‎tools/testing/ktest/ktest.pl‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
my $booted_timeout;
118118
my $detect_triplefault;
119119
my $console;
120+
my $reboot_success_line;
120121
my $success_line;
121122
my $stop_after_success;
122123
my $stop_after_failure;
@@ -612,6 +613,13 @@ sub doprint {
612613
sub reboot {
613614
my ($time) = @_;
614615

616+
if (defined($time)) {
617+
start_monitor;
618+
# flush out current monitor
619+
# May contain the reboot success line
620+
wait_for_monitor 1;
621+
}
622+
615623
# try to reboot normally
616624
if (run_command $reboot) {
617625
if (defined($powercycle_after_reboot)) {
@@ -624,8 +632,7 @@ sub reboot {
624632
}
625633

626634
if (defined($time)) {
627-
start_monitor;
628-
wait_for_monitor $time;
635+
wait_for_monitor($time, $reboot_success_line);
629636
end_monitor;
630637
}
631638
}
@@ -706,16 +713,29 @@ sub end_monitor {
706713
}
707714

708715
sub wait_for_monitor {
709-
my ($time) = @_;
716+
my ($time, $stop) = @_;
717+
my $full_line = "";
710718
my $line;
719+
my $booted = 0;
711720

712721
doprint "** Wait for monitor to settle down **\n";
713722

714723
# read the monitor and wait for the system to calm down
715-
do {
724+
while (!$booted) {
716725
$line = wait_for_input($monitor_fp, $time);
717-
print "$line" if (defined($line));
718-
} while (defined($line));
726+
last if (!defined($line));
727+
print "$line";
728+
$full_line .= $line;
729+
730+
if (defined($stop) && $full_line =~ /$stop/) {
731+
doprint "wait for monitor detected $stop\n";
732+
$booted = 1;
733+
}
734+
735+
if ($line =~ /\n/) {
736+
$full_line = "";
737+
}
738+
}
719739
print "** Monitor flushed **\n";
720740
}
721741

@@ -2836,6 +2856,7 @@ sub set_test_option {
28362856
$console = set_test_option("CONSOLE", $i);
28372857
$detect_triplefault = set_test_option("DETECT_TRIPLE_FAULT", $i);
28382858
$success_line = set_test_option("SUCCESS_LINE", $i);
2859+
$reboot_success_line = set_test_option("REBOOT_SUCCESS_LINE", $i);
28392860
$stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i);
28402861
$stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i);
28412862
$stop_test_after = set_test_option("STOP_TEST_AFTER", $i);

‎tools/testing/ktest/sample.conf‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,14 @@
423423
# (default "login:")
424424
#SUCCESS_LINE = login:
425425

426+
# To speed up between reboots, defining a line that the
427+
# default kernel produces that represents that the default
428+
# kernel has successfully booted and can be used to pass
429+
# a new test kernel to it. Otherwise ktest.pl will wait till
430+
# SLEEP_TIME to continue.
431+
# (default undefined)
432+
#REBOOT_SUCCESS_LINE = login:
433+
426434
# In case the console constantly fills the screen, having
427435
# a specified time to stop the test after success is recommended.
428436
# (in seconds)
@@ -488,6 +496,8 @@
488496
# another test. If a reboot to the reliable kernel happens,
489497
# we wait SLEEP_TIME for the console to stop producing output
490498
# before starting the next test.
499+
#
500+
# You can speed up reboot times even more by setting REBOOT_SUCCESS_LINE.
491501
# (default 60)
492502
#SLEEP_TIME = 60
493503

0 commit comments

Comments
 (0)