2 # SPDX-License-Identifier: LGPL-2.1-only
4 if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
5 UTILSSH
="$UST_TESTS_SRCDIR/utils/utils.sh"
7 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
10 # shellcheck source=../../utils/utils.sh
13 # shellcheck source=../../utils/tap.sh
14 source "$UST_TESTS_SRCDIR/utils/tap.sh"
16 CURDIR
="${UST_TESTS_BUILDDIR}/regression/abi0-conflict"
18 LIBFAKEUST0_PATH
="${CURDIR}/.libs"
19 LIBFAKEUST0
="${LIBFAKEUST0_PATH}/libfakeust0.so"
21 LIBUST1_PATH
="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/"
22 LIBUST1
="${LIBUST1_PATH}/liblttng-ust.so.1"
24 STD_OUTPUT
="/dev/null"
29 # On FreeBSD, symbol resolution when dlopening a shared object will always
30 # favor symbols local to this shared object and thus our canary function will
31 # never be called which breaks our abi conflict detection when abi1 is loaded
33 if [ "$UST_OS_TYPE" = "freebsd" ]; then
34 NUM_TESTS
=$
((NUM_TESTS
- 4))
37 # Force abort on CRIT() to detect ABI conflicts
38 export LTTNG_UST_ABORT_ON_CRITICAL
=1
48 ## App NOT linked on liblttng-ust
50 "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
51 ok $?
"LD_PRELOAD: no-ust app works"
53 LD_PRELOAD
="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
54 ok $?
"LD_PRELOAD: no-ust app with abi0 preload succeeds"
56 LD_PRELOAD
="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
57 isnt $?
0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
59 LD_PRELOAD
="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
60 isnt $?
0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
63 ## App linked on liblttng-ust.so.1
65 "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
66 ok $?
"LD_PRELOAD: ust app works"
68 LD_PRELOAD
="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
69 isnt $?
0 "LD_PRELOAD: ust app with abi0 preload fails"
71 LD_PRELOAD
="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
72 isnt $?
0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
74 LD_PRELOAD
="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
75 isnt $?
0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
84 ## App NOT linked on liblttng-ust
86 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
87 ok $?
"dlopen: no-ust app works"
89 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
90 ok $?
"dlopen: no-ust app with abi1 and abi1 succeeds"
92 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
93 isnt $?
0 "dlopen: no-ust app with abi0 and abi1 fails"
95 if [ "$UST_OS_TYPE" != "freebsd" ]; then
96 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
97 isnt $?
0 "dlopen: no-ust app with abi1 and abi0 fails"
100 ## App linked on liblttng-ust.so.1
102 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
103 ok $?
"dlopen: ust app works"
105 if [ "$UST_OS_TYPE" != "freebsd" ]; then
106 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
107 isnt $?
0 "dlopen: ust app with abi0 fails"
109 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
110 isnt $?
0 "dlopen: ust app with abi0 and abi1 fails"
112 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1_abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
113 isnt $?
0 "dlopen: ust app with abi1 and abi0 fails"
121 diag
"Indirect linking"
123 ## App NOT linked on liblttng-ust
125 "${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
126 ok $?
"indirect: no-ust app with abi0 succeeds"
128 "${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
129 ok $?
"indirect: no-ust app with abi1 succeeds"
131 "${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
132 isnt $?
0 "indirect: no-ust app with abi0 and abi1 fails"
134 ## App linked on liblttng-ust
136 "${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
137 isnt $?
0 "indirect: ust app with abi0 fails"
139 "${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
140 ok $?
"indirect: ust app with abi1 succeeds"
142 "${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
143 isnt $?
0 "indirect: ust app with abi0 and abi1 fails"