libphobos.exp (libphobos_init): Add multi-lib libgcc dirs to the ld_library_path...
[gcc.git] / libphobos / testsuite / lib / libphobos.exp
index 6d113bc51723392c7dae590471fa23c307bdf560..056e8f1d444ebad4c715cf5a274d654b80816635 100644 (file)
@@ -47,8 +47,8 @@ proc libphobos-dg-test { prog do_what extra_tool_flags } {
     set output_file ""
 
     global libphobos_test_name
+    upvar name name
     if { $libphobos_test_name != "" } {
-       upvar name name
        set name $libphobos_test_name
     }
 
@@ -80,11 +80,19 @@ proc libphobos-dg-test { prog do_what extra_tool_flags } {
        lappend options "additional_flags=$extra_tool_flags"
     }
 
-    set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]
+    set unsupported_message [libphobos_skipped_test_p $name]
+    if { $unsupported_message != "" } {
+       return [list "::unsupported::$unsupported_message" $output_file]
+    }
 
+    set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]
     return [list $comp_output $output_file]
 }
 
+proc libphobos-dg-prune { system text } {
+    return $text
+}
+
 #
 # libphobos_init
 #
@@ -120,6 +128,9 @@ proc libphobos_init { args } {
     global libphobos_test_name
     set libphobos_test_name ""
 
+    global libphobos_skip_tests
+    set libphobos_skip_tests { }
+
     # Default settings.
     set blddir [lookfor_file [get_multilibs] libphobos]
     set flags_file "${blddir}/testsuite/testsuite_flags"
@@ -143,7 +154,7 @@ proc libphobos_init { args } {
     }
 
     # Compute what needs to be added to the existing LD_LIBRARY_PATH.
-    set ld_library_path ""
+    set ld_library_path "."
 
     set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
     if {$gccdir != ""} {
@@ -159,6 +170,25 @@ proc libphobos_init { args } {
        append ld_library_path ":${blddir}/src/.libs"
     }
 
+    # Compute what needs to be added to the existing LD_LIBRARY_PATH.
+    if {$gccdir != ""} {
+       set compiler ${gccdir}/gdc
+
+       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
 
     libphobos_maybe_build_wrapper "${objdir}/testglue.o"
@@ -218,3 +248,52 @@ proc filter_libphobos_unittests { list } {
     }
     return $res
 }
+
+# Skip the unittest (report it as UNSUPPORTED) if the module exists in
+# libphobos_skip_tests and its target list is matched by dg-process-target.
+#
+# The expected format of the libphobos_skip_tests file is:
+# { test { targets } }
+proc libphobos_skipped_test_p { test } {
+    global libphobos_skip_tests
+
+    set row [lsearch -inline -index 0 $libphobos_skip_tests $test]
+    if { $row eq "" } {
+       return ""
+    }
+
+    if { [llength $row] != 2 } {
+       error "syntax error in libphobos_skip_tests: $row"
+    }
+
+    set selector [list target [lindex $row 1]]
+    if { [dg-process-target-1 $selector] != "S" } {
+       return ""
+    }
+
+    return "skipped test"
+}
+
+# Return true if the curl library is supported on the target.
+proc check_effective_target_libcurl_available { } {
+    return [check_no_compiler_messages libcurl_available executable {
+       int main (void) { return 0; }
+    } "-lcurl"]
+}
+
+# Return true if the target is linux version < 2.6.39
+proc check_effective_target_linux_pre_2639 { } {
+    if { ![istarget *-*-linux*] } {
+       return 0
+    }
+
+    if { [check_no_compiler_messages linux_pre_2639 assembly {
+       #include <linux/version.h>
+       #if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE < KERNEL_VERSION(2.6.39)
+       #error Yes, it is.
+       #endif
+    }] } {
+       return 0
+    }
+    return 1
+}