aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-11-02 14:58:15 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-11-18 11:23:08 -0500
commit2b7d9b21426f10448cb047d1d7c3be05da848fd2 (patch)
tree185d03bbe4a948927df2710e8082e963c87b0470 /tools
parentd6ce2a0b33eb71f6862dfb6cbddd0e842f8132de (diff)
ktest: Added continuing on success, clear log and timeout
Add option to continue after a test fails. Add option to reset the log at start of running ktest. Update default timeout to 2 minutes. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/ktest/ktest.pl116
1 files changed, 78 insertions, 38 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 0dc403e7170c..0a0b1b16fccd 100644
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -19,7 +19,7 @@ my %opt;
19$opt{"NUM_BUILDS"} = 5; 19$opt{"NUM_BUILDS"} = 5;
20$opt{"DEFAULT_BUILD_TYPE"} = "randconfig"; 20$opt{"DEFAULT_BUILD_TYPE"} = "randconfig";
21$opt{"MAKE_CMD"} = "make"; 21$opt{"MAKE_CMD"} = "make";
22$opt{"TIMEOUT"} = 50; 22$opt{"TIMEOUT"} = 120;
23$opt{"TMP_DIR"} = "/tmp/autotest"; 23$opt{"TMP_DIR"} = "/tmp/autotest";
24$opt{"SLEEP_TIME"} = 60; # sleep time between tests 24$opt{"SLEEP_TIME"} = 60; # sleep time between tests
25$opt{"BUILD_NOCLEAN"} = 0; 25$opt{"BUILD_NOCLEAN"} = 0;
@@ -29,6 +29,10 @@ $opt{"REBOOT_ON_SUCCESS"} = 1;
29$opt{"POWEROFF_ON_SUCCESS"} = 0; 29$opt{"POWEROFF_ON_SUCCESS"} = 0;
30$opt{"BUILD_OPTIONS"} = ""; 30$opt{"BUILD_OPTIONS"} = "";
31$opt{"BISECT_SLEEP_TIME"} = 10; # sleep time between bisects 31$opt{"BISECT_SLEEP_TIME"} = 10; # sleep time between bisects
32$opt{"CLEAR_LOG"} = 0;
33$opt{"SUCCESS_LINE"} = "login:";
34$opt{"BOOTED_TIMEOUT"} = 1;
35$opt{"DIE_ON_FAILURE"} = 1;
32 36
33my $version; 37my $version;
34my $grub_number; 38my $grub_number;
@@ -36,6 +40,7 @@ my $target;
36my $make; 40my $make;
37my $noclean; 41my $noclean;
38my $minconfig; 42my $minconfig;
43my $addconfig;
39my $in_bisect = 0; 44my $in_bisect = 0;
40my $bisect_bad = ""; 45my $bisect_bad = "";
41my $reverse_bisect; 46my $reverse_bisect;
@@ -92,6 +97,16 @@ sub dodie {
92 die @_; 97 die @_;
93} 98}
94 99
100sub fail {
101
102 if ($opt{"DIE_ON_FAILURE"}) {
103 dodie @_;
104 }
105
106 doprint "Failed: ", @_, "\n";
107 return 1;
108}
109
95sub run_command { 110sub run_command {
96 my ($command) = @_; 111 my ($command) = @_;
97 my $dolog = 0; 112 my $dolog = 0;
@@ -101,7 +116,7 @@ sub run_command {
101 doprint("$command ... "); 116 doprint("$command ... ");
102 117
103 $pid = open(CMD, "$command 2>&1 |") or 118 $pid = open(CMD, "$command 2>&1 |") or
104 dodie "unable to exec $command"; 119 (fail "unable to exec $command" and return 0);
105 120
106 if (defined($opt{"LOG_FILE"})) { 121 if (defined($opt{"LOG_FILE"})) {
107 open(LOG, ">>$opt{LOG_FILE}") or 122 open(LOG, ">>$opt{LOG_FILE}") or
@@ -228,6 +243,7 @@ sub monitor {
228 my $pid; 243 my $pid;
229 my $skip_call_trace = 0; 244 my $skip_call_trace = 0;
230 my $fp = \*IN; 245 my $fp = \*IN;
246 my $loops;
231 247
232 $pid = open_console($fp); 248 $pid = open_console($fp);
233 249
@@ -244,7 +260,11 @@ sub monitor {
244 260
245 for (;;) { 261 for (;;) {
246 262
247 $line = wait_for_input($fp); 263 if ($booted) {
264 $line = wait_for_input($fp, $opt{"BOOTED_TIMEOUT"});
265 } else {
266 $line = wait_for_input($fp);
267 }
248 268
249 last if (!defined($line)); 269 last if (!defined($line));
250 270
@@ -253,7 +273,7 @@ sub monitor {
253 # we are not guaranteed to get a full line 273 # we are not guaranteed to get a full line
254 $full_line .= $line; 274 $full_line .= $line;
255 275
256 if ($full_line =~ /login:/) { 276 if ($full_line =~ /$opt{"SUCCESS_LINE"}/) {
257 $booted = 1; 277 $booted = 1;
258 } 278 }
259 279
@@ -281,16 +301,16 @@ sub monitor {
281 close_console($fp, $pid); 301 close_console($fp, $pid);
282 302
283 if (!$booted) { 303 if (!$booted) {
284 return 1 if ($in_bisect); 304 return 0 if ($in_bisect);
285 dodie "failed - never got a boot prompt.\n"; 305 fail "failed - never got a boot prompt.\n" and return 0;
286 } 306 }
287 307
288 if ($bug) { 308 if ($bug) {
289 return 1 if ($in_bisect); 309 return 0 if ($in_bisect);
290 dodie "failed - got a bug report\n"; 310 fail "failed - got a bug report\n" and return 0;
291 } 311 }
292 312
293 return 0; 313 return 1;
294} 314}
295 315
296sub install { 316sub install {
@@ -363,12 +383,14 @@ sub check_buildlog {
363 foreach my $file (@files) { 383 foreach my $file (@files) {
364 my $fullpath = "$opt{BUILD_DIR}/$file"; 384 my $fullpath = "$opt{BUILD_DIR}/$file";
365 if ($file eq $err || $fullpath eq $err) { 385 if ($file eq $err || $fullpath eq $err) {
366 dodie "$file built with warnings"; 386 fail "$file built with warnings" and return 0;
367 } 387 }
368 } 388 }
369 } 389 }
370 } 390 }
371 close(IN); 391 close(IN);
392
393 return 1;
372} 394}
373 395
374sub build { 396sub build {
@@ -426,12 +448,12 @@ sub build {
426 if (!run_command "$make $opt{BUILD_OPTIONS}") { 448 if (!run_command "$make $opt{BUILD_OPTIONS}") {
427 undef $redirect; 449 undef $redirect;
428 # bisect may need this to pass 450 # bisect may need this to pass
429 return 1 if ($in_bisect); 451 return 0 if ($in_bisect);
430 dodie "failed build"; 452 fail "failed build" and return 0;
431 } 453 }
432 undef $redirect; 454 undef $redirect;
433 455
434 return 0; 456 return 1;
435} 457}
436 458
437sub reboot { 459sub reboot {
@@ -545,41 +567,40 @@ sub do_run_test {
545 close_console($fp, $pid); 567 close_console($fp, $pid);
546 568
547 if ($bug || $child_exit) { 569 if ($bug || $child_exit) {
548 return 1 if $in_bisect; 570 return 0 if $in_bisect;
549 dodie "test failed"; 571 fail "test failed" and return 0;
550 } 572 }
551 return 0; 573 return 1;
552} 574}
553 575
554sub run_bisect { 576sub run_bisect {
555 my ($type) = @_; 577 my ($type) = @_;
556 578
557 my $failed; 579 my $failed = 0;
558 my $result; 580 my $result;
559 my $output; 581 my $output;
560 my $ret; 582 my $ret;
561 583
562
563 if (defined($minconfig)) { 584 if (defined($minconfig)) {