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>
* 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.
* 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)
*/
void init_usterr(void);
void init_usterr(void)
STD_OUTPUT="/dev/null"
STD_ERROR="/dev/null"
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
# Force abort on CRIT() to detect ABI conflicts
export LTTNG_UST_ABORT_ON_CRITICAL=1
-## 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"
"${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
ok $? "LD_PRELOAD: no-ust app works"
isnt $? 0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
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"
"${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
ok $? "LD_PRELOAD: ust app works"
-## 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"
LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
ok $? "dlopen: no-ust app works"
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" 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" 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
-## 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"
"${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
ok $? "indirect: no-ust app with abi0 succeeds"
"${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails"
"${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"
"${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
isnt $? 0 "indirect: ust app with abi0 fails"
UST_TESTS_BUILDDIR="$testsdir"
fi
export UST_TESTS_BUILDDIR
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
+