blob: 74da3beb2f8bda20b15a5d6517a0f080e4392bcb [file] [log] [blame]
Christophe Lyonbff39612015-11-18 16:29:11 +01001#!/bin/sh
2# This script automatically test the given tool with the tool's test cases,
3# reporting anything of interest.
4
5# Written by Mike Stump <mrs@cygnus.com>
6# Subdir comparison added by Quentin Neill <quentin.neill@amd.com>
7# Modified by Yvan Roux <yvan.roux@linaro.org> and
8# Christophe Lyon <christophe.lyon@linaro.org>
9usage()
10{
11 if [ -n "$1" ] ; then
12 echo "$0: Error: $1" >&2
13 echo >&2
14 fi
15 cat >&2 <<EOUSAGE
16Usage: $0 [-strict] [-target target-triplet] PREVIOUS CURRENT
17
18Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest.
19
20 If PREVIOUS and CURRENT are directories, find and compare any *.sum files.
21
22 Unless -strict is given, these discrepancies are not counted as errors:
23 missing/extra .sum files when comparing directories
24 tests that failed in PREVIOUS but pass in CURRENT
25 tests that were not in PREVIOUS but appear in CURRENT
26 tests in PREVIOUS that are missing in CURRENT
27
28 -target enables to provide the target name to use when parsing
29 the file containing the list of unstable tests.
30
31 Exit with the following values:
32 0 if there is nothing of interest
33 1 if there are errors when comparing single test case files
34 N for the number of errors found when comparing directories
35EOUSAGE
36 exit 2
37}
38
39export LC_ALL=C
40
41me="`which $0`"
42my_path="`dirname ${me}`"
43
44tool=gxx
45
46tmp1=/tmp/$tool-testing.$$a
47tmp2=/tmp/$tool-testing.$$b
48now_s=/tmp/$tool-testing.$$d
49before_s=/tmp/$tool-testing.$$e
50lst1=/tmp/$tool-lst1.$$
51lst2=/tmp/$tool-lst2.$$
52lst3=/tmp/$tool-lst3.$$
53lst4=/tmp/$tool-lst4.$$
54lst5=/tmp/$tool-lst5.$$
55sum1=/tmp/$tool-sum1.$$
56sum2=/tmp/$tool-sum2.$$
57tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
58
59[ "$1" = "-strict" ] && strict=$1 && shift
60[ "$1" = "-target" ] && target=$2 && shift 2
61[ "$1" = "-?" ] && usage
62[ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT"
63
64trap "rm -f $tmps" 0 1 2 3 5 9 13 15
65exit_status=0
66
67if [ -d "$1" -a -d "$2" ] ; then
68 find "$1/" \( -name '*.sum.xz' ! -name '*go.sum.xz' ! -name 'libgo-all.sum.xz' \)>$lst1
69 find "$2/" \( -name '*.sum.xz' ! -name '*go.sum.xz' ! -name 'libgo-all.sum.xz' \)>$lst2
70 echo "# Comparing directories"
71 echo "# REFERENCE: $1"
72 echo "# CURRENT: $2"
73 echo
74 # remove leading directory components to compare
75 sed -e "s|^$1[/]*||" $lst1 | sort >$lst3
76 sed -e "s|^$2[/]*||" $lst2 | sort >$lst4
77 comm -23 $lst3 $lst4 >$lst5
78 if [ -s $lst5 ] ; then
79 echo "# Extra sum files in Dir1=$1"
80 sed -e "s|^|< $1/|" $lst5
81 echo
82 [ -n "$strict" ] && exit_status=`expr $exit_status + 1`
83 fi
84 comm -13 $lst3 $lst4 >$lst5
85 if [ -s $lst5 ] ; then
86 echo "# Extra sum files in Dir2=$2"
87 sed -e "s|^|> $2/|" $lst5
88 echo
89 [ -n "$strict" ] && exit_status=`expr $exit_status + 1`
90 fi
91 comm -12 $lst3 $lst4 | sort -u >$lst5
92 if [ ! -s $lst5 ] ; then
93 echo "# No common sum files"
94 exit_status=`expr $exit_status + 1`
95 exit $exit_status
96 fi
97 cmnsums=`cat $lst5 | wc -l`
98 echo "# Comparing $cmnsums common sum files:"
99 cat $lst5
100 ( for fname in `cat $lst5`; do
101 bname=`basename $fname .sum.xz`
102 xzcat $1/$fname | sed -e "s/^\([A-Z]*: \)/\1 $bname:/" | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/'
103 done ) >$sum1
104 ( for fname in `cat $lst5`; do
105 bname=`basename $fname .sum.xz`
106 xzcat $2/$fname | sed -e "s/^\([A-Z]*: \)/\1 $bname:/" | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/'
107 done ) >$sum2
108 if [ "x${target}" != "x" ] ; then
109 unstable_target="--unstable-marker ${target}"
110 fi
111 for sum in $sum1 $sum2; do
112 board="$(grep "Running target " $sum | head -n 1 | sed -e "s/Running target //")"
113 if [ x"$board" != x"" ]; then
114 unstable_target="$unstable_target --unstable-marker $board"
115 fi
116 done
Christophe Lyon19142d72015-11-20 00:13:34 +0100117 ${CONFIG_SHELL-/usr/bin/perl} ${my_path}/compare_dg_tests.pl -l --unstable-test=${my_path}/unstable-tests.txt ${unstable_target} $sum1 $sum2
Christophe Lyonbff39612015-11-18 16:29:11 +0100118 ret=$?
Christophe Lyona8755e82015-11-20 00:40:34 +0100119 case $ret in
120 2)
121 exit_status=`expr $exit_status + 2`
Christophe Lyonbff39612015-11-18 16:29:11 +0100122 echo "# Regressions found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100123 ;;
124 1)
125 exit_status=`expr $exit_status + 1`
Christophe Lyonbff39612015-11-18 16:29:11 +0100126 echo "# Improvements found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100127 ;;
128 esac
129 if [ $ret -eq 2 ]; then
Christophe Lyonbff39612015-11-18 16:29:11 +0100130 echo "# Regressions in $cmnsums common sum files found"
131 else
132 echo "# No regression found in $cmnsums common sum files"
133 fi
134 exit $exit_status
135elif [ -d "$1" -o -d "$2" ] ; then
136 usage "Must specify either two directories or two files"
137fi