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 |
| 16 | Usage: $0 [-strict] [-target target-triplet] PREVIOUS CURRENT |
| 17 | |
| 18 | Compare 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 |
| 35 | EOUSAGE |
| 36 | exit 2 |
| 37 | } |
| 38 | |
| 39 | export LC_ALL=C |
| 40 | |
| 41 | me="`which $0`" |
| 42 | my_path="`dirname ${me}`" |
| 43 | |
| 44 | tool=gxx |
| 45 | |
| 46 | tmp1=/tmp/$tool-testing.$$a |
| 47 | tmp2=/tmp/$tool-testing.$$b |
| 48 | now_s=/tmp/$tool-testing.$$d |
| 49 | before_s=/tmp/$tool-testing.$$e |
| 50 | lst1=/tmp/$tool-lst1.$$ |
| 51 | lst2=/tmp/$tool-lst2.$$ |
| 52 | lst3=/tmp/$tool-lst3.$$ |
| 53 | lst4=/tmp/$tool-lst4.$$ |
| 54 | lst5=/tmp/$tool-lst5.$$ |
| 55 | sum1=/tmp/$tool-sum1.$$ |
| 56 | sum2=/tmp/$tool-sum2.$$ |
| 57 | tmps="$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 | |
| 64 | trap "rm -f $tmps" 0 1 2 3 5 9 13 15 |
| 65 | exit_status=0 |
| 66 | |
| 67 | if [ -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` |
Christophe Lyon | a140aa8 | 2015-12-17 22:53:03 +0100 | [diff] [blame^] | 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 | | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 104 | done ) >$sum1 |
| 105 | ( for fname in `cat $lst5`; do |
| 106 | bname=`basename $fname .sum.xz` |
Christophe Lyon | a140aa8 | 2015-12-17 22:53:03 +0100 | [diff] [blame^] | 107 | 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/' \ |
| 108 | | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 109 | done ) >$sum2 |
| 110 | if [ "x${target}" != "x" ] ; then |
| 111 | unstable_target="--unstable-marker ${target}" |
| 112 | fi |
| 113 | for sum in $sum1 $sum2; do |
| 114 | board="$(grep "Running target " $sum | head -n 1 | sed -e "s/Running target //")" |
| 115 | if [ x"$board" != x"" ]; then |
| 116 | unstable_target="$unstable_target --unstable-marker $board" |
| 117 | fi |
| 118 | done |
Christophe Lyon | 19142d7 | 2015-11-20 00:13:34 +0100 | [diff] [blame] | 119 | ${CONFIG_SHELL-/usr/bin/perl} ${my_path}/compare_dg_tests.pl -l --unstable-test=${my_path}/unstable-tests.txt ${unstable_target} $sum1 $sum2 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 120 | ret=$? |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 121 | case $ret in |
| 122 | 2) |
| 123 | exit_status=`expr $exit_status + 2` |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 124 | echo "# Regressions found" |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 125 | ;; |
| 126 | 1) |
| 127 | exit_status=`expr $exit_status + 1` |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 128 | echo "# Improvements found" |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 129 | ;; |
| 130 | esac |
| 131 | if [ $ret -eq 2 ]; then |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 132 | echo "# Regressions in $cmnsums common sum files found" |
| 133 | else |
| 134 | echo "# No regression found in $cmnsums common sum files" |
| 135 | fi |
| 136 | exit $exit_status |
| 137 | elif [ -d "$1" -o -d "$2" ] ; then |
| 138 | usage "Must specify either two directories or two files" |
| 139 | fi |