d66230ac89427893b52413382f5b3190f4e3cc33
[lttng-tools.git] / tests / regression / ust / multi-lib / test_multi_lib
1 #!/bin/bash
2 #
3 # Copyright (C) - 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
4 #
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18 TEST_DESC="UST - Dynamic loading and unloading of libraries"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 SESSION_NAME="multi_lib"
23
24 EXEC_NAME_WITH_CALLSITES=./$CURDIR/exec-with-callsites
25 EXEC_NAME_WITHOUT_CALLSITES=./$CURDIR/exec-without-callsites
26 SO_DIR=$CURDIR/.libs/
27 SO_PROBES_A=$SO_DIR/libprobes_a.so
28 SO_PROBES_A_PRIME=$SO_DIR/libprobes_a_prime.so
29 SO_PROBES_B=$SO_DIR/libprobes_b.so
30 SO_PROBES_C=$SO_DIR/libprobes_c.so
31 SO_PROBES_C_PRIME=$SO_DIR/libprobes_c_prime.so
32 SO_PROBES_D=$SO_DIR/libprobes_d.so
33 SO_CALLSITE_1=$SO_DIR/libcallsites_1.so
34 SO_CALLSITE_2=$SO_DIR/libcallsites_2.so
35
36 NUM_TESTS=55
37
38 source $TESTDIR/utils/utils.sh
39
40 test_dlopen_same_provider_name_same_event()
41 {
42 local event_name="multi:tp"
43 diag "dlopen 2 providers, same event name, same payload"
44
45 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
46
47 start_lttng_tracing_ok $SESSION_NAME
48
49 $EXEC_NAME_WITH_CALLSITES -t 0 $SO_PROBES_A $SO_PROBES_A_PRIME
50
51 stop_lttng_tracing_ok $SESSION_NAME
52
53 # Expect 2 identical events in the trace
54 trace_match_only $event_name 2 $TRACE_PATH
55
56 # Expect a single event ID in the metadata
57 validate_metadata_event $event_name 1 $TRACE_PATH
58
59 return $?
60 }
61
62 test_dlopen_same_provider_name_different_event()
63 {
64 local event_name="multi:tp"
65 # Regular expression for event tp with one argument: arg_long
66 local event_a_payload_exp="^.*$event_name.*arg_long_A.*"
67 # Regular expression for event tp with two arguments: arg_long and
68 # arg_float
69 local event_b_payload_exp="^.*$event_name.*arg_long_B.*arg_float_B.*"
70 diag "dlopen 2 providers, same event name, different payload"
71
72 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
73
74 start_lttng_tracing_ok $SESSION_NAME
75
76 $EXEC_NAME_WITH_CALLSITES -t 0 $SO_PROBES_A $SO_PROBES_B
77
78 stop_lttng_tracing_ok $SESSION_NAME
79
80 # Expect 2 identical events in the trace
81 trace_match_only $event_name 2 $TRACE_PATH
82
83 # Expect 2 events ID in the metadata
84 validate_metadata_event $event_name 2 $TRACE_PATH
85
86 # Expect 2 events with different payloads
87 validate_trace_exp $event_a_payload_exp $TRACE_PATH
88 validate_trace_exp $event_b_payload_exp $TRACE_PATH
89
90 return $?
91 }
92
93 test_dlopen_same_provider_name_same_enum()
94 {
95 local event_name="multi:tp"
96 # Regular expression for event tp with one argument: arg_long
97 local event_c_payload_exp="^.*$event_name.*enum_int_C.*"
98 # Regular expression for event tp with two arguments: arg_long and
99 # arg_float
100 local event_d_payload_exp="^.*$event_name.*enum_int_D.*"
101 diag "dlopen 2 providers, same event name, same enum definition"
102
103 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
104
105 start_lttng_tracing_ok $SESSION_NAME
106
107 $EXEC_NAME_WITH_CALLSITES -t 0 $SO_PROBES_C $SO_PROBES_C_PRIME
108
109 stop_lttng_tracing_ok $SESSION_NAME
110
111 # Expect 2 identical events in the trace
112 trace_match_only $event_name 2 $TRACE_PATH
113
114 # Expect 2 events ID in the metadata
115 validate_metadata_event $event_name 1 $TRACE_PATH
116
117 return $?
118 }
119
120 test_dlopen_same_provider_name_different_enum()
121 {
122 local event_name="multi:tp"
123 # Regular expression for event tp with one argument: arg_long
124 local event_c_payload_exp="^.*$event_name.*enum_int_C.*"
125 # Regular expression for event tp with two arguments: arg_long and
126 # arg_float
127 local event_d_payload_exp="^.*$event_name.*enum_int_D.*"
128 diag "dlopen 2 providers, same event name, different enum definition"
129
130 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
131
132 start_lttng_tracing_ok $SESSION_NAME
133
134 $EXEC_NAME_WITH_CALLSITES -t 0 $SO_PROBES_C $SO_PROBES_D
135
136 stop_lttng_tracing_ok $SESSION_NAME
137
138 # Expect 2 identical events in the trace
139 trace_match_only $event_name 2 $TRACE_PATH
140
141 # Expect 2 events ID in the metadata
142 validate_metadata_event $event_name 2 $TRACE_PATH
143
144 # Expect 2 events with different payloads
145 validate_trace_exp $event_c_payload_exp $TRACE_PATH
146 validate_trace_exp $event_d_payload_exp $TRACE_PATH
147
148 return $?
149 }
150
151 test_upgrade_probes_dlopen_dclose()
152 {
153 local event_name="multi:tp"
154 diag "Upgrade probe provider using dlopen/dlclose during tracing"
155
156 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
157
158 start_lttng_tracing_ok $SESSION_NAME
159
160 $EXEC_NAME_WITH_CALLSITES -t 1 $SO_PROBES_A $SO_PROBES_B
161
162 stop_lttng_tracing_ok $SESSION_NAME
163
164 # Expect 2 identical events in the trace
165 trace_match_only $event_name 4 $TRACE_PATH
166
167 # Expect 2 events ID in the metadata
168 validate_metadata_event $event_name 2 $TRACE_PATH
169
170 return $?
171 }
172
173 test_upgrade_callsites_dlopen_dclose()
174 {
175 local event_name="multi:tp"
176 diag "Upgrade callsite using dlopen/dlclose during tracing"
177
178 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
179
180 start_lttng_tracing_ok $SESSION_NAME
181
182 $EXEC_NAME_WITHOUT_CALLSITES -t 2 $SO_CALLSITE_1 $SO_CALLSITE_2
183
184 stop_lttng_tracing_ok $SESSION_NAME
185
186 # Expect 2 identical events in the trace
187 trace_match_only $event_name 3 $TRACE_PATH
188
189 # Expect 2 events ID in the metadata
190 validate_metadata_event $event_name 1 $TRACE_PATH
191
192 return $?
193 }
194
195 test_event_field_comparison()
196 {
197 local event_name="multi:tp"
198 diag "Load mutliple events with slight variations in the field descriptions."
199
200 local library_prefix="libprobes_"
201 local nb_libs=0
202 local library_list=" "
203 # Concatenate all the probe libraries in a string.
204 for postfix in {a..p}; do
205 library_list="$library_list $SO_DIR/$library_prefix$postfix.so"
206 let nb_libs+=1
207 done
208
209 enable_ust_lttng_event_ok $SESSION_NAME "$event_name"
210
211 start_lttng_tracing_ok $SESSION_NAME
212
213 $EXEC_NAME_WITH_CALLSITES -t 0 $library_list
214
215 stop_lttng_tracing_ok $SESSION_NAME
216
217 # Expect $nb_libs identical events in the trace
218 trace_match_only $event_name $nb_libs $TRACE_PATH
219
220 # Expect $nb_libs events ID in the metadata
221 validate_metadata_event $event_name $nb_libs $TRACE_PATH
222
223 return $?
224 }
225
226
227 plan_tests $NUM_TESTS
228
229 print_test_banner "$TEST_DESC"
230
231 TESTS=(
232 "test_dlopen_same_provider_name_same_event"
233 "test_dlopen_same_provider_name_different_event"
234 "test_dlopen_same_provider_name_different_enum"
235 "test_dlopen_same_provider_name_same_enum"
236 "test_event_field_comparison"
237 "test_upgrade_probes_dlopen_dclose"
238 "test_upgrade_callsites_dlopen_dclose"
239 )
240
241 TEST_COUNT=${#TESTS[@]}
242 i=0
243
244 start_lttng_sessiond
245
246 while [ "$i" -lt "$TEST_COUNT" ]; do
247
248 TRACE_PATH=$(mktemp -d)
249
250 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
251
252 # Execute test
253 ${TESTS[$i]}
254
255 destroy_lttng_session_ok $SESSION_NAME
256
257 rm -rf $TRACE_PATH
258
259 let "i++"
260 done
261
262 stop_lttng_sessiond
This page took 0.033559 seconds and 3 git commands to generate.