From patchwork Tue Sep 24 06:21:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 1988779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axis.com header.i=@axis.com header.a=rsa-sha256 header.s=selector1 header.b=WkqDgluO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XCVBg1kFKz1xst for ; Tue, 24 Sep 2024 16:22:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF012385C6E1 for ; Tue, 24 Sep 2024 06:22:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on20608.outbound.protection.outlook.com [IPv6:2a01:111:f403:2607::608]) by sourceware.org (Postfix) with ESMTPS id AAD563858D39; Tue, 24 Sep 2024 06:21:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AAD563858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AAD563858D39 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2607::608 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1727158896; cv=pass; b=U6dYRn/I8wKdfAxBDRhg83HTcTYI3mZGjD+NkdHI3n3dooVnl5yGbZHVr+bHJM4HRkHwjD4GZ2XqC28aP2m+I7CrCSiNc7EfT4Y+9a+8xbV7DnTT5w143ARG29nnBih1o8ZvUhPsnPT+4U1mdEmRiDlnFpedSaskqdwx80qPCdA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1727158896; c=relaxed/simple; bh=YVoGgrBRCOTRFsAzmScOSDfq/lc4yly/Tq8kFchDdWs=; h=DKIM-Signature:From:To:Subject:MIME-Version:Message-ID:Date; b=WukcuVDEPmRTM15Y0eAxVjhZfUBtBTHRO/ClnZGVBHTy0k6d0cq/dri7cBpyU4K33ExPWQqPN6hfv/BkAJjG9VEzVEe4YfTOuIdKkho1di8hyyxrrbR+CElsCYqLc1Tuy/SumsMfKuk94m52VuS5QC2fGDNRsjiEj7x7Yfw9VuE= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LljwOJoEJCemG/JJQ/QTZTXPhGIgTCK6f06j+v75o+0n6SE7WVFxULqSTfVLKcTz3bhN04qtblYB1u9Cx1YlM9x8xjdpnMkKlyTPbpuq+tK6D3Bq1rwJQgAn+vMTm3OT8p8A/b0cPuyQkZYtd2tBuOvt1fL99/v+drxYPF7mi8PgDhGDahACeScrfquuQBZG0b6ON2DkX0fCdWrvwJk3KwkJWAWF17ia3ZjAEfx90zf+T55DQ8TLBhBpTCL74MyY85eiwmDwqBbvIRW6zFuIkoVdyxU8gUehmNXJX/Vul+TI5A84isDtmXPIJRfLls665mdKbqkbnUgLbIDOEj8kwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dxRP4yb1HdxR8PnaCzJefBpYkuXz52wL1UUmXpXhHZU=; b=fj/WOZDilwlQfgr/BVAIUnMXU5PL3/o8FSGpf1wW1wV3b6Mss+yk6IXkB4QsLrXnssgTVxwGE+DIl4lMRJRFrQw8Hx3M4JUlZl41xpGtumSMnA485FlsZmULStSh4oA9fnnwXFzu2IiGES3nDdnzkZgybpc9JscIbPcHpSJbqlUruL0+Fh9k2WdQY7j3VxeKBigxeViQbJxknewgtHobSAtPpY67R0MuNv9CoZayADg03FqCMzCOIS0MnB7g61YFkaW4z+G7PMPZ3vX+aa54+gksjJcRCvi9GxMc711pP1jc+diOv3CyTT4otu4u5peugvhfoApHG8a2wwE4DSghbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dxRP4yb1HdxR8PnaCzJefBpYkuXz52wL1UUmXpXhHZU=; b=WkqDgluO8S6wg5PvtksGon+DA6VKlbU2lSHbXps7nf1cTxPaNBO2ZMtKaZkTENu10X2jRM0RoEjlG/c87u7cRgJD0a/zQ77xNkDjpe+a3ZT0+cBnX/IwM4AI5CfhhT8NLDwkNHwz6V1LjtqHbgjl5TnwkZW93W2E7j8pP+8pT3k= Received: from DUZPR01CA0286.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::12) by PR3PR02MB6492.eurprd02.prod.outlook.com (2603:10a6:102:73::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Tue, 24 Sep 2024 06:21:23 +0000 Received: from DB1PEPF000509F1.eurprd03.prod.outlook.com (2603:10a6:10:4b7:cafe::53) by DUZPR01CA0286.outlook.office365.com (2603:10a6:10:4b7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27 via Frontend Transport; Tue, 24 Sep 2024 06:21:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by DB1PEPF000509F1.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Tue, 24 Sep 2024 06:21:21 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 24 Sep 2024 08:21:20 +0200 Received: from se-intmail02x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 24 Sep 2024 08:21:20 +0200 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail02x.se.axis.com (Postfix) with ESMTP id 9700ECC; Tue, 24 Sep 2024 08:21:20 +0200 (CEST) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 91CD920432; Tue, 24 Sep 2024 08:21:20 +0200 (CEST) From: Hans-Peter Nilsson To: , Subject: [PATCH] gfortran testsuite: Remove unit-files in files having open-statements, PR116701 MIME-Version: 1.0 Message-ID: <20240924062120.91CD920432@pchp3.se.axis.com> Date: Tue, 24 Sep 2024 08:21:20 +0200 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509F1:EE_|PR3PR02MB6492:EE_ X-MS-Office365-Filtering-Correlation-Id: 0be9cf4b-dcab-40f8-a1bd-08dcdc611b85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?q?+CU5PE2ZENHSIxz6/K6Yl6qO41?= =?iso-8859-1?q?QyHMl3AjOFGu0N/83+9A7bqelCZGvw8QCLdpuTWsZfkSUN6gtHmhDnc86vAS?= =?iso-8859-1?q?witQaLCdt3epxgEztmj0V0ZwFlaWhlYRccyfhVKzeaMRB5STrtYYsAB+W///?= =?iso-8859-1?q?3wDUAYo5uobt3KkgekLQevYcGPNdrt1/ViLAEFep4DYjkt0NnR59Ad7Xh0ZD?= =?iso-8859-1?q?E1LIn/uYDbtGq3z4RLtQ1o9aveDxlOSCzPKDF/OE6NgfvWF1YVZwSxSKhCDv?= =?iso-8859-1?q?qYsM/Dqrvfob3K2wTIgud03SbkQsGauk2e22Pr358uHcKBExRZJtbtdQ4lvs?= =?iso-8859-1?q?Sqps8hc4BT2zU07bjhI53XtXyLQ+H268ZdOhWBXOBPI1HOe87502bfzwbx/z?= =?iso-8859-1?q?AOSOnlFS91Th9NukTK6PgSxzS3Eqkf0gave4nTbIr9ApEJtI4CLvm6bs5BZm?= =?iso-8859-1?q?RlJgJ3BCNYG3YxxJyJu1YAp7q7ZqBH0AZLsq6Mh8mh16NRsIApQmtC+4Qhnz?= =?iso-8859-1?q?EU6c+suhz/avdaYhXRv8F6AWbFPHzx8cEhIErknjaJQAkHDaoGW8TO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forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2024 06:21:21.0823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0be9cf4b-dcab-40f8-a1bd-08dcdc611b85 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509F1.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR02MB6492 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Here's a general approach to handle PR116701. I considered adding manual deletions as quoted below and mentioned in the PR, but seeing the handling of "integer 8" in fortran-torture-execute I decided to follow that example: better scan the source for open-statements than relying on manual annotations and people remembering to add them for new test-cases. I hope the inclusion of gfortran-dg.exp in fortran-torture.exp is not controversial, but there's no fortran-specific testsuite file common to dg and classic-torture and also this placement is still in the "Utility routines" section of gfortran-dg.exp. (BTW, the C torture-tests changed to the dg framework some time ago - no more .x-files there and dg-directives actually work - there are some in gfortran.fortran-torture that are apparently ignored!) There's one further cleanup possible, removing the manual removal in open_errors_2.f90 (which should have used "target", not "build"). Works for (no regressions, manual check verifies functionality) cris-elf as well as native x86_64-linux-gnu. Ok to commit? -- >8 -- PR testsuite/116701 shows that left-behind files from unnamed gfortran open statements (named unit.N, where N = unit number) can interfere with the result of a subsequent run. While that's unlikely to happen for a "real" fortran target or a test with a deleting close-statement, test-cases should not rely on previous test-cases passing and not execute along different execution paths depending on earlier runs, even if the difference is benevolent. Most but not all fortran test-cases go through gfortran-dg-runtest (gfortran.dg) or fortran-torture-execute (gfortran.fortran-torture). However, the exceptions, with more complex framework and call-chains, either don't run or don't have open-statements, so a more complex solution doesn't seem worthwhile. If test-cases with open-statements are added later to those parts of the test-suite, calls to gfortran-dg-rmunits at the right spot may be added or worst case, "manual" cleanup-calls added, like: ! { dg-final { remote_file target delete "fort.10" } } PR testsuite/116701 * lib/gfortran-dg.exp (gfortran-dg-rmunits): New proc. (gfortran-dg-runtest): Call gfortran-dg-rmunits after executing test. * lib/fortran-torture.exp: Include gfortran-dg.exp. (fortran-torture-execute): Call gfortran-dg-rmunits after executing test. --- gcc/testsuite/lib/fortran-torture.exp | 3 +++ gcc/testsuite/lib/gfortran-dg.exp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gcc/testsuite/lib/fortran-torture.exp b/gcc/testsuite/lib/fortran-torture.exp index 66f5bc822232..c45db285f867 100644 --- a/gcc/testsuite/lib/fortran-torture.exp +++ b/gcc/testsuite/lib/fortran-torture.exp @@ -23,6 +23,7 @@ load_lib target-supports.exp load_lib fortran-modules.exp load_lib target-utils.exp +load_lib gfortran-dg.exp # Return the list of options to use for fortran torture tests. # The default option list can be overridden by @@ -332,6 +333,8 @@ proc fortran-torture-execute { src } { catch { remote_file build delete $executable } } $status "$testcase execution, $option" + + gfortran-dg-rmunits $src } cleanup-modules "" } diff --git a/gcc/testsuite/lib/gfortran-dg.exp b/gcc/testsuite/lib/gfortran-dg.exp index fcba95dc3961..eb54844607dc 100644 --- a/gcc/testsuite/lib/gfortran-dg.exp +++ b/gcc/testsuite/lib/gfortran-dg.exp @@ -160,6 +160,7 @@ proc gfortran-dg-runtest { testcases flags default-extra-flags } { foreach flags_t $option_list { verbose "Testing $nshort, $flags $flags_t" 1 dg-test $test "$flags $flags_t" ${default-extra-flags} + gfortran-dg-rmunits $test cleanup-modules "" } } @@ -233,3 +234,25 @@ proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } { } } } + +# If the code has any "open" statements for numbered units, make sure +# no corresponding output file remains. Redundant remove operations +# are ok. + +proc gfortran-dg-rmunits { src } { + set openpat {open *\( *(?:unit *= *)?([0-9]+)} + set openmatches [igrep $src $openpat] + if {![string match "" $openmatches]} { + # verbose -log "Found \"$openmatches\"" + set deleted_units {} + foreach openmatch $openmatches { + regexp -nocase -- "$openpat" $openmatch match unit + if {[lsearch $deleted_units $unit] < 0} { + set rmfile "fort.$unit" + verbose -log "Deleting $rmfile" + remote_file target delete "fort.$unit" + lappend deleted_units $unit + } + } + } +}