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]

PATCH: Eliminate more testsuite code duplication


This patch eliminates more shameful code duplication in our testsuite.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-05-17  Mark Mitchell  <mark@codesourcery.com>

	* lib/gcc-dg.exp (gcc-dg-debug-runtest): New method.
	* g++.dg/debug/debug.exp: Use gcc-dg-debug-runtest.
	* gcc.dg/debug/debug.exp: Likewise.

Index: g++.dg/debug/debug.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/debug/debug.exp,v
retrieving revision 1.1
diff -c -5 -p -r1.1 debug.exp
*** g++.dg/debug/debug.exp	14 Feb 2002 14:17:42 -0000	1.1
--- g++.dg/debug/debug.exp	17 May 2003 22:12:20 -0000
***************
*** 17,78 ****
  # G++ testsuite that uses the `dg.exp' driver.
  
  # Load support procs.
  load_lib g++-dg.exp
  
- # This is the list of debugging options we'll try.  Some of them won't
- # be supported, that's OK; they will be quickly eliminated.
- # It's probably not a good idea to add more optimisation options.
- 
- if ![info exists DEBUG_TORTURE_OPTIONS] {
-     set DEBUG_TORTURE_OPTIONS ""
-     foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
- 	set comp_output [g++_target_compile \
- 		"$srcdir/$subdir/trivial.C" "trivial.S" assembly \
- 		"additional_flags=$type"]
- 	if { ! [string match "*: unknown or unsupported -g option*" \
- 		$comp_output] } {
- 	    foreach level {1 "" 3} {
- 		lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
- 		foreach opt { -O2 -O3 } {
- 		    lappend DEBUG_TORTURE_OPTIONS \
- 			    [list "${type}${level}" "$opt" ]
- 		}
- 	    }
- 	}
-     }
- }
- 
- verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
- 
  # Initialize `dg'.
  dg-init
  
  # Main loop.
! 
! foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
!     global runtests
! 
!     # If we're only testing specific files and this isn't one of 
!     # them, skip it.
!     if ![runtest_file_p $runtests $test] {
! 	continue
!     }
! 
!     set nshort [file tail [file dirname $test]]/[file tail $test]
! 
!     foreach flags $DEBUG_TORTURE_OPTIONS {
! 	set doit 1
! 	# if { [string match {*/debug-[126].c} "$nshort"] \
! 	#	&& [string match "*1" [lindex "$flags" 0] ] } { 
! 	#    set doit 0
! 	# }
! 	
! 	if { $doit } {
! 	    verbose -log "Testing $nshort, $flags" 1
! 	    dg-test $test $flags ""
! 	}
!     }
! }
  
  # All done.
  dg-finish
--- 17,30 ----
  # G++ testsuite that uses the `dg.exp' driver.
  
  # Load support procs.
  load_lib g++-dg.exp
  
  # Initialize `dg'.
  dg-init
  
  # Main loop.
! gcc-dg-debug-runtest g++_target_compile trivial.C \
!     [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
  
  # All done.
  dg-finish
Index: gcc.dg/debug/debug.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/debug/debug.exp,v
retrieving revision 1.2
diff -c -5 -p -r1.2 debug.exp
*** gcc.dg/debug/debug.exp	12 May 2003 21:16:55 -0000	1.2
--- gcc.dg/debug/debug.exp	17 May 2003 22:12:21 -0000
***************
*** 17,89 ****
  # GCC testsuite that uses the `dg.exp' driver.
  
  # Load support procs.
  load_lib gcc-dg.exp
  
- # This is the list of debugging options we'll try.  Some of them won't
- # be supported, that's OK; they will be quickly eliminated.
- # It's probably not a good idea to add more optimisation options.
- 
- if ![info exists DEBUG_TORTURE_OPTIONS] {
-     set DEBUG_TORTURE_OPTIONS ""
-     foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
- 	set comp_output [gcc_target_compile \
- 		"$srcdir/$subdir/trivial.c" "trivial.S" assembly \
- 		"additional_flags=$type"]
- 	if { ! [string match "*: unknown or unsupported -g option*" \
- 		$comp_output] } {
- 	    foreach level {1 "" 3} {
- 		lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
- 		foreach opt { -O -O3 } {
- 		    lappend DEBUG_TORTURE_OPTIONS \
- 			    [list "${type}${level}" "$opt" ]
- 		}
- 	    }
- 	}
-     }
- }
- 
- verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
- 
  # Initialize `dg'.
  dg-init
  
  # Main loop.
  
! foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] {
!     global runtests
! 
!     # If we're only testing specific files and this isn't one of 
!     # them, skip it.
!     if ![runtest_file_p $runtests $test] {
! 	continue
!     }
! 
!     set nshort [file tail [file dirname $test]]/[file tail $test]
! 
!     foreach flags $DEBUG_TORTURE_OPTIONS {
! 	set doit 1
! 	if { [string match {*/debug-[126].c} "$nshort"] \
! 		&& [string match "*1" [lindex "$flags" 0] ] } { 
! 	    set doit 0
! 	}
! 
! # High optimization can remove the variable whose existence is tested.
! # Dwarf debugging with commentary (-dA) preserves the symbol name in the
! # assembler output, but stabs debugging does not.
! # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
! 	if { [string match {*/debug-[12].c} "$nshort"] \
! 		&& [string match "*O3*" "$flags"] \
! 		&& ( [string match "*coff*" "$flags"] \
! 		     || [string match "*stabs*" "$flags"] ) } {
! 	    set doit 0
! 	}
! 
! 	if { $doit } {
! 	    verbose -log "Testing $nshort, $flags" 1
! 	    dg-test $test $flags ""
! 	}
!     }
! }
  
  # All done.
  dg-finish
--- 17,31 ----
  # GCC testsuite that uses the `dg.exp' driver.
  
  # Load support procs.
  load_lib gcc-dg.exp
  
  # Initialize `dg'.
  dg-init
  
  # Main loop.
  
! gcc-dg-debug-runtest gcc_target_compile trivial.c \
!     [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
  
  # All done.
  dg-finish
Index: lib/gcc-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.14
diff -c -5 -p -r1.14 gcc-dg.exp
*** lib/gcc-dg.exp	16 May 2003 20:53:04 -0000	1.14
--- lib/gcc-dg.exp	17 May 2003 22:12:21 -0000
*************** proc gcc-dg-runtest { testcases default-
*** 187,191 ****
--- 187,252 ----
  	    verbose "Testing $nshort, $flags" 1
  	    dg-test $test $flags ${default-extra-flags}
  	}
      }
  }
+ 
+ proc gcc-dg-debug-runtest { target_compile trivial testcases } {
+     global srcdir subdir
+ 
+     if ![info exists DEBUG_TORTURE_OPTIONS] {
+ 	set DEBUG_TORTURE_OPTIONS ""
+ 	foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
+ 	    set comp_output [$target_compile \
+ 		    "$srcdir/$subdir/$trivial" "trivial.S" assembly \
+ 		    "additional_flags=$type"]
+ 	    if { ! [string match "*: unknown or unsupported -g option*" \
+ 		    $comp_output] } {
+ 		foreach level {1 "" 3} {
+ 		    lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
+ 		    foreach opt { -O2 -O3 } {
+ 			lappend DEBUG_TORTURE_OPTIONS \
+ 				[list "${type}${level}" "$opt" ]
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ 
+     verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
+ 
+     global runtests
+ 
+     foreach test $testcases {
+ 	# If we're only testing specific files and this isn't one of 
+ 	# them, skip it.
+ 	if ![runtest_file_p $runtests $test] {
+ 	    continue
+ 	}
+ 
+ 	set nshort [file tail [file dirname $test]]/[file tail $test]
+ 
+ 	foreach flags $DEBUG_TORTURE_OPTIONS {
+ 	    set doit 1
+ 	    if { [string match {*/debug-[126].c} "$nshort"] \
+ 		    && [string match "*1" [lindex "$flags" 0] ] } { 
+ 		set doit 0
+ 	    }
+ 
+     # High optimization can remove the variable whose existence is tested.
+     # Dwarf debugging with commentary (-dA) preserves the symbol name in the
+     # assembler output, but stabs debugging does not.
+     # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
+ 	    if { [string match {*/debug-[12].c} "$nshort"] \
+ 		    && [string match "*O3*" "$flags"] \
+ 		    && ( [string match "*coff*" "$flags"] \
+ 			 || [string match "*stabs*" "$flags"] ) } {
+ 		set doit 0
+ 	    }
+ 
+ 	    if { $doit } {
+ 		verbose -log "Testing $nshort, $flags" 1
+ 		dg-test $test $flags ""
+ 	    }
+ 	}
+     }
+ }


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