3 # SPDX-FileCopyrightText: 2023 EfficiOS, Inc
5 # SPDX-License-Identifier: LGPL-2.1-only
7 if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
8 UTILSSH
="$UST_TESTS_SRCDIR/utils/utils.sh"
10 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
13 # shellcheck source=../../utils/utils.sh
16 # shellcheck source=../../utils/tap.sh
17 source "$UST_TESTS_SRCDIR/utils/tap.sh"
19 CURDIR
="${UST_TESTS_BUILDDIR}/regression/abi0-conflict"
21 LIBFAKEUST0_PATH
="${CURDIR}/.libs"
22 LIBFAKEUST0
="${LIBFAKEUST0_PATH}/libfakeust0.so"
24 LIBUST1_PATH
="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/"
25 LIBUST1
="${LIBUST1_PATH}/liblttng-ust.so.1"
27 STD_OUTPUT
="/dev/null"
32 # Set this variable to disable tests that rely on a library using a symbol from
33 # the global offset table even if it provides its own copy, which is the
34 # default behavior on Linux. This happens when using the '-Bsymbolic-functions'
36 UST_TESTS_LD_SYMBOLIC_FUNC
=${UST_TESTS_LD_SYMBOLIC_FUNC:-}
38 # On FreeBSD, symbol resolution when dlopening a shared object will always
39 # favor symbols local to this shared object and thus our canary function will
40 # never be called which breaks our abi conflict detection when abi1 is loaded
42 if [ "$UST_OS_TYPE" = "freebsd" ]; then
43 UST_TESTS_LD_SYMBOLIC_FUNC
=1
46 if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" != "" ]; then
47 NUM_TESTS
=$
((NUM_TESTS
- 4))
50 # Force abort on CRIT() to detect ABI conflicts
51 export LTTNG_UST_ABORT_ON_CRITICAL
=1
61 ## App NOT linked on liblttng-ust
63 "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
64 ok $?
"LD_PRELOAD: no-ust app works"
66 LD_PRELOAD
="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
67 ok $?
"LD_PRELOAD: no-ust app with abi0 preload succeeds"
69 LD_PRELOAD
="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
70 isnt $?
0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
72 LD_PRELOAD
="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
73 isnt $?
0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
76 ## App linked on liblttng-ust.so.1
78 "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
79 ok $?
"LD_PRELOAD: ust app works"
81 LD_PRELOAD
="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
82 isnt $?
0 "LD_PRELOAD: ust app with abi0 preload fails"
84 LD_PRELOAD
="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
85 isnt $?
0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
87 LD_PRELOAD
="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
88 isnt $?
0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
97 ## App NOT linked on liblttng-ust
99 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
100 ok $?
"dlopen: no-ust app works"
102 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
103 ok $?
"dlopen: no-ust app with abi1 and abi1 succeeds"
105 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
106 isnt $?
0 "dlopen: no-ust app with abi0 and abi1 fails"
108 if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then
109 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
110 isnt $?
0 "dlopen: no-ust app with abi1 and abi0 fails"
113 ## App linked on liblttng-ust.so.1
115 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
116 ok $?
"dlopen: ust app works"
118 if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then
119 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
120 isnt $?
0 "dlopen: ust app with abi0 fails"
122 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0_abi1
>"$STD_OUTPUT" 2>"$STD_ERROR"
123 isnt $?
0 "dlopen: ust app with abi0 and abi1 fails"
125 LD_LIBRARY_PATH
="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1_abi0
>"$STD_OUTPUT" 2>"$STD_ERROR"
126 isnt $?
0 "dlopen: ust app with abi1 and abi0 fails"
134 diag
"Indirect linking"
136 ## App NOT linked on liblttng-ust
138 "${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
139 ok $?
"indirect: no-ust app with abi0 succeeds"
141 "${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
142 ok $?
"indirect: no-ust app with abi1 succeeds"
144 "${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
145 isnt $?
0 "indirect: no-ust app with abi0 and abi1 fails"
147 ## App linked on liblttng-ust
149 "${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
150 isnt $?
0 "indirect: ust app with abi0 fails"
152 "${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
153 ok $?
"indirect: ust app with abi1 succeeds"
155 "${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
156 isnt $?
0 "indirect: ust app with abi0 and abi1 fails"