From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25608 invoked by alias); 4 Oct 2011 21:37:24 -0000 Received: (qmail 25562 invoked by uid 22791); 4 Oct 2011 21:37:23 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_SV,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Oct 2011 21:37:08 +0000 Received: by gyg8 with SMTP id 8so1076718gyg.20 for ; Tue, 04 Oct 2011 14:37:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.116.19 with SMTP id o19mr1602434ybc.391.1317764227761; Tue, 04 Oct 2011 14:37:07 -0700 (PDT) Received: by 10.150.140.1 with HTTP; Tue, 4 Oct 2011 14:37:07 -0700 (PDT) In-Reply-To: References: Date: Tue, 04 Oct 2011 21:45:00 -0000 Message-ID: Subject: Re: PATCH: Add capability to contrib/compare_tests to handle directories From: Quentin Neill To: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00276.txt.bz2 Ping? On Wed, Sep 7, 2011 at 12:21 PM, Quentin Neill wrote: > Hi, > > Should not change behavior for comparing two files (expect for usage > output), and also should be POSIX compliant. > > Tested on x86_64 tests logs and test directories, would be interested > in help testing on other platforms. > > Ok to commit? > -- > Quentin Neill > > > From 4d4fa9d094745ace0b6e51faadb2f3ea40cb7c7f Mon Sep 17 00:00:00 2001 > From: Quentin Neill > Date: Wed, 7 Sep 2011 12:04:35 -0500 > Subject: [PATCH] Add capability to compare test log directories. > > --- > =A0contrib/ChangeLog =A0 =A0 | =A0 =A04 ++ > =A0contrib/compare_tests | =A0107 +++++++++++++++++++++++++++++++++++++++= +++++----- > =A02 files changed, 101 insertions(+), 10 deletions(-) > > diff --git a/contrib/ChangeLog b/contrib/ChangeLog > index 07adb58..e2007e7 100644 > --- a/contrib/ChangeLog > +++ b/contrib/ChangeLog > @@ -1,3 +1,7 @@ > +2011-09-07 =A0Quentin Neill =A0 > + > + =A0 =A0 =A0 * compare_tests: Add capability to compare test log directo= ries. > + > =A02011-08-25 =A0Rainer Orth =A0 > > =A0 =A0 =A0 =A0* gcc_update: Determine svn branch from hg convert_revisio= n. > diff --git a/contrib/compare_tests b/contrib/compare_tests > index bed9742..b0e3321 100755 > --- a/contrib/compare_tests > +++ b/contrib/compare_tests > @@ -2,13 +2,36 @@ > =A0# This script automatically test the given tool with the tool's test c= ases, > =A0# reporting anything of interest. > > -# exits with 0 if there is nothing of interest > -# exits with 1 if there is something interesting > -# exits with 2 if an error occurred > - > -# Give two .sum files to compare them > +usage() > +{ > + =A0 =A0 =A0 if [ -n "$1" ] ; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "$0: Error: $1" >&2 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo >&2 > + =A0 =A0 =A0 fi > + =A0 =A0 =A0 cat >&2 < +Usage: $0 [-strict] PREVIOUS CURRENT > + > + =A0 =A0 =A0 Compare the PREVIOUS and CURRENT test case logs, reporting = anything > of interest. > + > + =A0 =A0 =A0 If PREVIOUS and CURRENT are directories, find and compare a= ny *.log files > + =A0 =A0 =A0 therein (except config.log files). > + > + =A0 =A0 =A0 Unless -strict is given, these discrepancies are not counte= d as errors: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 missing/extra log files when comparing dire= ctories > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tests that failed in PREVIOUS but pass in C= URRENT > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tests that were not in PREVIOUS but appear = in CURRENT > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 tests in PREVIOUS that are missing in CURRE= NT > + > + =A0 =A0 =A0 Exit with the following values: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 if there is nothing of interest > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 1 if there are errors when comparing single= test case files > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 N for the number of errors found when compa= ring directories > +EOUSAGE > + =A0 =A0 =A0 exit 2 > +} > > =A0# Written by Mike Stump > +# Subdir comparison added by Quentin Neill > > =A0tool=3Dgxx > > @@ -16,10 +39,72 @@ tmp1=3D/tmp/$tool-testing.$$a > =A0tmp2=3D/tmp/$tool-testing.$$b > =A0now_s=3D/tmp/$tool-testing.$$d > =A0before_s=3D/tmp/$tool-testing.$$e > +lst1=3D/tmp/$tool-lst1.$$ > +lst2=3D/tmp/$tool-lst2.$$ > +lst3=3D/tmp/$tool-lst3.$$ > +lst4=3D/tmp/$tool-lst4.$$ > +lst5=3D/tmp/$tool-lst5.$$ > +tmps=3D"$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5" > + > +[ "$1" =3D "-strict" ] && strict=3D$1 && shift > +[ "$1" =3D "-?" ] && usage > +[ "$2" =3D "" ] && usage "Must specify both PREVIOUS and CURRENT" > + > +trap "rm -f $tmps" 0 1 2 3 5 9 13 15 > +exit_status=3D0 > > -if [ "$2" =3D "" ]; then > - =A0 =A0 =A0 echo "Usage: $0 previous current" >&2 > - =A0 =A0 =A0 exit 2 > +if [ -d "$1" -a -d "$2" ] ; then > + =A0 =A0 =A0 find "$1" \( ! -name config.log \) -name '*.log' >$lst1 > + =A0 =A0 =A0 find "$2" \( ! -name config.log \) -name '*.log' >$lst2 > + =A0 =A0 =A0 echo "# Comparing directories" > + =A0 =A0 =A0 echo "## Dir1=3D$1: `cat $lst1 | wc -l` log files" > + =A0 =A0 =A0 echo "## Dir2=3D$2: `cat $lst2 | wc -l` log files" > + =A0 =A0 =A0 echo > + =A0 =A0 =A0 # remove leading directory components to compare > + =A0 =A0 =A0 sed -e "s|^$1/||" $lst1 | sort >$lst3 > + =A0 =A0 =A0 sed -e "s|^$2/||" $lst2 | sort >$lst4 > + =A0 =A0 =A0 comm -23 $lst3 $lst4 >$lst5 > + =A0 =A0 =A0 if [ -s $lst5 ] ; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "# Extra log files in Dir1=3D$1" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sed -e "s|^|< $1/|" $lst5 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 [ -n "$strict" ] && exit_status=3D`expr $ex= it_status + 1` > + =A0 =A0 =A0 fi > + =A0 =A0 =A0 comm -13 $lst3 $lst4 >$lst5 > + =A0 =A0 =A0 if [ -s $lst5 ] ; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "# Extra log files in Dir2=3D$2" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sed -e "s|^|> $2/|" $lst5 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 [ -n "$strict" ] && exit_status=3D`expr $ex= it_status + 1` > + =A0 =A0 =A0 fi > + =A0 =A0 =A0 comm -12 $lst3 $lst4 | sort -u >$lst5 > + =A0 =A0 =A0 if [ ! -s $lst5 ] ; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "# No common log files" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit_status=3D`expr $exit_status + 1` > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit $exit_status > + =A0 =A0 =A0 fi > + =A0 =A0 =A0 cmnlogs=3D`cat $lst5 | wc -l` > + =A0 =A0 =A0 echo "# Comparing $cmnlogs common log files" > + =A0 =A0 =A0 for fname in `cat $lst5` > + =A0 =A0 =A0 do > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 f1=3D"$1/$fname" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 f2=3D"$2/$fname" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "## ${CONFIG_SHELL-/bin/sh} $0 $strict= $f1 $f2" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ${CONFIG_SHELL-/bin/sh} $0 $strict $f1 $f2 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret=3D$? > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ $ret -ne 0 ]; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit_status=3D`expr $exit_s= tatus + 1` > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "## Differences found:= $fname" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fi > + =A0 =A0 =A0 done > + =A0 =A0 =A0 if [ $exit_status -ne 0 ]; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "# $exit_status differences in $cmnlog= s common log files found" > + =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "# No differences found in $cmnlogs co= mmon log files" > + =A0 =A0 =A0 fi > + =A0 =A0 =A0 exit $exit_status > +elif [ -d "$1" -o -d "$2" ] ; then > + =A0 =A0 =A0 usage "Must specify either two directories or two files" > =A0fi > > =A0sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$1" | awk '/^Running target / > {target =3D $3} { if (target !=3D "unix") { sub(/: /, "&"target": " ); }; > print $0; }' >$tmp1 > @@ -28,8 +113,6 @@ sed 's/^XFAIL/FAIL/; s/^XPASS/PASS/' < "$2" | awk > '/^Running target / {target =3D > =A0before=3D$tmp1 > =A0now=3D$tmp2 > > -exit_status=3D0 > -trap "rm -f $tmp1 $tmp2 $now_s $before_s" 0 1 2 3 5 9 13 15 > > =A0if sort -k 2 /dev/null 2>&1; then > =A0 skip1=3D'-k 2' > @@ -60,6 +143,7 @@ if [ $? =3D 0 ]; then > =A0 =A0 =A0 =A0echo "Tests that now work, but didn't before:" > =A0 =A0 =A0 =A0echo > =A0 =A0 =A0 =A0cat $tmp2 > + =A0 =A0 =A0 [ -n "$strict" ] && echo "Strict test fails" && exit_status= =3D1 > =A0 =A0 =A0 =A0echo > =A0fi > > @@ -83,6 +167,7 @@ if [ $? =3D 0 ]; then > =A0 =A0 =A0 =A0echo "New tests that PASS:" > =A0 =A0 =A0 =A0echo > =A0 =A0 =A0 =A0cat $tmp2 > + =A0 =A0 =A0 [ -n "$strict" ] && echo "Strict test fails" && exit_status= =3D1 > =A0 =A0 =A0 =A0echo > =A0fi > > @@ -94,6 +179,7 @@ if [ $? =3D 0 ]; then > =A0 =A0 =A0 =A0echo "Old tests that passed, that have disappeared: (Eeek!= )" > =A0 =A0 =A0 =A0echo > =A0 =A0 =A0 =A0cat $tmp2 > + =A0 =A0 =A0 [ -n "$strict" ] && echo "Strict test fails" && exit_status= =3D1 > =A0 =A0 =A0 =A0echo > =A0fi > > @@ -105,6 +191,7 @@ if [ $? =3D 0 ]; then > =A0 =A0 =A0 =A0echo "Old tests that failed, that have disappeared: (Eeek!= )" > =A0 =A0 =A0 =A0echo > =A0 =A0 =A0 =A0cat $tmp2 > + =A0 =A0 =A0 [ -n "$strict" ] && echo "Strict test fails" && exit_status= =3D1 > =A0 =A0 =A0 =A0echo > =A0fi > > -- > 1.7.1 >