blob: 092760d0e3482779b9ac5f92558d1bee2dfe7e85 [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
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010016Usage: $0 [-target target-triplet] PREVIOUS CURRENT
Christophe Lyonbff39612015-11-18 16:29:11 +010017
18Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest.
19
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010020 PREVIOUS and CURRENT must be directories, this tool finds and
21 compares any *.sum files they contain.
Christophe Lyonbff39612015-11-18 16:29:11 +010022
23 -target enables to provide the target name to use when parsing
24 the file containing the list of unstable tests.
25
26 Exit with the following values:
27 0 if there is nothing of interest
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010028 1 if there are improvements
29 2 if the are regressions or new errors
30 3 if there were build errors (no common logs)
31 4 if there are extra .sum files in either PREVIOUS or
32 CURRENT
Christophe Lyonbff39612015-11-18 16:29:11 +010033EOUSAGE
34 exit 2
35}
36
37export LC_ALL=C
38
39me="`which $0`"
40my_path="`dirname ${me}`"
41
42tool=gxx
43
44tmp1=/tmp/$tool-testing.$$a
45tmp2=/tmp/$tool-testing.$$b
46now_s=/tmp/$tool-testing.$$d
47before_s=/tmp/$tool-testing.$$e
48lst1=/tmp/$tool-lst1.$$
49lst2=/tmp/$tool-lst2.$$
50lst3=/tmp/$tool-lst3.$$
51lst4=/tmp/$tool-lst4.$$
52lst5=/tmp/$tool-lst5.$$
53sum1=/tmp/$tool-sum1.$$
54sum2=/tmp/$tool-sum2.$$
55tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
56
Christophe Lyonbff39612015-11-18 16:29:11 +010057[ "$1" = "-target" ] && target=$2 && shift 2
58[ "$1" = "-?" ] && usage
59[ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT"
60
61trap "rm -f $tmps" 0 1 2 3 5 9 13 15
62exit_status=0
63
64if [ -d "$1" -a -d "$2" ] ; then
65 find "$1/" \( -name '*.sum.xz' ! -name '*go.sum.xz' ! -name 'libgo-all.sum.xz' \)>$lst1
66 find "$2/" \( -name '*.sum.xz' ! -name '*go.sum.xz' ! -name 'libgo-all.sum.xz' \)>$lst2
67 echo "# Comparing directories"
68 echo "# REFERENCE: $1"
69 echo "# CURRENT: $2"
70 echo
71 # remove leading directory components to compare
72 sed -e "s|^$1[/]*||" $lst1 | sort >$lst3
73 sed -e "s|^$2[/]*||" $lst2 | sort >$lst4
74 comm -23 $lst3 $lst4 >$lst5
75 if [ -s $lst5 ] ; then
76 echo "# Extra sum files in Dir1=$1"
77 sed -e "s|^|< $1/|" $lst5
78 echo
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010079 exit_status=4
Christophe Lyonbff39612015-11-18 16:29:11 +010080 fi
81 comm -13 $lst3 $lst4 >$lst5
82 if [ -s $lst5 ] ; then
83 echo "# Extra sum files in Dir2=$2"
84 sed -e "s|^|> $2/|" $lst5
85 echo
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010086 exit_status=4
Christophe Lyonbff39612015-11-18 16:29:11 +010087 fi
88 comm -12 $lst3 $lst4 | sort -u >$lst5
89 if [ ! -s $lst5 ] ; then
90 echo "# No common sum files"
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010091 exit_status=3
Christophe Lyonbff39612015-11-18 16:29:11 +010092 exit $exit_status
93 fi
94 cmnsums=`cat $lst5 | wc -l`
95 echo "# Comparing $cmnsums common sum files:"
96 cat $lst5
97 ( for fname in `cat $lst5`; do
98 bname=`basename $fname .sum.xz`
99 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/'
100 done ) >$sum1
101 ( for fname in `cat $lst5`; do
102 bname=`basename $fname .sum.xz`
103 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/'
104 done ) >$sum2
105 if [ "x${target}" != "x" ] ; then
106 unstable_target="--unstable-marker ${target}"
107 fi
108 for sum in $sum1 $sum2; do
109 board="$(grep "Running target " $sum | head -n 1 | sed -e "s/Running target //")"
110 if [ x"$board" != x"" ]; then
111 unstable_target="$unstable_target --unstable-marker $board"
112 fi
113 done
Christophe Lyon19142d72015-11-20 00:13:34 +0100114 ${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 +0100115 ret=$?
Christophe Lyona8755e82015-11-20 00:40:34 +0100116 case $ret in
117 2)
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100118 [ $exit_status -eq 0 ] && exit_status=2
Christophe Lyonbff39612015-11-18 16:29:11 +0100119 echo "# Regressions found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100120 ;;
121 1)
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100122 [ $exit_status -eq 0 ] && exit_status=1
Christophe Lyonbff39612015-11-18 16:29:11 +0100123 echo "# Improvements found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100124 ;;
125 esac
126 if [ $ret -eq 2 ]; then
Christophe Lyonbff39612015-11-18 16:29:11 +0100127 echo "# Regressions in $cmnsums common sum files found"
128 else
129 echo "# No regression found in $cmnsums common sum files"
130 fi
131 exit $exit_status
132elif [ -d "$1" -o -d "$2" ] ; then
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100133 usage "Must specify two directories"
Christophe Lyonbff39612015-11-18 16:29:11 +0100134fi