Commit | Line | Data |
---|---|---|
d2a010d1 | 1 | #!/bin/bash |
89a8858d MJ |
2 | |
3 | # SPDX-FileCopyrightText: 2023 EfficiOS, Inc | |
4 | # | |
d2a010d1 MJ |
5 | # SPDX-License-Identifier: LGPL-2.1-only |
6 | ||
7 | if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then | |
8 | UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh" | |
9 | else | |
10 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" | |
11 | fi | |
12 | ||
13 | # shellcheck source=../../utils/utils.sh | |
14 | source "$UTILSSH" | |
15 | ||
16 | # shellcheck source=../../utils/tap.sh | |
17 | source "$UST_TESTS_SRCDIR/utils/tap.sh" | |
18 | ||
19 | CURDIR="${UST_TESTS_BUILDDIR}/regression/abi0-conflict" | |
20 | ||
21 | LIBFAKEUST0_PATH="${CURDIR}/.libs" | |
22 | LIBFAKEUST0="${LIBFAKEUST0_PATH}/libfakeust0.so" | |
23 | ||
24 | LIBUST1_PATH="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/" | |
25 | LIBUST1="${LIBUST1_PATH}/liblttng-ust.so.1" | |
26 | ||
27 | STD_OUTPUT="/dev/null" | |
28 | STD_ERROR="/dev/null" | |
29 | ||
ef9cd5c7 MJ |
30 | NUM_TESTS=22 |
31 | ||
14f8b52c MJ |
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' | |
35 | # linker flag. | |
36 | UST_TESTS_LD_SYMBOLIC_FUNC=${UST_TESTS_LD_SYMBOLIC_FUNC:-} | |
37 | ||
ef9cd5c7 MJ |
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 | |
41 | # first. | |
42 | if [ "$UST_OS_TYPE" = "freebsd" ]; then | |
14f8b52c MJ |
43 | UST_TESTS_LD_SYMBOLIC_FUNC=1 |
44 | fi | |
45 | ||
46 | if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" != "" ]; then | |
ef9cd5c7 MJ |
47 | NUM_TESTS=$((NUM_TESTS - 4)) |
48 | fi | |
49 | ||
d2a010d1 MJ |
50 | # Force abort on CRIT() to detect ABI conflicts |
51 | export LTTNG_UST_ABORT_ON_CRITICAL=1 | |
52 | ||
ef9cd5c7 | 53 | plan_tests $NUM_TESTS |
d2a010d1 MJ |
54 | |
55 | ### | |
56 | ## LD_PRELOAD tests | |
57 | ### | |
58 | ||
59 | diag "LD_PRELOAD" | |
60 | ||
ef9cd5c7 | 61 | ## App NOT linked on liblttng-ust |
d2a010d1 MJ |
62 | |
63 | "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
64 | ok $? "LD_PRELOAD: no-ust app works" | |
65 | ||
66 | LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
67 | ok $? "LD_PRELOAD: no-ust app with abi0 preload succeeds" | |
68 | ||
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" | |
71 | ||
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" | |
74 | ||
75 | ||
ef9cd5c7 | 76 | ## App linked on liblttng-ust.so.1 |
d2a010d1 MJ |
77 | |
78 | "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
79 | ok $? "LD_PRELOAD: ust app works" | |
80 | ||
81 | LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
82 | isnt $? 0 "LD_PRELOAD: ust app with abi0 preload fails" | |
83 | ||
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" | |
86 | ||
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" | |
89 | ||
90 | ||
91 | ### | |
92 | ## dlopen tests | |
93 | ### | |
94 | ||
95 | diag "dlopen" | |
96 | ||
ef9cd5c7 | 97 | ## App NOT linked on liblttng-ust |
d2a010d1 MJ |
98 | |
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" | |
101 | ||
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" | |
104 | ||
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" | |
107 | ||
14f8b52c | 108 | if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then |
ef9cd5c7 MJ |
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" | |
111 | fi | |
d2a010d1 | 112 | |
ef9cd5c7 | 113 | ## App linked on liblttng-ust.so.1 |
d2a010d1 MJ |
114 | |
115 | LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR" | |
116 | ok $? "dlopen: ust app works" | |
117 | ||
14f8b52c | 118 | if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then |
ef9cd5c7 MJ |
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" | |
d2a010d1 | 121 | |
ef9cd5c7 MJ |
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" | |
d2a010d1 | 124 | |
ef9cd5c7 MJ |
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" | |
127 | fi | |
d2a010d1 MJ |
128 | |
129 | ||
130 | ### | |
131 | ## Indirect linking | |
132 | ### | |
133 | ||
134 | diag "Indirect linking" | |
135 | ||
ef9cd5c7 | 136 | ## App NOT linked on liblttng-ust |
d2a010d1 MJ |
137 | |
138 | "${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
139 | ok $? "indirect: no-ust app with abi0 succeeds" | |
140 | ||
141 | "${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
142 | ok $? "indirect: no-ust app with abi1 succeeds" | |
143 | ||
144 | "${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
145 | isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails" | |
146 | ||
ef9cd5c7 | 147 | ## App linked on liblttng-ust |
d2a010d1 MJ |
148 | |
149 | "${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
150 | isnt $? 0 "indirect: ust app with abi0 fails" | |
151 | ||
152 | "${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
153 | ok $? "indirect: ust app with abi1 succeeds" | |
154 | ||
155 | "${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR" | |
156 | isnt $? 0 "indirect: ust app with abi0 and abi1 fails" |