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 # Set this variable to disable tests that rely on a library using a symbol from
30 # the global offset table even if it provides its own copy, which is the
31 # default behavior on Linux. This happens when using the '-Bsymbolic-functions'
33 UST_TESTS_LD_SYMBOLIC_FUNC
=${UST_TESTS_LD_SYMBOLIC_FUNC:-}
35 # On FreeBSD, symbol resolution when dlopening a shared object will always
36 # favor symbols local to this shared object and thus our canary function will
37 # never be called which breaks our abi conflict detection when abi1 is loaded
39 if [ "$UST_OS_TYPE" = "freebsd" ]; then
40 UST_TESTS_LD_SYMBOLIC_FUNC
=1
43 if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" != "" ]; then
44 NUM_TESTS
=$
((NUM_TESTS
- 4))
47 # Force abort on CRIT() to detect ABI conflicts
48 export LTTNG_UST_ABORT_ON_CRITICAL
=1
58 ## App NOT linked on liblttng-ust
60 "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
61 ok $?
"LD_PRELOAD: no-ust app works"
63 LD_PRELOAD
="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
64 ok $?
"LD_PRELOAD: no-ust app with abi0 preload succeeds"
66 LD_PRELOAD
="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
67 isnt $?
0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
69 LD_PRELOAD
="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
70 isnt $?
0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
73 ## App linked on liblttng-ust.so.1
75 "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
76 ok $?
"LD_PRELOAD: ust app works"
78 LD_PRELOAD
="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
79 isnt $?
0 "LD_PRELOAD: ust app with abi0 preload fails"
81 LD_PRELOAD
="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
82 isnt $?
0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
84 LD_PRELOAD
="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
85 isnt $?
0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
94 ## App NOT linked on liblttng-ust
96 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
97 ok $?
"dlopen: no-ust app works"
99 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
100 ok $?
"dlopen: no-ust app with abi1 and abi1 succeeds"
102 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
103 isnt $?
0 "dlopen: no-ust app with abi0 and abi1 fails"
105 if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then
106 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
107 isnt $?
0 "dlopen: no-ust app with abi1 and abi0 fails"
110 ## App linked on liblttng-ust.so.1
112 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
113 ok $?
"dlopen: ust app works"
115 if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then
116 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
117 isnt $?
0 "dlopen: ust app with abi0 fails"
119 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
120 isnt $?
0 "dlopen: ust app with abi0 and abi1 fails"
122 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1_abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
123 isnt $?
0 "dlopen: ust app with abi1 and abi0 fails"
131 diag
"Indirect linking"
133 ## App NOT linked on liblttng-ust
135 "${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
136 ok $?
"indirect: no-ust app with abi0 succeeds"
138 "${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
139 ok $?
"indirect: no-ust app with abi1 succeeds"
141 "${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
142 isnt $?
0 "indirect: no-ust app with abi0 and abi1 fails"
144 ## App linked on liblttng-ust
146 "${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
147 isnt $?
0 "indirect: ust app with abi0 fails"
149 "${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
150 ok $?
"indirect: ust app with abi1 succeeds"
152 "${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
153 isnt $?
0 "indirect: ust app with abi0 and abi1 fails"