Tests: implement REUSE with SPDX identifiers
[lttng-ust.git] / tests / regression / abi0-conflict / test_abi0_conflict
CommitLineData
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
7if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
8 UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh"
9else
10 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
11fi
12
13# shellcheck source=../../utils/utils.sh
14source "$UTILSSH"
15
16# shellcheck source=../../utils/tap.sh
17source "$UST_TESTS_SRCDIR/utils/tap.sh"
18
19CURDIR="${UST_TESTS_BUILDDIR}/regression/abi0-conflict"
20
21LIBFAKEUST0_PATH="${CURDIR}/.libs"
22LIBFAKEUST0="${LIBFAKEUST0_PATH}/libfakeust0.so"
23
24LIBUST1_PATH="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/"
25LIBUST1="${LIBUST1_PATH}/liblttng-ust.so.1"
26
27STD_OUTPUT="/dev/null"
28STD_ERROR="/dev/null"
29
ef9cd5c7
MJ
30NUM_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.
36UST_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.
42if [ "$UST_OS_TYPE" = "freebsd" ]; then
14f8b52c
MJ
43 UST_TESTS_LD_SYMBOLIC_FUNC=1
44fi
45
46if [ "$UST_TESTS_LD_SYMBOLIC_FUNC" != "" ]; then
ef9cd5c7
MJ
47 NUM_TESTS=$((NUM_TESTS - 4))
48fi
49
d2a010d1
MJ
50# Force abort on CRIT() to detect ABI conflicts
51export LTTNG_UST_ABORT_ON_CRITICAL=1
52
ef9cd5c7 53plan_tests $NUM_TESTS
d2a010d1
MJ
54
55###
56## LD_PRELOAD tests
57###
58
59diag "LD_PRELOAD"
60
ef9cd5c7 61## App NOT linked on liblttng-ust
d2a010d1
MJ
62
63"${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
64ok $? "LD_PRELOAD: no-ust app works"
65
66LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
67ok $? "LD_PRELOAD: no-ust app with abi0 preload succeeds"
68
69LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
70isnt $? 0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
71
72LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
73isnt $? 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"
79ok $? "LD_PRELOAD: ust app works"
80
81LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
82isnt $? 0 "LD_PRELOAD: ust app with abi0 preload fails"
83
84LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
85isnt $? 0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
86
87LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
88isnt $? 0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
89
90
91###
92## dlopen tests
93###
94
95diag "dlopen"
96
ef9cd5c7 97## App NOT linked on liblttng-ust
d2a010d1
MJ
98
99LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
100ok $? "dlopen: no-ust app works"
101
102LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
103ok $? "dlopen: no-ust app with abi1 and abi1 succeeds"
104
105LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
106isnt $? 0 "dlopen: no-ust app with abi0 and abi1 fails"
107
14f8b52c 108if [ "$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"
111fi
d2a010d1 112
ef9cd5c7 113## App linked on liblttng-ust.so.1
d2a010d1
MJ
114
115LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
116ok $? "dlopen: ust app works"
117
14f8b52c 118if [ "$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"
127fi
d2a010d1
MJ
128
129
130###
131## Indirect linking
132###
133
134diag "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"
139ok $? "indirect: no-ust app with abi0 succeeds"
140
141"${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
142ok $? "indirect: no-ust app with abi1 succeeds"
143
144"${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
145isnt $? 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"
150isnt $? 0 "indirect: ust app with abi0 fails"
151
152"${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
153ok $? "indirect: ust app with abi1 succeeds"
154
155"${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
156isnt $? 0 "indirect: ust app with abi0 and abi1 fails"
This page took 0.030266 seconds and 4 git commands to generate.