2 # This script automatically test the given tool with the tool's test cases,
3 # reporting anything of interest.
8 echo "$0: Error: $1" >&2
12 Usage: $0 [-strict] PREVIOUS CURRENT
14 Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest.
16 If PREVIOUS and CURRENT are directories, find and compare any *.sum files.
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
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
32 # Written by Mike Stump <mrs@cygnus.com>
33 # Subdir comparison added by Quentin Neill <quentin.neill@amd.com>
37 tmp1
=/tmp
/$tool-testing.$
$a
38 tmp2
=/tmp
/$tool-testing.$
$b
39 now_s
=/tmp
/$tool-testing.$
$d
40 before_s
=/tmp
/$tool-testing.$
$e
41 lst1
=/tmp
/$tool-lst1.$$
42 lst2
=/tmp
/$tool-lst2.$$
43 lst3
=/tmp
/$tool-lst3.$$
44 lst4
=/tmp
/$tool-lst4.$$
45 lst5
=/tmp
/$tool-lst5.$$
46 tmps
="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5"
48 [ "$1" = "-strict" ] && strict
=$1 && shift
49 [ "$1" = "-?" ] && usage
50 [ "$2" = "" ] && usage
"Must specify both PREVIOUS and CURRENT"
52 trap "rm -f $tmps" 0 1 2 3 5 9 13 15
55 if [ -d "$1" -a -d "$2" ] ; then
56 find "$1" -name '*.sum' >$lst1
57 find "$2" -name '*.sum' >$lst2
58 echo "# Comparing directories"
59 echo "## Dir1=$1: `cat $lst1 | wc -l` sum files"
60 echo "## Dir2=$2: `cat $lst2 | wc -l` sum files"
62 # remove leading directory components to compare
63 sed -e "s|^$1/||" $lst1 |
sort >$lst3
64 sed -e "s|^$2/||" $lst2 |
sort >$lst4
65 comm -23 $lst3 $lst4 >$lst5
66 if [ -s $lst5 ] ; then
67 echo "# Extra sum files in Dir1=$1"
68 sed -e "s|^|< $1/|" $lst5
70 [ -n "$strict" ] && exit_status
=`expr $exit_status + 1`
72 comm -13 $lst3 $lst4 >$lst5
73 if [ -s $lst5 ] ; then
74 echo "# Extra sum files in Dir2=$2"
75 sed -e "s|^|> $2/|" $lst5
77 [ -n "$strict" ] && exit_status
=`expr $exit_status + 1`
79 comm -12 $lst3 $lst4 |
sort -u >$lst5
80 if [ ! -s $lst5 ] ; then
81 echo "# No common sum files"
82 exit_status
=`expr $exit_status + 1`
85 cmnsums
=`cat $lst5 | wc -l`
86 echo "# Comparing $cmnsums common sum files"
87 ( for fname
in `cat $lst5`; do cat $1/$fname; done ) >$sum1
88 ( for fname
in `cat $lst5`; do cat $2/$fname; done ) >$sum2
89 echo "## ${CONFIG_SHELL-/bin/sh} $0 $strict $sum1 $sum2"
90 ${CONFIG_SHELL-/bin/sh} $0 $strict $sum1 $sum2
92 if [ $ret -ne 0 ]; then
93 exit_status
=`expr $exit_status + 1`
94 echo "## Differences found: $fname"
96 if [ $exit_status -ne 0 ]; then
97 echo "# $exit_status differences in $cmnsums common sum files found"
99 echo "# No differences found in $cmnsums common sum files"
102 elif [ -d "$1" -o -d "$2" ] ; then
103 usage
"Must specify either two directories or two files"
106 sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$1" |
awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp1
107 sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$2" |
awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp2
113 if sort -k 2 </dev
/null
>/dev
/null
2>&1; then
119 sort -t ':' $skip1 "$now" > "$now_s"
120 sort -t ':' $skip1 "$before" > "$before_s"
122 grep '^FAIL:' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
123 grep '^PASS' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -12 $tmp1 - >$tmp2
125 grep -s .
$tmp2 >/dev
/null
127 echo "Tests that now fail, but worked before:"
134 grep '^PASS' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
135 grep '^FAIL' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -12 $tmp1 - >$tmp2
137 grep -s .
$tmp2 >/dev
/null
139 echo "Tests that now work, but didn't before:"
142 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1
146 grep '^FAIL' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
147 grep '^[PF]A[SI][SL]' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -23 $tmp1 - >$tmp2
149 grep -s .
$tmp2 >/dev
/null
151 echo "New tests that FAIL:"
158 grep '^PASS' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
159 grep '^[PF]A[SI][SL]' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -23 $tmp1 - >$tmp2
161 grep -s .
$tmp2 >/dev
/null
163 echo "New tests that PASS:"
166 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1
170 grep '^[PF]A[SI][SL]' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
171 grep '^PASS' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -13 $tmp1 - >$tmp2
173 grep -s .
$tmp2 >/dev
/null
175 echo "Old tests that passed, that have disappeared: (Eeek!)"
178 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1
182 grep '^[PF]A[SI][SL]' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
183 grep '^FAIL' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -13 $tmp1 - >$tmp2
185 grep -s .
$tmp2 >/dev
/null
187 echo "Old tests that failed, that have disappeared: (Eeek!)"
190 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1