From patchwork Fri May 15 10:31:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederik Harwath X-Patchwork-Id: 1291014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Nl8q53Rmz9sTC for ; Fri, 15 May 2020 20:32:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35271397A4BA; Fri, 15 May 2020 10:32:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 5D29C3851C25 for ; Fri, 15 May 2020 10:32:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5D29C3851C25 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Frederik_Harwath@mentor.com IronPort-SDR: h/xL1B0rwxDa6ZFk/CYbXSryIVcIIdPtR+Lv4DhGlQfJNwQnLZCjxX8xUzqAGUQ48niwjhv6z8 ClHZ5cmOiMNpCSAkKbeYBqdiynwLxfoGxRReF9yD5Cd2amY3BMwxaXrhdxJK+2cDltSsoqipEd AQiAXzE4SVQBygmV3SJ0f53fYbQ2kp3KRO8uNsBGCiquDVrPHcSSrD4YGbm3XXztetv52Nu5u5 KpwQidx5ycuai9UmQ8TP+NS/Rpr426k0fTJU62kKx9fbwO+BB+8QKYZOBS+oJBw2CgT0CpaUe8 orM= X-IronPort-AV: E=Sophos;i="5.73,394,1583222400"; d="scan'208,223";a="48814865" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 15 May 2020 02:32:00 -0800 IronPort-SDR: v2J6dp8ynKYKfElWgC6XdockQSV/jyYF8rchQH2m4UsT0E4UK9uMCcwC/+cPi7kF9WdUrhluwe 146W9GA+xASR2yZWl7aYilC3zcD11GUPY9vEOkPR6SnTIm4Jr2O6mw8PPi7dmSWXfHA/iXbktW RIXkRicfvU4tvpxWX0uHhcjArpxvSmd1X3X9kBj7SMG8HnR6DdVsGAKp7SadH3D7XyOegIS4Jf 2vTuCN45Slz77FKNO5iSIqsZtnliBLkjYu6MsYh1RKAqvkdAlsGOKYgKObg0PhogakPCyhg2AE 81g= From: Frederik Harwath To: , , Subject: testsuite: clarify scan-dump file globbing behavior Date: Fri, 15 May 2020 12:31:54 +0200 Message-ID: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Schwinge Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, The test commands for scanning optimization dump files perform globbing on the argument that specifies the suffix of the dump files to be scanned. This behavior is currently undocumented. Furthermore, the current implementation of "scan-dump" and related procedures yields an error whenever the file name globbing matches more than one file (due to an attempt to call "open" on multiple files) while a failure to match any file at all results in an unresolved test. This patch documents the globbing behavior. The dump scanning procedures are changed to make the test unresolved if globbing matches more than one file. The procedures in scandump.exp all perform the file name expansion in essentially the same way and I have extracted this into a new procedure. But there is one very minor exception: > @@ -67,10 +95,10 @@ proc scan-dump { args } { > set dumpbase [dump-base $src [lindex $args 3]] > - set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]" > + > + set pattern "$dumpbase.[lindex $args 2]" > + set output_file "[glob-dump-file $testcase $pattern]" > if { $output_file == "" } { > - verbose -log "$testcase: dump file does not exist" > - verbose -log "dump file: $dumpbase.$suf" "scan-dump" is the only procedure that prints the "dump file: ..." line. Should this be kept or is it ok to remove this as I have done in the patch? $dumpbase.$suf does not emit the correct file name anyway (a random example from my testing: "dump file: stdatomic-init.c.dce*") and the name of the files can be inferred from the test name easily. I have tested the changes by running "make check" (with a --enable-languages=C only build, but this covers lots of uses of the affected test procedures) and observed no regressions. Ok to commit this to master? Best regards, Frederik ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter From 6912e03d51d360dbbcf7eb1dc8d77d08c2a6e54c Mon Sep 17 00:00:00 2001 From: Frederik Harwath Date: Fri, 15 May 2020 10:35:48 +0200 Subject: [PATCH] testsuite: clarify scan-dump file globbing behavior The test commands for scanning optimization dump files perform globbing on the argument that specifies the suffix of the dump files to be scanned. This behavior is currently undocumented. Furthermore, the current implementation of "scan-dump" and similar procedures yields an error whenever the file name globbing matches more than one file (due to an attempt to call "open" on multiple files) while a failure to match any file results in an unresolved test. This commit documents the globbing behavior. The dump scanning procedures are changed to make the test unresolved if globbing matches more than one file. gcc/ChangeLog: 2020-05-15 Frederik Harwath * doc/sourcebuild.texi: Describe globbing of the dump file scanning commands "suffix" argument. gcc/testsuite/ChangeLog: 2020-05-15 Frederik Harwath * lib/scandump.exp (glob-dump-file): New proc. (scan-dump): Use glob-dump-file for file name expansion. (scan-dump-times): Likewise. (scan-dump-dem): Likewise. (scan-dump-dem-not): Likewise. --- gcc/doc/sourcebuild.texi | 4 ++- gcc/testsuite/lib/scandump.exp | 54 +++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 240d6e4b08e..b6c5a21cb71 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2888,7 +2888,9 @@ stands for zero or more unmatched lines; the whitespace after These commands are available for @var{kind} of @code{tree}, @code{ltrans-tree}, @code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa}, and -@code{wpa-ipa}. +@code{wpa-ipa}. The @var{suffix} argument which describes the dump file +to be scanned may contain a glob pattern that must expand to exactly one +file name. @table @code @item scan-@var{kind}-dump @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}] diff --git a/gcc/testsuite/lib/scandump.exp b/gcc/testsuite/lib/scandump.exp index d6ba350acc8..f3a991b590a 100644 --- a/gcc/testsuite/lib/scandump.exp +++ b/gcc/testsuite/lib/scandump.exp @@ -39,6 +39,34 @@ proc dump-base { args } { return $dumpbase } +# Expand dump file name pattern to exactly one file. +# Return a single dump file name or an empty string +# if the pattern matches no file or more than one file. +# +# Argument 0 is the testcase name +# Argument 1 is the dump file glob pattern +proc glob-dump-file { args } { + + set pattern [lindex $args 1] + set dump_file "[glob -nocomplain $pattern]" + set num_files [llength $dump_file] + + if { $num_files != 1 } { + set testcase [lindex $args 0] + if { $num_files == 0 } { + verbose -log "$testcase: dump file does not exist" + } + + if { $num_files > 1 } { + verbose -log "$testcase: multiple dump files found" + } + + return + } + + return $dump_file +} + # Utility for scanning compiler result, invoked via dg-final. # Call pass if pattern is present, otherwise fail. # @@ -67,10 +95,10 @@ proc scan-dump { args } { set testname "$testcase scan-[lindex $args 0]-dump $suf \"$printable_pattern\"" set src [file tail $filename] set dumpbase [dump-base $src [lindex $args 3]] - set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]" + + set pattern "$dumpbase.[lindex $args 2]" + set output_file "[glob-dump-file $testcase $pattern]" if { $output_file == "" } { - verbose -log "$testcase: dump file does not exist" - verbose -log "dump file: $dumpbase.$suf" unresolved "$testname" return } @@ -113,9 +141,10 @@ proc scan-dump-times { args } { set testname "$testcase scan-[lindex $args 0]-dump-times $suf \"$printable_pattern\" [lindex $args 2]" set src [file tail $filename] set dumpbase [dump-base $src [lindex $args 4]] - set output_file "[glob -nocomplain $dumpbase.[lindex $args 3]]" + + set pattern "$dumpbase.[lindex $args 3]" + set output_file "[glob-dump-file $testcase $pattern]" if { $output_file == "" } { - verbose -log "$testcase: dump file does not exist" unresolved "$testname" return } @@ -159,9 +188,10 @@ proc scan-dump-not { args } { set testname "$testcase scan-[lindex $args 0]-dump-not $suf \"$printable_pattern\"" set src [file tail $filename] set dumpbase [dump-base $src [lindex $args 3]] - set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]" + + set pattern "$dumpbase.[lindex $args 2]" + set output_file "[glob-dump-file $testcase $pattern]" if { $output_file == "" } { - verbose -log "$testcase: dump file does not exist" unresolved "$testname" return } @@ -216,9 +246,10 @@ proc scan-dump-dem { args } { set testname "$testcase scan-[lindex $args 0]-dump-dem $suf \"$printable_pattern\"" set src [file tail $filename] set dumpbase [dump-base $src [lindex $args 3]] - set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]" + + set pattern "$dumpbase.[lindex $args 2]" + set output_file "[glob-dump-file $testcase $pattern]" if { $output_file == "" } { - verbose -log "$testcase: dump file does not exist" unresolved "$testname" return } @@ -272,9 +303,10 @@ proc scan-dump-dem-not { args } { set testname "$testcase scan-[lindex $args 0]-dump-dem-not $suf \"$printable_pattern\"" set src [file tail $filename] set dumpbase [dump-base $src [lindex $args 3]] - set output_file "[glob -nocomplain $dumpbase.[lindex $args 2]]" + + set pattern "$dumpbase.[lindex $args 2]" + set output_file "[glob-dump-file $testcase $pattern]" if { $output_file == "" } { - verbose -log "$testcase: dump file does not exist" unresolved "$testname" return } -- 2.17.1