This is the mail archive of the gcc@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: How do I disable classes of test?


Hi Dave,

Thanks for that patch. It has taken me a while to get around to using it, but it is very useful. I've attached a version which works with the current mainline.

Was there any particular reason why you haven't submitted it to mainline, as I'm sure that others could benefit from it?

dan.

Dave Korn wrote:

 Yep.  The attached patch shows how to extend the testsuite to add a whole
load of useful test-enable/disable-per-feature functionality.  After
applying this patch, you could add a line reading

set_board_info no_floating_point 0

to your board.exp and any testfile that contains the words 'float' or
'double' will be skipped.  It's just a crude line-based substring match, so
there will be false positives.  The patch is against 3.3.3, but should be
easily ported to newer or older versions, within reason.  It could be
reworked to allow cleverer regex searching if desired, but I didn't want to
make it overly slow.



--
============================================================================
Daniel Towner
picoChip Designs Ltd, Riverside Buildings, 108, Walcot Street, BATH, BA1 5BG
daniel.towner@picochip.com
+44 (0) 7786 702589

Index: lib/c-torture.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/c-torture.exp,v
retrieving revision 1.20
diff -c -3 -p -r1.20 c-torture.exp
*** lib/c-torture.exp	25 Jun 2005 01:45:22 -0000	1.20
--- lib/c-torture.exp	17 Oct 2005 10:02:56 -0000
***************
*** 17,22 ****
--- 17,23 ----
  # This file was written by Rob Savoye. (rob@cygnus.com)
  
  load_lib file-format.exp
+ load_lib target-supports.exp
  
  # The default option list can be overridden by
  # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
*************** proc c-torture-execute { sources args } 
*** 99,104 ****
--- 100,108 ----
      global tmpdir tool srcdir output compiler_conditional_xfail_data
  
      # Use the first source filename given as the filename under test.
+     global last_unsupported_match
+ 
+     # Use the first source filename given as the filename under test.
      set src [lindex $sources 0]
  
      if { [llength $args] > 0 } {
*************** proc c-torture-execute { sources args } 
*** 136,141 ****
--- 140,148 ----
  	set testcase "[file tail [file dirname $src]]/[file tail $src]"
      }
  
+     # Check for any unsupported features in this testcase
+     set unsup [check_for_unsupported $src]
+ 
      set count 0
      set oldstatus "foo"
      foreach option $option_list {
*************** proc c-torture-execute { sources args } 
*** 165,170 ****
--- 172,185 ----
  	if { $additional_flags != "" } {
  	    lappend options "additional_flags=$additional_flags"
  	}
+ 
+ 	# If unsupported for any reason, don't go ahead with it.
+ 	if $unsup then {
+ 	    unsupported "$last_unsupported_match, $testcase execution, $option"
+ 	    continue
+ 	}
+ 
+ 	# Not unsupported; go ahead and compile
  	set comp_output [gcc_target_compile "$sources" "${execname}" executable $options]
  
  	if ![gcc_check_compile "$testcase compilation" $option $execname $comp_output] {
*************** proc c-torture-execute { sources args } 
*** 173,187 ****
  	    continue
  	}
  
- 	# See if this source file uses "long long" types, if it does, and
- 	# no_long_long is set, skip execution of the test.
- 	if [target_info exists no_long_long] then {
- 	    if [expr [search_for $src "long long"]] then {
- 		unsupported "$testcase execution, $option"
- 		continue
- 	    }
- 	}
- 
  	if [info exists torture_execute_xfail] {
  	    setup_xfail $torture_execute_xfail
  	}
--- 188,193 ----
*************** proc search_for { file pattern } {
*** 256,261 ****
--- 262,268 ----
  #
  proc c-torture { args } {
      global srcdir subdir compiler_conditional_xfail_data
+     global last_unsupported_match
  
      set src [lindex $args 0]
      if { [llength $args] > 1 } {
*************** proc c-torture { args } {
*** 288,293 ****
--- 295,313 ----
  	set option_list $torture_without_loops
      }
  
+     # set testcase name from source file name
+     regsub "^$srcdir/?" $src "" testcase
+     # If we couldn't rip $srcdir out of `src' then just do the best we can.
+     # The point is to reduce the unnecessary noise in the logs.  Don't strip
+     # out too much because different testcases with the same name can confuse
+     # `test-tool'.
+     if [string match "/*" $testcase] {
+ 	set testcase "[file tail [file dirname $src]]/[file tail $src]"
+     }
+ 
+     # Check for any unsupported features in this testcase
+     set unsup [check_for_unsupported $src]
+ 
      # loop through all the options
      foreach option $option_list {
  	# torture_compile_xfail is set by the .x script (if present)
*************** proc c-torture { args } {
*** 300,305 ****
--- 320,332 ----
              set ignore_me [eval $torture_eval_before_compile]
  	}
  
+ 	# If unsupported for any reason, don't go ahead with it.
+ 	if $unsup then {
+ 	    unsupported "$last_unsupported_match, $testcase compilation, $option"
+ 	    continue
+ 	}
+ 
+ 	# only compile *after* checking if unsupported!
  	c-torture-compile $src "$option $options"
      }
  }
Index: lib/gcc-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.57
diff -c -3 -p -r1.57 gcc-dg.exp
*** lib/gcc-dg.exp	13 Sep 2005 23:27:25 -0000	1.57
--- lib/gcc-dg.exp	17 Oct 2005 10:02:57 -0000
*************** proc search_for { file pattern } {
*** 197,202 ****
--- 197,203 ----
  # as c-torture does.
  proc gcc-dg-runtest { testcases default-extra-flags } {
      global runtests
+     global last_unsupported_match
  
      foreach test $testcases {
  	# If we're only testing specific files and this isn't one of
*************** proc gcc-dg-runtest { testcases default-
*** 216,222 ****
--- 217,232 ----
  
  	set nshort [file tail [file dirname $test]]/[file tail $test]
  
+ 	# Check for any unsupported features in this testcase
+ 	set unsup [check_for_unsupported $test]
+ 
  	foreach flags $option_list {
+ 	    # If unsupported for any reason, don't go ahead with it.
+ 	    if $unsup then {
+ 	        unsupported "$last_unsupported_match, $test runtest, $option_list"
+ 		continue
+ 	    }
+ 
  	    verbose "Testing $nshort, $flags" 1
  	    dg-test $test $flags ${default-extra-flags}
  	}
Index: lib/mike-gcc.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/mike-gcc.exp,v
retrieving revision 1.6
diff -c -3 -p -r1.6 mike-gcc.exp
*** lib/mike-gcc.exp	25 Jun 2005 01:45:23 -0000	1.6
--- lib/mike-gcc.exp	17 Oct 2005 10:02:57 -0000
***************
*** 16,21 ****
--- 16,23 ----
  
  # This file was derived from mike-g++.exp written by Mike Stump <mrs@cygnus.com>
  
+ load_lib target-supports.exp
+ 
  #
  # mike_cleanup -- remove any files that are created by the testcase
  #
*************** proc postbase  { src_code run groups arg
*** 57,62 ****
--- 59,65 ----
      global subdir
      global not_compiler_output
      global compiler_output
+     global last_unsupported_match
      global compiler_result
      global not_compiler_result
      global program_output
*************** proc postbase  { src_code run groups arg
*** 78,83 ****
--- 81,93 ----
  	return
      }
  
+     # Check for any unsupported features in this testcase
+     set unsup [check_for_unsupported $srcdir/$subdir/$src_code]
+     if $unsup then {
+ 	unsupported "$last_unsupported_match, $srcdir/$subdir/$src_code, $option"
+ 	continue
+     }
+ 
      if { [llength $args] > 0 } {
  	set comp_options [lindex $args 0]
      } else {
Index: lib/target-supports.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/target-supports.exp,v
retrieving revision 1.70
diff -c -3 -p -r1.70 target-supports.exp
*** lib/target-supports.exp	4 Oct 2005 21:45:50 -0000	1.70
--- lib/target-supports.exp	17 Oct 2005 10:02:57 -0000
***************
*** 19,24 ****
--- 19,145 ----
  
  # This file defines procs for determining features supported by the target.
  
+ # Init a global for the unsupported testcase matching
+ set last_unsupported_match ""
+ 
+ #
+ # search_for_many -- looks in a file for a string match with
+ # any of an entire list of strings.
+ #
+ proc search_for_many { file pattlist } {
+     global last_unsupported_match
+     set fd [open $file r]
+     while { [gets $fd cur_line]>=0 } {
+ 	foreach pattern $pattlist {
+ 	    if [string match "*$pattern*" $cur_line] then {
+ 		verbose "MATCH: Found $pattern in $file" 1
+ 		verbose ">$cur_line" 2
+ 		close $fd
+ 		set last_unsupported_match $pattern
+ 		return 1
+ 	    }
+ 	}
+     }
+     close $fd
+     return 0
+ }
+ 
+ #
+ # check_for_unsupported: tests all the various target board info 
+ # flags that might be set to indicate unsupported features and
+ # build a list of strings that can be searched for in the source
+ # code of a testcase to spot it as unsupported.
+ #
+ proc check_for_unsupported { src } {
+     # See if this testcase is unsupported for any of several reasons.
+     set unsup_patterns [list]
+ 
+     # See if this source file uses "long long" types, and if
+     # no_long_long is also set, skip execution of the test.
+     if [target_info exists no_long_long] then {
+ 	lappend unsup_patterns "long long"
+     }
+     # See if this source file uses "FILE" types; if it does, and
+     # no_file_io is set, skip execution of the test.
+     if [target_info exists no_file_io] then {
+ 	lappend unsup_patterns "FILE"
+     }
+     # See if this source file uses stdin/out/err, and no_stdio is set.
+     if [target_info exists no_stdio] then {
+ 	# it is a fact that all uses of stdin in the testsuite are followed
+ 	# immediately by a , or ; so we use this to prevent a false positive
+ 	# match against <stdint.h> - this isn't the right solution really FIXME
+ 	lappend unsup_patterns "stdin,"
+ 	lappend unsup_patterns "stdin;"
+ 	lappend unsup_patterns "stdout"
+ 	lappend unsup_patterns "stderr"
+ 	lappend unsup_patterns "putchar"
+ 	lappend unsup_patterns "puts"
+     }
+     if [target_info exists no_floating_point] then {
+ 	lappend unsup_patterns "float"
+ 	lappend unsup_patterns "double"
+     }
+     if [target_info exists no_formatted_io] then {
+ 	lappend unsup_patterns "printf"
+ 	# also catches sprintf, fprintf, etc...
+     }
+     if [target_info exists no_string_funcs] then {
+ 	lappend unsup_patterns "strcat"
+ 	lappend unsup_patterns "strchr"
+ 	lappend unsup_patterns "strcmp"
+ 	lappend unsup_patterns "strcpy"
+ 	lappend unsup_patterns "strcspn"
+ 	lappend unsup_patterns "strlen"
+ 	lappend unsup_patterns "strncat"
+ 	lappend unsup_patterns "strncmp"
+ 	lappend unsup_patterns "strncpy"
+ 	lappend unsup_patterns "strpbrk"
+ 	lappend unsup_patterns "strrchr"
+ 	lappend unsup_patterns "strspn"
+ 	lappend unsup_patterns "strstr"
+     }
+     if [target_info exists no_ctype] then {
+ 	lappend unsup_patterns "isprint"
+     }
+     if [target_info exists no_malloc] then {
+ 	lappend unsup_patterns "malloc"
+     }
+     if [target_info exists no_alloca] then {
+ 	lappend unsup_patterns "alloca"
+     }
+     # Check for unsupported header files
+     if [target_info exists no_math_h] then {
+ 	lappend unsup_patterns "math.h"
+     }
+     if [target_info exists no_setjmp_h] then {
+ 	lappend unsup_patterns "setjmp.h"
+     }
+     if [target_info exists no_signal_h] then {
+ 	lappend unsup_patterns "signal.h"
+     }
+     if [target_info exists no_stdio_h] then {
+ 	lappend unsup_patterns "stdio.h"
+     }
+     if [target_info exists no_stdlib_h] then {
+ 	lappend unsup_patterns "stdlib.h"
+     }
+     if [target_info exists no_string_h] then {
+ 	lappend unsup_patterns "string.h"
+     }
+     if [target_info exists no_wchar_h] then {
+ 	lappend unsup_patterns "wchar.h"
+     }
+     if [target_info exists no_builtin_funcs] then {
+ 	lappend unsup_patterns "__builtin_"
+     }
+     # Now check for any of the unsupported patterns.
+     if [expr [search_for_many $src $unsup_patterns]] then {
+ 	return 1
+     }
+     return 0
+ }
+ 
  # Try to compile some code and return the messages printed by the compiler.
  #
  # BASENAME is a basename to use for temporary files.

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