From patchwork Tue Dec 16 21:43:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 422106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0612E1400DD for ; Wed, 17 Dec 2014 08:43:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=Kj6XzuNHhYIT1gjW 3OYEAjA7FEhZoTwni8PYemRltRhxKYHno/pPxi1YJJq+/EUzntKjUSEHm4t6qPnE L6KAxKQaUpZ+fzNzRKtdFTB5bCKXs97csvodKWviBHaOqAMkLsoOJg7LPxsjoJ02 /tlmDECxnX3uH6R7/Lz0Gppb2Xc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=1fsdwQIRE06k1mFFhYLgCd FGJSc=; b=hx7LTlOQUW4ta6bei/FPdHb0jzhADS2KcWXANkbz4TAa6OedhrVvUG aVbs8EQZzJwu3q1M0Z/TEy/mg8QZ3iawz3OMwoTjDpBV/AOqoDjQR9NkYCjhwoHi 2xMXIUcX4GfBVXWmjFFOUYcpCiv+I7LxzsRTf6+UY7eyo3mGg7BBk= Received: (qmail 17202 invoked by alias); 16 Dec 2014 21:43:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17187 invoked by uid 89); 16 Dec 2014 21:43:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 16 Dec 2014 21:43:36 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBGLhW91020887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 16 Dec 2014 16:43:32 -0500 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBGLhVCm017352 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Tue, 16 Dec 2014 16:43:32 -0500 From: Sergio Durigan Junior To: Mike Stump Cc: GCC Patches Subject: Re: [PATCH] Make dg-extract-results.sh explicitly treat .{sum, log} files as text References: <1418683023-26087-1-git-send-email-sergiodj@redhat.com> <0B13F311-5EC9-4658-86A3-A97A9BD57AFB@comcast.net> X-URL: http://blog.sergiodj.net Date: Tue, 16 Dec 2014 16:43:31 -0500 In-Reply-To: <0B13F311-5EC9-4658-86A3-A97A9BD57AFB@comcast.net> (Mike Stump's message of "Tue, 16 Dec 2014 02:03:07 -0800") Message-ID: <87egrz46f0.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes On Tuesday, December 16 2014, Mike Stump wrote: > So, either, the tool should not generate 0 in the output, which, is rather anti-social, or one should strip the funny characters in a more portable fashion. > > tr and cat -v come to mind; both should be pretty portable. > >> OK to apply? > > Try cat | cat -v in there instead. Thanks, Mike. WDYT of the attached patch? It tries to use "grep --text" if that is available, and falls back to using "cat -v" otherwise. Unfortunately, it is necessary to provide the filenames to grep here: CNT=`$GREP '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` so I couldn't use "cat -v $SUM_FILES" directly. Thanks, diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh index a83c8e8..0ddf25b 100755 --- a/contrib/dg-extract-results.sh +++ b/contrib/dg-extract-results.sh @@ -127,13 +127,28 @@ do done test $ERROR -eq 0 || exit 1 +# Test if grep supports the '--text' option + +GREP=grep + +if echo -e '\x00foo\x00' | $GREP --text foo > /dev/null 2>&1 ; then + GREP="grep --text" +else + # Our grep does not recognize the '--text' option. We have to + # treat our files in order to remove any non-printable character. + for file in $SUM_FILES ; do + mv $file ${file}.orig + cat -v ${file}.orig > $file + done +fi + if [ -z "$TOOL" ]; then # If no tool was specified, all specified summary files must be for # the same tool. - CNT=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` + CNT=`$GREP '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` if [ $CNT -eq 1 ]; then - TOOL=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` + TOOL=`$GREP '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` else msg "${PROGNAME}: sum files are for multiple tools, specify a tool" msg "" @@ -144,7 +159,7 @@ else # Ignore the specified summary files that are not for this tool. This # should keep the relevant files in the same order. - SUM_FILES=`grep -l "=== $TOOL" $SUM_FILES` + SUM_FILES=`$GREP -l "=== $TOOL" $SUM_FILES` if test -z "$SUM_FILES" ; then msg "${PROGNAME}: none of the specified files are results for $TOOL" exit 1 @@ -233,7 +248,7 @@ else VARIANTS="" for VAR in $VARS do - grep "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" + $GREP "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" done fi @@ -435,6 +450,6 @@ cat ${TMP}/var-* | $AWK -f $TOTAL_AWK # This is ugly, but if there's version output from the compiler under test # at the end of the file, we want it. The other thing that might be there # is the final summary counts. -tail -2 $FIRST_SUM | grep '^#' > /dev/null || tail -2 $FIRST_SUM +tail -2 $FIRST_SUM | $GREP '^#' > /dev/null || tail -2 $FIRST_SUM exit 0