changeset 313:73b5b9e224e2

- dynload_plain test: stability fix for picking right testing lib on build
author Tassilo Philipp
date Tue, 05 Nov 2019 15:19:16 +0100
parents 18de5758980e
children b2e4e23d9953
files test/dynload_plain/CMakeLists.txt test/dynload_plain/Makefile.embedded test/dynload_plain/Makefile.generic test/dynload_plain/dynload_plain.c
diffstat 4 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/test/dynload_plain/CMakeLists.txt	Tue Oct 29 16:09:58 2019 +0100
+++ b/test/dynload_plain/CMakeLists.txt	Tue Nov 05 15:19:16 2019 +0100
@@ -6,7 +6,7 @@
 set_target_properties(x PROPERTIES PREFIX "")
 set_target_properties(x PROPERTIES SUFFIX "")
 if(${UNIX})
-exec_program("((ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\\.a\$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1" OUTPUT_VARIABLE DEF_C_DYLIB)
+exec_program("((ldd `which ls` | grep -o '/.*/libc.so[^ ]*' || ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\\.a\$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1" OUTPUT_VARIABLE DEF_C_DYLIB)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEF_C_DYLIB=\\\"${DEF_C_DYLIB}\\\"")
 endif()
 
--- a/test/dynload_plain/Makefile.embedded	Tue Oct 29 16:09:58 2019 +0100
+++ b/test/dynload_plain/Makefile.embedded	Tue Nov 05 15:19:16 2019 +0100
@@ -1,8 +1,8 @@
 # path to default libc.so file, easier to do via shell than in code (see main() in dynload_plain.c)
 # for compat: first gmake style, then assignment op which will use ! as part of var name on gmake<4
 #             and thus not override previously set var
-DEF_C_DYLIB=$(shell ((ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1)
-DEF_C_DYLIB!=((ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1
+DEF_C_DYLIB=$(shell ((ldd `which ls` | grep -o '/.*/libc.so[^ ]*' || ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1)
+DEF_C_DYLIB!=((ldd `which ls` | grep -o '/.*/libc.so[^ ]*' || ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1
 
 APP = dynload_plain
 OBJS = dynload_plain.o
--- a/test/dynload_plain/Makefile.generic	Tue Oct 29 16:09:58 2019 +0100
+++ b/test/dynload_plain/Makefile.generic	Tue Nov 05 15:19:16 2019 +0100
@@ -1,8 +1,8 @@
 # path to default libc.so file, easier to do via shell than in code (see main() in dynload_plain.c)
 # for compat: first gmake style, then assignment op which will use ! as part of var name on gmake<4
 #             and thus not override previously set var
-DEF_C_DYLIB=$(shell ((ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1)
-DEF_C_DYLIB!=((ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1
+DEF_C_DYLIB=$(shell ((ldd `which ls` | grep -o '/.*/libc.so[^ ]*' || ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1)
+DEF_C_DYLIB!=((ldd `which ls` | grep -o '/.*/libc.so[^ ]*' || ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2)) 2>/dev/null | head -1
 
 APP        = dynload_plain
 OBJS       = dynload_plain.o
--- a/test/dynload_plain/dynload_plain.c	Tue Oct 29 16:09:58 2019 +0100
+++ b/test/dynload_plain/dynload_plain.c	Tue Nov 05 15:19:16 2019 +0100
@@ -58,16 +58,17 @@
 #if defined(DEF_C_DYLIB)
     DEF_C_DYLIB,
 #endif
+	/* fallback guessing if not provided by Makefile */
     "/lib/libc.so",
     "/lib32/libc.so",
     "/lib64/libc.so",
     "/usr/lib/libc.so",
     "/usr/lib/system/libsystem_c.dylib", /* macos */
     "/usr/lib/libc.dylib",
-    "/boot/system/lib/libroot.so", /* Haiku */
-    "\\ReactOS\\system32\\msvcrt.dll", /* ReactOS */
+    "/boot/system/lib/libroot.so",       /* Haiku */
+    "\\ReactOS\\system32\\msvcrt.dll",   /* ReactOS */
     "C:\\ReactOS\\system32\\msvcrt.dll",
-    "\\Windows\\system32\\msvcrt.dll", /* Windows */
+    "\\Windows\\system32\\msvcrt.dll",   /* Windows */
     "C:\\Windows\\system32\\msvcrt.dll"
   };