3 # Three-way DejaGNU comparison; uses dglib.pm. Run perldoc on this file for
6 # Author: Matthew Sachs <msachs@apple.com>
8 # Copyright (c) 2006 Free Software Foundation.
10 # This file is part of GCC.
12 # GCC is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # GCC is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with GCC; see the file COPYING. If not, write to
24 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
25 # Boston, MA 02110-1301, USA.
31 compareSumTests3 -- Two-way or three-way compare between DejaGNU .sum files
35 compareSumTests3 old1.sum [old2.sum] new.sum
36 compareSumTests3 -i 1:2 -x 2:3 old1.sum old2.sum new.sum
40 Gives results in terms of 'new' (e.g. things that work in 'new' and don't in
41 other compilers are improvements, things that don't in 'new' and do in others
42 are regressions, and it tells you which of the two old compilers (or both)
43 the test is a regression from.
45 We treat any DG result other than PASS or XFAIL as a failure, e.g.
46 UNRESOLVED, UNTESTED or test was not run.
48 We merge some tests into 'logical tests' with multiple subphases.
49 For instance, some tests will have compile, execute, and link
50 subtests. For these tests, if one of the phases fails, we
51 indicate which phase the failure originates in. For instance,
52 in the following test results:
54 gcc.c-torture/compile_execute/xxxx.c: [FAIL:C,FAIL:X,PASS]
56 the "compile_execute" replaces the compile or execute portion of the test name,
57 and "FAIL:C" and "FAIL:X" indicates where the combined test failed.
67 C<-i X:Y>: Only display differences between the two indicated runs.
71 C<-p>: Give plain output, suitable for piping to another program.
75 C<-x X:Y>: Exclude differences between the two indicated runs.
79 =head2 PLAIN OUTPUT FORMAT
82 output format, the category headers are not displayed and there are no tabs
83 in front of each result line. Instead, each result line has two characters
84 followed by a space in front of it. The first character will be either an 'I'
85 for improvement or 'R' for regression; the second character will be a 1, 2, or 3,
86 indicating which run was the odd one out.
90 =head2 SELECTING CHANGE SUBSETS
92 The following options cause only a selected subset of changes to be displayed.
93 These options ask for a "run", a number which is used to select
94 one of the three runs (C<old1>, C<old2>, or C<new>.) C<1> and C<2> signify C<old1> and C<old2>
95 respectively; 3 signifies C<new>. If multiple options are given, the changes displayed
96 will be those which obey all of the given restrictions.
98 Typical usage of these options is to express something like "give me all changes
99 between 2 and 3, except for those where there was the same difference betwen 1 and 2
100 (as between 2 and 3.)" This would be given as:
108 C<-i X:Y>: Only differences which are present between the two runs given
109 are displayed. For instance, if C<-i 1:2> is given and test A passes in
110 runs 1 and 2 but fails in run 3, that result will not be displayed.
114 C<-x X:Y>: Differences which are identical to a difference between the two runs
115 given will B<not> be displayed. For instance, if C<-x 1:2> is given and
116 test A passes in run 1 and fails in runs 2 and 3, that result will not be
117 displayed (since C<-x> will cause the difference between 1 and 2 to be ignored,
118 and the difference in 1 and 3 parallels the difference between 1 and 2.)
119 This option may only be used in conjunction with C<-i>.
129 use FindBin qw($Bin);
138 "i=s" => \$options{i},
139 "x=s" => \$options{x},
142 } elsif(@ARGV != 2 and @ARGV != 3) {
144 } elsif($options{x} and !$options{i}) {
145 $error = "-x may only be given in conjunction with -i.";
147 foreach my $opt("i", "x") {
148 if($options{$opt} and
149 ($options{$opt} !~ /^([123]):([123])$/ or
152 $error = "Invalid -$opt argument.";
157 if(defined($error)) {
158 print STDERR "$error\n" if $error;
159 print STDERR "Usage: compareSumTests3 [-p] [-i X:Y [-x X:Y]] old1.sum old2.sum new.sum\n";
160 print STDERR "Try 'perldoc $0' for further information.\n";
164 my(@sumfiles) = @ARGV;
165 -f $_ || die "$_ is not a regular file!\n" foreach @sumfiles;
166 my(%results, @inc_changes, @exc_changes, %checksums);
168 # We decrement the values given so that they correspond
169 # to indices into our results array.
171 $options{i} =~ /(\d+):(\d+)/;
172 @inc_changes = ($1 - 1, $2 - 1);
175 $options{x} =~ /(\d+):(\d+)/;
176 @exc_changes = ($1 - 1, $2 - 1);
180 my %analyzed_results = compareSumFiles(\@sumfiles);
182 foreach my $cat (qw(improvements regressions miscellaneous)) {
186 $subcounts[$_] = @{$analyzed_results{$cat}->[$_] || []} for(0..2);
187 print "\u$cat: ", ($subcounts[0]+$subcounts[1]+$subcounts[2]), "\n";
190 for(my $i = 0; $i < 3; $i++) {
191 if(!$options{p} and $cat ne "miscellaneous") {
193 if($cat eq "regressions") {
194 print "\tSuccess in old1 only: $subcounts[$i]\n";
196 print "\tFailure in old1 only: $subcounts[$i]\n";
199 if($cat eq "regressions") {
200 print "\tSuccess in old2 only: $subcounts[$i]\n";
202 print "\tFailure in old2 only: $subcounts[$i]\n";
205 if($cat eq "regressions") {
206 print "\tFailure in new only: $subcounts[$i]\n";
208 print "\tSuccess in new only: $subcounts[$i]\n";
213 foreach my $test (sort {$a->{name} cmp $b->{name}} @{$analyzed_results{$cat}->[$i] || []}) {
215 if($cat eq "miscellaneous") {
221 if($cat eq "regressions") {
229 printf "%s [%s,%s,%s]\n", $test->{name}, $test->{data}->[0], $test->{data}->[1], $test->{data}->[2];
234 my $subcount = @{$analyzed_results{$cat}};
235 print "\u$cat: $subcount\n";
238 foreach my $test (sort {$a->{name} cmp $b->{name}} @{$analyzed_results{$cat}}) {
242 if($cat eq "regressions") {
249 printf "%s [%s,%s]\n", $test->{name}, $test->{data}->[0], $test->{data}->[1], $test->{data}->[2];