]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/compare_tests
2012-04-24 Andrew Pinski <apinski@cavium.com>
[thirdparty/gcc.git] / contrib / compare_tests
CommitLineData
974daf94 1#!/bin/sh
2# This script automatically test the given tool with the tool's test cases,
3# reporting anything of interest.
4
cd652b25 5usage()
6{
7 if [ -n "$1" ] ; then
8 echo "$0: Error: $1" >&2
9 echo >&2
10 fi
11 cat >&2 <<EOUSAGE
12Usage: $0 [-strict] PREVIOUS CURRENT
13
14Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest.
15
16 If PREVIOUS and CURRENT are directories, find and compare any *.sum files.
17
18 Unless -strict is given, these discrepancies are not counted as errors:
19 missing/extra .sum files when comparing directories
20 tests that failed in PREVIOUS but pass in CURRENT
21 tests that were not in PREVIOUS but appear in CURRENT
22 tests in PREVIOUS that are missing in CURRENT
23
24 Exit with the following values:
25 0 if there is nothing of interest
26 1 if there are errors when comparing single test case files
27 N for the number of errors found when comparing directories
28EOUSAGE
29 exit 2
30}
974daf94 31
32# Written by Mike Stump <mrs@cygnus.com>
cd652b25 33# Subdir comparison added by Quentin Neill <quentin.neill@amd.com>
974daf94 34
5cd22fd0 35tool=gxx
36
974daf94 37tmp1=/tmp/$tool-testing.$$a
38tmp2=/tmp/$tool-testing.$$b
39now_s=/tmp/$tool-testing.$$d
40before_s=/tmp/$tool-testing.$$e
cd652b25 41lst1=/tmp/$tool-lst1.$$
42lst2=/tmp/$tool-lst2.$$
43lst3=/tmp/$tool-lst3.$$
44lst4=/tmp/$tool-lst4.$$
45lst5=/tmp/$tool-lst5.$$
839c4f22 46sum1=/tmp/$tool-sum1.$$
47sum2=/tmp/$tool-sum2.$$
48tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
cd652b25 49
50[ "$1" = "-strict" ] && strict=$1 && shift
51[ "$1" = "-?" ] && usage
52[ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT"
53
54trap "rm -f $tmps" 0 1 2 3 5 9 13 15
55exit_status=0
974daf94 56
cd652b25 57if [ -d "$1" -a -d "$2" ] ; then
58 find "$1" -name '*.sum' >$lst1
59 find "$2" -name '*.sum' >$lst2
60 echo "# Comparing directories"
61 echo "## Dir1=$1: `cat $lst1 | wc -l` sum files"
62 echo "## Dir2=$2: `cat $lst2 | wc -l` sum files"
63 echo
64 # remove leading directory components to compare
839c4f22 65 sed -e "s|^$1[/]*||" $lst1 | sort >$lst3
66 sed -e "s|^$2[/]*||" $lst2 | sort >$lst4
cd652b25 67 comm -23 $lst3 $lst4 >$lst5
68 if [ -s $lst5 ] ; then
69 echo "# Extra sum files in Dir1=$1"
70 sed -e "s|^|< $1/|" $lst5
71 echo
72 [ -n "$strict" ] && exit_status=`expr $exit_status + 1`
73 fi
74 comm -13 $lst3 $lst4 >$lst5
75 if [ -s $lst5 ] ; then
76 echo "# Extra sum files in Dir2=$2"
77 sed -e "s|^|> $2/|" $lst5
78 echo
79 [ -n "$strict" ] && exit_status=`expr $exit_status + 1`
80 fi
81 comm -12 $lst3 $lst4 | sort -u >$lst5
82 if [ ! -s $lst5 ] ; then
83 echo "# No common sum files"
84 exit_status=`expr $exit_status + 1`
85 exit $exit_status
86 fi
87 cmnsums=`cat $lst5 | wc -l`
88 echo "# Comparing $cmnsums common sum files"
89 ( for fname in `cat $lst5`; do cat $1/$fname; done ) >$sum1
90 ( for fname in `cat $lst5`; do cat $2/$fname; done ) >$sum2
91 echo "## ${CONFIG_SHELL-/bin/sh} $0 $strict $sum1 $sum2"
92 ${CONFIG_SHELL-/bin/sh} $0 $strict $sum1 $sum2
93 ret=$?
94 if [ $ret -ne 0 ]; then
95 exit_status=`expr $exit_status + 1`
96 echo "## Differences found: $fname"
97 fi
98 if [ $exit_status -ne 0 ]; then
99 echo "# $exit_status differences in $cmnsums common sum files found"
100 else
101 echo "# No differences found in $cmnsums common sum files"
102 fi
103 exit $exit_status
104elif [ -d "$1" -o -d "$2" ] ; then
105 usage "Must specify either two directories or two files"
974daf94 106fi
107
4befda8b 108sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$1" | awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp1
109sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$2" | awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp2
974daf94 110
111before=$tmp1
112now=$tmp2
113
974daf94 114
108cf177 115if sort -k 2 </dev/null >/dev/null 2>&1; then
116 skip1='-k 2'
117else
118 skip1='+1'
119fi
120
121sort -t ':' $skip1 "$now" > "$now_s"
122sort -t ':' $skip1 "$before" > "$before_s"
974daf94 123
5cd22fd0 124grep '^FAIL:' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
125grep '^PASS' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -12 $tmp1 - >$tmp2
974daf94 126
127grep -s . $tmp2 >/dev/null
128if [ $? = 0 ]; then
129 echo "Tests that now fail, but worked before:"
130 echo
131 cat $tmp2
132 echo
5cd22fd0 133 exit_status=1
974daf94 134fi
135
5cd22fd0 136grep '^PASS' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
137grep '^FAIL' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -12 $tmp1 - >$tmp2
974daf94 138
139grep -s . $tmp2 >/dev/null
140if [ $? = 0 ]; then
141 echo "Tests that now work, but didn't before:"
142 echo
143 cat $tmp2
cd652b25 144 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
974daf94 145 echo
146fi
147
5cd22fd0 148grep '^FAIL' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
149grep '^[PF]A[SI][SL]' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -23 $tmp1 - >$tmp2
974daf94 150
151grep -s . $tmp2 >/dev/null
152if [ $? = 0 ]; then
153 echo "New tests that FAIL:"
154 echo
155 cat $tmp2
156 echo
5cd22fd0 157 exit_status=1
974daf94 158fi
159
5cd22fd0 160grep '^PASS' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
161grep '^[PF]A[SI][SL]' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -23 $tmp1 - >$tmp2
974daf94 162
163grep -s . $tmp2 >/dev/null
164if [ $? = 0 ]; then
165 echo "New tests that PASS:"
166 echo
167 cat $tmp2
cd652b25 168 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
974daf94 169 echo
170fi
171
5cd22fd0 172grep '^[PF]A[SI][SL]' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
173grep '^PASS' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -13 $tmp1 - >$tmp2
974daf94 174
175grep -s . $tmp2 >/dev/null
176if [ $? = 0 ]; then
177 echo "Old tests that passed, that have disappeared: (Eeek!)"
178 echo
179 cat $tmp2
cd652b25 180 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
974daf94 181 echo
182fi
183
5cd22fd0 184grep '^[PF]A[SI][SL]' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
185grep '^FAIL' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -13 $tmp1 - >$tmp2
974daf94 186
187grep -s . $tmp2 >/dev/null
188if [ $? = 0 ]; then
189 echo "Old tests that failed, that have disappeared: (Eeek!)"
190 echo
191 cat $tmp2
cd652b25 192 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
974daf94 193 echo
194fi
5cd22fd0 195
196exit $exit_status