[ld, testsuite] Restrict dl1*main and dl6*main tests on platforms which have libdl...
authorJiong Wang <jiong.wang@arm.com>
Wed, 1 Feb 2017 16:44:40 +0000 (16:44 +0000)
committerJiong Wang <jiong.wang@arm.com>
Thu, 2 Feb 2017 09:57:26 +0000 (09:57 +0000)
ld/
* testsuite/lib/ld-lib.exp (check_libdl_available): New function.
* testsuite/ld-elf/shared.exp (run_tests): Split tests which require
dlopen support into "dlopen_run_tests".  These tests include dl1*main
and dl6*main.
(dlopen_run_tests): New and only run it when check_libdl_available
returns true.  XFAIL on *-*-netbsdelf*.

ld/ChangeLog
ld/testsuite/ld-elf/shared.exp
ld/testsuite/lib/ld-lib.exp

index 6b0484f7d53280c9046ecdf349bc15c2aecd7d3d..1ce8439e86a66b9363642d1f18b0f4ab80085d37 100644 (file)
@@ -1,3 +1,12 @@
+2017-02-02  Jiong Wang  <jiong.wang@arm.com>
+
+       * testsuite/lib/ld-lib.exp (check_libdl_available): New function.
+       * testsuite/ld-elf/shared.exp (run_tests): Split tests which require
+       dlopen support into "dlopen_run_tests".  These tests include dl1*main
+       and dl6*main.
+       (dlopen_run_tests): New and only run it when check_libdl_available
+       returns true.  XFAIL on *-*-netbsdelf*.
+
 2017-02-01  Maciej W. Rozycki  <macro@imgtec.com>
 
        * testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the
index eea9453d0e18769aca4925aa4d904e591ae56a72..29462629fa0200fe26340f445c0eb709920c686c 100644 (file)
@@ -373,12 +373,6 @@ set run_tests [list \
     [list "Run hidden libbar.so with versioned libfoo.so" \
      "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
      {main.c} "hidden" "hidden.out" ] \
-    [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
-     "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
-     {dl1main.c} "dl1a" "dl1.out" ] \
-    [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
-     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
-     {dl1main.c} "dl1b" "dl1.out" ] \
     [list "Run with libdl2a.so" \
      "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
      {dl2main.c} "dl2a" "dl2a.out" ] \
@@ -406,39 +400,6 @@ set run_tests [list \
     [list "Run with libdl4f.so" \
      "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
      {dl4main.c} "dl4f" "dl4a.out" ] \
-    [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
-     {dl6amain.c} "dl6a1" "dl6a.out" ] \
-    [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
-     {dl6amain.c} "dl6a2" "dl6b.out" ] \
-    [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
-     {dl6amain.c} "dl6a3" "dl6b.out" ] \
-    [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
-     {dl6amain.c} "dl6a4" "dl6a.out" ] \
-    [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
-     {dl6amain.c} "dl6a5" "dl6b.out" ] \
-    [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
-     {dl6amain.c} "dl6a6" "dl6b.out" ] \
-    [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
-     "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
-     {dl6amain.c} "dl6a7" "dl6a.out" ] \
-    [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
-     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
-     {dl6bmain.c} "dl6b1" "dl6a.out" ] \
-    [list "Run dl6b2 with dlopen on libdl6b.so" \
-     "-Wl,--no-as-needed $extralibs" "" \
-     {dl6bmain.c} "dl6b2" "dl6b.out" ] \
-    [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
-     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
-     {dl6cmain.c} "dl6c1" "dl6b.out" ] \
-    [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
-     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
-     {dl6dmain.c} "dl6d1" "dl6b.out" ] \
     [list "Run with libdata1.so" \
      "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
      {dynbss1.c} "dynbss1" "pass.out" ] \
@@ -486,6 +447,56 @@ set run_tests [list \
 # NetBSD ELF systems do not currently support the .*_array sections.
 run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
 
+# These tests require dlopen support.
+set dlopen_run_tests [list \
+    [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
+     "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
+     {dl1main.c} "dl1a" "dl1.out" ] \
+    [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl1main.c} "dl1b" "dl1.out" ] \
+    [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6amain.c} "dl6a1" "dl6a.out" ] \
+    [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
+     {dl6amain.c} "dl6a2" "dl6b.out" ] \
+    [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
+     {dl6amain.c} "dl6a3" "dl6b.out" ] \
+    [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
+     {dl6amain.c} "dl6a4" "dl6a.out" ] \
+    [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
+     {dl6amain.c} "dl6a5" "dl6b.out" ] \
+    [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
+     {dl6amain.c} "dl6a6" "dl6b.out" ] \
+    [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
+     {dl6amain.c} "dl6a7" "dl6a.out" ] \
+    [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6bmain.c} "dl6b1" "dl6a.out" ] \
+    [list "Run dl6b2 with dlopen on libdl6b.so" \
+     "-Wl,--no-as-needed $extralibs" "" \
+     {dl6bmain.c} "dl6b2" "dl6b.out" ] \
+    [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6cmain.c} "dl6c1" "dl6b.out" ] \
+    [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6dmain.c} "dl6d1" "dl6b.out" ] \
+]
+
+# Only run them when libdl is available.
+if [check_libdl_available] {
+  # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
+  # sections.
+  run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*"
+}
+
 # Check --no-add-needed and --no-copy-dt-needed-entries
 set testname "--no-add-needed"
 set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
index a44358e0aaace22514f1b3a770ff4e9be1938136..61626ec5796344532eec82d5805019163b9791ad 100644 (file)
@@ -2120,3 +2120,38 @@ proc istarget { target } {
     }
     return [istarget_ld $target]
 }
+
+# Return true if libdl is supported.
+
+proc check_libdl_available { } {
+    global libdl_available_saved
+    global CC
+
+    if {![info exists libdl_available_saved]} {
+        if { [which $CC] == 0 } {
+           set libdl_available_saved 0
+           return 0
+       }
+
+       set basename "tmpdir/dl_avail_test[pid]"
+       set src ${basename}.c
+       set output ${basename}.out
+       set f [open $src "w"]
+       # Sample test file.
+       puts $f "#include <dlfcn.h>"
+       puts $f "int main (void)"
+       puts $f "{"
+       puts $f "  dlopen (\"dummy.so\", RTLD_NOW);"
+       puts $f "  return 0; "
+       puts $f "}"
+       close $f
+       if [is_remote host] {
+           set src [remote_download host $src]
+       }
+       set libdl_available_saved [run_host_cmd_yesno "$CC" "$src -o $output -ldl"]
+       remote_file host delete $src
+       remote_file host delete $output
+       file delete $src
+    }
+    return $libdl_available_saved
+}