aboutsummaryrefslogtreecommitdiffstats
path: root/tools
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
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')
-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 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
3use strict; 7use strict;
4use IPC::Open2; 8use IPC::Open2;
@@ -34,6 +38,7 @@ my $noclean;
34my $minconfig; 38my $minconfig;
35my $in_bisect = 0; 39my $in_bisect = 0;
36my $bisect_bad = ""; 40my $bisect_bad = "";
41my $reverse_bisect;
37my $in_patchcheck = 0; 42my $in_patchcheck = 0;
38my $run_test; 43my $run_test;
39my $redirect; 44my $redirect;
@@ -89,22 +94,39 @@ sub dodie {
89 94
90sub run_command { 95sub 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