Skip to content

Commit 2562af6

Browse files
committed
Merge tag 'ktest-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest
Pull ktest updates from Steven Rostedt: - Fix three instances that the tty is not given back to the console on exit. Forcing the user to do a "reset" to get the console back. - Fix the console monitor to not hang when too much data is given by the ssh output. * tag 'ktest-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest: ktest: Restore stty setting at first in dodie ktest.pl: Add RUN_TIMEOUT option with default unlimited ktest.pl: Give back console on Ctrt^C on monitor ktest.pl: Fix missing "end_monitor" when machine check fails
2 parents 89f1a24 + 7dc8e24 commit 2562af6

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

tools/testing/ktest/ktest.pl

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
my $store_successes;
179179
my $test_name;
180180
my $timeout;
181+
my $run_timeout;
181182
my $connect_timeout;
182183
my $config_bisect_exec;
183184
my $booted_timeout;
@@ -340,6 +341,7 @@
340341
"STORE_SUCCESSES" => \$store_successes,
341342
"TEST_NAME" => \$test_name,
342343
"TIMEOUT" => \$timeout,
344+
"RUN_TIMEOUT" => \$run_timeout,
343345
"CONNECT_TIMEOUT" => \$connect_timeout,
344346
"CONFIG_BISECT_EXEC" => \$config_bisect_exec,
345347
"BOOTED_TIMEOUT" => \$booted_timeout,
@@ -1495,7 +1497,8 @@ sub reboot {
14951497

14961498
# Still need to wait for the reboot to finish
14971499
wait_for_monitor($time, $reboot_success_line);
1498-
1500+
}
1501+
if ($powercycle || $time) {
14991502
end_monitor;
15001503
}
15011504
}
@@ -1535,6 +1538,11 @@ sub dodie {
15351538
return if ($in_die);
15361539
$in_die = 1;
15371540

1541+
if ($monitor_cnt) {
1542+
# restore terminal settings
1543+
system("stty $stty_orig");
1544+
}
1545+
15381546
my $i = $iteration;
15391547

15401548
doprint "CRITICAL FAILURE... [TEST $i] ", @_, "\n";
@@ -1581,11 +1589,6 @@ sub dodie {
15811589
"Your test started at $script_start_time has failed with:\n@_\n", $log_file);
15821590
}
15831591

1584-
if ($monitor_cnt) {
1585-
# restore terminal settings
1586-
system("stty $stty_orig");
1587-
}
1588-
15891592
if (defined($post_test)) {
15901593
run_command $post_test;
15911594
}
@@ -1857,6 +1860,14 @@ sub run_command {
18571860
$command =~ s/\$SSH_USER/$ssh_user/g;
18581861
$command =~ s/\$MACHINE/$machine/g;
18591862

1863+
if (!defined($timeout)) {
1864+
$timeout = $run_timeout;
1865+
}
1866+
1867+
if (!defined($timeout)) {
1868+
$timeout = -1; # tell wait_for_input to wait indefinitely
1869+
}
1870+
18601871
doprint("$command ... ");
18611872
$start_time = time;
18621873

@@ -1883,13 +1894,10 @@ sub run_command {
18831894

18841895
while (1) {
18851896
my $fp = \*CMD;
1886-
if (defined($timeout)) {
1887-
doprint "timeout = $timeout\n";
1888-
}
18891897
my $line = wait_for_input($fp, $timeout);
18901898
if (!defined($line)) {
18911899
my $now = time;
1892-
if (defined($timeout) && (($now - $start_time) >= $timeout)) {
1900+
if ($timeout >= 0 && (($now - $start_time) >= $timeout)) {
18931901
doprint "Hit timeout of $timeout, killing process\n";
18941902
$hit_timeout = 1;
18951903
kill 9, $pid;
@@ -2061,6 +2069,11 @@ sub wait_for_input {
20612069
$time = $timeout;
20622070
}
20632071

2072+
if ($time < 0) {
2073+
# Negative number means wait indefinitely
2074+
undef $time;
2075+
}
2076+
20642077
$rin = '';
20652078
vec($rin, fileno($fp), 1) = 1;
20662079
vec($rin, fileno(\*STDIN), 1) = 1;
@@ -4200,6 +4213,9 @@ sub send_email {
42004213
}
42014214

42024215
sub cancel_test {
4216+
if ($monitor_cnt) {
4217+
end_monitor;
4218+
}
42034219
if ($email_when_canceled) {
42044220
my $name = get_test_name;
42054221
send_email("KTEST: Your [$name] test was cancelled",

tools/testing/ktest/sample.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,11 @@
817817
# is issued instead of a reboot.
818818
# CONNECT_TIMEOUT = 25
819819

820+
# The timeout in seconds for how long to wait for any running command
821+
# to timeout. If not defined, it will let it go indefinitely.
822+
# (default undefined)
823+
#RUN_TIMEOUT = 600
824+
820825
# In between tests, a reboot of the box may occur, and this
821826
# is the time to wait for the console after it stops producing
822827
# output. Some machines may not produce a large lag on reboot

0 commit comments

Comments
 (0)