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 | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 16 | Usage: $0 [-target target-triplet] 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 | |
| 26 | Exit with the following values: |
| 27 | 0 if there is nothing of interest |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 28 | 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 Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 33 | EOUSAGE |
| 34 | exit 2 |
| 35 | } |
| 36 | |
| 37 | export LC_ALL=C |
| 38 | |
| 39 | me="`which $0`" |
| 40 | my_path="`dirname ${me}`" |
| 41 | |
| 42 | tool=gxx |
| 43 | |
| 44 | tmp1=/tmp/$tool-testing.$$a |
| 45 | tmp2=/tmp/$tool-testing.$$b |
| 46 | now_s=/tmp/$tool-testing.$$d |
| 47 | before_s=/tmp/$tool-testing.$$e |
| 48 | lst1=/tmp/$tool-lst1.$$ |
| 49 | lst2=/tmp/$tool-lst2.$$ |
| 50 | lst3=/tmp/$tool-lst3.$$ |
| 51 | lst4=/tmp/$tool-lst4.$$ |
| 52 | lst5=/tmp/$tool-lst5.$$ |
| 53 | sum1=/tmp/$tool-sum1.$$ |
| 54 | sum2=/tmp/$tool-sum2.$$ |
| 55 | tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2" |
| 56 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 57 | [ "$1" = "-target" ] && target=$2 && shift 2 |
| 58 | [ "$1" = "-?" ] && usage |
| 59 | [ "$2" = "" ] && usage "Must specify both PREVIOUS and CURRENT" |
| 60 | |
| 61 | trap "rm -f $tmps" 0 1 2 3 5 9 13 15 |
| 62 | exit_status=0 |
| 63 | |
| 64 | if [ -d "$1" -a -d "$2" ] ; then |
Yvan Roux | 8e7c706 | 2016-01-25 17:36:51 +0100 | [diff] [blame] | 65 | find "$1/" \( -name '*.sum.xz' \)>$lst1 |
| 66 | find "$2/" \( -name '*.sum.xz' \)>$lst2 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 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 Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 79 | exit_status=4 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 80 | 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 Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 86 | exit_status=4 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 87 | fi |
| 88 | comm -12 $lst3 $lst4 | sort -u >$lst5 |
| 89 | if [ ! -s $lst5 ] ; then |
| 90 | echo "# No common sum files" |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 91 | exit_status=3 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 92 | 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` |
Christophe Lyon | a140aa8 | 2015-12-17 22:53:03 +0100 | [diff] [blame] | 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 | | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 101 | done ) >$sum1 |
| 102 | ( for fname in `cat $lst5`; do |
| 103 | bname=`basename $fname .sum.xz` |
Christophe Lyon | a140aa8 | 2015-12-17 22:53:03 +0100 | [diff] [blame] | 104 | 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/' \ |
| 105 | | sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 106 | done ) >$sum2 |
| 107 | if [ "x${target}" != "x" ] ; then |
| 108 | unstable_target="--unstable-marker ${target}" |
| 109 | fi |
| 110 | for sum in $sum1 $sum2; do |
| 111 | board="$(grep "Running target " $sum | head -n 1 | sed -e "s/Running target //")" |
| 112 | if [ x"$board" != x"" ]; then |
| 113 | unstable_target="$unstable_target --unstable-marker $board" |
| 114 | fi |
| 115 | done |
Christophe Lyon | 19142d7 | 2015-11-20 00:13:34 +0100 | [diff] [blame] | 116 | ${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] | 117 | ret=$? |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 118 | case $ret in |
| 119 | 2) |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 120 | [ $exit_status -eq 0 ] && exit_status=2 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 121 | echo "# Regressions found" |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 122 | ;; |
| 123 | 1) |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 124 | [ $exit_status -eq 0 ] && exit_status=1 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 125 | echo "# Improvements found" |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 126 | ;; |
| 127 | esac |
| 128 | if [ $ret -eq 2 ]; then |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 129 | echo "# Regressions in $cmnsums common sum files found" |
| 130 | else |
| 131 | echo "# No regression found in $cmnsums common sum files" |
| 132 | fi |
| 133 | exit $exit_status |
| 134 | elif [ -d "$1" -o -d "$2" ] ; then |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 135 | usage "Must specify two directories" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 136 | fi |