fix: Allow disabling some abi compat tests
[lttng-ust.git] / tests / regression / abi0-conflict / test_abi0_conflict
CommitLineData
d2a010d1
MJ
1#!/bin/bash
2# SPDX-License-Identifier: LGPL-2.1-only
3
4if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
5 UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh"
6else
7 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
8fi
9
10# shellcheck source=../../utils/utils.sh
11source "$UTILSSH"
12
13# shellcheck source=../../utils/tap.sh
14source "$UST_TESTS_SRCDIR/utils/tap.sh"
15
16CURDIR="${UST_TESTS_BUILDDIR}/regression/abi0-conflict"
17
18LIBFAKEUST0_PATH="${CURDIR}/.libs"
19LIBFAKEUST0="${LIBFAKEUST0_PATH}/libfakeust0.so"
20
21LIBUST1_PATH="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/"
22LIBUST1="${LIBUST1_PATH}/liblttng-ust.so.1"
23
24STD_OUTPUT="/dev/null"
25STD_ERROR="/dev/null"
26
ef9cd5c7
MJ
27NUM_TESTS=22
28
14f8b52c
MJ
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'
32# linker flag.
33UST_TESTS_LD_SYMBOLIC_FUNC=${UST_TESTS_LD_SYMBOLIC_FUNC:-}
34
ef9cd5c7
MJ
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
38# first.
39if [ "$UST_OS_TYPE" = "freebsd" ]; then
14f8b52c
MJ
40 UST_TESTS_LD_SYMBOLIC_FUNC=1
41fi
42
43if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" != "" ]; then
ef9cd5c7
MJ
44 NUM_TESTS=$((NUM_TESTS - 4))
45fi
46
d2a010d1
MJ
47# Force abort on CRIT() to detect ABI conflicts
48export LTTNG_UST_ABORT_ON_CRITICAL=1
49
ef9cd5c7 50plan_tests $NUM_TESTS
d2a010d1
MJ
51
52###
53## LD_PRELOAD tests
54###
55
56diag "LD_PRELOAD"
57
ef9cd5c7 58## App NOT linked on liblttng-ust
d2a010d1
MJ
59
60"${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
61ok $? "LD_PRELOAD: no-ust app works"
62
63LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
64ok $? "LD_PRELOAD: no-ust app with abi0 preload succeeds"
65
66LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
67isnt $? 0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
68
69LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
70isnt $? 0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
71
72
ef9cd5c7 73## App linked on liblttng-ust.so.1
d2a010d1
MJ
74
75"${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
76ok $? "LD_PRELOAD: ust app works"
77
78LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
79isnt $? 0 "LD_PRELOAD: ust app with abi0 preload fails"
80
81LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
82isnt $? 0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
83
84LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
85isnt $? 0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
86
87
88###
89## dlopen tests
90###
91
92diag "dlopen"
93
ef9cd5c7 94## App NOT linked on liblttng-ust
d2a010d1
MJ
95
96LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
97ok $? "dlopen: no-ust app works"
98
99LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
100ok $? "dlopen: no-ust app with abi1 and abi1 succeeds"
101
102LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
103isnt $? 0 "dlopen: no-ust app with abi0 and abi1 fails"
104
14f8b52c 105if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then
ef9cd5c7
MJ
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"
108fi
d2a010d1 109
ef9cd5c7 110## App linked on liblttng-ust.so.1
d2a010d1
MJ
111
112LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
113ok $? "dlopen: ust app works"
114
14f8b52c 115if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" = "" ]; then
ef9cd5c7
MJ
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"
d2a010d1 118
ef9cd5c7
MJ
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"
d2a010d1 121
ef9cd5c7
MJ
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"
124fi
d2a010d1
MJ
125
126
127###
128## Indirect linking
129###
130
131diag "Indirect linking"
132
ef9cd5c7 133## App NOT linked on liblttng-ust
d2a010d1
MJ
134
135"${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
136ok $? "indirect: no-ust app with abi0 succeeds"
137
138"${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
139ok $? "indirect: no-ust app with abi1 succeeds"
140
141"${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
142isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails"
143
ef9cd5c7 144## App linked on liblttng-ust
d2a010d1
MJ
145
146"${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
147isnt $? 0 "indirect: ust app with abi0 fails"
148
149"${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
150ok $? "indirect: ust app with abi1 succeeds"
151
152"${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
153isnt $? 0 "indirect: ust app with abi0 and abi1 fails"
This page took 0.029067 seconds and 4 git commands to generate.