Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6ce2a0b authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt
Browse files

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: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 6c5ee0be
Loading
Loading
Loading
Loading
+45 −6
Original line number Original line Diff line number Diff line
#!/usr/bin/perl -w
#!/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 strict;
use IPC::Open2;
use IPC::Open2;
@@ -34,6 +38,7 @@ my $noclean;
my $minconfig;
my $minconfig;
my $in_bisect = 0;
my $in_bisect = 0;
my $bisect_bad = "";
my $bisect_bad = "";
my $reverse_bisect;
my $in_patchcheck = 0;
my $in_patchcheck = 0;
my $run_test;
my $run_test;
my $redirect;
my $redirect;
@@ -89,22 +94,39 @@ sub dodie {


sub run_command {
sub run_command {
    my ($command) = @_;
    my ($command) = @_;
    my $redirect_log = "";
    my $dolog = 0;
    my $redirect_tee = "";
    my $dord = 0;
    my $pid;

    doprint("$command ... ");

    $pid = open(CMD, "$command 2>&1 |") or
	dodie "unable to exec $command";


    if (defined($opt{"LOG_FILE"})) {
    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)) {
    if (defined($redirect)) {
	$redirect_tee = "| tee $redirect"
	open (RD, ">$redirect") or
	    dodie "failed to write to redirect $redirect";
	$dord = 1;
    }
    }


    doprint "$command ... ";
    while (<CMD>) {
    `$command 2>&1 $redirect_tee $redirect_log > /dev/null`;
	print LOG if ($dolog);
	print RD  if ($dord);
    }


    waitpid($pid, 0);
    my $failed = $?;
    my $failed = $?;


    close(CMD);
    close(LOG) if ($dolog);
    close(RD)  if ($dord);

    if ($failed) {
    if ($failed) {
	doprint "FAILED!\n";
	doprint "FAILED!\n";
    } else {
    } else {
@@ -574,6 +596,15 @@ sub run_bisect {
	$result = "good";
	$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 ... ";
    doprint "git bisect $result ... ";
    $output = `git bisect $result 2>&1`;
    $output = `git bisect $result 2>&1`;
    $ret = $?;
    $ret = $?;
@@ -614,6 +645,14 @@ sub bisect {
    my $bad = $opt{"BISECT_BAD[$i]"};
    my $bad = $opt{"BISECT_BAD[$i]"};
    my $type = $opt{"BISECT_TYPE[$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;
    $in_bisect = 1;


    run_command "git bisect start" or
    run_command "git bisect start" or