From patchwork Thu Aug 15 18:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1972873 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=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NETLb7qi; 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 4WlCsJ5PS8z1yXl for ; Fri, 16 Aug 2024 04:12:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 955DC3858432 for ; Thu, 15 Aug 2024 18:12:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 019733858C50 for ; Thu, 15 Aug 2024 18:12:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 019733858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 019733858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723745532; cv=none; b=sh8VYcmgQVZGmLfR8ujtxWPBiz1chqyYjpwXTlA4FLx/t3JHYTffe0HGJ99EOsUWI6P0izBfDuVdacXhir+nAvLrG+FLCHEvEYA13IyIGz46tPyO2gag2emjkoxgdAsW9aaDdmy9s4Y1FeIHDcvXXdl6tkmjV9i2zTBIFjghFHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723745532; c=relaxed/simple; bh=skM8dBPrFtP2KrBYa+nVLJUAKy0edUQneOv3xvTOfwI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=c7cWUKFE78nW8gQD2rJhweb+YMEQRsN8u/yNnGNLrLItrMbKIdWnQlT/cUhUO0R7ZO94uuVAbEYFYquYhnNZ68vspF+e+E8vCfhJJ47A9iyTlmT1T+7q48KvCR7jqCd+pfVHZY7gli5z/RbOpsWCgYYJ9y9DgniLFAuakh6rVFY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723745528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vzScpv6BnYJqsrrbV48N8LoXSihUT9ZhpNyp3pwv8YQ=; b=NETLb7qiA3FGTpLhs2OuAg4tR6aMQX4TwcwrkA7giSUxOCgYHyw+JpBiQkEiMRTj3XkSlz 0+yYB5il7ecNnuuJIYz+/GfnLxKcVonF9HerV/+L6Ad/Zu8OXI7biFM6poU0IT6F23G9ev peiD57fLSkPXXaqgwpuQZEGNldoFy0Y= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-8Px7k84uP2688uQMBRwGeg-1; Thu, 15 Aug 2024 14:12:06 -0400 X-MC-Unique: 8Px7k84uP2688uQMBRwGeg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0E35D1955D4B for ; Thu, 15 Aug 2024 18:12:06 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.16.43]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2EFA61955D44; Thu, 15 Aug 2024 18:12:04 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 4/7] testsuite: move dg-test cleanup code from gcc-dg.exp to its own file Date: Thu, 15 Aug 2024 14:11:53 -0400 Message-Id: <20240815181156.1815075-5-dmalcolm@redhat.com> In-Reply-To: <20240815181156.1815075-1-dmalcolm@redhat.com> References: <20240815181156.1815075-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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 I need to use this cleanup logic for the testsuite for libdiagnostics where it's too awkward to directly use gcc-dg.exp itself. No functional change intended. gcc/testsuite/ChangeLog: * lib/dg-test-cleanup.exp: New file, from material moved from lib/gcc-dg.exp. * lib/gcc-dg.exp: Add load_lib of dg-test-cleanup.exp. (cleanup-after-saved-dg-test): Move to lib/dg-test-cleanup.exp. (dg-test): Likewise for override. (initialize_prune_notes): Likewise. libatomic/ChangeLog: * testsuite/lib/libatomic.exp: Add "load_gcc_lib dg-test-cleanup.exp". libgomp/ChangeLog: * testsuite/lib/libgomp.exp: Add "load_gcc_lib dg-test-cleanup.exp". libitm/ChangeLog: * testsuite/lib/libitm.exp: Add "load_gcc_lib dg-test-cleanup.exp". libphobos/ChangeLog: * testsuite/lib/libphobos-dg.exp: Add "load_gcc_lib dg-test-cleanup.exp". libstdc++-v3/ChangeLog: * testsuite/lib/libstdc++.exp: Add "load_gcc_lib dg-test-cleanup.exp". libvtv/ChangeLog: * testsuite/lib/libvtv.exp: Add "load_gcc_lib dg-test-cleanup.exp". Signed-off-by: David Malcolm --- gcc/testsuite/lib/dg-test-cleanup.exp | 116 +++++++++++++++++++++++ gcc/testsuite/lib/gcc-dg.exp | 102 +------------------- libatomic/testsuite/lib/libatomic.exp | 1 + libgomp/testsuite/lib/libgomp.exp | 1 + libitm/testsuite/lib/libitm.exp | 1 + libphobos/testsuite/lib/libphobos-dg.exp | 1 + libstdc++-v3/testsuite/lib/libstdc++.exp | 1 + libvtv/testsuite/lib/libvtv.exp | 1 + 8 files changed, 123 insertions(+), 101 deletions(-) create mode 100644 gcc/testsuite/lib/dg-test-cleanup.exp diff --git a/gcc/testsuite/lib/dg-test-cleanup.exp b/gcc/testsuite/lib/dg-test-cleanup.exp new file mode 100644 index 000000000000..b2b8507a0320 --- /dev/null +++ b/gcc/testsuite/lib/dg-test-cleanup.exp @@ -0,0 +1,116 @@ +# Copyright (C) 1997-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# We need to make sure that additional_* are cleared out after every +# test. It is not enough to clear them out *before* the next test run +# because gcc-target-compile gets run directly from some .exp files +# (outside of any test). (Those uses should eventually be eliminated.) + +# Because the DG framework doesn't provide a hook that is run at the +# end of a test, we must replace dg-test with a wrapper. + +if { [info procs saved-dg-test] == [list] } { + rename dg-test saved-dg-test + + # Helper function for cleanups that should happen after the call + # to the real dg-test, whether or not it returns normally, or + # fails with an error. + proc cleanup-after-saved-dg-test { } { + global additional_files + global additional_sources + global additional_sources_used + global additional_prunes + global compiler_conditional_xfail_data + global shouldfail + global expect_ice + global testname_with_flags + global set_target_env_var + global set_compiler_env_var + global saved_compiler_env_var + global keep_saved_temps_suffixes + global nn_line_numbers_enabled + global multiline_expected_outputs + global freeform_regexps + global save_linenr_varnames + + set additional_files "" + set additional_sources "" + set additional_sources_used "" + set additional_prunes "" + set shouldfail 0 + set expect_ice 0 + if [info exists set_target_env_var] { + unset set_target_env_var + } + if [info exists set_compiler_env_var] { + restore-compiler-env-var + unset set_compiler_env_var + unset saved_compiler_env_var + } + if [info exists keep_saved_temps_suffixes] { + unset keep_saved_temps_suffixes + } + unset_timeout_vars + if [info exists compiler_conditional_xfail_data] { + unset compiler_conditional_xfail_data + } + if [info exists testname_with_flags] { + unset testname_with_flags + } + set nn_line_numbers_enabled 0 + set multiline_expected_outputs [] + set freeform_regexps [] + + if { [info exists save_linenr_varnames] } { + foreach varname $save_linenr_varnames { + # Cleanup varname + eval global $varname + eval unset $varname + + # Cleanup varname_used, or generate defined-but-not-used + # warning. + set varname_used used_$varname + eval global $varname_used + eval set used [info exists $varname_used] + if { $used } { + eval unset $varname_used + } else { + regsub {^saved_linenr_} $varname "" org_varname + warning "dg-line var $org_varname defined, but not used" + } + } + unset save_linenr_varnames + } + + initialize_prune_notes + } + + proc dg-test { args } { + global errorInfo + + if { [ catch { eval saved-dg-test $args } errmsg ] } { + set saved_info $errorInfo + cleanup-after-saved-dg-test + error $errmsg $saved_info + } + cleanup-after-saved-dg-test + } +} + +proc initialize_prune_notes { } { + global prune_notes + set prune_notes 1 +} diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 992062103c12..33b7e5a1e2c2 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -34,6 +34,7 @@ load_lib target-libpath.exp load_lib torture-options.exp load_lib fortran-modules.exp load_lib multiline.exp +load_lib dg-test-cleanup.exp # We set LC_ALL and LANG to C so that we get the same error messages as expected. setenv LC_ALL C @@ -990,102 +991,6 @@ proc output-exists-not { args } { } } -# We need to make sure that additional_* are cleared out after every -# test. It is not enough to clear them out *before* the next test run -# because gcc-target-compile gets run directly from some .exp files -# (outside of any test). (Those uses should eventually be eliminated.) - -# Because the DG framework doesn't provide a hook that is run at the -# end of a test, we must replace dg-test with a wrapper. - -if { [info procs saved-dg-test] == [list] } { - rename dg-test saved-dg-test - - # Helper function for cleanups that should happen after the call - # to the real dg-test, whether or not it returns normally, or - # fails with an error. - proc cleanup-after-saved-dg-test { } { - global additional_files - global additional_sources - global additional_sources_used - global additional_prunes - global compiler_conditional_xfail_data - global shouldfail - global expect_ice - global testname_with_flags - global set_target_env_var - global set_compiler_env_var - global saved_compiler_env_var - global keep_saved_temps_suffixes - global nn_line_numbers_enabled - global multiline_expected_outputs - global freeform_regexps - global save_linenr_varnames - - set additional_files "" - set additional_sources "" - set additional_sources_used "" - set additional_prunes "" - set shouldfail 0 - set expect_ice 0 - if [info exists set_target_env_var] { - unset set_target_env_var - } - if [info exists set_compiler_env_var] { - restore-compiler-env-var - unset set_compiler_env_var - unset saved_compiler_env_var - } - if [info exists keep_saved_temps_suffixes] { - unset keep_saved_temps_suffixes - } - unset_timeout_vars - if [info exists compiler_conditional_xfail_data] { - unset compiler_conditional_xfail_data - } - if [info exists testname_with_flags] { - unset testname_with_flags - } - set nn_line_numbers_enabled 0 - set multiline_expected_outputs [] - set freeform_regexps [] - - if { [info exists save_linenr_varnames] } { - foreach varname $save_linenr_varnames { - # Cleanup varname - eval global $varname - eval unset $varname - - # Cleanup varname_used, or generate defined-but-not-used - # warning. - set varname_used used_$varname - eval global $varname_used - eval set used [info exists $varname_used] - if { $used } { - eval unset $varname_used - } else { - regsub {^saved_linenr_} $varname "" org_varname - warning "dg-line var $org_varname defined, but not used" - } - } - unset save_linenr_varnames - } - - initialize_prune_notes - } - - proc dg-test { args } { - global errorInfo - - if { [ catch { eval saved-dg-test $args } errmsg ] } { - set saved_info $errorInfo - cleanup-after-saved-dg-test - error $errmsg $saved_info - } - cleanup-after-saved-dg-test - } -} - if { [info procs saved-dg-warning] == [list] \ && [info exists gcc_warning_prefix] } { rename dg-warning saved-dg-warning @@ -1329,11 +1234,6 @@ proc dg-missed { args } { variable prune_notes -proc initialize_prune_notes { } { - global prune_notes - set prune_notes 1 -} - initialize_prune_notes proc dg-note { args } { diff --git a/libatomic/testsuite/lib/libatomic.exp b/libatomic/testsuite/lib/libatomic.exp index ed6ba806732f..f90bc4b708a0 100644 --- a/libatomic/testsuite/lib/libatomic.exp +++ b/libatomic/testsuite/lib/libatomic.exp @@ -50,6 +50,7 @@ load_gcc_lib torture-options.exp load_gcc_lib timeout.exp load_gcc_lib timeout-dg.exp load_gcc_lib fortran-modules.exp +load_gcc_lib dg-test-cleanup.exp set dg-do-what-default run diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp index 7c1092629168..cad0280f3798 100644 --- a/libgomp/testsuite/lib/libgomp.exp +++ b/libgomp/testsuite/lib/libgomp.exp @@ -41,6 +41,7 @@ load_gcc_lib scanwpaipa.exp load_gcc_lib timeout-dg.exp load_gcc_lib torture-options.exp load_gcc_lib fortran-modules.exp +load_gcc_lib dg-test-cleanup.exp # Try to load a test support file, built during libgomp configuration. # Search in '..' vs. '.' to support parallel vs. sequential testing. diff --git a/libitm/testsuite/lib/libitm.exp b/libitm/testsuite/lib/libitm.exp index 3e60797c3e31..5b387f2ec408 100644 --- a/libitm/testsuite/lib/libitm.exp +++ b/libitm/testsuite/lib/libitm.exp @@ -50,6 +50,7 @@ load_gcc_lib scanwpaipa.exp load_gcc_lib timeout-dg.exp load_gcc_lib torture-options.exp load_gcc_lib fortran-modules.exp +load_gcc_lib dg-test-cleanup.exp set dg-do-what-default run diff --git a/libphobos/testsuite/lib/libphobos-dg.exp b/libphobos/testsuite/lib/libphobos-dg.exp index 965ff025a04d..09b644ac573f 100644 --- a/libphobos/testsuite/lib/libphobos-dg.exp +++ b/libphobos/testsuite/lib/libphobos-dg.exp @@ -29,6 +29,7 @@ load_gcc_lib scanipa.exp load_gcc_lib torture-options.exp load_gcc_lib timeout-dg.exp load_gcc_lib fortran-modules.exp +load_gcc_lib dg-test-cleanup.exp load_gcc_lib gcc-dg.exp # Utility routines. diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 2510c7f4cbb9..161e9501a379 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -73,6 +73,7 @@ load_gcc_lib timeout.exp load_gcc_lib timeout-dg.exp load_gcc_lib wrapper.exp load_gcc_lib target-utils.exp +load_gcc_lib dg-test-cleanup.exp # Useful for debugging. Pass the name of a variable and the verbosity # threshold (number of -v's on the command line). diff --git a/libvtv/testsuite/lib/libvtv.exp b/libvtv/testsuite/lib/libvtv.exp index bfd03d7d2580..61980141a7ea 100644 --- a/libvtv/testsuite/lib/libvtv.exp +++ b/libvtv/testsuite/lib/libvtv.exp @@ -48,6 +48,7 @@ load_gcc_lib scanwpaipa.exp load_gcc_lib timeout-dg.exp load_gcc_lib torture-options.exp load_gcc_lib fortran-modules.exp +load_gcc_lib dg-test-cleanup.exp set dg-do-what-default run