blob: 27acaf67f6de76c37800e2d53ae2cd08f5c8665e [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 Lyon8823eeb2025-04-07 15:40:22 +000086 "-flaky-tests")
87 flaky_tests=$2
88 shift 2
89 ;;
Christophe Lyonca9d8302017-05-22 12:04:00 +000090 "-?")
91 usage
92 ;;
93 *)
94 if [ $# -gt 2 ]; then
95 echo "ERROR: Too many arguments: $@"
96 usage
97 fi
98 ;;
99 esac
100done
101
Christophe Lyonbff39612015-11-18 16:29:11 +0100102[ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT"
103
104trap "rm -f $tmps" 0 1 2 3 5 9 13 15
105exit_status=0
106
107if [ -d "$1" -a -d "$2" ] ; then
Christophe Lyon3938b432020-06-30 08:41:29 +0000108 find "$1/" \( -name "*.sum${compr_suffix}" \)>$lst1
109 find "$2/" \( -name "*.sum${compr_suffix}" \)>$lst2
Christophe Lyonbff39612015-11-18 16:29:11 +0100110 echo "# Comparing directories"
111 echo "# REFERENCE: $1"
112 echo "# CURRENT: $2"
113 echo
114 # remove leading directory components to compare
115 sed -e "s|^$1[/]*||" $lst1 | sort >$lst3
116 sed -e "s|^$2[/]*||" $lst2 | sort >$lst4
117 comm -23 $lst3 $lst4 >$lst5
118 if [ -s $lst5 ] ; then
119 echo "# Extra sum files in Dir1=$1"
120 sed -e "s|^|< $1/|" $lst5
121 echo
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100122 exit_status=4
Christophe Lyonbff39612015-11-18 16:29:11 +0100123 fi
124 comm -13 $lst3 $lst4 >$lst5
125 if [ -s $lst5 ] ; then
126 echo "# Extra sum files in Dir2=$2"
127 sed -e "s|^|> $2/|" $lst5
128 echo
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100129 exit_status=4
Christophe Lyonbff39612015-11-18 16:29:11 +0100130 fi
131 comm -12 $lst3 $lst4 | sort -u >$lst5
132 if [ ! -s $lst5 ] ; then
133 echo "# No common sum files"
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100134 exit_status=3
Christophe Lyonbff39612015-11-18 16:29:11 +0100135 exit $exit_status
136 fi
137 cmnsums=`cat $lst5 | wc -l`
138 echo "# Comparing $cmnsums common sum files:"
139 cat $lst5
140 ( for fname in `cat $lst5`; do
Christophe Lyonc63afc92021-07-01 09:52:29 +0000141 ${compr}cat $1/$fname \
142 | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
143 | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|"
Christophe Lyonbff39612015-11-18 16:29:11 +0100144 done ) >$sum1
145 ( for fname in `cat $lst5`; do
Christophe Lyonc63afc92021-07-01 09:52:29 +0000146 ${compr}cat $2/$fname \
147 | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
148 | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|"
Christophe Lyonbff39612015-11-18 16:29:11 +0100149 done ) >$sum2
150 if [ "x${target}" != "x" ] ; then
151 unstable_target="--unstable-marker ${target}"
152 fi
153 for sum in $sum1 $sum2; do
154 board="$(grep "Running target " $sum | head -n 1 | sed -e "s/Running target //")"
155 if [ x"$board" != x"" ]; then
156 unstable_target="$unstable_target --unstable-marker $board"
157 fi
158 done
Christophe Lyon73ac1d82018-06-12 13:32:47 +0000159 ${CONFIG_SHELL-/usr/bin/perl} ${my_path}/compare_dg_tests.pl \
Christophe Lyon8823eeb2025-04-07 15:40:22 +0000160 -l \
161 ${pass_thresh:+-pass-thresh=${pass_thresh}} \
162 ${flaky_tests:+-flaky-tests=${flaky_tests}} \
163 --unstable-test=${my_path}/unstable-tests.txt \
164 ${unstable_target} \
165 --hwdep-tests=${my_path}/host-hw-dependent-tests.txt \
166 $sum1 $sum2
Christophe Lyonbff39612015-11-18 16:29:11 +0100167 ret=$?
Christophe Lyona8755e82015-11-20 00:40:34 +0100168 case $ret in
169 2)
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100170 [ $exit_status -eq 0 ] && exit_status=2
Christophe Lyonbff39612015-11-18 16:29:11 +0100171 echo "# Regressions found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100172 ;;
173 1)
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100174 [ $exit_status -eq 0 ] && exit_status=1
Christophe Lyonbff39612015-11-18 16:29:11 +0100175 echo "# Improvements found"
Christophe Lyona8755e82015-11-20 00:40:34 +0100176 ;;
177 esac
178 if [ $ret -eq 2 ]; then
Christophe Lyonbff39612015-11-18 16:29:11 +0100179 echo "# Regressions in $cmnsums common sum files found"
180 else
181 echo "# No regression found in $cmnsums common sum files"
182 fi
183 exit $exit_status
184elif [ -d "$1" -o -d "$2" ] ; then
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100185 usage "Must specify two directories"
Christophe Lyonbff39612015-11-18 16:29:11 +0100186fi