diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-11-02 14:58:05 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-18 11:23:07 -0500 |
commit | d6ce2a0b33eb71f6862dfb6cbddd0e842f8132de (patch) | |
tree | 4e20dd9dc9701a599259f9c2ea7a532f24be4700 /tools/testing | |
parent | 6c5ee0be02f73ebd70eb50b84013e8830f08a6da (diff) |
ktest: Add reverse bisect, better logging, copyright
Added the ability to do a reverse bisect.
Better logging of running commands.
Added the copyright statement.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/ktest/ktest.pl | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index e0ded14b5477..0dc403e7170c 100644 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -1,4 +1,8 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!/usr/bin/perl -w |
2 | # | ||
3 | # Copywrite 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc. | ||
4 | # Licensed under the terms of the GNU GPL License version 2 | ||
5 | # | ||
2 | 6 | ||
3 | use strict; | 7 | use strict; |
4 | use IPC::Open2; | 8 | use IPC::Open2; |
@@ -34,6 +38,7 @@ my $noclean; | |||
34 | my $minconfig; | 38 | my $minconfig; |
35 | my $in_bisect = 0; | 39 | my $in_bisect = 0; |
36 | my $bisect_bad = ""; | 40 | my $bisect_bad = ""; |
41 | my $reverse_bisect; | ||
37 | my $in_patchcheck = 0; | 42 | my $in_patchcheck = 0; |
38 | my $run_test; | 43 | my $run_test; |
39 | my $redirect; | 44 | my $redirect; |
@@ -89,22 +94,39 @@ sub dodie { | |||
89 | 94 | ||
90 | sub run_command { | 95 | sub run_command { |
91 | my ($command) = @_; | 96 | my ($command) = @_; |
92 | my $redirect_log = ""; | 97 | my $dolog = 0; |
93 | my $redirect_tee = ""; | 98 | my $dord = 0; |
99 | my $pid; | ||
100 | |||
101 | doprint("$command ... "); | ||
102 | |||
103 | $pid = open(CMD, "$command 2>&1 |") or | ||
104 | dodie "unable to exec $command"; | ||
94 | 105 | ||
95 | if (defined($opt{"LOG_FILE"})) { | 106 | if (defined($opt{"LOG_FILE"})) { |
96 | $redirect_log = "| tee -a $opt{LOG_FILE}"; | 107 | open(LOG, ">>$opt{LOG_FILE}") or |
108 | dodie "failed to write to log"; | ||
109 | $dolog = 1; | ||
97 | } | 110 | } |
98 | 111 | ||
99 | if (defined($redirect)) { | 112 | if (defined($redirect)) { |
100 | $redirect_tee = "| tee $redirect" | 113 | open (RD, ">$redirect") or |
114 | dodie "failed to write to redirect $redirect"; | ||
115 | $dord = 1; | ||
101 | } | 116 | } |
102 | 117 | ||
103 | doprint "$command ... "; | 118 | while (<CMD>) { |
104 | `$command 2>&1 $redirect_tee $redirect_log > /dev/null`; | 119 | print LOG if ($dolog); |
120 | print RD if ($dord); | ||
121 | } | ||
105 | 122 | ||
123 | waitpid($pid, 0); | ||
106 | my $failed = $?; | 124 | my $failed = $?; |
107 | 125 | ||
126 | close(CMD); | ||
127 | close(LOG) if ($dolog); | ||
128 | close(RD) if ($dord); | ||
129 | |||
108 | if ($failed) { | 130 | if ($failed) { |
109 | doprint "FAILED!\n"; | 131 | doprint "FAILED!\n"; |
110 | } else { | 132 | } else { |
@@ -574,6 +596,15 @@ sub run_bisect { | |||
574 | $result = "good"; | 596 | $result = "good"; |
575 | } | 597 | } |
576 | 598 | ||
599 | # Are we looking for where it worked, not failed? | ||
600 | if ($reverse_bisect) { | ||
601 | if ($failed) { | ||
602 | $result = "good"; | ||
603 | } else { | ||
604 | $result = "bad"; | ||
605 | } | ||
606 | } | ||
607 | |||
577 | doprint "git bisect $result ... "; | 608 | doprint "git bisect $result ... "; |
578 | $output = `git bisect $result 2>&1`; | 609 | $output = `git bisect $result 2>&1`; |
579 | $ret = $?; | 610 | $ret = $?; |
@@ -614,6 +645,14 @@ sub bisect { | |||
614 | my $bad = $opt{"BISECT_BAD[$i]"}; | 645 | my $bad = $opt{"BISECT_BAD[$i]"}; |
615 | my $type = $opt{"BISECT_TYPE[$i]"}; | 646 | my $type = $opt{"BISECT_TYPE[$i]"}; |
616 | 647 | ||
648 | if (defined($opt{"BISECT_REVERSE[$i]"}) && | ||
649 | $opt{"BISECT_REVERSE[$i]"} == 1) { | ||
650 | doprint "Performing a reverse bisect (bad is good, good is bad!)\n"; | ||
651 | $reverse_bisect = 1; | ||
652 | } else { | ||
653 | $reverse_bisect = 0; | ||
654 | } | ||
655 | |||
617 | $in_bisect = 1; | 656 | $in_bisect = 1; |
618 | 657 | ||
619 | run_command "git bisect start" or | 658 | run_command "git bisect start" or |