OSDN Git Service

* testsuite/lib/libffi-dg.exp (libffi-dg-test-1): Replace \n with
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / lib / libffi-dg.exp
index 95d09c1..7b98711 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+proc load_gcc_lib { filename } {
+    global srcdir
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+}
+
 load_lib dg.exp
 load_lib libgloss.exp
-
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
 
 
 # Define libffi callbacks for dg.exp.
 
 proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } {
+
+    # To get all \n in dg-output test strings to match printf output
+    # in a system that outputs it as \015\012 (i.e. not just \012), we
+    # need to change all \n into \r?\n.  As there is no dejagnu flag
+    # or hook to do that, we simply change the text being tested.
+    # Unfortunately, we have to know that the variable is called
+    # dg-output-text and lives in the caller of libffi-dg-test, which
+    # is two calls up.  Overriding proc dg-output would be longer and
+    # would necessarily have the same assumption.
+    upvar 2 dg-output-text output_match
+
+    if { [llength $output_match] > 1 } {
+       set x [regsub -all "\n" [lindex $output_match 1] "\r?\n"]
+       set output_match [lreplace $output_match 1 1 $x]
+    }
+
     # Set up the compiler flags, based on what we're going to do.
 
     set options [list]
@@ -71,12 +93,14 @@ proc libffi-init { args } {
     global gluefile wrap_flags;
     global srcdir
     global blddirffi
+    global objdir
     global blddircxx
     global TOOL_OPTIONS
-    global ld_library_path
+    global tool
     global libffi_include
     global libffi_link_flags
     global tool_root_dir
+    global ld_library_path
 
     set blddirffi [lookfor_file [get_multilibs] libffi]
     verbose "libffi $blddirffi"
@@ -101,7 +125,7 @@ proc libffi-init { args } {
            if { "$mldir" == "." } {
                continue
            }
-           if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] == 1 } {
+           if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
                append ld_library_path ":${gccdir}/${mldir}"
            }
        }
@@ -125,18 +149,17 @@ proc libffi-init { args } {
        lappend libffi_link_flags "-L${blddircxx}/src/.libs"
     }
 
-    # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
-    # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
-    # (for the 64-bit ABI).  The right way to do this would be to modify
-    # unix.exp -- but that's not an option since it's part of DejaGNU
-    # proper, so we do it here.  We really only need to do
-    # this on IRIX, but it shouldn't hurt to do it anywhere else.
-    setenv  LD_LIBRARY_PATH     $ld_library_path
-    setenv  SHLIB_PATH          $ld_library_path
-    setenv  LD_LIBRARYN32_PATH  $ld_library_path
-    setenv  LD_LIBRARY64_PATH   $ld_library_path
-    setenv  LD_LIBRARY_PATH_64  $ld_library_path
-    setenv  DYLD_LIBRARY_PATH   $ld_library_path
+    set_ld_library_path_env_vars
+    libffi_maybe_build_wrapper "${objdir}/testglue.o"
+}
+
+proc libffi_exit { } {
+    global gluefile;
+
+    if [info exists gluefile] {
+       file_on_build delete $gluefile;
+       unset gluefile;
+    }
 }
 
 proc libffi_target_compile { source dest type options } {
@@ -144,7 +167,6 @@ proc libffi_target_compile { source dest type options } {
     global srcdir
     global blddirffi
     global TOOL_OPTIONS
-    global ld_library_path
     global libffi_link_flags
     global libffi_include
     global target_triplet