]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: move dg-test cleanup code from gcc-dg.exp to its own file
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 18 Nov 2024 21:49:04 +0000 (16:49 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 18 Nov 2024 21:49:04 +0000 (16:49 -0500)
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 <dmalcolm@redhat.com>
gcc/testsuite/lib/dg-test-cleanup.exp [new file with mode: 0644]
gcc/testsuite/lib/gcc-dg.exp
libatomic/testsuite/lib/libatomic.exp
libgomp/testsuite/lib/libgomp.exp
libitm/testsuite/lib/libitm.exp
libphobos/testsuite/lib/libphobos-dg.exp
libstdc++-v3/testsuite/lib/libstdc++.exp
libvtv/testsuite/lib/libvtv.exp

diff --git a/gcc/testsuite/lib/dg-test-cleanup.exp b/gcc/testsuite/lib/dg-test-cleanup.exp
new file mode 100644 (file)
index 0000000..b2b8507
--- /dev/null
@@ -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
+# <http://www.gnu.org/licenses/>.
+
+# 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
+}
index 7adca02f9377db27cf4ff7de4a3d4eac0d06d029..b787bd46b116c46a43d8e2d2fdba0bbbc1ec5ad6 100644 (file)
@@ -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
@@ -991,102 +992,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
@@ -1330,11 +1235,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 } {
index 642530557f782355ee207e30addce64098c4c5eb..4b52a6f748763c372b880140ea91ccc077f100c0 100644 (file)
@@ -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
 
index 2d0339b5e56522a404086e3de6a5a227dc9cca76..fd21371dce81e7a90fce94ff511082c44a672365 100644 (file)
@@ -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.
index 0182234a24ab8a46b52b1a1fbf2054617be8e37d..ac390d6d0dd09e47ed7a7aa7cc65ff2533acaaac 100644 (file)
@@ -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
 
index 90bc02ef5e5ee770c51f7eee2ffba183e7da3917..e3524ad0426aea592a5c892fe1d2c0c14d98f860 100644 (file)
@@ -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.
index 2510c7f4cbb9a74c20a506933d5c08f29ecf02fb..161e9501a3793cd38a645026e7d7b6a6f7fbb405 100644 (file)
@@ -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).
index 788a207e94872a3a973339b35ae038f6cba06016..23c6270975b68338ecb662b750cc51a5805e3b69 100644 (file)
@@ -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