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: 4.0 backport of libstdc++ testsuite changes


As previously mentioned, here is a backport to 4.0 of the bits
required to run the libstdc++ testsuite on an installed toolchain.
My next patch will be a patch to test.html explaining how to run the
tests in this manner.

This patch contains no changes from the mainline version of the
patch.  I plan to check this in after 24 hours, unless there are
objections.  Benjamin has already OK'd the backport in principle, but
I am going to err on the side of caution.

Tested on x86_64-unknown-linux-gnu.

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

2005-05-04  Mark Mitchell  <mark@codesourcery.com>

	Backport:
	2005-03-25  Mark Mitchell  <mark@codesourcery.com>
	* testsuite/lib/libstdc++.exp (libstdc++_init): Define LOCALEDIR
	when testing an installed compiler.
	* testsuite/lib/libstdc++.exp (v3-build_support): Pass -w when
	compiling support objects.
	2005-03-23  Mark Mitchell  <mark@codesourcery.com>
	* testsuite/libstdc++-dg/normal.exp: Read testsuite_files, if it
	exists.
	* testsuite/lib/libstdc++.exp (libstdc++_wchar_t): Rename to ...
	(v3-wchar_t): ... this.
	(libstdc++_threads): Rename to ...
	(v3-threads): ... this.
	(libstdc++_test_objs): Rename to ...
	(v3-test_objs): ... this.
	(libstdc++_build_support): Rename to ...
	(v3-build_support): ... this.
	* testsuite/libstdc++-dg/normal.exp: Adjust to use new names.
	* testsuite/lib/libstdc++.exp (libstdc++_init): Improve handling
	of compilers not in the build directory.
	(libstdc++_wchar_t): New variable.
	(libstdc++_threads): Likewise.
	(libstdc++_test_objs): Likewise.
	(v3_target_compile): Use libstdc++_test_objs.
	(v3-list-tests): Remove.
	(listdc++_build_support): New function.
	* testsuite/libstdc++-dg/normal.exp: Rework to dynamically
	generate list of tests.
	
Index: libstdc++-dg/normal.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/libstdc++-dg/normal.exp,v
retrieving revision 1.4
retrieving revision 1.7
diff -c -5 -p -r1.4 -r1.7
*** libstdc++-dg/normal.exp	27 Feb 2004 22:01:32 -0000	1.4
--- libstdc++-dg/normal.exp	24 Mar 2005 04:26:30 -0000	1.7
***************
*** 19,30 ****
  # libstdc++-v3 testsuite that uses the 'dg.exp' driver.
  
  # Initialization.
  dg-init
  
  # Main loop.
  global DEFAULT_CXXFLAGS
! dg-runtest [v3-list-tests testsuite_files] "" $DEFAULT_CXXFLAGS
! #dg-runtest [v3-list-tests testsuite_files_interactive] "" $DEFAULT_CXXFLAGS
  
  # All done.
  dg-finish
--- 19,93 ----
  # libstdc++-v3 testsuite that uses the 'dg.exp' driver.
  
  # Initialization.
  dg-init
  
+ # Build the support objects.
+ v3-build_support
+ 
+ set tests [list]
+ 
+ # If there is a "testsuite_files" file, use it.
+ #
+ # This is a workaround for problems reported with using:
+ #
+ #   runtest normal.exp="`cat testsuite_files`"
+ #
+ # See:
+ #  http://gcc.gnu.org/ml/libstdc++/2005-03/msg00278.html
+ # for discussion of the problem.
+ #
+ # If that worked consistently, we could modify "make check" to
+ # pass that option, and then remove this code.
+ if {[info exists blddir]} {
+     set tests_file "${blddir}/testsuite/testsuite_files"
+ }
+ if {[info exists tests_file] && [file exists $tests_file]} {
+     set f [open $tests_file]
+     while { ! [eof $f] } {
+ 	set t [gets $f]
+ 	if { [string length "$t"] != 0 } {
+ 	    lappend tests ${srcdir}/${t}
+ 	}
+     } 
+     close $f
+ } else {
+     # Find directories that might have tests.
+     set subdirs [glob "$srcdir/\[0-9\]\[0-9\]*"]
+     foreach d [glob "$srcdir/\[a-z\]*"] {
+ 	if {[file isdirectory $d]} { 
+ 	    lappend subdirs $d
+ 	}
+     }
+     # Find all the tests.
+     foreach s $subdirs {
+ 	set subdir_tests [find $s *.cc]
+ 	# Filter out tests that should not be run.
+ 	foreach t $subdir_tests {
+ 	    # The DejaGNU "find" procedure sometimes returns a list 
+ 	    # containing an empty string, when it should really return
+ 	    # an empty list.
+ 	    if { $t == "" } {
+ 		continue
+ 	    }
+ 	    # Filter out:
+ 	    # 1. interactive tests.
+ 	    # 2. performance tests.
+ 	    # 3. wchar_t tests, if not supported.
+ 	    # 4. thread tests, if not supported. 
+ 	    if { [string first _xin $t] == -1
+ 		 && [string first performance $t] == -1
+ 		 && (${v3-wchar_t} || [string first wchar_t $t] == -1) 
+ 		 && (${v3-threads} || [string first thread $t] == -1) } {
+ 		lappend tests $t
+ 	    }
+ 	}
+     }
+ }
+ set tests [lsort $tests]
+ 
  # Main loop.
  global DEFAULT_CXXFLAGS
! dg-runtest $tests "" $DEFAULT_CXXFLAGS
  
  # All done.
  dg-finish
Index: lib/libstdc++.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/lib/libstdc++.exp,v
retrieving revision 1.32
retrieving revision 1.36
diff -c -5 -p -r1.32 -r1.36
*** lib/libstdc++.exp	11 Feb 2005 22:40:15 -0000	1.32
--- lib/libstdc++.exp	25 Mar 2005 23:24:57 -0000	1.36
*************** proc libstdc++_init { testfile } {
*** 132,162 ****
          set gccdir [file dirname $gccdir]
      }
      v3track gccdir 3
  
      # Compute what needs to be added to the existing LD_LIBRARY_PATH.
!     set ld_library_path ""
!     append ld_library_path ":${gccdir}"
!     set compiler ${gccdir}/g++
!     if { [is_remote host] == 0 && [which $compiler] != 0 } {
!       foreach i "[exec $compiler --print-multi-lib]" {
!         set mldir ""
!         regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
!         set mldir [string trimright $mldir "\;@"]
!         if { "$mldir" == "." } {
!           continue
!         }
!         if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
!           append ld_library_path ":${gccdir}/${mldir}"
!         }
!       }
!     }
!     append ld_library_path ":${blddir}/src/.libs"
! 
!     set_ld_library_path_env_vars
!     if [info exists env(LD_LIBRARY_PATH)] {
!       verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
      }
  
      # Do a bunch of handstands and backflips for cross compiling and
      # finding simulators...
      if [is_remote host] {
--- 132,167 ----
          set gccdir [file dirname $gccdir]
      }
      v3track gccdir 3
  
      # Compute what needs to be added to the existing LD_LIBRARY_PATH.
!     if {$gccdir != ""} {
! 	set ld_library_path ""
! 	append ld_library_path ":${gccdir}"
! 	set compiler ${gccdir}/g++
! 	append ld_library_path ":${blddir}/src/.libs"
! 
! 	if { [is_remote host] == 0 && [which $compiler] != 0 } {
! 	  foreach i "[exec $compiler --print-multi-lib]" {
! 	    set mldir ""
! 	    regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
! 	    set mldir [string trimright $mldir "\;@"]
! 	    if { "$mldir" == "." } {
! 	      continue
! 	    }
! 	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
! 	      append ld_library_path ":${gccdir}/${mldir}"
! 	    }
! 	  }
! 	}
! 
! 	set_ld_library_path_env_vars
! 	if [info exists env(LD_LIBRARY_PATH)] {
! 	  verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
! 	}
!     } else {
! 	set compiler [transform "g++"]
      }
  
      # Do a bunch of handstands and backflips for cross compiling and
      # finding simulators...
      if [is_remote host] {
*************** proc libstdc++_init { testfile } {
*** 174,185 ****
              set cxx [exec sh $flags_file --build-cxx]
              set cxxflags [exec sh $flags_file --cxxflags]
              set includes [exec sh $flags_file --build-includes]
          } else {
              set cxx [transform "g++"]
!             set cxxflags "-ggdb3"
              set includes "-I${srcdir}"
          }
      }
  
      libstdc++_maybe_build_wrapper "${objdir}/testglue.o"
  }
--- 179,198 ----
              set cxx [exec sh $flags_file --build-cxx]
              set cxxflags [exec sh $flags_file --cxxflags]
              set includes [exec sh $flags_file --build-includes]
          } else {
              set cxx [transform "g++"]
!             set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0" 
              set includes "-I${srcdir}"
+ 	    # Guess at the location of the installed locale files.
+ 	    # (It would be nice if "gcc --print-file-name" could find
+ 	    # message files, but it cannot.)
+ 	    set absolute_cxx [which $cxx]
+ 	    if { $absolute_cxx != "" } {
+ 		set localedir "[file dirname $absolute_cxx]/../share/locale"
+ 	    }
+ 	    set cxxflags "$cxxflags -DLOCALEDIR=\"$localedir\""
          }
      }
  
      libstdc++_maybe_build_wrapper "${objdir}/testglue.o"
  }
*************** proc libstdc++-dg-test { prog do_what ex
*** 240,258 ****
--- 253,281 ----
      set comp_output [ prune_g++_output $comp_output ];
  
      return [list $comp_output $output_file]
  }
  
+ # True if the library supports wchar_t.
+ set v3-wchar_t 0
+ 
+ # True if the library supports threads.
+ set v3-threads 0
+ 
+ # A string naming object files to be linked into all tests.
+ set v3-test_objs ""
+ 
  # Called from libstdc++-dg-test above.  Calls back into system's
  # target_compile to actually do the work.
  proc v3_target_compile { source dest type options } {
      global gluefile 
      global wrap_flags
      global cxx
      global cxxflags
      global includes
      global blddir
+     global v3-test_objs
  
      if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
          lappend options "libs=${gluefile}"
          lappend options "ldflags=${wrap_flags}"
      }
*************** proc v3_target_compile { source dest typ
*** 260,303 ****
      set cxx_final $cxx
      set cxxlibglossflags  [libgloss_link_flags]
      set cxx_final [concat $cxx_final $cxxlibglossflags]
      set cxx_final [concat $cxx_final $cxxflags]
      set cxx_final [concat $cxx_final $includes]
  
      lappend options "compiler=$cxx_final"
  
-     # Picks up the freshly-built testsuite library corresponding to the
-     # multilib under test.
-     lappend options "ldflags=-L${blddir}/testsuite"
-     lappend options "libs=-lv3test"
- 
      return [target_compile $source $dest $type $options]
  }
  
! 
! # Called once, from libstdc++/normal.exp.
! proc v3-list-tests { filename } {
      global srcdir
!     global blddir
! 
!     set tests_file "${blddir}/testsuite/${filename}"
!     set sfiles ""
! 
!     verbose -log "In v3-list-tests"
!     verbose -log "blddir = ${blddir}"
!     verbose -log "tests_file = $tests_file"
! 
!     # If there is a testsuite_file, use it. 
!     if { [file exists $tests_file] } {
!         set f [open $tests_file]
!         while { ! [eof $f] } {
!             set t [gets $f]
!             if { [string length "$t"] != 0 } {
!                 lappend sfiles  ${srcdir}/${t}
!             }
!         } 
!         close $f
!     } else {
!         verbose "cannot open $tests_file"
      }
-     return $sfiles
  }
--- 283,342 ----
      set cxx_final $cxx
      set cxxlibglossflags  [libgloss_link_flags]
      set cxx_final [concat $cxx_final $cxxlibglossflags]
      set cxx_final [concat $cxx_final $cxxflags]
      set cxx_final [concat $cxx_final $includes]
+     # Link the support objects into executables.
+     if { $type == "executable" } {
+ 	set cxx_final [concat $cxx_final ${v3-test_objs}]
+     }
  
      lappend options "compiler=$cxx_final"
  
      return [target_compile $source $dest $type $options]
  }
  
! # Build the support objects linked in with the libstdc++ tests.  In
! # addition, set v3-wchar_t, v3-threads, and v3-test_objs
! # appropriately.
! proc v3-build_support {} {
      global srcdir
!     global v3-wchar_t
!     global v3-threads
!     global v3-test_objs
! 
!     # Figure out whether or not the library supports certain features.
!     set v3-wchar_t 0
!     set v3-threads 0
!     set v3-test_objs ""
! 
!     set config_src "config.cc"
!     set f [open $config_src "w"]
!     puts $f "#include <bits/c++config.h>"
!     close $f
!     set preprocessed [v3_target_compile $config_src "" \
! 	    	       preprocess "additional_flags=-dN"]
!     foreach l $preprocessed {
! 	if { [string first "_GLIBCXX_USE_WCHAR_T" $l] != -1 } {
! 	    verbose -log "wchar_t support detected"
! 	    set v3-wchar_t 1
! 	} elseif { [string first "_GLIBCXX_HAVE_GTHR_DEFAULT" $l] != -1 } {
! 	    verbose -log "thread support detected"
! 	    set v3-threads 1
! 	}
!     }
! 
!     # Build the support objects.
!     set source_files \
! 	[list testsuite_abi.cc testsuite_allocator.cc testsuite_hooks.cc]
!     foreach f $source_files {
! 	set object_file [file rootname $f].o
! 	# Compile with "-w" so that warnings issued by the compiler
! 	# do not prevent compilation.
! 	if { [v3_target_compile $srcdir/$f $object_file "object" \
! 		  [list "incdir=$srcdir" "additional_flags=-w"]]
! 	     != "" } {
! 	    error "could not compile $f"
! 	}
! 	append v3-test_objs "$object_file "
      }
  }


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