aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-11-02 14:57:21 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-11-18 11:23:06 -0500
commit75c3fda79e97b1e2c390e3623f19476e1e78ca0c (patch)
tree445302ecc568c46f77ab5d6d46d5950a89c2d3e9 /tools/testing
parent5c42fc5b975869e73bb8b6c279dd2da81eab5607 (diff)
ktest: New features reboot on error, make options
REBOOT_ON_ERROR to reboot the box on error BUILD_OPTIONS to add options to the make build (like -j40) Added "useconfig:<config>". Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/ktest/ktest.pl62
1 files changed, 46 insertions, 16 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 1acb0e1ab0f..79da57f3023 100644
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -19,8 +19,10 @@ $opt{"TIMEOUT"} = 50;
19$opt{"TMP_DIR"} = "/tmp/autotest"; 19$opt{"TMP_DIR"} = "/tmp/autotest";
20$opt{"SLEEP_TIME"} = 60; # sleep time between tests 20$opt{"SLEEP_TIME"} = 60; # sleep time between tests
21$opt{"BUILD_NOCLEAN"} = 0; 21$opt{"BUILD_NOCLEAN"} = 0;
22$opt{"REBOOT_ON_ERROR"} = 0;
22$opt{"POWEROFF_ON_ERROR"} = 0; 23$opt{"POWEROFF_ON_ERROR"} = 0;
23$opt{"POWEROFF_ON_SUCCESS"} = 0; 24$opt{"POWEROFF_ON_SUCCESS"} = 0;
25$opt{"BUILD_OPTIONS"} = "";
24 26
25my $version; 27my $version;
26my $install_mods; 28my $install_mods;
@@ -63,10 +65,15 @@ sub doprint {
63sub dodie { 65sub dodie {
64 doprint "CRITICAL FAILURE... ", @_; 66 doprint "CRITICAL FAILURE... ", @_;
65 67
66 if ($opt{"POWEROFF_ON_ERROR"} && defined($opt{"POWER_OFF"})) { 68 if ($opt{"REBOOT_ON_ERROR"}) {
69 doprint "REBOOTING\n";
70 `$opt{"POWER_CYCLE"}`;
71
72 } elsif ($opt{"POWEROFF_ON_ERROR"} && defined($opt{"POWER_OFF"})) {
67 doprint "POWERING OFF\n"; 73 doprint "POWERING OFF\n";
68 `$opt{"POWER_OFF"}`; 74 `$opt{"POWER_OFF"}`;
69 } 75 }
76
70 die @_; 77 die @_;
71} 78}
72 79
@@ -125,7 +132,7 @@ sub wait_for_input
125 return $line; 132 return $line;
126} 133}
127 134
128sub reboot { 135sub reboot_to {
129 run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; 136 run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'";
130} 137}
131 138
@@ -138,7 +145,7 @@ sub monitor {
138 my $skip_call_trace = 0; 145 my $skip_call_trace = 0;
139 146
140 if ($doopen2) { 147 if ($doopen2) {
141 $pid = open2(\*IN, \*OUT, $opt{CONSOLE}); 148 $pid = open2(\*IN, \*OUT, $opt{"CONSOLE"});
142 if ($pid < 0) { 149 if ($pid < 0) {
143 dodie "Failed to connect to the console"; 150 dodie "Failed to connect to the console";
144 } 151 }
@@ -161,7 +168,7 @@ sub monitor {
161 $line = wait_for_input(\*IN, 5); 168 $line = wait_for_input(\*IN, 5);
162 } while (defined($line)); 169 } while (defined($line));
163 170
164 reboot; 171 reboot_to;
165 172
166 for (;;) { 173 for (;;) {
167 174
@@ -229,7 +236,7 @@ sub install {
229 } 236 }
230 237
231 # would be nice if scp -r did not follow symbolic links 238 # would be nice if scp -r did not follow symbolic links
232 if (run_command "cd $opt{TMP_DIR}; tar -cjf $modtar lib/modules/$version") { 239 if (run_command "cd $opt{TMP_DIR} && tar -cjf $modtar lib/modules/$version") {
233 dodie "making tarball"; 240 dodie "making tarball";
234 } 241 }
235 242
@@ -253,9 +260,20 @@ sub build {
253 my $defconfig = ""; 260 my $defconfig = "";
254 my $append = ""; 261 my $append = "";
255 262
263 if ($type =~ /^useconfig:(.*)/) {
264 if (run_command "cp $1 $opt{OUTPUT_DIR}/.config") {
265 dodie "could not copy $1 to .config";
266 }
267 $type = "oldconfig";
268 }
269
256 # old config can ask questions 270 # old config can ask questions
257 if ($type eq "oldconfig") { 271 if ($type eq "oldconfig") {
258 $append = "yes ''|"; 272 $append = "yes ''|";
273
274 # allow for empty configs
275 run_command "touch $opt{OUTPUT_DIR}/.config";
276
259 if (run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp") { 277 if (run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp") {
260 dodie "moving .config"; 278 dodie "moving .config";
261 } 279 }
@@ -293,6 +311,21 @@ sub build {
293 } 311 }
294} 312}
295 313
314sub reboot {
315 # try to reboot normally
316 if (run_command "ssh $target reboot") {
317 # nope? power cycle it.
318 run_command "$opt{POWER_CYCLE}";
319 }
320}
321
322sub halt {
323 if ((run_command "ssh $target halt") or defined($opt{"POWER_OFF"})) {
324 # nope? the zap it!
325 run_command "$opt{POWER_OFF}";
326 }
327}
328
296read_config $ARGV[0]; 329read_config $ARGV[0];
297 330
298# mandatory configs 331# mandatory configs
@@ -301,6 +334,7 @@ die "SSH_USER not defined\n" if (!defined($opt{"SSH_USER"}));
301die "BUILD_DIR not defined\n" if (!defined($opt{"BUILD_DIR"})); 334die "BUILD_DIR not defined\n" if (!defined($opt{"BUILD_DIR"}));
302die "OUTPUT_DIR not defined\n" if (!defined($opt{"OUTPUT_DIR"})); 335die "OUTPUT_DIR not defined\n" if (!defined($opt{"OUTPUT_DIR"}));
303die "BUILD_TARGET not defined\n" if (!defined($opt{"BUILD_TARGET"})); 336die "BUILD_TARGET not defined\n" if (!defined($opt{"BUILD_TARGET"}));
337die "TARGET_IMAGE not defined\n" if (!defined($opt{"TARGET_IMAGE"}));
304die "POWER_CYCLE not defined\n" if (!defined($opt{"POWER_CYCLE"})); 338die "POWER_CYCLE not defined\n" if (!defined($opt{"POWER_CYCLE"}));
305die "CONSOLE not defined\n" if (!defined($opt{"CONSOLE"})); 339die "CONSOLE not defined\n" if (!defined($opt{"CONSOLE"}));
306die "LOCALVERSION not defined\n" if (!defined($opt{"LOCALVERSION"})); 340die "LOCALVERSION not defined\n" if (!defined($opt{"LOCALVERSION"}));
@@ -388,20 +422,16 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
388 doprint "*******************************************\n"; 422 doprint "*******************************************\n";
389 doprint "*******************************************\n"; 423 doprint "*******************************************\n";
390 424
391 # try to reboot normally 425 if ($i != $opt{"NUM_BUILDS"}) {
392 426 reboot;
393 if (run_command "ssh $target reboot") { 427 sleep "$opt{SLEEP_TIME}";
394 # nope? power cycle it.
395 run_command "$opt{POWER_CYCLE}";
396 } 428 }
397
398 sleep "$opt{SLEEP_TIME}";
399} 429}
400 430
401if ($opt{"POWEROFF_ON_SUCCESS"}) { 431if ($opt{"POWEROFF_ON_SUCCESS"}) {
402 if (run_command "ssh $target halt" && defined($opt{"POWER_OFF"})) { 432 halt;
403 # nope? the zap it! 433} else {
404 run_command "$opt{POWER_OFF}"; 434 reboot;
405 }
406} 435}
436
407exit 0; 437exit 0;