aboutsummaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-11-02 14:58:05 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-11-18 11:23:07 -0500
commitd6ce2a0b33eb71f6862dfb6cbddd0e842f8132de (patch)
tree4e20dd9dc9701a599259f9c2ea7a532f24be4700 /tools/testing
parent6c5ee0be02f73ebd70eb50b84013e8830f08a6da (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.pl51
1 files changed, 45 insertions, 6 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index e0ded14b547..0dc403e7170 100644
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1,4 +1,8 @@
#!/usr/bin/perl -w
+#
+# Copywrite 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
+# Licensed under the terms of the GNU GPL License version 2
+#
use strict;
use IPC::Open2;
@@ -34,6 +38,7 @@ my $noclean;
my $minconfig;
my $in_bisect = 0;
my $bisect_bad = "";
+my $reverse_bisect;
my $in_patchcheck = 0;
my $run_test;
my $redirect;
@@ -89,22 +94,39 @@ sub dodie {
sub run_command {
my ($command) = @_;
- my $redirect_log = "";
- my $redirect_tee = "";
+ my $dolog = 0;
+ my $dord = 0;
+ my $pid;
+
+ doprint("$command ... ");
+
+ $pid = open(CMD, "$command 2>&1 |") or
+ dodie "unable to exec $command";
if (defined($opt{"LOG_FILE"})) {
- $redirect_log = "| tee -a $opt{LOG_FILE}";
+ open(LOG, ">>$opt{LOG_FILE}") or
+ dodie "failed to write to log";
+ $dolog = 1;
}
if (defined($redirect)) {
- $redirect_tee = "| tee $redirect"
+ open (RD, ">$redirect") or
+ dodie "failed to write to redirect $redirect";
+ $dord = 1;
}
- doprint "$command ... ";
- `$command 2>&1 $redirect_tee $redirect_log > /dev/null`;
+ while (<CMD>) {
+ print LOG if ($dolog);
+ print RD if ($dord);
+ }
+ waitpid($pid, 0);
my $failed = $?;
+ close(CMD);
+ close(LOG) if ($dolog);
+ close(RD) if ($dord);
+
if ($failed) {
doprint "FAILED!\n";
} else {
@@ -574,6 +596,15 @@ sub run_bisect {
$result = "good";
}
+ # Are we looking for where it worked, not failed?
+ if ($reverse_bisect) {
+ if ($failed) {
+ $result = "good";
+ } else {
+ $result = "bad";
+ }
+ }
+
doprint "git bisect $result ... ";
$output = `git bisect $result 2>&1`;
$ret = $?;
@@ -614,6 +645,14 @@ sub bisect {
my $bad = $opt{"BISECT_BAD[$i]"};
my $type = $opt{"BISECT_TYPE[$i]"};
+ if (defined($opt{"BISECT_REVERSE[$i]"}) &&
+ $opt{"BISECT_REVERSE[$i]"} == 1) {
+ doprint "Performing a reverse bisect (bad is good, good is bad!)\n";
+ $reverse_bisect = 1;
+ } else {
+ $reverse_bisect = 0;
+ }
+
$in_bisect = 1;
run_command "git bisect start" or