comparison contrib/compare_tests @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents a06113de4d67
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 #!/bin/sh 1 #!/bin/sh
2 # This script automatically test the given tool with the tool's test cases, 2 # This script automatically test the given tool with the tool's test cases,
3 # reporting anything of interest. 3 # reporting anything of interest.
4 4
5 # exits with 0 if there is nothing of interest 5 # Written by Mike Stump <mrs@cygnus.com>
6 # exits with 1 if there is something interesting 6 # Subdir comparison added by Quentin Neill <quentin.neill@amd.com>
7 # exits with 2 if an error occurred
8 7
9 # Give two .sum files to compare them 8 usage()
9 {
10 if [ -n "$1" ] ; then
11 echo "$0: Error: $1" >&2
12 echo >&2
13 fi
14 cat >&2 <<EOUSAGE
15 Usage: $0 [-strict] PREVIOUS CURRENT
10 16
11 # Written by Mike Stump <mrs@cygnus.com> 17 Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest.
18
19 If PREVIOUS and CURRENT are directories, find and compare any *.sum files.
20
21 Unless -strict is given, these discrepancies are not counted as errors:
22 missing/extra .sum files when comparing directories
23 tests that failed in PREVIOUS but pass in CURRENT
24 tests that were not in PREVIOUS but appear in CURRENT
25 tests in PREVIOUS that are missing in CURRENT
26
27 Exit with the following values:
28 0 if there is nothing of interest
29 1 if there are errors when comparing single test case files
30 N for the number of errors found when comparing directories
31 EOUSAGE
32 exit 2
33 }
34
35 export LC_ALL=C
12 36
13 tool=gxx 37 tool=gxx
14 38
15 tmp1=/tmp/$tool-testing.$$a 39 tmp1=/tmp/$tool-testing.$$a
16 tmp2=/tmp/$tool-testing.$$b 40 tmp2=/tmp/$tool-testing.$$b
17 now_s=/tmp/$tool-testing.$$d 41 now_s=/tmp/$tool-testing.$$d
18 before_s=/tmp/$tool-testing.$$e 42 before_s=/tmp/$tool-testing.$$e
43 lst1=/tmp/$tool-lst1.$$
44 lst2=/tmp/$tool-lst2.$$
45 lst3=/tmp/$tool-lst3.$$
46 lst4=/tmp/$tool-lst4.$$
47 lst5=/tmp/$tool-lst5.$$
48 sum1=/tmp/$tool-sum1.$$
49 sum2=/tmp/$tool-sum2.$$
50 tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
19 51
20 if [ "$2" = "" ]; then 52 [ "$1" = "-strict" ] && strict=$1 && shift
21 echo "Usage: $0 previous current" >&2 53 [ "$1" = "-?" ] && usage
22 exit 2 54 [ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT"
55
56 trap "rm -f $tmps" 0 1 2 3 5 9 13 15
57 exit_status=0
58
59 if [ -d "$1" -a -d "$2" ] ; then
60 find "$1/" -name '*.sum' >$lst1
61 find "$2/" -name '*.sum' >$lst2
62 echo "# Comparing directories"
63 echo "## Dir1=$1: `cat $lst1 | wc -l` sum files"
64 echo "## Dir2=$2: `cat $lst2 | wc -l` sum files"
65 echo
66 # remove leading directory components to compare
67 sed -e "s|^$1[/]*||" $lst1 | sort >$lst3
68 sed -e "s|^$2[/]*||" $lst2 | sort >$lst4
69 comm -23 $lst3 $lst4 >$lst5
70 if [ -s $lst5 ] ; then
71 echo "# Extra sum files in Dir1=$1"
72 sed -e "s|^|< $1/|" $lst5
73 echo
74 [ -n "$strict" ] && exit_status=`expr $exit_status + 1`
75 fi
76 comm -13 $lst3 $lst4 >$lst5
77 if [ -s $lst5 ] ; then
78 echo "# Extra sum files in Dir2=$2"
79 sed -e "s|^|> $2/|" $lst5
80 echo
81 [ -n "$strict" ] && exit_status=`expr $exit_status + 1`
82 fi
83 comm -12 $lst3 $lst4 | sort -u >$lst5
84 if [ ! -s $lst5 ] ; then
85 echo "# No common sum files"
86 exit_status=`expr $exit_status + 1`
87 exit $exit_status
88 fi
89 cmnsums=`cat $lst5 | wc -l`
90 echo "# Comparing $cmnsums common sum files"
91 ( for fname in `cat $lst5`; do cat $1/$fname; done ) >$sum1
92 ( for fname in `cat $lst5`; do cat $2/$fname; done ) >$sum2
93 echo "## ${CONFIG_SHELL-/bin/sh} $0 $strict $sum1 $sum2"
94 ${CONFIG_SHELL-/bin/sh} $0 $strict $sum1 $sum2
95 ret=$?
96 if [ $ret -ne 0 ]; then
97 exit_status=`expr $exit_status + 1`
98 echo "## Differences found: $fname"
99 fi
100 if [ $exit_status -ne 0 ]; then
101 echo "# $exit_status differences in $cmnsums common sum files found"
102 else
103 echo "# No differences found in $cmnsums common sum files"
104 fi
105 exit $exit_status
106 elif [ -d "$1" -o -d "$2" ] ; then
107 usage "Must specify either two directories or two files"
23 fi 108 fi
24 109
25 sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$1" | awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp1 110 sed 's/^XFAIL/FAIL/; s/^ERROR/FAIL/; s/^XPASS/PASS/' < "$1" | awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' | cut -c1-2000 >$tmp1
26 sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$2" | awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp2 111 sed 's/^XFAIL/FAIL/; s/^ERROR/FAIL/; s/^XPASS/PASS/' < "$2" | awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' | cut -c1-2000 >$tmp2
27 112
28 before=$tmp1 113 before=$tmp1
29 now=$tmp2 114 now=$tmp2
30 115
31 exit_status=0
32 trap "rm -f $tmp1 $tmp2 $now_s $before_s" 0 1 2 3 5 9 13 15
33 116
34 if sort -k 2 </dev/null >/dev/null 2>&1; then 117 if sort -k 2 </dev/null >/dev/null 2>&1; then
35 skip1='-k 2' 118 skip1='-k 2'
36 else 119 else
37 skip1='+1' 120 skip1='+1'
58 grep -s . $tmp2 >/dev/null 141 grep -s . $tmp2 >/dev/null
59 if [ $? = 0 ]; then 142 if [ $? = 0 ]; then
60 echo "Tests that now work, but didn't before:" 143 echo "Tests that now work, but didn't before:"
61 echo 144 echo
62 cat $tmp2 145 cat $tmp2
146 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
63 echo 147 echo
64 fi 148 fi
65 149
66 grep '^FAIL' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1 150 grep '^FAIL' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
67 grep '^[PF]A[SI][SL]' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -23 $tmp1 - >$tmp2 151 grep '^[PF]A[SI][SL]' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -23 $tmp1 - >$tmp2
81 grep -s . $tmp2 >/dev/null 165 grep -s . $tmp2 >/dev/null
82 if [ $? = 0 ]; then 166 if [ $? = 0 ]; then
83 echo "New tests that PASS:" 167 echo "New tests that PASS:"
84 echo 168 echo
85 cat $tmp2 169 cat $tmp2
170 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
86 echo 171 echo
87 fi 172 fi
88 173
89 grep '^[PF]A[SI][SL]' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1 174 grep '^[PF]A[SI][SL]' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
90 grep '^PASS' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -13 $tmp1 - >$tmp2 175 grep '^PASS' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -13 $tmp1 - >$tmp2
92 grep -s . $tmp2 >/dev/null 177 grep -s . $tmp2 >/dev/null
93 if [ $? = 0 ]; then 178 if [ $? = 0 ]; then
94 echo "Old tests that passed, that have disappeared: (Eeek!)" 179 echo "Old tests that passed, that have disappeared: (Eeek!)"
95 echo 180 echo
96 cat $tmp2 181 cat $tmp2
182 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
97 echo 183 echo
98 fi 184 fi
99 185
100 grep '^[PF]A[SI][SL]' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1 186 grep '^[PF]A[SI][SL]' "$now_s" | sed 's/^[^:]*:[ ]//' >$tmp1
101 grep '^FAIL' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -13 $tmp1 - >$tmp2 187 grep '^FAIL' "$before_s" | sed 's/^[^:]*:[ ]//' | comm -13 $tmp1 - >$tmp2
103 grep -s . $tmp2 >/dev/null 189 grep -s . $tmp2 >/dev/null
104 if [ $? = 0 ]; then 190 if [ $? = 0 ]; then
105 echo "Old tests that failed, that have disappeared: (Eeek!)" 191 echo "Old tests that failed, that have disappeared: (Eeek!)"
106 echo 192 echo
107 cat $tmp2 193 cat $tmp2
194 [ -n "$strict" ] && echo "Strict test fails" && exit_status=1
108 echo 195 echo
109 fi 196 fi
110 197
111 exit $exit_status 198 exit $exit_status