blob: 193c693754fc96b0656fb7aeafb99f1bb6d69a4f [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 Lyon3938b432020-06-30 08:41:29 +000016Usage: $0 [-target target-triplet] [-pass-thresh pass-ratio-threshold] [-compr compression-type] 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
Christophe Lyonca9d8302017-05-22 12:04:00 +000026 -pass-thresh controls the level of warning when too few tests
27 pass.
28
Christophe Lyon3938b432020-06-30 08:41:29 +000029 -compr controls the compression type used when searching for
30 the .sum files. Defaults to xz, use 'none' for uncompressed
31 .sum files.
32
Christophe Lyonbff39612015-11-18 16:29:11 +010033 Exit with the following values:
34 0 if there is nothing of interest
Christophe Lyonf02cb6b2016-01-12 14:32:24 +010035 1 if there are improvements
36 2 if the are regressions or new errors
37 3 if there were build errors (no common logs)
38 4 if there are extra .sum files in either PREVIOUS or
39 CURRENT
Christophe Lyonbff39612015-11-18 16:29:11 +010040EOUSAGE
41 exit 2
42}
43
44export LC_ALL=C
45
46me="`which $0`"
47my_path="`dirname ${me}`"
48
49tool=gxx
50
51tmp1=/tmp/$tool-testing.$$a
52tmp2=/tmp/$tool-testing.$$b
53now_s=/tmp/$tool-testing.$$d
54before_s=/tmp/$tool-testing.$$e
55lst1=/tmp/$tool-lst1.$$
56lst2=/tmp/$tool-lst2.$$
57lst3=/tmp/$tool-lst3.$$
58lst4=/tmp/$tool-lst4.$$
59lst5=/tmp/$tool-lst5.$$
60sum1=/tmp/$tool-sum1.$$
61sum2=/tmp/$tool-sum2.$$
62tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
Christophe Lyon3938b432020-06-30 08:41:29 +000063compr="xz"
64compr_suffix=".xz"
Christophe Lyonbff39612015-11-18 16:29:11 +010065
Christophe Lyonca9d8302017-05-22 12:04:00 +000066while [ $# -gt 2 ]
67do
68 case "$1" in
69 "-target")
70 target=$2
71 shift 2
72 ;;
73 "-pass-thresh")
74 pass_thresh=$2
75 shift 2
76 ;;
Christophe Lyon3938b432020-06-30 08:41:29 +000077 "-compr")
78 compr=$2
79 compr_suffix=".$2"
80 shift 2
81 if [ x"$compr" = xnone ]; then
82 compr=""
83 compr_suffix=""
84 fi
85 ;;
Christophe Lyonca9d8302017-05-22 12:04:00 +000086 "-?")
87 usage
88 ;;
89 *)
90 if [ $# -gt 2 ]; then
91 echo "ERROR: Too many arguments: $@"
92 usage
93 fi
94 ;;
95 esac
96done
97
Christophe Lyonbff39612015-11-18 16:29:11 +010098[ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT"
99
100trap "rm -f $tmps" 0 1 2 3 5 9 13 15
101exit_status=0
102
103if [ -d "$1" -a -d "$2" ] ; then
Christophe Lyon3938b432020-06-30 08:41:29 +0000104 find "$1/" \( -name "*.sum${compr_suffix}" \)>$lst1
105 find "$2/" \( -name "*.sum${compr_suffix}" \)>$lst2
Christophe Lyonbff39612015-11-18 16:29:11 +0100106 echo "# Comparing directories"
107 echo "# REFERENCE: $1"
108 echo "# CURRENT: $2"
109 echo
110 # remove leading directory components to compare
111 sed -e "s|^$1[/]*||" $lst1 | sort >$lst3
112 sed -e "s|^$2[/]*||" $lst2 | sort >$lst4
113 comm -23 $lst3 $lst4 >$lst5
114 if [ -s $lst5 ] ; then
115 echo "# Extra sum files in Dir1=$1"
116 sed -e "s|^|< $1/|" $lst5
117 echo
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100118 exit_status=4
Christophe Lyonbff39612015-11-18 16:29:11 +0100119 fi
120 comm -13 $lst3 $lst4 >$lst5
121 if [ -s $lst5 ] ; then
122 echo "# Extra sum files in Dir2=$2"
123 sed -e "s|^|> $2/|" $lst5
124 echo
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100125 exit_status=4
Christophe Lyonbff39612015-11-18 16:29:11 +0100126 fi
127 comm -12 $lst3 $lst4 | sort -u >$lst5
128 if [ ! -s $lst5 ] ; then
129 echo "# No common sum files"
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100130 exit_status=3
Christophe Lyonbff39612015-11-18 16:29:11 +0100131 exit $exit_status
132 fi
133 cmnsums=`cat $lst5 | wc -l`
134 echo "# Comparing $cmnsums common sum files:"
135 cat $lst5
136 ( for fname in `cat $lst5`; do
Christophe Lyonc63afc92021-07-01 09:52:29 +0000137 ${compr}cat $1/$fname \
138 | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
139 | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|"
Christophe Lyonbff39612015-11-18 16:29:11 +0100140 done ) >$sum1
141 ( for fname in `cat $lst5`; do
Christophe Lyonc63afc92021-07-01 09:52:29 +0000142 ${compr}cat $2/$fname \
143 | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
144 | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|"
Christophe Lyonbff39612015-11-18 16:29:11 +0100145 done ) >$sum2
146 if [ "x${target}" != "x" ] ; then
147 unstable_target="--unstable-marker ${target}"
148 fi
149 for sum in $sum1 $sum2; do
150 board="$(grep "Running target " $sum | head -n 1 | sed -e "s/Running target //")"
151 if [ x"$board" != x"" ]; then
152 unstable_target="$unstable_target --unstable-marker $board"
153 fi
154 done
Christophe Lyon73ac1d82018-06-12 13:32:47 +0000155 ${CONFIG_SHELL-/usr/bin/perl} ${my_path}/compare_dg_tests.pl \
156 ${pass_thresh:+-pass-thresh=${pass_thresh}} -l \
157 --unstable-test=${my_path}/unstable-tests.txt ${unstable_target} \
158 --hwdep-tests=${my_path}/host-hw-dependent-tests.txt $sum1 $sum2
Christophe Lyonbff39612015-11-18 16:29:11 +0100159 ret=$?
Christophe Lyona8755e82015-11-20 00:40:34 +0100160 case $ret in
161 2)
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100162 [ $exit_status -eq 0 ] && exit_status=2
Christophe Lyonbff39612015-11-18 16:29:11 +0100163 echo "# Regressions found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100164 ;;
165 1)
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100166 [ $exit_status -eq 0 ] && exit_status=1
Christophe Lyonbff39612015-11-18 16:29:11 +0100167 echo "# Improvements found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100168 ;;
169 esac
170 if [ $ret -eq 2 ]; then
Christophe Lyonbff39612015-11-18 16:29:11 +0100171 echo "# Regressions in $cmnsums common sum files found"
172 else
173 echo "# No regression found in $cmnsums common sum files"
174 fi
175 exit $exit_status
176elif [ -d "$1" -o -d "$2" ] ; then
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100177 usage "Must specify two directories"
Christophe Lyonbff39612015-11-18 16:29:11 +0100178fi