Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 1 | #!/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> |
| 9 | usage() |
| 10 | { |
| 11 | if [ -n "$1" ] ; then |
| 12 | echo "$0: Error: $1" >&2 |
| 13 | echo >&2 |
| 14 | fi |
| 15 | cat >&2 <<EOUSAGE |
Christophe Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 16 | Usage: $0 [-target target-triplet] [-pass-thresh pass-ratio-threshold] [-compr compression-type] PREVIOUS CURRENT |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 17 | |
| 18 | Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest. |
| 19 | |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 20 | PREVIOUS and CURRENT must be directories, this tool finds and |
| 21 | compares any *.sum files they contain. |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 22 | |
| 23 | -target enables to provide the target name to use when parsing |
| 24 | the file containing the list of unstable tests. |
| 25 | |
Christophe Lyon | ca9d830 | 2017-05-22 12:04:00 +0000 | [diff] [blame] | 26 | -pass-thresh controls the level of warning when too few tests |
| 27 | pass. |
| 28 | |
Christophe Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 29 | -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 Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 33 | Exit with the following values: |
| 34 | 0 if there is nothing of interest |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 35 | 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 Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 40 | EOUSAGE |
| 41 | exit 2 |
| 42 | } |
| 43 | |
| 44 | export LC_ALL=C |
| 45 | |
| 46 | me="`which $0`" |
| 47 | my_path="`dirname ${me}`" |
| 48 | |
| 49 | tool=gxx |
| 50 | |
| 51 | tmp1=/tmp/$tool-testing.$$a |
| 52 | tmp2=/tmp/$tool-testing.$$b |
| 53 | now_s=/tmp/$tool-testing.$$d |
| 54 | before_s=/tmp/$tool-testing.$$e |
| 55 | lst1=/tmp/$tool-lst1.$$ |
| 56 | lst2=/tmp/$tool-lst2.$$ |
| 57 | lst3=/tmp/$tool-lst3.$$ |
| 58 | lst4=/tmp/$tool-lst4.$$ |
| 59 | lst5=/tmp/$tool-lst5.$$ |
| 60 | sum1=/tmp/$tool-sum1.$$ |
| 61 | sum2=/tmp/$tool-sum2.$$ |
| 62 | tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2" |
Christophe Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 63 | compr="xz" |
| 64 | compr_suffix=".xz" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 65 | |
Christophe Lyon | ca9d830 | 2017-05-22 12:04:00 +0000 | [diff] [blame] | 66 | while [ $# -gt 2 ] |
| 67 | do |
| 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 Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 77 | "-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 Lyon | ca9d830 | 2017-05-22 12:04:00 +0000 | [diff] [blame] | 86 | "-?") |
| 87 | usage |
| 88 | ;; |
| 89 | *) |
| 90 | if [ $# -gt 2 ]; then |
| 91 | echo "ERROR: Too many arguments: $@" |
| 92 | usage |
| 93 | fi |
| 94 | ;; |
| 95 | esac |
| 96 | done |
| 97 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 98 | [ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT" |
| 99 | |
| 100 | trap "rm -f $tmps" 0 1 2 3 5 9 13 15 |
| 101 | exit_status=0 |
| 102 | |
| 103 | if [ -d "$1" -a -d "$2" ] ; then |
Christophe Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 104 | find "$1/" \( -name "*.sum${compr_suffix}" \)>$lst1 |
| 105 | find "$2/" \( -name "*.sum${compr_suffix}" \)>$lst2 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 106 | 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 Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 118 | exit_status=4 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 119 | 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 Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 125 | exit_status=4 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 126 | fi |
| 127 | comm -12 $lst3 $lst4 | sort -u >$lst5 |
| 128 | if [ ! -s $lst5 ] ; then |
| 129 | echo "# No common sum files" |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 130 | exit_status=3 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 131 | 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 Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 137 | bname=`basename $fname .sum${compr_suffix}` |
| 138 | ${compr}cat $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/' \ |
Christophe Lyon | a140aa8 | 2015-12-17 22:53:03 +0100 | [diff] [blame] | 139 | | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 140 | done ) >$sum1 |
| 141 | ( for fname in `cat $lst5`; do |
Christophe Lyon | 3938b43 | 2020-06-30 08:41:29 +0000 | [diff] [blame] | 142 | bname=`basename $fname .sum${compr_suffix}` |
| 143 | ${compr}cat $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/' \ |
Christophe Lyon | a140aa8 | 2015-12-17 22:53:03 +0100 | [diff] [blame] | 144 | | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 145 | 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 Lyon | 73ac1d8 | 2018-06-12 13:32:47 +0000 | [diff] [blame] | 155 | ${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 Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 159 | ret=$? |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 160 | case $ret in |
| 161 | 2) |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 162 | [ $exit_status -eq 0 ] && exit_status=2 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 163 | echo "# Regressions found" |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 164 | ;; |
| 165 | 1) |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 166 | [ $exit_status -eq 0 ] && exit_status=1 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 167 | echo "# Improvements found" |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 168 | ;; |
| 169 | esac |
| 170 | if [ $ret -eq 2 ]; then |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 171 | 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 |
| 176 | elif [ -d "$1" -o -d "$2" ] ; then |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 177 | usage "Must specify two directories" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 178 | fi |