target-supports.exp (check_iconv_available): Default libiconv to -liconv, if there...
authorMark Mitchell <mark@codesourcery.com>
Wed, 23 Mar 2005 16:45:45 +0000 (16:45 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 23 Mar 2005 16:45:45 +0000 (16:45 +0000)
* lib/target-supports.exp (check_iconv_available): Default
libiconv to -liconv, if there is no definition.

* 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.

From-SVN: r96934

gcc/testsuite/ChangeLog
gcc/testsuite/lib/target-supports.exp
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/lib/libstdc++.exp
libstdc++-v3/testsuite/libstdc++-dg/normal.exp

index 22ddaa58112ea71d8248a5978a2399edd218608f..d39269f7e00dcda015b4714e907e24e2c27099bb 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-23  Mark Mitchell  <mark@codesourcery.com>
+
+       * lib/target-supports.exp (check_iconv_available): Default
+       libiconv to -liconv, if there is no definition.
+
 2005-03-23  Hans-Peter Nilsson  <hp@axis.com>
 
        * gcc.dg/torture/cris-asm-mof-1.c: New test.
index 2acef12aeeaccd6d7ecc76c54797297125b246db..d37fd2d6b8ff30137928fed644cc463b82da8215 100644 (file)
@@ -303,6 +303,10 @@ proc check_iconv_available { test_what } {
     puts $f "return 0;\n}"
     close $f
 
+    # If the tool configuration file has not set libiconv, try "-liconv"
+    if { ![info exists libiconv] } {
+       set libiconv "-liconv"
+    }
     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
     file delete $src
 
index fe273acaff1b678919c975baf02ca3831c1c7e96..c62add61d43086b8058c6d24aeb543a9b5a47038 100644 (file)
@@ -1,3 +1,16 @@
+2005-03-23  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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.
+       
 2005-03-21  Chris Jefferson  <chris@bubblescope.net>
 
        PR libstdc++/20577
index 0ac4196b7c344237bddcfd3813da403bc117e0ff..5d7b642db17f2adc165fd6d872a0f1df3e0095de 100644 (file)
@@ -134,27 +134,32 @@ proc libstdc++_init { testfile } {
     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"
+    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)"
+       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
@@ -176,7 +181,7 @@ proc libstdc++_init { testfile } {
             set includes [exec sh $flags_file --build-includes]
         } else {
             set cxx [transform "g++"]
-            set cxxflags "-ggdb3"
+            set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0" 
             set includes "-I${srcdir}"
         }
     }
@@ -242,6 +247,15 @@ proc libstdc++-dg-test { prog do_what extra_tool_flags } {
     return [list $comp_output $output_file]
 }
 
+# True if the library supports wchar_t.
+set libstdc++_wchar_t 0
+
+# True if the library supports threads.
+set libstdc++_threads 0
+
+# A string naming object files to be linked into all tests.
+set libstdc++_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 } {
@@ -251,6 +265,7 @@ proc v3_target_compile { source dest type options } {
     global cxxflags
     global includes
     global blddir
+    global libstdc++_test_objs
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
         lappend options "libs=${gluefile}"
@@ -262,42 +277,56 @@ proc v3_target_compile { source dest type options } {
     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 ${libstdc++_test_objs}]
+    }
 
     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 } {
+# Build the support objects linked in with the libstdc++ tests.  In
+# addition, set libstdc++_wchar_t, libstdc++_threads, and libstdc++_test_objs
+# appropriately.
+proc libstdc++_build_support {} {
     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"
+    global libstdc++_wchar_t
+    global libstdc++_threads
+    global libstdc++_test_objs
+
+    # Figure out whether or not the library supports certain features.
+    set libstdc++_wchar_t 0
+    set libstdc++_threads 0
+    set libstdc++_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 libstdc++_wchar_t 1
+       } elseif { [string first "_GLIBCXX_HAVE_GTHR_DEFAULT" $l] != -1 } {
+           verbose -log "thread support detected"
+           set libstdc++_threads 1
+       }
+    }
 
-    # 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"
+    # 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
+       if { [v3_target_compile $srcdir/$f $object_file "object" \
+               "incdir=$srcdir"] 
+            != "" } {
+           error "could not compile $f"
+       }
+       append libstdc++_test_objs "$object_file "
     }
-    return $sfiles
 }
index b613c66da1cbca3ef9e7ad3a8976267e704c3586..67f4920eb1089432212843f4a719752efd455245 100644 (file)
 # Initialization.
 dg-init
 
+# Build the support objects.
+libstdc++_build_support
+
+# 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.
+set tests [list]
+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 realy 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
+            && (${libstdc++_wchar_t} || [string first wchar_t $t] == -1) 
+             && (${libstdc++_threads} || [string first thread $t] == -1) } {
+           lappend tests $t
+       }
+    }
+}
+set tests [lsort $tests]
+
 # Main loop.
 global DEFAULT_CXXFLAGS
-dg-runtest [v3-list-tests testsuite_files] "" $DEFAULT_CXXFLAGS
-#dg-runtest [v3-list-tests testsuite_files_interactive] "" $DEFAULT_CXXFLAGS
+dg-runtest $tests "" $DEFAULT_CXXFLAGS
 
 # All done.
 dg-finish