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: [PATCH] PR testsuite/28870: add dg-timeout


On Sun, 2008-02-24 at 18:03 +0100, Uros Bizjak wrote:
> Hello!
> 
> This patch implements { dg-timeout N [{ target }] } infrastructure, and 
> can be used to fix PR testsuite/28870. Using this patch, "problematic" 
> testcases can set its own timeout, different than the default one:
> 
> /* { dg-timeout 600 { target x86_64-*-* } } */
> 
> This sets timeout for certain target to 600 seconds.
> 
> BTW: The idea of overriding standard_wait procedure was taken from 
> mudflap testsuite.
> 
> 2008-02-24  Uros Bizjak  <ubizjak@gmail.com>
> 
>         * lib/gcc-dg.exp (dg-timeout): New procedure.
>         (standard_wait): New procedure to override default standard_wait.

Uros, I finally got access to my version of a fix for this PR.

I was working on this patch a few months ago, based on suggestions I had
made in comment #15 in PR testsuite/28870, and then lost track of it.
Meanwhile the machine where I had been developing the patch had major
problems and I didn't get access to that machine again until today.

This  patch uses a timeout value specified in new directive dg-timeout,
or a variable defined in ${HOME}/.dejagnurc for the relevant testsuite
(gcc_timeout for compiler tests, v3_timeout for libstdc++ tests), or
falls back to the timeout for the target board.

I haven't tested this for awhile but had several tests in the tree
that were modified to have low timeout values to see if the directive
and/or gcc_timeout variable were really consulted.  I don't remember
what I planned to do with this next, except perhaps hope for some
feedback in the PR.

Clearing the timeout variable is necessary if there might be another
directive after dg-timeout that would cause the test to be skipped,
in which case that timeout would be used for the following test instead.

Uros, do you mind looking at this patch to see what you think of it?

2008-03-04  Janis Johnson  <janis187@us.ibm.com>

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

testsuite/
	PR testsuite/28870
	* lib/gcc.exp (gcc_target_compile): Get timeout value from new proc.
	* lib/gcc-dg.exp (dg-test): Handle timeout for individual test.
	(dg-timeout): New.
	(timeout-value): New.
	(standard_wait): Override proc from DejaGnu.

libstdc++-v3/
	PR testsuite/28870
	* testsuite/lib/libstdc++.exp (v3_target_compile): Handle timeout
	for individual test.
	* testsuite/lib/dg-options.exp (dg-timeout): New.
	
Index: gcc/doc/sourcebuild.texi
===================================================================
--- gcc/doc/sourcebuild.texi	(revision 132883)
+++ gcc/doc/sourcebuild.texi	(working copy)
@@ -987,6 +987,9 @@ The target's C99 runtime (both headers a
 and only then in certain modes.
 @end table
 
+@item @{ dg-timeout @var{seconds} [@{ target @var{selector} @}] @}
+Set the time limit for compiling the test to the specified number of seconds.
+
 @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/gcc.exp
===================================================================
--- gcc/testsuite/lib/gcc.exp	(revision 132883)
+++ gcc/testsuite/lib/gcc.exp	(working copy)
@@ -147,8 +147,9 @@ proc gcc_target_compile { source dest ty
     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]"
+    set timeout_val [timeout-value]
+    if { $timeout_val != 0 } {
+	lappend options "timeout=$timeout_val"
     }
     lappend options "additional_flags=-fno-show-column"
     lappend options "compiler=$GCC_UNDER_TEST"
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp	(revision 132883)
+++ gcc/testsuite/lib/gcc-dg.exp	(working copy)
@@ -543,6 +543,7 @@ if { [info procs saved-dg-test] == [list
 	global errorInfo
 	global compiler_conditional_xfail_data
 	global shouldfail
+	global individual_timeout
 
 	if { [ catch { eval saved-dg-test $args } errmsg ] } {
 	    set saved_info $errorInfo
@@ -553,12 +554,18 @@ if { [info procs saved-dg-test] == [list
 	    if [info exists compiler_conditional_xfail_data] {
 		unset compiler_conditional_xfail_data
 	    }
+	    if [info exists individual_timeout] {
+		unset individual_timeout
+	    }
 	    error $errmsg $saved_info
 	}
 	set additional_files ""
 	set additional_sources ""
 	set additional_prunes ""
 	set shouldfail 0
+	if [info exists individual_timeout] {
+	    unset individual_timeout
+	}
 	if [info exists compiler_conditional_xfail_data] {
 	    unset compiler_conditional_xfail_data
 	}
@@ -627,4 +634,56 @@ proc dg-message { args } {
     process-message saved-dg-warning "" $args
 }
 
+
+# Set the timeout limit for the compiler, 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]
+    }
+}
+
+# Return the timeout value to use for this test.
+
+proc timeout-value { args } {
+    global gcc_timeout
+    global individual_timeout
+
+    if [info exists individual_timeout] {
+	set val $individual_timeout
+	verbose "setting timeout=$val based on dg-timeout directive" 1
+    } elseif [info exists gcc_timeout] {
+	set val $gcc_timeout
+	verbose "setting timeout=$val based on gcc_timeout value" 2
+    } elseif [target_info exists gcc,timeout] {
+	set val [target_info gcc,timeout]
+	verbose "setting timeout=$val based on target board" 2
+    } else {
+	set val 0
+    }
+    return $val
+}
+
+# Override standard_wait from DejaGnu to use timeout value specified by
+# a test, by the user, or by the target board.
+
+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
+    }
+}
+
 set additional_prunes ""
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 132883)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(working copy)
@@ -361,6 +361,8 @@ proc v3_target_compile { source dest typ
     global cxxflags
     global cxxldflags
     global includes
+    global individual_timeout
+    global v3_timeout
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
         lappend options "libs=${gluefile}"
@@ -386,7 +388,22 @@ proc v3_target_compile { source dest typ
     }
 
     lappend options "compiler=$cxx_final"
-    lappend options "timeout=600"
+    verbose "v3_target_compile: set timeout" 2
+    if [info exists individual_timeout] {
+	lappend options "timeout=$individual_timeout"
+	verbose "setting timeout=$individual_timeout based on dg-timeout directive" 1
+    } elseif [info exists v3_timeout] {
+	lappend options "timeout=$v3_timeout"
+	verbose "setting timeout=$v3_timeout based on v3_timeout value" 2
+    } else {
+	lappend options "timeout=600"
+    }
+
+    # We're done with this value so clear it.
+    if [info exists individual_timeout] {
+	verbose "unset individual_timeout" 2
+	unset individual_timeout
+    }
 
     return [target_compile $source $dest $type $options]
 }
Index: libstdc++-v3/testsuite/lib/dg-options.exp
===================================================================
--- libstdc++-v3/testsuite/lib/dg-options.exp	(revision 132883)
+++ libstdc++-v3/testsuite/lib/dg-options.exp	(working copy)
@@ -88,3 +88,20 @@ proc dg-require-rvalref { args } {
     }
     return
 }
+
+# Set the timeout limit for the compiler, 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]
+	    verbose "dg-timeout: set individual_timeout to $individual_timeout" 2
+	}
+    } else {
+	set individual_timeout [lindex $args 0]
+	verbose "dg-timeout: set individual_timeout to $individual_timeout" 2
+    }
+}



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