annotate contrib/compare_tests @ 128:fe568345ddd5

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