aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-11-02 14:57:58 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-11-18 11:23:07 -0500
commit6c5ee0be02f73ebd70eb50b84013e8830f08a6da (patch)
tree9c2cb5c77ab4090aebe7fdae4039fadb7d5c92a1 /tools
parent1a5cfce344711a541aa63bdff81a58db35e20564 (diff)
ktest: Added patchcheck
Added patchcheck functionality. It will checkout a given SHA1 and test that commit and all commits to another given SHA1. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/ktest/ktest.pl142
1 files changed, 140 insertions, 2 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index f344fd0d4f28..e0ded14b5477 100644
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -34,7 +34,9 @@ my $noclean;
34my $minconfig; 34my $minconfig;
35my $in_bisect = 0; 35my $in_bisect = 0;
36my $bisect_bad = ""; 36my $bisect_bad = "";
37my $in_patchcheck = 0;
37my $run_test; 38my $run_test;
39my $redirect;
38 40
39sub read_config { 41sub read_config {
40 my ($config) = @_; 42 my ($config) = @_;
@@ -88,13 +90,18 @@ sub dodie {
88sub run_command { 90sub run_command {
89 my ($command) = @_; 91 my ($command) = @_;
90 my $redirect_log = ""; 92 my $redirect_log = "";
93 my $redirect_tee = "";
91 94
92 if (defined($opt{"LOG_FILE"})) { 95 if (defined($opt{"LOG_FILE"})) {
93 $redirect_log = " >> $opt{LOG_FILE} 2>&1"; 96 $redirect_log = "| tee -a $opt{LOG_FILE}";
97 }
98
99 if (defined($redirect)) {
100 $redirect_tee = "| tee $redirect"
94 } 101 }
95 102
96 doprint "$command ... "; 103 doprint "$command ... ";
97 `$command $redirect_log`; 104 `$command 2>&1 $redirect_tee $redirect_log > /dev/null`;
98 105
99 my $failed = $?; 106 my $failed = $?;
100 107
@@ -311,6 +318,37 @@ sub install {
311 run_command "ssh $target rm -f /tmp/$modtar"; 318 run_command "ssh $target rm -f /tmp/$modtar";
312} 319}
313 320
321sub check_buildlog {
322 my ($patch) = @_;
323
324 my $buildlog = "$opt{TMP_DIR}/buildlog";
325 my @files = `git show $patch | diffstat -l`;
326
327 open(IN, "git show $patch |") or
328 dodie "failed to show $patch";
329 while (<IN>) {
330 if (m,^--- a/(.*),) {
331 chomp $1;
332 $files[$#files] = $1;
333 }
334 }
335 close(IN);
336
337 open(IN, $buildlog) or dodie "Can't open $buildlog";
338 while (<IN>) {
339 if (/^\s*(.*?):.*(warning|error)/) {
340 my $err = $1;
341 foreach my $file (@files) {
342 my $fullpath = "$opt{BUILD_DIR}/$file";
343 if ($file eq $err || $fullpath eq $err) {
344 dodie "$file built with warnings";
345 }
346 }
347 }
348 }
349 close(IN);
350}
351
314sub build { 352sub build {
315 my ($type) = @_; 353 my ($type) = @_;
316 my $defconfig = ""; 354 my $defconfig = "";
@@ -358,11 +396,18 @@ sub build {
358 run_command "$defconfig $append $make $type" or 396 run_command "$defconfig $append $make $type" or
359 dodie "failed make config"; 397 dodie "failed make config";
360 398
399 # patch check will examine the log
400 if ($in_patchcheck) {
401 $redirect = "$opt{TMP_DIR}/buildlog";
402 }
403
361 if (!run_command "$make $opt{BUILD_OPTIONS}") { 404 if (!run_command "$make $opt{BUILD_OPTIONS}") {
405 undef $redirect;
362 # bisect may need this to pass 406 # bisect may need this to pass
363 return 1 if ($in_bisect); 407 return 1 if ($in_bisect);
364 dodie "failed build"; 408 dodie "failed build";
365 } 409 }
410 undef $redirect;
366 411
367 return 0; 412 return 0;
368} 413}
@@ -602,6 +647,90 @@ sub bisect {
602 success $i; 647 success $i;
603} 648}
604 649
650sub patchcheck {
651 my ($i) = @_;
652
653 die "PATCHCHECK_START[$i] not defined\n"
654 if (!defined($opt{"PATCHCHECK_START[$i]"}));
655 die "PATCHCHECK_TYPE[$i] not defined\n"
656 if (!defined($opt{"PATCHCHECK_TYPE[$i]"}));
657
658 my $start = $opt{"PATCHCHECK_START[$i]"};
659
660 my $end = "HEAD";
661 if (defined($opt{"PATCHCHECK_END[$i]"})) {
662 $end = $opt{"PATCHCHECK_END[$i]"};
663 }
664
665 my $type = $opt{"PATCHCHECK_TYPE[$i]"};
666
667 # Can't have a test without having a test to run
668 if ($type eq "test" && !defined($run_test)) {
669 $type = "boot";
670 }
671
672 open (IN, "git log --pretty=oneline $end|") or
673 dodie "could not get git list";
674
675 my @list;
676
677 while (<IN>) {
678 chomp;
679 $list[$#list+1] = $_;
680 last if (/^$start/);
681 }
682 close(IN);
683
684 if ($list[$#list] !~ /^$start/) {
685 dodie "SHA1 $start not found";
686 }
687
688 # go backwards in the list
689 @list = reverse @list;
690
691 my $save_clean = $noclean;
692
693 $in_patchcheck = 1;
694 foreach my $item (@list) {
695 my $sha1 = $item;
696 $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
697
698 doprint "\nProcessing commit $item\n\n";
699
700 run_command "git checkout $sha1" or
701 die "Failed to checkout $sha1";
702
703 # only clean on the first and last patch
704 if ($item eq $list[0] ||
705 $item eq $list[$#list]) {
706 $noclean = $save_clean;
707 } else {
708 $noclean = 1;
709 }
710
711 if (defined($minconfig)) {
712 build "useconfig:$minconfig";
713 } else {
714 # ?? no config to use?
715 build "oldconfig";
716 }
717
718 check_buildlog $sha1;
719
720 next if ($type eq "build");
721
722 get_grub_index;
723 get_version;
724 install;
725 monitor;
726
727 next if ($type eq "boot");
728 do_run_test;
729 }
730 $in_patchcheck = 0;
731 success $i;
732}
733
605read_config $ARGV[0]; 734read_config $ARGV[0];
606 735
607# mandatory configs 736# mandatory configs
@@ -656,9 +785,18 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
656 doprint "\n\n"; 785 doprint "\n\n";
657 doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n"; 786 doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n";
658 787
788 my $checkout = $opt{"CHECKOUT[$i]"};
789 if (defined($checkout)) {
790 run_command "git checkout $checkout" or
791 die "failed to checkout $checkout";
792 }
793
659 if ($opt{$type} eq "bisect") { 794 if ($opt{$type} eq "bisect") {
660 bisect $i; 795 bisect $i;
661 next; 796 next;
797 } elsif ($opt{$type} eq "patchcheck") {
798 patchcheck $i;
799 next;
662 } 800 }
663 801
664 if ($opt{$type} ne "nobuild") { 802 if ($opt{$type} ne "nobuild") {