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 sum1
=/tmp
/$tool-sum1.$$
47 sum2
=/tmp
/$tool-sum2.$$
48 tmps
="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
50 [ "$1" = "-strict" ] && strict
=$1 && shift
51 [ "$1" = "-?" ] && usage
52 [ "$2" = "" ] && usage
"Must specify both PREVIOUS and CURRENT"
54 trap "rm -f $tmps" 0 1 2 3 5 9 13 15
57 if [ -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"
64 # remove leading directory components to compare
65 sed -e "s|^$1[/]*||" $lst1 |
sort >$lst3
66 sed -e "s|^$2[/]*||" $lst2 |
sort >$lst4
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
72 [ -n "$strict" ] && exit_status
=`expr $exit_status + 1`
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
79 [ -n "$strict" ] && exit_status
=`expr $exit_status + 1`
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`
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
94 if [ $ret -ne 0 ]; then
95 exit_status
=`expr $exit_status + 1`
96 echo "## Differences found: $fname"
98 if [ $exit_status -ne 0 ]; then
99 echo "# $exit_status differences in $cmnsums common sum files found"
101 echo "# No differences found in $cmnsums common sum files"
104 elif [ -d "$1" -o -d "$2" ] ; then
105 usage
"Must specify either two directories or two files"
108 sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$1" |
awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp1
109 sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$2" |
awk '/^Running target / {target = $3} { if (target != "unix") { sub(/: /, "&"target": " ); }; print $0; }' >$tmp2
115 if sort -k 2 </dev
/null
>/dev
/null
2>&1; then
121 sort -t ':' $skip1 "$now" > "$now_s"
122 sort -t ':' $skip1 "$before" > "$before_s"
124 grep '^FAIL:' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
125 grep '^PASS' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -12 $tmp1 - >$tmp2
127 grep -s .
$tmp2 >/dev
/null
129 echo "Tests that now fail, but worked before:"
136 grep '^PASS' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
137 grep '^FAIL' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -12 $tmp1 - >$tmp2
139 grep -s .
$tmp2 >/dev
/null
141 echo "Tests that now work, but didn't before:"
144 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1
148 grep '^FAIL' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
149 grep '^[PF]A[SI][SL]' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -23 $tmp1 - >$tmp2
151 grep -s .
$tmp2 >/dev
/null
153 echo "New tests that FAIL:"
160 grep '^PASS' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
161 grep '^[PF]A[SI][SL]' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -23 $tmp1 - >$tmp2
163 grep -s .
$tmp2 >/dev
/null
165 echo "New tests that PASS:"
168 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1
172 grep '^[PF]A[SI][SL]' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
173 grep '^PASS' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -13 $tmp1 - >$tmp2
175 grep -s .
$tmp2 >/dev
/null
177 echo "Old tests that passed, that have disappeared: (Eeek!)"
180 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1
184 grep '^[PF]A[SI][SL]' "$now_s" |
sed 's/^[^:]*:[ ]//' >$tmp1
185 grep '^FAIL' "$before_s" |
sed 's/^[^:]*:[ ]//' |
comm -13 $tmp1 - >$tmp2
187 grep -s .
$tmp2 >/dev
/null
189 echo "Old tests that failed, that have disappeared: (Eeek!)"
192 [ -n "$strict" ] && echo "Strict test fails" && exit_status
=1