fix: disable some abi conflict tests on FreeBSD
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 17 May 2021 15:24:47 +0000 (11:24 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 17 May 2021 15:55:20 +0000 (11:55 -0400)
On FreeBSD, symbol resolution when dlopening a shared object will always
favor symbols local to this shared object and thus our canary function will
never be called which breaks our abi conflict detection when abi1 is loaded
first.

Disable the test cases with this scenario on FreeBSD as we have no way
to fix this at the moment.

Change-Id: Ic0451ce61e21f94ece55429b41bf76db3ad74b3a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/lib/lttng-ust/lttng-ust-comm.c
tests/regression/abi0-conflict/test_abi0_conflict
tests/utils/utils.sh

index 2c902dc2737e922204628293e806306fa08e174a..2a105bd7dcefe5c5cd976cb0010f2b23b2c9349e 100644 (file)
@@ -2125,6 +2125,10 @@ void lttng_ust_check_soname_0(void)
  * Expose a canary symbol of the previous ABI to ensure we catch uses of a
  * liblttng-ust.so.0 dlopen'd after .so.1 has been loaded. Use a different
  * symbol than the detection code to ensure we don't detect ourself.
+ *
+ * This scheme will only work on systems where the global symbol table has
+ * priority when resolving the symbols of a dlopened shared object, which is
+ * the case on Linux but not on FreeBSD.
  */
 void init_usterr(void);
 void init_usterr(void)
index e79e3772cb23841be3ed96dc898cab2532313b4e..cc5966eae448ab4c724e8f8c93b5137b322cc010 100755 (executable)
@@ -24,10 +24,20 @@ LIBUST1="${LIBUST1_PATH}/liblttng-ust.so.1"
 STD_OUTPUT="/dev/null"
 STD_ERROR="/dev/null"
 
+NUM_TESTS=22
+
+# On FreeBSD, symbol resolution when dlopening a shared object will always
+# favor symbols local to this shared object and thus our canary function will
+# never be called which breaks our abi conflict detection when abi1 is loaded
+# first.
+if [ "$UST_OS_TYPE" = "freebsd" ]; then
+       NUM_TESTS=$((NUM_TESTS - 4))
+fi
+
 # Force abort on CRIT() to detect ABI conflicts
 export LTTNG_UST_ABORT_ON_CRITICAL=1
 
-plan_tests 22
+plan_tests $NUM_TESTS
 
 ###
 ##  LD_PRELOAD tests
@@ -35,7 +45,7 @@ plan_tests 22
 
 diag "LD_PRELOAD"
 
-## App NOT linked on liblttn-ust
+## App NOT linked on liblttng-ust
 
 "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
 ok $? "LD_PRELOAD: no-ust app works"
@@ -50,7 +60,7 @@ LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$
 isnt $? 0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
 
 
-## App linked on liblttn-ust.so.1
+## App linked on liblttng-ust.so.1
 
 "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
 ok $? "LD_PRELOAD: ust app works"
@@ -71,7 +81,7 @@ isnt $? 0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
 
 diag "dlopen"
 
-## App NOT linked on liblttn-ust
+## App NOT linked on liblttng-ust
 
 LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
 ok $? "dlopen: no-ust app works"
@@ -82,22 +92,26 @@ ok $? "dlopen: no-ust app with abi1 and abi1 succeeds"
 LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
 isnt $? 0 "dlopen: no-ust app with abi0 and abi1 fails"
 
-LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
-isnt $? 0 "dlopen: no-ust app with abi1 and abi0 fails"
+if [ "$UST_OS_TYPE" != "freebsd" ]; then
+    LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+    isnt $? 0 "dlopen: no-ust app with abi1 and abi0 fails"
+fi
 
-## App linked on liblttn-ust.so.1
+## App linked on liblttng-ust.so.1
 
 LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
 ok $? "dlopen: ust app works"
 
-LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
-isnt $? 0 "dlopen: ust app with abi0 fails"
+if [ "$UST_OS_TYPE" != "freebsd" ]; then
+    LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+    isnt $? 0 "dlopen: ust app with abi0 fails"
 
-LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
-isnt $? 0 "dlopen: ust app with abi0 and abi1 fails"
+    LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
+    isnt $? 0 "dlopen: ust app with abi0 and abi1 fails"
 
-LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1_abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
-isnt $? 0 "dlopen: ust app with abi1 and abi0 fails"
+    LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1_abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+    isnt $? 0 "dlopen: ust app with abi1 and abi0 fails"
+fi
 
 
 ###
@@ -106,7 +120,7 @@ isnt $? 0 "dlopen: ust app with abi1 and abi0 fails"
 
 diag "Indirect linking"
 
-## App NOT linked on liblttn-ust
+## App NOT linked on liblttng-ust
 
 "${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
 ok $? "indirect: no-ust app with abi0 succeeds"
@@ -117,7 +131,7 @@ ok $? "indirect: no-ust app with abi1 succeeds"
 "${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
 isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails"
 
-## App linked on liblttn-ust
+## App linked on liblttng-ust
 
 "${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
 isnt $? 0 "indirect: ust app with abi0 fails"
index cefb782c1d2aef4207dcbda646d45375708dbfa1..212807bba3f302cd6f0c7b7c7ff16b61538f7a61 100755 (executable)
@@ -31,3 +31,33 @@ if [ "x${UST_TESTS_BUILDDIR:-}" = "x" ]; then
        UST_TESTS_BUILDDIR="$testsdir"
 fi
 export UST_TESTS_BUILDDIR
+
+# The OS on which we are running. See [1] for possible values of 'uname -s'.
+# We do a bit of translation to ease our life down the road for comparison.
+# Export it so that called executables can use it.
+# [1] https://en.wikipedia.org/wiki/Uname#Examples
+if [ "x${UST_OS_TYPE:-}" = "x" ]; then
+       UST_OS_TYPE="$(uname -s)"
+       case "$UST_OS_TYPE" in
+       MINGW*)
+               UST_OS_TYPE="mingw"
+               ;;
+       Darwin)
+               UST_OS_TYPE="darwin"
+               ;;
+       Linux)
+               UST_OS_TYPE="linux"
+               ;;
+       CYGWIN*)
+               UST_OS_TYPE="cygwin"
+               ;;
+       FreeBSD)
+               UST_OS_TYPE="freebsd"
+               ;;
+       *)
+               UST_OS_TYPE="unsupported"
+               ;;
+       esac
+fi
+export UST_OS_TYPE
+
This page took 0.027901 seconds and 4 git commands to generate.