compareSumTests3 revision 1.1.1.2 1 1.1 mrg #!/usr/bin/perl
2 1.1 mrg
3 1.1 mrg # Three-way DejaGNU comparison; uses dglib.pm. Run perldoc on this file for
4 1.1 mrg # usage.
5 1.1 mrg #
6 1.1 mrg # Author: Matthew Sachs <msachs (at] apple.com>
7 1.1 mrg #
8 1.1.1.2 mrg # Copyright (C) 2006-2024 Free Software Foundation, Inc.
9 1.1 mrg #
10 1.1 mrg # This file is part of GCC.
11 1.1 mrg #
12 1.1 mrg # GCC is free software; you can redistribute it and/or modify
13 1.1 mrg # it under the terms of the GNU General Public License as published by
14 1.1 mrg # the Free Software Foundation; either version 3, or (at your option)
15 1.1 mrg # any later version.
16 1.1 mrg #
17 1.1 mrg # GCC is distributed in the hope that it will be useful,
18 1.1 mrg # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 1.1 mrg # GNU General Public License for more details.
21 1.1 mrg #
22 1.1 mrg # You should have received a copy of the GNU General Public License
23 1.1 mrg # along with GCC; see the file COPYING. If not, write to
24 1.1 mrg # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
25 1.1 mrg # Boston, MA 02110-1301, USA.
26 1.1 mrg
27 1.1 mrg =pod
28 1.1 mrg
29 1.1 mrg =head1 SYNOPSIS
30 1.1 mrg
31 1.1 mrg compareSumTests3 -- Two-way or three-way compare between DejaGNU .sum files
32 1.1 mrg
33 1.1 mrg =head1 USAGE
34 1.1 mrg
35 1.1 mrg compareSumTests3 old1.sum [old2.sum] new.sum
36 1.1 mrg compareSumTests3 -i 1:2 -x 2:3 old1.sum old2.sum new.sum
37 1.1 mrg
38 1.1 mrg =head1 DESCRIPTION
39 1.1 mrg
40 1.1 mrg Gives results in terms of 'new' (e.g. things that work in 'new' and don't in
41 1.1 mrg other compilers are improvements, things that don't in 'new' and do in others
42 1.1 mrg are regressions, and it tells you which of the two old compilers (or both)
43 1.1 mrg the test is a regression from.
44 1.1 mrg
45 1.1 mrg We treat any DG result other than PASS or XFAIL as a failure, e.g.
46 1.1 mrg UNRESOLVED, UNTESTED or test was not run.
47 1.1 mrg
48 1.1 mrg We merge some tests into 'logical tests' with multiple subphases.
49 1.1 mrg For instance, some tests will have compile, execute, and link
50 1.1 mrg subtests. For these tests, if one of the phases fails, we
51 1.1 mrg indicate which phase the failure originates in. For instance,
52 1.1 mrg in the following test results:
53 1.1 mrg
54 1.1 mrg gcc.c-torture/compile_execute/xxxx.c: [FAIL:C,FAIL:X,PASS]
55 1.1 mrg
56 1.1 mrg the "compile_execute" replaces the compile or execute portion of the test name,
57 1.1 mrg and "FAIL:C" and "FAIL:X" indicates where the combined test failed.
58 1.1 mrg
59 1.1 mrg =head1 OPTIONS
60 1.1 mrg
61 1.1 mrg =head2 OVERVIEW
62 1.1 mrg
63 1.1 mrg =over 4
64 1.1 mrg
65 1.1 mrg =item *
66 1.1 mrg
67 1.1 mrg C<-i X:Y>: Only display differences between the two indicated runs.
68 1.1 mrg
69 1.1 mrg =item *
70 1.1 mrg
71 1.1 mrg C<-p>: Give plain output, suitable for piping to another program.
72 1.1 mrg
73 1.1 mrg =item *
74 1.1 mrg
75 1.1 mrg C<-x X:Y>: Exclude differences between the two indicated runs.
76 1.1 mrg
77 1.1 mrg =back
78 1.1 mrg
79 1.1 mrg =head2 PLAIN OUTPUT FORMAT
80 1.1 mrg
81 1.1 mrg In the plain
82 1.1 mrg output format, the category headers are not displayed and there are no tabs
83 1.1 mrg in front of each result line. Instead, each result line has two characters
84 1.1 mrg followed by a space in front of it. The first character will be either an 'I'
85 1.1 mrg for improvement or 'R' for regression; the second character will be a 1, 2, or 3,
86 1.1 mrg indicating which run was the odd one out.
87 1.1 mrg
88 1.1 mrg =head2 SELECTING CHANGE SUBSETS
89 1.1 mrg
90 1.1 mrg The following options cause only a selected subset of changes to be displayed.
91 1.1 mrg These options ask for a "run", a number which is used to select
92 1.1 mrg one of the three runs (C<old1>, C<old2>, or C<new>.) C<1> and C<2> signify C<old1> and C<old2>
93 1.1 mrg respectively; 3 signifies C<new>. If multiple options are given, the changes displayed
94 1.1 mrg will be those which obey all of the given restrictions.
95 1.1 mrg
96 1.1 mrg Typical usage of these options is to express something like "give me all changes
97 1.1 mrg between 2 and 3, except for those where there was the same difference betwen 1 and 2
98 1.1 mrg (as between 2 and 3.)" This would be given as:
99 1.1 mrg
100 1.1 mrg -i 2:3 -x 1:2
101 1.1 mrg
102 1.1 mrg =over 4
103 1.1 mrg
104 1.1 mrg =item *
105 1.1 mrg
106 1.1 mrg C<-i X:Y>: Only differences which are present between the two runs given
107 1.1 mrg are displayed. For instance, if C<-i 1:2> is given and test A passes in
108 1.1 mrg runs 1 and 2 but fails in run 3, that result will not be displayed.
109 1.1 mrg
110 1.1 mrg =item *
111 1.1 mrg
112 1.1 mrg C<-x X:Y>: Differences which are identical to a difference between the two runs
113 1.1 mrg given will B<not> be displayed. For instance, if C<-x 1:2> is given and
114 1.1 mrg test A passes in run 1 and fails in runs 2 and 3, that result will not be
115 1.1 mrg displayed (since C<-x> will cause the difference between 1 and 2 to be ignored,
116 1.1 mrg and the difference in 1 and 3 parallels the difference between 1 and 2.)
117 1.1 mrg This option may only be used in conjunction with C<-i>.
118 1.1 mrg
119 1.1 mrg =back
120 1.1 mrg
121 1.1 mrg =cut
122 1.1 mrg
123 1.1 mrg use strict;
124 1.1 mrg use warnings;
125 1.1 mrg use Getopt::Long;
126 1.1 mrg
127 1.1 mrg use FindBin qw($Bin);
128 1.1 mrg use lib "$Bin";
129 1.1 mrg use dglib;
130 1.1 mrg
131 1.1 mrg my %options;
132 1.1 mrg my $error = undef;
133 1.1 mrg
134 1.1 mrg if(!GetOptions(
135 1.1 mrg "p" => \$options{p},
136 1.1 mrg "i=s" => \$options{i},
137 1.1 mrg "x=s" => \$options{x},
138 1.1 mrg )) {
139 1.1 mrg $error = "";
140 1.1 mrg } elsif(@ARGV != 2 and @ARGV != 3) {
141 1.1 mrg $error = "";
142 1.1 mrg } elsif($options{x} and !$options{i}) {
143 1.1 mrg $error = "-x may only be given in conjunction with -i.";
144 1.1 mrg } else {
145 1.1 mrg foreach my $opt("i", "x") {
146 1.1 mrg if($options{$opt} and
147 1.1 mrg ($options{$opt} !~ /^([123]):([123])$/ or
148 1.1 mrg $1 == $2)
149 1.1 mrg ) {
150 1.1 mrg $error = "Invalid -$opt argument.";
151 1.1 mrg }
152 1.1 mrg }
153 1.1 mrg }
154 1.1 mrg
155 1.1 mrg if(defined($error)) {
156 1.1 mrg print STDERR "$error\n" if $error;
157 1.1 mrg print STDERR "Usage: compareSumTests3 [-p] [-i X:Y [-x X:Y]] old1.sum old2.sum new.sum\n";
158 1.1 mrg print STDERR "Try 'perldoc $0' for further information.\n";
159 1.1 mrg exit 1;
160 1.1 mrg }
161 1.1 mrg
162 1.1 mrg my(@sumfiles) = @ARGV;
163 1.1 mrg -f $_ || die "$_ is not a regular file!\n" foreach @sumfiles;
164 1.1 mrg my(%results, @inc_changes, @exc_changes, %checksums);
165 1.1 mrg
166 1.1 mrg # We decrement the values given so that they correspond
167 1.1 mrg # to indices into our results array.
168 1.1 mrg if($options{i}) {
169 1.1 mrg $options{i} =~ /(\d+):(\d+)/;
170 1.1 mrg @inc_changes = ($1 - 1, $2 - 1);
171 1.1 mrg }
172 1.1 mrg if($options{x}) {
173 1.1 mrg $options{x} =~ /(\d+):(\d+)/;
174 1.1 mrg @exc_changes = ($1 - 1, $2 - 1);
175 1.1 mrg }
176 1.1 mrg
177 1.1 mrg
178 1.1 mrg my %analyzed_results = compareSumFiles(\@sumfiles);
179 1.1 mrg
180 1.1 mrg foreach my $cat (qw(improvements regressions miscellaneous)) {
181 1.1 mrg if(@sumfiles == 3) {
182 1.1 mrg my @subcounts;
183 1.1 mrg if(!$options{p}) {
184 1.1 mrg $subcounts[$_] = @{$analyzed_results{$cat}->[$_] || []} for(0..2);
185 1.1 mrg print "\u$cat: ", ($subcounts[0]+$subcounts[1]+$subcounts[2]), "\n";
186 1.1 mrg }
187 1.1 mrg
188 1.1 mrg for(my $i = 0; $i < 3; $i++) {
189 1.1 mrg if(!$options{p} and $cat ne "miscellaneous") {
190 1.1 mrg if($i == 0) {
191 1.1 mrg if($cat eq "regressions") {
192 1.1 mrg print "\tSuccess in old1 only: $subcounts[$i]\n";
193 1.1 mrg } else {
194 1.1 mrg print "\tFailure in old1 only: $subcounts[$i]\n";
195 1.1 mrg }
196 1.1 mrg } elsif($i == 1) {
197 1.1 mrg if($cat eq "regressions") {
198 1.1 mrg print "\tSuccess in old2 only: $subcounts[$i]\n";
199 1.1 mrg } else {
200 1.1 mrg print "\tFailure in old2 only: $subcounts[$i]\n";
201 1.1 mrg }
202 1.1 mrg } else {
203 1.1 mrg if($cat eq "regressions") {
204 1.1 mrg print "\tFailure in new only: $subcounts[$i]\n";
205 1.1 mrg } else {
206 1.1 mrg print "\tSuccess in new only: $subcounts[$i]\n";
207 1.1 mrg }
208 1.1 mrg }
209 1.1 mrg }
210 1.1 mrg
211 1.1 mrg foreach my $test (sort {$a->{name} cmp $b->{name}} @{$analyzed_results{$cat}->[$i] || []}) {
212 1.1 mrg if(!$options{p}) {
213 1.1 mrg if($cat eq "miscellaneous") {
214 1.1 mrg print "\t";
215 1.1 mrg } else {
216 1.1 mrg print "\t\t";
217 1.1 mrg }
218 1.1 mrg } else {
219 1.1 mrg if($cat eq "regressions") {
220 1.1 mrg print "R";
221 1.1 mrg } else {
222 1.1 mrg print "I";
223 1.1 mrg }
224 1.1 mrg
225 1.1 mrg print $i+1, " ";
226 1.1 mrg }
227 1.1 mrg printf "%s [%s,%s,%s]\n", $test->{name}, $test->{data}->[0], $test->{data}->[1], $test->{data}->[2];
228 1.1 mrg }
229 1.1 mrg }
230 1.1 mrg } else {
231 1.1 mrg if(!$options{p}) {
232 1.1 mrg my $subcount = @{$analyzed_results{$cat}};
233 1.1 mrg print "\u$cat: $subcount\n";
234 1.1 mrg }
235 1.1 mrg
236 1.1 mrg foreach my $test (sort {$a->{name} cmp $b->{name}} @{$analyzed_results{$cat}}) {
237 1.1 mrg if(!$options{p}) {
238 1.1 mrg print "\t";
239 1.1 mrg } else {
240 1.1 mrg if($cat eq "regressions") {
241 1.1 mrg print "R"; } else {
242 1.1 mrg print "I";
243 1.1 mrg }
244 1.1 mrg
245 1.1 mrg print " ";
246 1.1 mrg }
247 1.1 mrg printf "%s [%s,%s]\n", $test->{name}, $test->{data}->[0], $test->{data}->[1], $test->{data}->[2];
248 1.1 mrg }
249 1.1 mrg }
250 1.1 mrg }
251