aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-11-02 14:58:38 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-11-18 11:23:09 -0500
commit576f627c817dff0b7081374287a77247325b9cc0 (patch)
tree9c1c4a1a00ce62a4781d219c0d0561b80576e367 /tools
parent8b37ca8cac46b2c108386e3901cc8611dc81c7aa (diff)
ktest: Add poweroff after halt and powercycle after reboot
Added the options POWEROFF_AFTER_HALT to handle boxes that do not really shut off after a halt is called. Added POWERCYCLE_AFTER_REBOOT to force a power cycle for boxes that don't reboot but get stuck during the reboot. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/ktest/ktest.pl63
-rw-r--r--tools/testing/ktest/sample.conf18
2 files changed, 66 insertions, 15 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 687a85475af5..ef978171ecb7 100644
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -53,6 +53,8 @@ my $power_cycle;
53my $reboot_on_error; 53my $reboot_on_error;
54my $poweroff_on_error; 54my $poweroff_on_error;
55my $die_on_failure; 55my $die_on_failure;
56my $powercycle_after_reboot;
57my $poweroff_after_halt;
56my $power_off; 58my $power_off;
57my $grub_menu; 59my $grub_menu;
58my $grub_number; 60my $grub_number;
@@ -83,6 +85,7 @@ my $success_line;
83my $build_target; 85my $build_target;
84my $target_image; 86my $target_image;
85my $localversion; 87my $localversion;
88my $iteration = 0;
86 89
87sub read_config { 90sub read_config {
88 my ($config) = @_; 91 my ($config) = @_;
@@ -133,16 +136,32 @@ sub run_command;
133 136
134sub reboot { 137sub reboot {
135 # try to reboot normally 138 # try to reboot normally
136 if (!run_command "ssh $target reboot") { 139 if (run_command "ssh $target reboot") {
140 if (defined($powercycle_after_reboot)) {
141 sleep $powercycle_after_reboot;
142 run_command "$power_cycle";
143 }
144 } else {
137 # nope? power cycle it. 145 # nope? power cycle it.
138 run_command "$power_cycle"; 146 run_command "$power_cycle";
139 } 147 }
140} 148}
141 149
150sub do_not_reboot {
151 my $i = $iteration;
152
153 return $test_type eq "build" ||
154 ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") ||
155 ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build");
156}
157
142sub dodie { 158sub dodie {
143 doprint "CRITICAL FAILURE... ", @_, "\n"; 159 doprint "CRITICAL FAILURE... ", @_, "\n";
144 160
145 if ($reboot_on_error && $test_type ne "build") { 161 my $i = $iteration;
162
163 if ($reboot_on_error && !do_not_reboot) {
164
146 doprint "REBOOTING\n"; 165 doprint "REBOOTING\n";
147 reboot; 166 reboot;
148 167
@@ -151,7 +170,7 @@ sub dodie {
151 `$power_off`; 170 `$power_off`;
152 } 171 }
153 172
154 die @_; 173 die @_, "\n";
155} 174}
156 175
157sub open_console { 176sub open_console {
@@ -163,9 +182,9 @@ sub open_console {
163 dodie "Can't open console $console"; 182 dodie "Can't open console $console";
164 183
165 $flags = fcntl($fp, F_GETFL, 0) or 184 $flags = fcntl($fp, F_GETFL, 0) or
166 dodie "Can't get flags for the socket: $!\n"; 185 dodie "Can't get flags for the socket: $!";
167 $flags = fcntl($fp, F_SETFL, $flags | O_NONBLOCK) or 186 $flags = fcntl($fp, F_SETFL, $flags | O_NONBLOCK) or
168 dodie "Can't set flags for the socket: $!\n"; 187 dodie "Can't set flags for the socket: $!";
169 188
170 return $pid; 189 return $pid;
171} 190}
@@ -221,8 +240,10 @@ sub fail {
221 240
222 doprint "FAILED\n"; 241 doprint "FAILED\n";
223 242
243 my $i = $iteration;
244
224 # no need to reboot for just building. 245 # no need to reboot for just building.
225 if ($test_type ne "build") { 246 if (!do_not_reboot) {
226 doprint "REBOOTING\n"; 247 doprint "REBOOTING\n";
227 reboot; 248 reboot;
228 start_monitor; 249 start_monitor;
@@ -230,7 +251,11 @@ sub fail {
230 end_monitor; 251 end_monitor;
231 } 252 }
232 253
254 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
255 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
233 doprint "**** Failed: ", @_, " ****\n"; 256 doprint "**** Failed: ", @_, " ****\n";
257 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
258 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
234 259
235 return 1 if (!defined($store_failures)); 260 return 1 if (!defined($store_failures));
236 261
@@ -434,12 +459,12 @@ sub monitor {
434 459
435 if ($bug) { 460 if ($bug) {
436 return 0 if ($in_bisect); 461 return 0 if ($in_bisect);
437 fail "failed - got a bug report\n" and return 0; 462 fail "failed - got a bug report" and return 0;
438 } 463 }
439 464
440 if (!$booted) { 465 if (!$booted) {
441 return 0 if ($in_bisect); 466 return 0 if ($in_bisect);
442 fail "failed - never got a boot prompt.\n" and return 0; 467 fail "failed - never got a boot prompt." and return 0;
443 } 468 }
444 469
445 return 1; 470 return 1;
@@ -496,7 +521,8 @@ sub install {
496 my $save_env = $ENV{KERNEL_VERSION}; 521 my $save_env = $ENV{KERNEL_VERSION};
497 522
498 $ENV{KERNEL_VERSION} = $version; 523 $ENV{KERNEL_VERSION} = $version;
499 run_command "$post_install"; 524 run_command "$post_install" or
525 dodie "Failed to run post install";
500 526
501 $ENV{KERNEL_VERSION} = $save_env; 527 $ENV{KERNEL_VERSION} = $save_env;
502} 528}
@@ -596,6 +622,11 @@ sub build {
596 622
597sub halt { 623sub halt {
598 if (!run_command "ssh $target halt" or defined($power_off)) { 624 if (!run_command "ssh $target halt" or defined($power_off)) {
625 if (defined($poweroff_after_halt)) {
626 sleep $poweroff_after_halt;
627 run_command "$power_off";
628 }
629 } else {
599 # nope? the zap it! 630 # nope? the zap it!
600 run_command "$power_off"; 631 run_command "$power_off";
601 } 632 }
@@ -610,9 +641,7 @@ sub success {
610 doprint "*******************************************\n"; 641 doprint "*******************************************\n";
611 doprint "*******************************************\n"; 642 doprint "*******************************************\n";
612 643
613 if ($i != $opt{"NUM_TESTS"} && $test_type ne "build" && 644 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
614 !($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") &&
615 !($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build")) {
616 doprint "Reboot and wait $sleep_time seconds\n"; 645 doprint "Reboot and wait $sleep_time seconds\n";
617 reboot; 646 reboot;
618 start_monitor; 647 start_monitor;
@@ -1048,6 +1077,8 @@ sub set_test_option {
1048# First we need to do is the builds 1077# First we need to do is the builds
1049for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { 1078for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1050 1079
1080 $iteration = $i;
1081
1051 my $ssh_user = set_test_option("SSH_USER", $i); 1082 my $ssh_user = set_test_option("SSH_USER", $i);
1052 my $makecmd = set_test_option("MAKE_CMD", $i); 1083 my $makecmd = set_test_option("MAKE_CMD", $i);
1053 1084
@@ -1071,6 +1102,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1071 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i); 1102 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i);
1072 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i); 1103 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i);
1073 $power_off = set_test_option("POWER_OFF", $i); 1104 $power_off = set_test_option("POWER_OFF", $i);
1105 $powercycle_after_reboot = set_test_option("POWERCYCLE_AFTER_REBOOT", $i);
1106 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i);
1074 $sleep_time = set_test_option("SLEEP_TIME", $i); 1107 $sleep_time = set_test_option("SLEEP_TIME", $i);
1075 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); 1108 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i);
1076 $store_failures = set_test_option("STORE_FAILURES", $i); 1109 $store_failures = set_test_option("STORE_FAILURES", $i);
@@ -1096,9 +1129,9 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1096 $make = "$makecmd O=$outputdir"; 1129 $make = "$makecmd O=$outputdir";
1097 1130
1098 if ($reboot_type eq "grub") { 1131 if ($reboot_type eq "grub") {
1099 dodie "GRUB_MENU not defined\n" if (!defined($grub_menu)); 1132 dodie "GRUB_MENU not defined" if (!defined($grub_menu));
1100 } elsif (!defined($reboot_script)) { 1133 } elsif (!defined($reboot_script)) {
1101 dodie "REBOOT_SCRIPT not defined\n" 1134 dodie "REBOOT_SCRIPT not defined"
1102 } 1135 }
1103 1136
1104 my $run_type = $build_type; 1137 my $run_type = $build_type;
@@ -1167,7 +1200,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1167 1200
1168if ($opt{"POWEROFF_ON_SUCCESS"}) { 1201if ($opt{"POWEROFF_ON_SUCCESS"}) {
1169 halt; 1202 halt;
1170} elsif ($opt{"REBOOT_ON_SUCCESS"} && $test_type ne "build") { 1203} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) {
1171 reboot; 1204 reboot;
1172} 1205}
1173 1206
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 0115a6762a6d..546014a6bb03 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -160,6 +160,24 @@
160# (ignored if POWEROFF_ON_SUCCESS is set) 160# (ignored if POWEROFF_ON_SUCCESS is set)
161#REBOOT_ON_SUCCESS = 1 161#REBOOT_ON_SUCCESS = 1
162 162
163# In case there's isses with rebooting, you can specify this
164# to always powercycle after this amount of time after calling
165# reboot.
166# Note, POWERCYCLE_AFTER_REBOOT = 0 does NOT disable it. It just
167# makes it powercycle immediately after rebooting. Do not define
168# it if you do not want it.
169# (default undefined)
170#POWERCYCLE_AFTER_REBOOT = 5
171
172# In case there's isses with halting, you can specify this
173# to always poweroff after this amount of time after calling
174# halt.
175# Note, POWEROFF_AFTER_HALT = 0 does NOT disable it. It just
176# makes it poweroff immediately after halting. Do not define
177# it if you do not want it.
178# (default undefined)
179#POWEROFF_AFTER_HALT = 20
180
163# Stop testing if a build fails. If set, the script will end if 181# Stop testing if a build fails. If set, the script will end if
164# a failure is detected, otherwise it will save off the .config, 182# a failure is detected, otherwise it will save off the .config,
165# dmesg and bootlog in a directory called 183# dmesg and bootlog in a directory called