diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-11-02 14:58:15 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-18 11:23:08 -0500 |
| commit | 2b7d9b21426f10448cb047d1d7c3be05da848fd2 (patch) | |
| tree | 185d03bbe4a948927df2710e8082e963c87b0470 /tools | |
| parent | d6ce2a0b33eb71f6862dfb6cbddd0e842f8132de (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.pl | 116 |
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 | ||
| 33 | my $version; | 37 | my $version; |
| 34 | my $grub_number; | 38 | my $grub_number; |
| @@ -36,6 +40,7 @@ my $target; | |||
| 36 | my $make; | 40 | my $make; |
| 37 | my $noclean; | 41 | my $noclean; |
| 38 | my $minconfig; | 42 | my $minconfig; |
| 43 | my $addconfig; | ||
| 39 | my $in_bisect = 0; | 44 | my $in_bisect = 0; |
| 40 | my $bisect_bad = ""; | 45 | my $bisect_bad = ""; |
| 41 | my $reverse_bisect; | 46 | my $reverse_bisect; |
| @@ -92,6 +97,16 @@ sub dodie { | |||
| 92 | die @_; | 97 | die @_; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| 100 | sub fail { | ||
| 101 | |||
| 102 | if ($opt{"DIE_ON_FAILURE"}) { | ||
| 103 | dodie @_; | ||
| 104 | } | ||
| 105 | |||
| 106 | doprint "Failed: ", @_, "\n"; | ||
| 107 | return 1; | ||
| 108 | } | ||
| 109 | |||
| 95 | sub run_command { | 110 | sub 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 | ||
| 296 | sub install { | 316 | sub 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 | ||
| 374 | sub build { | 396 | sub 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 | ||
| 437 | sub reboot { | 459 | sub 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 | ||
| 554 | sub run_bisect { | 576 | sub 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)) { |
| 564 | $failed = build "useconfig:$minconfig"; | 585 | build "useconfig:$minconfig" or $failed = 1; |
| 565 | } else { | 586 | } else { |
| 566 | # ?? no config to use? | 587 | # ?? no config to use? |
| 567 | $failed = build "oldconfig"; | 588 | build "oldconfig" or $failed = 1; |
| 568 | } | 589 | } |
| 569 | 590 | ||
| 570 | if ($type ne "build") { | 591 | if ($type ne "build") { |
| 571 | dodie "Failed on build" if $failed; | 592 | fail "Failed on build" if $failed; |
| 572 | 593 | ||
| 573 | # Now boot the box | 594 | # Now boot the box |
| 574 | get_grub_index; | 595 | get_grub_index; |
| 575 | get_version; | 596 | get_version; |
| 576 | install; | 597 | install; |
| 577 | $failed = monitor; | 598 | monitor or $failed = 1; |
| 578 | 599 | ||
| 579 | if ($type ne "boot") { | 600 | if ($type ne "boot") { |
| 580 | dodie "Failed on boot" if $failed; | 601 | fail "Failed on boot" if $failed; |
| 581 | 602 | ||
| 582 | $failed = do_run_test; | 603 | do_run_test or $failed = 1; |
| 583 | } | 604 | } |
| 584 | } | 605 | } |
| 585 | 606 | ||
| @@ -613,7 +634,7 @@ sub run_bisect { | |||
| 613 | 634 | ||
| 614 | if ($ret) { | 635 | if ($ret) { |
| 615 | doprint "FAILED\n"; | 636 | doprint "FAILED\n"; |
| 616 | dodie "Failed to git bisect"; | 637 | fail "Failed to git bisect"; |
| 617 | } | 638 | } |
| 618 | 639 | ||
| 619 | doprint "SUCCESS\n"; | 640 | doprint "SUCCESS\n"; |
| @@ -656,13 +677,13 @@ sub bisect { | |||
| 656 | $in_bisect = 1; | 677 | $in_bisect = 1; |
| 657 | 678 | ||
| 658 | run_command "git bisect start" or | 679 | run_command "git bisect start" or |
| 659 | dodie "could not start bisect"; | 680 | fail "could not start bisect"; |
| 660 | 681 | ||
| 661 | run_command "git bisect good $good" or | 682 | run_command "git bisect good $good" or |
| 662 | dodie "could not set bisect good to $good"; | 683 | fail "could not set bisect good to $good"; |
| 663 | 684 | ||
| 664 | run_command "git bisect bad $bad" or | 685 | run_command "git bisect bad $bad" or |
| 665 | dodie "could not set bisect good to $bad"; | 686 | fail "could not set bisect good to $bad"; |
| 666 | 687 | ||
| 667 | # Can't have a test without having a test to run | 688 | # Can't have a test without having a test to run |
| 668 | if ($type eq "test" && !defined($run_test)) { | 689 | if ($type eq "test" && !defined($run_test)) { |
| @@ -721,7 +742,7 @@ sub patchcheck { | |||
| 721 | close(IN); | 742 | close(IN); |
| 722 | 743 | ||
| 723 | if ($list[$#list] !~ /^$start/) { | 744 | if ($list[$#list] !~ /^$start/) { |
| 724 | dodie "SHA1 $start not found"; | 745 | fail "SHA1 $start not found"; |
| 725 | } | 746 | } |
| 726 | 747 | ||
| 727 | # go backwards in the list | 748 | # go backwards in the list |
| @@ -748,26 +769,28 @@ sub patchcheck { | |||
| 748 | } | 769 | } |
| 749 | 770 | ||
| 750 | if (defined($minconfig)) { | 771 | if (defined($minconfig)) { |
| 751 | build "useconfig:$minconfig"; | 772 | build "useconfig:$minconfig" or return 0; |
| 752 | } else { | 773 | } else { |
| 753 | # ?? no config to use? | 774 | # ?? no config to use? |
| 754 | build "oldconfig"; | 775 | build "oldconfig" or return 0; |
| 755 | } | 776 | } |
| 756 | 777 | ||
| 757 | check_buildlog $sha1; | 778 | check_buildlog $sha1 or return 0; |
| 758 | 779 | ||
| 759 | next if ($type eq "build"); | 780 | next if ($type eq "build"); |
| 760 | 781 | ||
| 761 | get_grub_index; | 782 | get_grub_index; |
| 762 | get_version; | 783 | get_version; |
| 763 | install; | 784 | install; |
| 764 | monitor; | 785 | monitor or return 0; |
| 765 | 786 | ||
| 766 | next if ($type eq "boot"); | 787 | next if ($type eq "boot"); |
| 767 | do_run_test; | 788 | do_run_test or next; |
| 768 | } | 789 | } |
| 769 | $in_patchcheck = 0; | 790 | $in_patchcheck = 0; |
| 770 | success $i; | 791 | success $i; |
| 792 | |||
| 793 | return 1; | ||
| 771 | } | 794 | } |
| 772 | 795 | ||
| 773 | read_config $ARGV[0]; | 796 | read_config $ARGV[0]; |
| @@ -788,8 +811,15 @@ chdir $opt{"BUILD_DIR"} || die "can't change directory to $opt{BUILD_DIR}"; | |||
| 788 | 811 | ||
| 789 | $target = "$opt{SSH_USER}\@$opt{MACHINE}"; | 812 | $target = "$opt{SSH_USER}\@$opt{MACHINE}"; |
| 790 | 813 | ||
| 791 | doprint "\n\nSTARTING AUTOMATED TESTS\n"; | 814 | if ($opt{"CLEAR_LOG"} && defined($opt{"LOG_FILE"})) { |
| 815 | unlink $opt{"LOG_FILE"}; | ||
| 816 | } | ||
| 792 | 817 | ||
| 818 | doprint "\n\nSTARTING AUTOMATED TESTS\n\n"; | ||
| 819 | |||
| 820 | foreach my $option (sort keys %opt) { | ||
| 821 | doprint "$option = $opt{$option}\n"; | ||
| 822 | } | ||
| 793 | 823 | ||
| 794 | $make = "$opt{MAKE_CMD} O=$opt{OUTPUT_DIR}"; | 824 | $make = "$opt{MAKE_CMD} O=$opt{OUTPUT_DIR}"; |
| 795 | 825 | ||
| @@ -820,10 +850,20 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) { | |||
| 820 | $noclean = set_build_option("BUILD_NOCLEAN", $i); | 850 | $noclean = set_build_option("BUILD_NOCLEAN", $i); |
| 821 | $minconfig = set_build_option("MIN_CONFIG", $i); | 851 | $minconfig = set_build_option("MIN_CONFIG", $i); |
| 822 | $run_test = set_build_option("TEST", $i); | 852 | $run_test = set_build_option("TEST", $i); |
| 853 | $addconfig = set_build_option("ADD_CONFIG", $i); | ||
| 823 | 854 | ||
| 824 | doprint "\n\n"; | 855 | doprint "\n\n"; |
| 825 | doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n"; | 856 | doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n"; |
| 826 | 857 | ||
| 858 | if (!defined($minconfig)) { | ||
| 859 | $minconfig = $addconfig; | ||
| 860 | |||
| 861 | } elsif (defined($addconfig)) { | ||
| 862 | run_command "cat $addconfig $minconfig > $opt{TMP_DIR}/use_config" or | ||
| 863 | dodie "Failed to create temp config"; | ||
| 864 | $minconfig = "$opt{TMP_DIR}/use_config"; | ||
| 865 | } | ||
| 866 | |||
| 827 | my $checkout = $opt{"CHECKOUT[$i]"}; | 867 | my $checkout = $opt{"CHECKOUT[$i]"}; |
| 828 | if (defined($checkout)) { | 868 | if (defined($checkout)) { |
| 829 | run_command "git checkout $checkout" or | 869 | run_command "git checkout $checkout" or |
| @@ -839,16 +879,16 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) { | |||
| 839 | } | 879 | } |
| 840 | 880 | ||
| 841 | if ($opt{$type} ne "nobuild") { | 881 | if ($opt{$type} ne "nobuild") { |
| 842 | build $opt{$type}; | 882 | build $opt{$type} or next; |
| 843 | } | 883 | } |
| 844 | 884 | ||
| 845 | get_grub_index; | 885 | get_grub_index; |
| 846 | get_version; | 886 | get_version; |
| 847 | install; | 887 | install; |
| 848 | monitor; | 888 | monitor or next; |
| 849 | 889 | ||
| 850 | if (defined($run_test)) { | 890 | if (defined($run_test)) { |
| 851 | do_run_test; | 891 | do_run_test or next; |
| 852 | } | 892 | } |
| 853 | 893 | ||
| 854 | success $i; | 894 | success $i; |
