This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [testsuite] add dg-timeout, dg-timeout-factor for PR 28870


On Thu, 2008-11-20 at 13:41 -0800, Janis Johnson wrote:
> This patch fixes a piece of PR testsuite/28870, allowing specific
> timeouts or multiples of a default timeout for tests under
> gcc/testsuite.  I have plans for similar support for libstdc++-v3,
> libmudflap (which already has dg-timeout), and libgomp, but meanwhile
> I'd like some feedback on this piece.

I found lots of little problems with that version.  The new version
has support for all compiler tests plus libstdc++-v3, libgomp, and
replaces the existing dg-timeout support for libmudflap.  New test
directives are

  { dg-timeout N [{ target SELECTOR }] }
  { dg-timeout-factor X [{ target SELECTOR }] }

The default timeout from DejaGnu, as defined in remote.exp, can be
overridden for any of these tests by setting gcc,,timeout in the
target board.  That can be overridden for a particular set of tests
(as is done for libstdc++-v3) with tool_timeout.  All of those are
overridden by using dg-timeout and/or dg-timeout-factor within a
test.

Tested on powerpc64-linux with -m32/-m64 with lots of local changes
to tests to use one of the directives, and doc changes tested with
make dvi/html/info.  I plan to check this in tomorrow.

2008-11-25  Janis Johnson  <janis187@us.ibm.com>

gcc/
	PR testsuite/28870
	* doc/sourcebuild.texi (Test Directives): Add dg-timeout and
	dg-timeout-factor.

gcc/testsuite/
	PR testsuite/28870
	* lib/timeout.exp: New.
	* lib/timeout-dg.exp: New.
	* lib/gcc-dg.exp: Include new timeout library files.
	(dg-test): Unset timeout variables.
	* lib/gcc.exp (gcc_target_compile): Set timeout value from new proc.
	* lib/g++.exp (g++_target_compile): Ditto.
	* lib/gfortran.exp (gfortran_target_compile): Ditto.
	* lib/objc.exp (objc_target_compile): Ditto.
	* lib/obj-c++.exp (obj-c++_target_compile): Ditto.
	* lib/obj-c++.exp (obj-c++_target_compile): Ditto.
	* lib/gnat.exp (gnat_target_compile): Ditto.

libstdc++-v3/
	PR testsuite/28870
	* testsuite/lib/libstdc++.exp: Include new timeout library files.
	(libstdc++_init): Define tool_timeout.
	(dg-test): Override DejaGnu proc.
	(v3_target_compile): Set timeout value from new proc.
	(v3_target_compile_as_c): Ditto.

libmudflap/
	PR testsuite/28870
	* testsuite/lib/mfdg.exp (dg-test): Use new timeout support.
	(dg-timeout): Remove.
	(standard-wait): Remove.
	* testsuite/lib/libmudflap.exp: Include new timeout library files.
	(libmudflap_target_compile): Set timeout value from new proc.

libgomp/
	PR testsuite/28870
	* testsuite/lib/libgomp.exp: Include new timeout library files.
	(libgomp_target_compile): Set timeout value from new proc.

Index: gcc/doc/sourcebuild.texi
===================================================================
--- gcc/doc/sourcebuild.texi	(revision 142182)
+++ gcc/doc/sourcebuild.texi	(working copy)
@@ -990,6 +990,26 @@
 and only then in certain modes.
 @end table
 
+@item @{ dg-timeout @var{n} [@{target @var{selector} @}] @}
+Set the time limit for the compilation and for the execution of the test
+to the specified number of seconds.
+
+@item @{ dg-timeout-factor @var{x} [@{ target @var{selector} @}] @}
+Multiply the normal time limit for compilation and execution of the test
+by the specified floating-point factor.  The normal timeout limit, in
+seconds, is found by searching the following in order:
+
+@itemize @bullet
+@item the value defined by an earlier @code{dg-timeout} directive in
+the test
+
+@item variable @var{tool_timeout} defined by the set of tests
+
+@item @var{gcc,,timeout} set in the target board
+
+@item 300
+@end itemize
+
 @item @{ dg-skip-if @var{comment} @{ @var{selector} @} @{ @var{include-opts} @} @{ @var{exclude-opts} @} @}
 Skip the test if the test system is included in @var{selector} and if
 each of the options in @var{include-opts} is in the set of options with
Index: gcc/testsuite/lib/timeout.exp
===================================================================
--- gcc/testsuite/lib/timeout.exp	(revision 0)
+++ gcc/testsuite/lib/timeout.exp	(revision 0)
@@ -0,0 +1,81 @@
+# Copyright (C) 2008 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/>.
+
+#
+# unset_timeout_vars -- Unset variables used for timeouts
+#
+
+proc unset_timeout_vars { args } {
+    global individual_timeout
+    global timeout_factor
+
+    if [info exists individual_timeout] {
+	unset individual_timeout
+    }
+    if [info exists timeout_factor] {
+	unset timeout_factor
+    }
+}
+
+#
+# timeout_value -- Return the integer timeout value to use for this test
+#
+
+proc timeout_value { args } {
+    global tool_timeout
+    global individual_timeout
+    global timeout_factor
+
+    # Find the current timeout limit, in seconds.
+    if [info exists individual_timeout] {
+	set val $individual_timeout
+    } elseif [info exists tool_timeout] {
+	set val $tool_timeout
+    } elseif [target_info exists gcc,timeout] {
+	set val [target_info gcc,timeout]
+    } else {
+	# This is really, REALLY ugly, but this is the default from
+	# remote.exp deep within DejaGnu.
+	set val 300
+    }
+
+    # If the test specified a timeout factor, adjust by that.
+    if [info exists timeout_factor] {
+	set val [expr int([expr $val * $timeout_factor])]
+    }
+
+    return $val
+}
+
+#
+# standard_wait -- Set the timeout value used by DejaGnu
+#
+
+# Override standard_wait from DejaGnu to use timeout value specified by
+# by the user or by the target board, possibly multiplied by a factor
+# for a particular test.
+
+if { [info procs standard_wait] != [list] \
+     && [info procs saved_standard_wait] == [list] } {
+    rename standard_wait saved_standard_wait
+    proc standard_wait { dest timeout } {
+	set val [timeout_value]
+	if { $val != 0 } {
+	    set timeout $val
+	}
+	saved_standard_wait $dest $timeout
+    }
+}
Index: gcc/testsuite/lib/timeout-dg.exp
===================================================================
--- gcc/testsuite/lib/timeout-dg.exp	(revision 0)
+++ gcc/testsuite/lib/timeout-dg.exp	(revision 0)
@@ -0,0 +1,49 @@
+# Copyright (C) 2008 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/>.
+
+#
+# dg-timeout -- Set the timout limit, in seconds, for a particular test
+#
+
+proc dg-timeout { args } {
+    global individual_timeout
+
+    set args [lreplace $args 0 0]
+    if { [llength $args] > 1 } {
+	if { [dg-process-target [lindex $args 1]] == "S" } {
+	    set individual_timeout [lindex $args 0]
+	}
+    } else {
+	set individual_timeout [lindex $args 0]
+    }
+}
+
+#
+# dg-timeout-factor -- Scale the timeout limit for a particular test
+#
+
+proc dg-timeout-factor { args } {
+    global timeout_factor
+
+    set args [lreplace $args 0 0]
+    if { [llength $args] > 1 } {
+	if { [dg-process-target [lindex $args 1]] == "S" } {
+	    set timeout_factor [lindex $args 0]
+	}
+    } else {
+	set timeout_factor [lindex $args 0]
+    }
+}
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp	(revision 142182)
+++ gcc/testsuite/lib/gcc-dg.exp	(working copy)
@@ -23,6 +23,8 @@
 load_lib scanrtl.exp
 load_lib scantree.exp
 load_lib scanipa.exp
+load_lib timeout.exp
+load_lib timeout-dg.exp
 load_lib prune.exp
 load_lib libgloss.exp
 load_lib target-libpath.exp
@@ -580,12 +582,14 @@
 	    if [info exists compiler_conditional_xfail_data] {
 		unset compiler_conditional_xfail_data
 	    }
+	    unset_timeout_vars
 	    error $errmsg $saved_info
 	}
 	set additional_files ""
 	set additional_sources ""
 	set additional_prunes ""
 	set shouldfail 0
+	unset_timeout_vars
 	if [info exists compiler_conditional_xfail_data] {
 	    unset compiler_conditional_xfail_data
 	}
Index: gcc/testsuite/lib/gcc.exp
===================================================================
--- gcc/testsuite/lib/gcc.exp	(revision 142182)
+++ gcc/testsuite/lib/gcc.exp	(working copy)
@@ -29,6 +29,7 @@
 load_lib libgloss.exp
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib timeout.exp
 
 #
 # GCC_UNDER_TEST is the compiler under test.
@@ -147,9 +148,7 @@
     if [info exists TOOL_OPTIONS] {
 	set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
     }
-    if [target_info exists gcc,timeout] {
-	lappend options "timeout=[target_info gcc,timeout]"
-    }
+    lappend options "timeout=[timeout_value]"
     lappend options "compiler=$GCC_UNDER_TEST"
     set options [dg-additional-files-options $options $source]
     return [target_compile $source $dest $type $options]
Index: gcc/testsuite/lib/g++.exp
===================================================================
--- gcc/testsuite/lib/g++.exp	(revision 142182)
+++ gcc/testsuite/lib/g++.exp	(working copy)
@@ -24,6 +24,7 @@
 #
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib timeout.exp
 load_lib target-libpath.exp
 
 #
@@ -279,6 +280,7 @@
 
     lappend options "additional_flags=[libio_include_flags]"
     lappend options "compiler=$GXX_UNDER_TEST"
+    lappend options "timeout=[timeout_value]"
 
     set options [concat $gpp_compile_options $options]
 
Index: gcc/testsuite/lib/gfortran.exp
===================================================================
--- gcc/testsuite/lib/gfortran.exp	(revision 142182)
+++ gcc/testsuite/lib/gfortran.exp	(working copy)
@@ -24,6 +24,7 @@
 #
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib timeout.exp
 load_lib target-libpath.exp
 
 #
@@ -193,6 +194,7 @@
     }
 
     lappend options "compiler=$GFORTRAN_UNDER_TEST"
+    lappend options "timeout=[timeout_value]"
 
     set options [concat "$ALWAYS_GFORTRANFLAGS" $options]
     set options [dg-additional-files-options $options $source]
Index: gcc/testsuite/lib/objc.exp
===================================================================
--- gcc/testsuite/lib/objc.exp	(revision 142182)
+++ gcc/testsuite/lib/objc.exp	(working copy)
@@ -28,6 +28,7 @@
 load_lib libgloss.exp
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib timeout.exp
 load_lib target-libpath.exp
 
 #
@@ -193,6 +194,7 @@
 	set source [concat "-x objective-c-header" $source]
     }
     lappend options "compiler=$OBJC_UNDER_TEST"
+    lappend options "timeout=[timeout_value]
 
     set_ld_library_path_env_vars
 
Index: gcc/testsuite/lib/obj-c++.exp
===================================================================
--- gcc/testsuite/lib/obj-c++.exp	(revision 142182)
+++ gcc/testsuite/lib/obj-c++.exp	(working copy)
@@ -23,6 +23,7 @@
 #
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib timeout.exp
 load_lib target-libpath.exp
 
 #
@@ -324,6 +325,7 @@
 
     lappend options "additional_flags=[libio_include_flags]"
     lappend options "compiler=$OBJCXX_UNDER_TEST";
+    lappend options "timeout=[timeout_value]"
 
     set options [concat $gpp_compile_options $options]
 
Index: gcc/testsuite/lib/gnat.exp
===================================================================
--- gcc/testsuite/lib/gnat.exp	(revision 142182)
+++ gcc/testsuite/lib/gnat.exp	(working copy)
@@ -27,6 +27,7 @@
 load_lib libgloss.exp
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib timeout.exp
 
 #
 # GNAT_UNDER_TEST is the compiler under test.
@@ -131,6 +132,7 @@
     set ld_library_path ".:${gnat_libgcc_s_path}"
     lappend options "compiler=$GNAT_UNDER_TEST -q -f"
     lappend options "incdir=${rootme}/ada/rts"
+    lappend options "timeout=[timeout_value]
 
     if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
 	lappend options "libs=${gluefile}"
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 142182)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(working copy)
@@ -53,6 +53,8 @@
 load_lib prune.exp
 load_lib dg-options.exp
 load_gcc_lib target-libpath.exp
+load_gcc_lib timeout.exp
+load_gcc_lib timeout-dg.exp
 load_gcc_lib wrapper.exp
 
 # Useful for debugging.  Pass the name of a variable and the verbosity
@@ -89,6 +91,7 @@
     global ld_library_path
     global target_triplet
     global flags_file
+    global tool_timeout
 
     # We set LC_ALL and LANG to C so that we get the same error
     # messages as expected.
@@ -184,6 +187,9 @@
 	set compiler [transform "g++"]
     }
 
+    # Set the default timeout for v3 tests.
+    set tool_timeout 600
+
     # Default settings.
     set cxx [transform "g++"]
     set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
@@ -346,6 +352,24 @@
     return [list $comp_output $output_file]
 }
 
+# Override the DejaGnu dg-test in order to clear flags after a test, as
+# is done for compiler tests in gcc-dg.exp.
+
+if { [info procs saved-dg-test] == [list] } {
+    rename dg-test saved-dg-test
+
+    proc dg-test { args } {
+	global errorInfo
+
+	if { [ catch { eval saved-dg-test $args } errmsg ] } {
+	    set saved_info $errorInfo
+	    unset_timeout_vars
+	    error $errmsg $saved_info
+	}
+	unset_timeout_vars
+    }
+}
+
 # True if the library supports wchar_t.
 set v3-wchar_t 0
 
@@ -389,7 +413,7 @@
     }
 
     lappend options "compiler=$cxx_final"
-    lappend options "timeout=600"
+    lappend options "timeout=[timeout_value]"
 
     return [target_compile $source $dest $type $options]
 }
@@ -455,7 +479,7 @@
     set cc_final [concat $cc_final "$libdir"]
 
     lappend options "compiler=$cc_final"
-    lappend options "timeout=600"
+    lappend options "timeout=[timeout_value]"
 
     return [target_compile $source $dest $type $options]
 }
Index: libmudflap/testsuite/lib/mfdg.exp
===================================================================
--- libmudflap/testsuite/lib/mfdg.exp	(revision 142182)
+++ libmudflap/testsuite/lib/mfdg.exp	(working copy)
@@ -40,8 +40,7 @@
     set keep 0
     set i 0
     set dg-repetitions 1 ;# may be overridden by { dg-repetitions N }
-    global dg-timeout
-    set dg-timeout 0 ;# likewise by { dg-timeout N }
+    unset_timeout_vars
 
     if { [string index [lindex $args 0] 0] == "-" } {
 	for { set i 0 } { $i < [llength $args] } { incr i } {
@@ -347,31 +346,3 @@
     upvar dg-repetitions repetitions
     set repetitions $value
 }
-
-
-# 
-# Indicate that this test case is to be run with a short timeout.
-# The embedded format is "{ dg-timeout N }", where N is in seconds.
-#
-proc dg-timeout { line value } {
-    global dg-timeout
-    set dg-timeout $value
-}
-
-
-# dejagnu's config/unix.exp hard-codes 300 seconds as the timeout
-# for any natively run executable.  That's too long for tests run
-# multiple times and that may possibly hang.  So we override it here
-# to provide some degree of control.
-rename standard_wait hooked_standard_wait
-proc standard_wait { dest timeout } {
-    global dg-timeout
-    if {[info exists dg-timeout]} {
-	if {${dg-timeout} > 0} {
-	    verbose -log "Overriding timeout = ${dg-timeout}"
-	    set timeout ${dg-timeout}
-	}
-    }
-
-    hooked_standard_wait $dest $timeout
-}
Index: libmudflap/testsuite/lib/libmudflap.exp
===================================================================
--- libmudflap/testsuite/lib/libmudflap.exp	(revision 142182)
+++ libmudflap/testsuite/lib/libmudflap.exp	(working copy)
@@ -29,6 +29,8 @@
 load_lib mfdg.exp
 load_lib libgloss.exp
 load_gcc_lib target-libpath.exp
+load_gcc_lib timeout.exp
+load_gcc_lib timeout-dg.exp
 
 proc libmudflap-init { language } {
     global env
@@ -213,6 +215,7 @@
     set cxx_final [concat $cxx_final $libs]
 
     lappend options "compiler=$cxx_final"
+    lappend options "timeout=[timeout_value]"
 
     # Picks up the freshly-built testsuite library corresponding to the
     # multilib under test.
Index: libgomp/testsuite/lib/libgomp.exp
===================================================================
--- libgomp/testsuite/lib/libgomp.exp	(revision 142182)
+++ libgomp/testsuite/lib/libgomp.exp	(working copy)
@@ -22,6 +22,8 @@
 load_gcc_lib wrapper.exp
 load_gcc_lib gcc-defs.exp
 load_gcc_lib torture-options.exp
+load_gcc_lib timeout.exp
+load_gcc_lib timeout-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
@@ -180,6 +182,7 @@
     }
 
     lappend options "additional_flags=[libio_include_flags]"
+    lappend options "timeout=[timeout_value]"
     lappend options "compiler=$GCC_UNDER_TEST"
 
     set options [concat $libgomp_compile_options $options]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]