From patchwork Thu Dec 10 14:56:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 555164 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 D9014140213 for ; Fri, 11 Dec 2015 01:37:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rODGjFfz; dkim-atps=neutral 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:date:message-id; q=dns; s=default; b=g3Lxy8uNilcQ RRuRkz7pN7kzVNY+GE/H5ccT3+6tEstO+WHOcZiv/MMWp+OjKtkfn2qbVvRImS9p CY6klC+ORzzabMEcrCd3ua8sdWsmoSa5TQrnCaDEWG8GH+QceZwCKO/vG0VQgOTX Xx9sYjTTTgZ8s4kt7qfdvxDYQV3yd64= 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:date:message-id; s=default; bh=td/hHhnaFEV2135JqQ b0vD864aQ=; b=rODGjFfziwJYjuPJh49oAqD37f5qAdepWU2FBISmCj/dvnHuBc HuWbbsqNo6FGKdpPjShQWK/p+HbohNFEBc0zEsTkNlya9L2gJ4f3UVZnCL6EgVQa 8e8J2/pEgUzfbD4IOU7bt6FlTjNf9/p2j8Kr7y+FMcGoTqKCeAZMtCHOk= Received: (qmail 71703 invoked by alias); 10 Dec 2015 14:37:03 -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 71687 invoked by uid 89); 10 Dec 2015 14:37:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_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; Thu, 10 Dec 2015 14:37:01 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2D502C001242 for ; Thu, 10 Dec 2015 14:37:00 +0000 (UTC) Received: from c64.redhat.com (vpn-236-116.phx2.redhat.com [10.3.236.116]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBAEax5i012585; Thu, 10 Dec 2015 09:36:59 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] testsuite/lib/multline.exp: show test name and line numbers Date: Thu, 10 Dec 2015 09:56:15 -0500 Message-Id: <1449759375-31396-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes The output from multiline.exp doesn't scale well when reviewing and comparing .sum files. Lines in e.g. gcc.sum from a dg-{begin|end}-multiline-output pair are currently of the form: PASS: expected multiline pattern 0 was found: "\s*myvar = myvar\.x;.*\n ~~~~~\^~\n" as compared to e.g. this result line for a dg-warning: PASS: gcc.dg/plugin/diagnostic-test-show-locus-bw.c -fplugin=./diagnostic_plugin_test_show_locus.so (test for warnings, line 198) In particular the line doesn't identify the filename/options of the test, which means in a .sum file with a FAIL of one of these we can't easily locate the testcase of interest. The following patch updates multiline.exp to use the global $testname_with_flags as a prefix in such results. I also dropped the printing of the index in favor of printing the line numbers enclosed within dg-{begin|end}-multiline-output. After the patch, we get result lines like this: PASS: gcc.dg/plugin/diagnostic-test-show-locus-bw.c -fplugin=./diagnostic_plugin_test_show_locus.so expected multiline pattern lines 17-18 was found: "\s*myvar = myvar\.x;.*\n ~~~~~\^~\n" (note the presence of the source file and options and the "lines 17-18") Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu; I compared the results against a control build (of r231445), and the results were unchanged, other than the expected changes from the above, leading to - 92 PASS results changing name within g++.sum - 7 PASS results changing name within each of obj-c++.sum and objc.sum, and - 125 PASS results changing name within gcc.sum. OK for trunk for gcc 6? gcc/testsuite/ChangeLog: * lib/multiline.exp (_multiline_expected_outputs): Update comment. (dg-end-multiline-output): Capture line numbers within _multiline_expected_outputs. (handle-multiline-outputs): Access global $testname_with_flags and add it as a prefix to pass/fail results. Extract line numbers from $_multiline_expected_outputs and print them within pass/fail results, replacing the printing of $index. Consolidate the string prefix shared between pass/fail into a new local: $title. --- gcc/testsuite/lib/multiline.exp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp index c3d0506..5367437 100644 --- a/gcc/testsuite/lib/multiline.exp +++ b/gcc/testsuite/lib/multiline.exp @@ -54,7 +54,9 @@ # The line number of the last dg-begin-multiline-output directive. set _multiline_last_beginning_line -1 -# A list of lists of strings. +# A list of +# first-line-number, last-line-number, lines +# where each "lines" is a list of strings. set _multiline_expected_outputs [] ############################################################################ @@ -88,12 +90,15 @@ proc dg-end-multiline-output { args } { # Load it and split it into lines set lines [_get_lines $prog $_multiline_last_beginning_line $line] - set _multiline_last_beginning_line -1 verbose "lines: $lines" 3 + # Create an entry of the form: first-line, last-line, lines + set entry [list $_multiline_last_beginning_line $line $lines] global _multiline_expected_outputs - lappend _multiline_expected_outputs $lines + lappend _multiline_expected_outputs $entry verbose "within dg-end-multiline-output: _multiline_expected_outputs: $_multiline_expected_outputs" 3 + + set _multiline_last_beginning_line -1 } # Hook to be called by prune.exp's prune_gcc_output to @@ -107,9 +112,14 @@ proc dg-end-multiline-output { args } { proc handle-multiline-outputs { text } { global _multiline_expected_outputs + global testname_with_flags set index 0 - foreach multiline $_multiline_expected_outputs { - verbose " multiline: $multiline" 4 + foreach entry $_multiline_expected_outputs { + verbose " entry: $entry" 3 + set start_line [lindex $entry 0] + set end_line [lindex $entry 1] + set multiline [lindex $entry 2] + verbose " multiline: $multiline" 3 set rexp [_build_multiline_regex $multiline $index] verbose "rexp: ${rexp}" 4 # Escape newlines in $rexp so that we can print them in @@ -117,12 +127,14 @@ proc handle-multiline-outputs { text } { set escaped_regex [string map {"\n" "\\n"} $rexp] verbose "escaped_regex: ${escaped_regex}" 4 + set title "$testname_with_flags expected multiline pattern lines $start_line-$end_line" + # Use "regsub" to attempt to prune the pattern from $text if {[regsub -line $rexp $text "" text]} { # Success; the multiline pattern was pruned. - pass "expected multiline pattern $index was found: \"$escaped_regex\"" + pass "$title was found: \"$escaped_regex\"" } else { - fail "expected multiline pattern $index not found: \"$escaped_regex\"" + fail "$title not found: \"$escaped_regex\"" } set index [expr $index + 1]