fix: disable some abi conflict tests on FreeBSD
[lttng-ust.git] / tests / regression / abi0-conflict / test_abi0_conflict
1 #!/bin/bash
2 # SPDX-License-Identifier: LGPL-2.1-only
3
4 if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
5 UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh"
6 else
7 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
8 fi
9
10 # shellcheck source=../../utils/utils.sh
11 source "$UTILSSH"
12
13 # shellcheck source=../../utils/tap.sh
14 source "$UST_TESTS_SRCDIR/utils/tap.sh"
15
16 CURDIR="${UST_TESTS_BUILDDIR}/regression/abi0-conflict"
17
18 LIBFAKEUST0_PATH="${CURDIR}/.libs"
19 LIBFAKEUST0="${LIBFAKEUST0_PATH}/libfakeust0.so"
20
21 LIBUST1_PATH="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/"
22 LIBUST1="${LIBUST1_PATH}/liblttng-ust.so.1"
23
24 STD_OUTPUT="/dev/null"
25 STD_ERROR="/dev/null"
26
27 NUM_TESTS=22
28
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
32 # first.
33 if [ "$UST_OS_TYPE" = "freebsd" ]; then
34 NUM_TESTS=$((NUM_TESTS - 4))
35 fi
36
37 # Force abort on CRIT() to detect ABI conflicts
38 export LTTNG_UST_ABORT_ON_CRITICAL=1
39
40 plan_tests $NUM_TESTS
41
42 ###
43 ## LD_PRELOAD tests
44 ###
45
46 diag "LD_PRELOAD"
47
48 ## App NOT linked on liblttng-ust
49
50 "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
51 ok $? "LD_PRELOAD: no-ust app works"
52
53 LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
54 ok $? "LD_PRELOAD: no-ust app with abi0 preload succeeds"
55
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"
58
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"
61
62
63 ## App linked on liblttng-ust.so.1
64
65 "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
66 ok $? "LD_PRELOAD: ust app works"
67
68 LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
69 isnt $? 0 "LD_PRELOAD: ust app with abi0 preload fails"
70
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"
73
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"
76
77
78 ###
79 ## dlopen tests
80 ###
81
82 diag "dlopen"
83
84 ## App NOT linked on liblttng-ust
85
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"
88
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"
91
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"
94
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"
98 fi
99
100 ## App linked on liblttng-ust.so.1
101
102 LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
103 ok $? "dlopen: ust app works"
104
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"
108
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"
111
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"
114 fi
115
116
117 ###
118 ## Indirect linking
119 ###
120
121 diag "Indirect linking"
122
123 ## App NOT linked on liblttng-ust
124
125 "${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
126 ok $? "indirect: no-ust app with abi0 succeeds"
127
128 "${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
129 ok $? "indirect: no-ust app with abi1 succeeds"
130
131 "${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
132 isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails"
133
134 ## App linked on liblttng-ust
135
136 "${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
137 isnt $? 0 "indirect: ust app with abi0 fails"
138
139 "${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
140 ok $? "indirect: ust app with abi1 succeeds"
141
142 "${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
143 isnt $? 0 "indirect: ust app with abi0 and abi1 fails"
This page took 0.032519 seconds and 4 git commands to generate.