fix: disable some abi conflict tests on FreeBSD
[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
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.
33if [ "$UST_OS_TYPE" = "freebsd" ]; then
34 NUM_TESTS=$((NUM_TESTS - 4))
35fi
36
d2a010d1
MJ
37# Force abort on CRIT() to detect ABI conflicts
38export LTTNG_UST_ABORT_ON_CRITICAL=1
39
ef9cd5c7 40plan_tests $NUM_TESTS
d2a010d1
MJ
41
42###
43## LD_PRELOAD tests
44###
45
46diag "LD_PRELOAD"
47
ef9cd5c7 48## App NOT linked on liblttng-ust
d2a010d1
MJ
49
50"${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
51ok $? "LD_PRELOAD: no-ust app works"
52
53LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
54ok $? "LD_PRELOAD: no-ust app with abi0 preload succeeds"
55
56LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
57isnt $? 0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
58
59LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
60isnt $? 0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
61
62
ef9cd5c7 63## App linked on liblttng-ust.so.1
d2a010d1
MJ
64
65"${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
66ok $? "LD_PRELOAD: ust app works"
67
68LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
69isnt $? 0 "LD_PRELOAD: ust app with abi0 preload fails"
70
71LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
72isnt $? 0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
73
74LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
75isnt $? 0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
76
77
78###
79## dlopen tests
80###
81
82diag "dlopen"
83
ef9cd5c7 84## App NOT linked on liblttng-ust
d2a010d1
MJ
85
86LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
87ok $? "dlopen: no-ust app works"
88
89LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
90ok $? "dlopen: no-ust app with abi1 and abi1 succeeds"
91
92LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
93isnt $? 0 "dlopen: no-ust app with abi0 and abi1 fails"
94
ef9cd5c7
MJ
95if [ "$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"
98fi
d2a010d1 99
ef9cd5c7 100## App linked on liblttng-ust.so.1
d2a010d1
MJ
101
102LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
103ok $? "dlopen: ust app works"
104
ef9cd5c7
MJ
105if [ "$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"
d2a010d1 108
ef9cd5c7
MJ
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"
d2a010d1 111
ef9cd5c7
MJ
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"
114fi
d2a010d1
MJ
115
116
117###
118## Indirect linking
119###
120
121diag "Indirect linking"
122
ef9cd5c7 123## App NOT linked on liblttng-ust
d2a010d1
MJ
124
125"${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
126ok $? "indirect: no-ust app with abi0 succeeds"
127
128"${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
129ok $? "indirect: no-ust app with abi1 succeeds"
130
131"${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
132isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails"
133
ef9cd5c7 134## App linked on liblttng-ust
d2a010d1
MJ
135
136"${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
137isnt $? 0 "indirect: ust app with abi0 fails"
138
139"${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
140ok $? "indirect: ust app with abi1 succeeds"
141
142"${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
143isnt $? 0 "indirect: ust app with abi0 and abi1 fails"
This page took 0.028774 seconds and 4 git commands to generate.