Commit | Line | Data |
---|---|---|
ebaaaf5e JD |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com> |
ebaaaf5e | 4 | # |
9d16b343 MJ |
5 | # SPDX-License-Identifier: LGPL-2.1-only |
6 | ||
ebaaaf5e JD |
7 | TEST_DESC="Snapshots - UST tracing" |
8 | ||
c1896e2d KS |
9 | CURDIR=$(dirname "$0")/ |
10 | TESTDIR="$CURDIR/../../.." | |
ebaaaf5e | 11 | EVENT_NAME="tp:tptest" |
ebaaaf5e JD |
12 | SESSION_NAME="" |
13 | CHANNEL_NAME="snapchan" | |
14 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
15 | TESTAPP_NAME="gen-ust-events" | |
16 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
c1896e2d | 17 | APPS_PID=() |
ebaaaf5e | 18 | |
84901915 | 19 | NUM_TESTS=106 |
ebaaaf5e | 20 | |
8d5a3312 | 21 | TRACE_PATH=$(mktemp -d -t tmp.test_snapshots_ust_trace_path.XXXXXX) |
ebaaaf5e | 22 | |
c1896e2d KS |
23 | # shellcheck source-path=SCRIPTDIR/../../../ |
24 | source "$TESTDIR/utils/utils.sh" | |
ebaaaf5e JD |
25 | |
26 | if [ ! -x "$TESTAPP_BIN" ]; then | |
ce83431d | 27 | BAIL_OUT "No UST events binary detected" |
ebaaaf5e JD |
28 | fi |
29 | ||
1d20c959 | 30 | # Need the number of snapshot to do. |
c1896e2d | 31 | if [ -z "$1" ]; then |
ce83431d | 32 | BAIL_OUT "A number of snapshot is needed" |
1d20c959 DG |
33 | fi |
34 | NR_SNAPSHOT=$1 | |
35 | ||
c1896e2d | 36 | NUM_TESTS=$((NUM_TESTS + (NR_SNAPSHOT * 3))) |
1d20c959 | 37 | |
209b934f DG |
38 | function start_test_app() |
39 | { | |
c1896e2d KS |
40 | local tmp_file |
41 | tmp_file=$(mktemp -u -t "tmp.${FUNCNAME[0]}_tmp_file.XXXXXX") | |
209b934f DG |
42 | |
43 | # Start application with a temporary file. | |
c1896e2d | 44 | $TESTAPP_BIN -i "$NR_ITER" -w "$NR_USEC_WAIT" --sync-after-first-event "$tmp_file" & |
0fc2834c | 45 | ret=$? |
c1896e2d | 46 | APPS_PID+=(${!}) |
0fc2834c | 47 | ok $ret "Start application to trace" |
209b934f DG |
48 | |
49 | # Wait for the application file to appear indicating that at least one | |
50 | # tracepoint has been fired. | |
51 | while [ ! -f "$tmp_file" ]; do | |
52 | sleep 0.5 | |
53 | done | |
54 | diag "Removing test app temporary file $tmp_file" | |
c1896e2d | 55 | rm -f "$tmp_file" |
209b934f DG |
56 | } |
57 | ||
ae779dd6 MD |
58 | function wait_test_apps() |
59 | { | |
60 | diag "Waiting for $TESTAPP_NAME" | |
c1896e2d | 61 | wait "${APPS_PID[@]}" 2>/dev/null |
ae779dd6 MD |
62 | } |
63 | ||
0fc2834c | 64 | function stop_test_apps() |
209b934f | 65 | { |
0fc2834c | 66 | diag "Stopping $TESTAPP_NAME" |
c1896e2d KS |
67 | kill "${APPS_PID[@]}" |
68 | wait "${APPS_PID[@]}" | |
69 | APPS_PID=() | |
209b934f DG |
70 | } |
71 | ||
5e83c405 CB |
72 | function snapshot_add_output () |
73 | { | |
74 | local sess_name=$1 | |
75 | local trace_path=$2 | |
76 | local name=$3 | |
77 | local max_size=$4 | |
c1896e2d | 78 | local extra_opt=() |
5e83c405 | 79 | |
c1896e2d KS |
80 | if [ -n "$name" ]; then |
81 | extra_opt+=(-n "$name") | |
5e83c405 CB |
82 | fi |
83 | ||
c1896e2d KS |
84 | if [ -n "$max_size" ]; then |
85 | extra_opt+=(-m "$max_size") | |
5e83c405 CB |
86 | fi |
87 | ||
c1896e2d KS |
88 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" snapshot add-output \ |
89 | -s "$sess_name" "${extra_opt[@]}" "$trace_path" > /dev/null 2>&1 | |
5e83c405 | 90 | |
c1896e2d | 91 | ok $? "Added snapshot output $trace_path (${extra_opt[*]})" |
5e83c405 CB |
92 | } |
93 | ||
94 | function snapshot_del_output () | |
95 | { | |
96 | local sess_name=$1 | |
97 | local name=$2 | |
98 | ||
c1896e2d KS |
99 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" snapshot del-output \ |
100 | -s "$sess_name" "$name" > /dev/null 2>&1 | |
5e83c405 CB |
101 | |
102 | ok $? "Deleted snapshot output named $name" | |
103 | } | |
104 | ||
105 | function enable_mmap_overwrite_subbuf_ust_channel () | |
106 | { | |
107 | local sess_name=$1 | |
108 | local chan_name=$2 | |
109 | local subbuf_size=$3 | |
d34e7a4d | 110 | local subbuf_count=$4 |
5e83c405 | 111 | |
c1896e2d KS |
112 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel -s "$sess_name" \ |
113 | "$chan_name" -u --output mmap --overwrite \ | |
114 | --num-subbuf="$subbuf_count" \ | |
115 | --subbuf-size "$subbuf_size" > /dev/null 2>&1 | |
5e83c405 CB |
116 | |
117 | ok $? "Enable channel $channel_name for session $sess_name with subbuf size $subbuf_size" | |
118 | } | |
119 | ||
ae779dd6 MD |
120 | function enable_mmap_small_discard_ust_channel () |
121 | { | |
122 | local sess_name=$1 | |
123 | local chan_name=$2 | |
124 | ||
c1896e2d KS |
125 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel -s "$sess_name" \ |
126 | "$chan_name" -u --output mmap --discard \ | |
127 | --subbuf-size "$(getconf PAGE_SIZE)" --num-subbuf 2 \ | |
ae779dd6 MD |
128 | > /dev/null 2>&1 |
129 | ||
130 | ok $? "Enable channel $channel_name for session $sess_name with small discard buffers" | |
131 | } | |
132 | ||
133 | function enable_mmap_small_overwrite_ust_channel () | |
134 | { | |
135 | local sess_name=$1 | |
136 | local chan_name=$2 | |
137 | ||
c1896e2d KS |
138 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel -s "$sess_name" \ |
139 | "$chan_name" -u --output mmap --overwrite \ | |
140 | --subbuf-size "$(getconf PAGE_SIZE)" --num-subbuf 2 \ | |
ae779dd6 MD |
141 | > /dev/null 2>&1 |
142 | ||
143 | ok $? "Enable channel $channel_name for session $sess_name with small discard buffers" | |
144 | } | |
5e83c405 CB |
145 | |
146 | function test_ust_list_output () | |
147 | { | |
148 | output_names=("randomname" "somesnapshot") | |
149 | ||
150 | diag "Test UST snapshot output listing" | |
c1896e2d KS |
151 | create_lttng_session_no_output "$SESSION_NAME" |
152 | enable_lttng_mmap_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
153 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
5e83c405 | 154 | |
c1896e2d | 155 | start_lttng_tracing_ok "$SESSION_NAME" |
5e83c405 | 156 | |
c1896e2d | 157 | snapshot_add_output "$SESSION_NAME" "file://$TRACE_PATH" "${output_names[0]}" |
5e83c405 | 158 | |
c1896e2d KS |
159 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" snapshot list-output \ |
160 | -s "$SESSION_NAME" 2>&1 | grep "${output_names[0]}" > /dev/null | |
5e83c405 CB |
161 | ok $? "Snapshot named ${output_names[0]} present in list-output listing" |
162 | ||
c1896e2d | 163 | snapshot_del_output "$SESSION_NAME" "${output_names[0]}" |
5e83c405 | 164 | |
c1896e2d | 165 | snapshot_add_output "$SESSION_NAME" "file://$TRACE_PATH" "${output_names[1]}" |
5e83c405 | 166 | |
c1896e2d KS |
167 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" snapshot list-output \ |
168 | -s "$SESSION_NAME" 2>&1 | grep "${output_names[1]}" > /dev/null | |
5e83c405 CB |
169 | |
170 | ok $? "Snapshot named ${output_names[1]} present in list-output listing" | |
171 | ||
c1896e2d KS |
172 | stop_lttng_tracing_ok "$SESSION_NAME" |
173 | destroy_lttng_session_ok "$SESSION_NAME" | |
5e83c405 CB |
174 | } |
175 | ||
ebaaaf5e JD |
176 | function test_ust_local_snapshot () |
177 | { | |
18c9d47c | 178 | NR_ITER=-1 |
ae779dd6 MD |
179 | NR_USEC_WAIT=100 |
180 | ||
ebaaaf5e | 181 | diag "Test local UST snapshots" |
c1896e2d KS |
182 | create_lttng_session_no_output "$SESSION_NAME" |
183 | enable_lttng_mmap_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
184 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
185 | start_lttng_tracing_ok "$SESSION_NAME" | |
186 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
187 | |
188 | # Returns once the application has at least fired ONE tracepoint. | |
189 | start_test_app | |
190 | ||
c1896e2d KS |
191 | lttng_snapshot_record "$SESSION_NAME" |
192 | stop_lttng_tracing_ok "$SESSION_NAME" | |
193 | destroy_lttng_session_ok "$SESSION_NAME" | |
ebaaaf5e JD |
194 | |
195 | # Validate test | |
bd666153 | 196 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 197 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
ebaaaf5e | 198 | # Only delete if successful |
c1896e2d | 199 | rm -rf "$TRACE_PATH" |
ebaaaf5e | 200 | fi |
209b934f | 201 | |
0fc2834c | 202 | stop_test_apps |
ebaaaf5e JD |
203 | } |
204 | ||
ae779dd6 MD |
205 | function test_ust_local_snapshot_small_discard_buffers () |
206 | { | |
207 | NR_ITER=10000 | |
208 | NR_USEC_WAIT=0 | |
209 | OLDCPUSET=$(taskset -p $$) | |
210 | ||
211 | diag "Test local UST snapshots with small discard buffers" | |
84901915 KS |
212 | taskset -cp "$(get_any_available_cpu)" $$ 1>/dev/null 2>&1 |
213 | ok $? "Set current process CPU affinity" | |
c1896e2d KS |
214 | create_lttng_session_no_output "$SESSION_NAME" |
215 | enable_mmap_small_discard_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
216 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
217 | start_lttng_tracing_ok "$SESSION_NAME" | |
218 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
ae779dd6 MD |
219 | |
220 | # Run test apps, wait for them to complete. | |
221 | start_test_app | |
222 | wait_test_apps | |
223 | ||
224 | # Take first snapshot, remember first line. | |
c1896e2d KS |
225 | lttng_snapshot_record "$SESSION_NAME" |
226 | FIRST_LINE="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 227 | diag "First line (1st snapshot): $FIRST_LINE" |
c1896e2d | 228 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
229 | |
230 | # Run test apps, wait for them to complete. | |
231 | start_test_app | |
232 | wait_test_apps | |
233 | ||
234 | # Take second snapshot, remember first line. | |
c1896e2d KS |
235 | lttng_snapshot_record "$SESSION_NAME" |
236 | FIRST_LINE_2="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 237 | diag "First line (2nd snapshot): $FIRST_LINE_2" |
c1896e2d | 238 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
239 | |
240 | if [ x"$FIRST_LINE" != x"$FIRST_LINE_2" ]; then | |
ce83431d | 241 | fail "First snapshot event do not match" |
ae779dd6 | 242 | else |
ce83431d | 243 | pass "First snapshot event match" |
ae779dd6 MD |
244 | fi |
245 | ||
c1896e2d KS |
246 | stop_lttng_tracing_ok "$SESSION_NAME" |
247 | destroy_lttng_session_ok "$SESSION_NAME" | |
248 | taskset -p "$OLDCPUSET" $$ 1>/dev/null 2>&1 | |
ae779dd6 MD |
249 | } |
250 | ||
251 | function test_ust_local_snapshot_small_overwrite_buffers () | |
252 | { | |
253 | NR_ITER=10000 | |
254 | NR_USEC_WAIT=0 | |
255 | OLDCPUSET=$(taskset -p $$) | |
256 | ||
257 | diag "Test local UST snapshots with small overwrite buffers" | |
84901915 KS |
258 | taskset -cp "$(get_any_available_cpu)" $$ 1>/dev/null 2>&1 |
259 | ok $? "Set current process CPU affinity" | |
c1896e2d KS |
260 | create_lttng_session_no_output "$SESSION_NAME" |
261 | enable_mmap_small_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
262 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
263 | start_lttng_tracing_ok "$SESSION_NAME" | |
264 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
ae779dd6 MD |
265 | |
266 | # Run test apps, wait for them to complete. | |
267 | start_test_app | |
268 | wait_test_apps | |
269 | ||
270 | # Take first snapshot, remember first line. | |
c1896e2d KS |
271 | lttng_snapshot_record "$SESSION_NAME" |
272 | FIRST_LINE="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 273 | diag "First line (1st snapshot): $FIRST_LINE" |
c1896e2d | 274 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
275 | |
276 | # Run test apps, wait for them to complete. | |
277 | start_test_app | |
278 | wait_test_apps | |
279 | ||
280 | # Take second snapshot, remember first line. | |
c1896e2d KS |
281 | lttng_snapshot_record "$SESSION_NAME" |
282 | FIRST_LINE_2="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 283 | diag "First line (2nd snapshot): $FIRST_LINE_2" |
c1896e2d | 284 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
285 | |
286 | if [ x"$FIRST_LINE" != x"$FIRST_LINE_2" ]; then | |
ce83431d | 287 | pass "First snapshot event do not match" |
ae779dd6 | 288 | else |
ce83431d | 289 | fail "First snapshot event match" |
ae779dd6 MD |
290 | fi |
291 | ||
c1896e2d KS |
292 | stop_lttng_tracing_ok "$SESSION_NAME" |
293 | destroy_lttng_session_ok "$SESSION_NAME" | |
294 | taskset -p "$OLDCPUSET" $$ 1>/dev/null 2>&1 | |
ae779dd6 MD |
295 | } |
296 | ||
5e83c405 CB |
297 | function test_ust_local_snapshot_max_size () |
298 | { | |
d34e7a4d | 299 | local possible_cpus |
3bfde48a | 300 | local cpus_list |
d34e7a4d OD |
301 | local subbuf_size |
302 | local subbuf_count | |
303 | local snapshot_max_size | |
304 | local channel_max_size_per_cpu | |
305 | ||
d2456f81 | 306 | IFS=" " read -r -a cpus_list <<< "$(get_online_cpus)" |
3bfde48a | 307 | |
d34e7a4d | 308 | possible_cpus=$(get_possible_cpus_count) |
d34e7a4d OD |
309 | subbuf_size=$(getconf PAGE_SIZE) |
310 | subbuf_count=8 | |
311 | snapshot_max_size=$((subbuf_size*possible_cpus)) | |
312 | channel_max_size_per_cpu=$((subbuf_size*subbuf_count)) | |
5e83c405 CB |
313 | |
314 | diag "Test local UST snapshots with max size $max_size" | |
d34e7a4d | 315 | create_lttng_session_no_output "$SESSION_NAME" |
5e83c405 | 316 | |
d34e7a4d OD |
317 | enable_mmap_overwrite_subbuf_ust_channel \ |
318 | "$SESSION_NAME" "$CHANNEL_NAME" \ | |
319 | "$subbuf_size" "$subbuf_count" | |
5e83c405 | 320 | |
d34e7a4d OD |
321 | enable_ust_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" "$CHANNEL_NAME" |
322 | start_lttng_tracing_ok "$SESSION_NAME" | |
5e83c405 | 323 | |
d34e7a4d | 324 | snapshot_add_output "$SESSION_NAME" "file://$TRACE_PATH" "" "$snapshot_max_size" |
5e83c405 | 325 | |
d34e7a4d OD |
326 | # Fill all ring-buffers of the channel; assuming event size of at least one |
327 | # byte | |
3bfde48a | 328 | for cpu in "${cpus_list[@]}"; |
d34e7a4d | 329 | do |
3bfde48a OD |
330 | diag "setting affinity to $cpu" |
331 | taskset --cpu-list "$cpu" "$TESTAPP_BIN" \ | |
d34e7a4d OD |
332 | --iter "$channel_max_size_per_cpu" |
333 | done | |
334 | diag "Filled channel ring-buffers" | |
5e83c405 | 335 | |
d34e7a4d | 336 | lttng_snapshot_record "$SESSION_NAME" |
5e83c405 CB |
337 | |
338 | # Check file size | |
d34e7a4d OD |
339 | local snapshot_size |
340 | snapshot_size=$(find "$TRACE_PATH" -name "${CHANNEL_NAME}_*" \ | |
341 | -exec stat -c '%s' {} \; | \ | |
342 | awk '{s = s + $1}END{print s}') | |
5e83c405 | 343 | |
d34e7a4d | 344 | if [ "$snapshot_size" -eq "$snapshot_max_size" ]; then |
b67cdb8c | 345 | pass "Tracefiles size sum validation" |
d34e7a4d OD |
346 | else |
347 | fail "Tracefiles size sum validation" | |
348 | diag "Tracefiles size sum: $snapshot_size Expected max: $snapshot_max_size" | |
5e83c405 CB |
349 | fi |
350 | ||
d34e7a4d OD |
351 | stop_lttng_tracing_ok "$SESSION_NAME" |
352 | destroy_lttng_session_ok "$SESSION_NAME" | |
5e83c405 CB |
353 | |
354 | # Validate test | |
bd666153 | 355 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
5e83c405 | 356 | |
d34e7a4d | 357 | if validate_trace "$EVENT_NAME" "$TRACE_PATH/"; then |
5e83c405 | 358 | # Only delete if successful |
d34e7a4d | 359 | rm -rf "$TRACE_PATH" |
5e83c405 CB |
360 | fi |
361 | ||
0fc2834c | 362 | stop_test_apps |
5e83c405 CB |
363 | } |
364 | ||
a54047ec JD |
365 | function test_ust_local_snapshot_large_metadata () |
366 | { | |
367 | LM_EVENT="tp:tptest1,tp:tptest2,tp:tptest3,tp:tptest4,tp:tptest5" | |
368 | LM_PATH="$TESTDIR/utils/testapp" | |
369 | LM_NAME="gen-ust-nevents" | |
370 | LM_BIN="$LM_PATH/$LM_NAME/$LM_NAME" | |
371 | ||
372 | diag "Test local UST snapshots with > 4kB metadata" | |
c1896e2d KS |
373 | create_lttng_session_no_output "$SESSION_NAME" |
374 | enable_lttng_mmap_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
375 | enable_ust_lttng_event_ok "$SESSION_NAME" $LM_EVENT $CHANNEL_NAME | |
376 | start_lttng_tracing_ok "$SESSION_NAME" | |
377 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
8db430e7 | 378 | $LM_BIN --iter 1 --wait 1 |
a54047ec | 379 | ok $? "Start application to trace" |
c1896e2d KS |
380 | lttng_snapshot_record "$SESSION_NAME" |
381 | stop_lttng_tracing_ok "$SESSION_NAME" | |
382 | destroy_lttng_session_ok "$SESSION_NAME" | |
a54047ec JD |
383 | |
384 | # Validate test | |
bd666153 | 385 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 386 | if validate_trace $LM_EVENT "$TRACE_PATH/" ; then |
a54047ec | 387 | # Only delete if successful |
c1896e2d | 388 | rm -rf "${TRACE_PATH:?}/" |
a54047ec JD |
389 | fi |
390 | } | |
391 | ||
5f4c2d80 JD |
392 | function enable_channel_per_uid_mmap_overwrite() |
393 | { | |
394 | sess_name=$1 | |
395 | channel_name=$2 | |
396 | ||
c1896e2d | 397 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel --buffers-uid -u "$channel_name" -s "$sess_name" --output mmap --overwrite >/dev/null 2>&1 |
5f4c2d80 JD |
398 | ok $? "Enable channel $channel_name per UID for session $sess_name" |
399 | } | |
400 | ||
401 | function test_ust_per_uid_local_snapshot () | |
402 | { | |
18c9d47c JR |
403 | NR_ITER=-1 |
404 | NR_USEC_WAIT=100 | |
891d74dd | 405 | diag "Test per-uid local UST snapshots" |
c1896e2d KS |
406 | create_lttng_session_no_output "$SESSION_NAME" |
407 | enable_channel_per_uid_mmap_overwrite "$SESSION_NAME" $CHANNEL_NAME | |
408 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
409 | start_lttng_tracing_ok "$SESSION_NAME" | |
410 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
411 | |
412 | # Returns once the application has at least fired ONE tracepoint. | |
413 | start_test_app | |
414 | ||
c1896e2d KS |
415 | lttng_snapshot_record "$SESSION_NAME" |
416 | stop_lttng_tracing_ok "$SESSION_NAME" | |
417 | destroy_lttng_session_ok "$SESSION_NAME" | |
5f4c2d80 JD |
418 | |
419 | # Validate test | |
bd666153 | 420 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 421 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
5f4c2d80 | 422 | # Only delete if successful |
c1896e2d | 423 | rm -rf "${TRACE_PATH:?}/" |
5f4c2d80 | 424 | fi |
209b934f | 425 | |
0fc2834c | 426 | stop_test_apps |
5f4c2d80 JD |
427 | } |
428 | ||
4f03c06d JD |
429 | function test_ust_per_uid_local_snapshot_post_mortem () |
430 | { | |
18c9d47c | 431 | NR_ITER=-1 |
ae779dd6 MD |
432 | NR_USEC_WAIT=100 |
433 | ||
4f03c06d | 434 | diag "Test local UST snapshots post-mortem" |
c1896e2d KS |
435 | create_lttng_session_no_output "$SESSION_NAME" |
436 | enable_channel_per_uid_mmap_overwrite "$SESSION_NAME" $CHANNEL_NAME | |
437 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
438 | start_lttng_tracing_ok "$SESSION_NAME" | |
439 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
440 | |
441 | # Returns once the application has at least fired ONE tracepoint. | |
442 | start_test_app | |
0fc2834c | 443 | stop_test_apps |
209b934f | 444 | |
c1896e2d KS |
445 | lttng_snapshot_record "$SESSION_NAME" |
446 | stop_lttng_tracing_ok "$SESSION_NAME" | |
447 | destroy_lttng_session_ok "$SESSION_NAME" | |
4f03c06d JD |
448 | |
449 | # Validate test | |
bd666153 | 450 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 451 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
4f03c06d | 452 | # Only delete if successful |
c1896e2d | 453 | rm -rf "${TRACE_PATH:?}/" |
4f03c06d JD |
454 | fi |
455 | } | |
456 | ||
1d20c959 | 457 | function test_ust_local_snapshots () |
ebaaaf5e | 458 | { |
18c9d47c | 459 | NR_ITER=-1 |
ae779dd6 MD |
460 | NR_USEC_WAIT=100 |
461 | ||
1d20c959 | 462 | diag "Test $NR_SNAPSHOT local UST snapshots" |
c1896e2d KS |
463 | create_lttng_session_no_output "$SESSION_NAME" |
464 | enable_lttng_mmap_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
465 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
466 | start_lttng_tracing_ok "$SESSION_NAME" | |
467 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
468 | |
469 | # Returns once the application has at least fired ONE tracepoint. | |
470 | start_test_app | |
471 | ||
c1896e2d | 472 | for i in $(seq 1 "$NR_SNAPSHOT"); do |
1d20c959 | 473 | diag "Snapshot $i/$NR_SNAPSHOT" |
c1896e2d KS |
474 | rm -rf "$TRACE_PATH/snapshot/*" 2>/dev/null |
475 | lttng_snapshot_record "$SESSION_NAME" | |
ebaaaf5e | 476 | # Validate test |
bd666153 | 477 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" $((i - 1)) |
c1896e2d | 478 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
ebaaaf5e | 479 | # Only delete if successful |
c1896e2d | 480 | rm -rf "${TRACE_PATH:?}/" |
ebaaaf5e JD |
481 | fi |
482 | done | |
c1896e2d KS |
483 | stop_lttng_tracing_ok "$SESSION_NAME" |
484 | destroy_lttng_session_ok "$SESSION_NAME" | |
209b934f | 485 | |
0fc2834c | 486 | stop_test_apps |
ebaaaf5e JD |
487 | } |
488 | ||
489 | plan_tests $NUM_TESTS | |
490 | ||
491 | print_test_banner "$TEST_DESC" | |
492 | ||
c125de8f FD |
493 | bail_out_if_no_babeltrace |
494 | ||
c1896e2d | 495 | # shellcheck disable=SC2119 |
ebaaaf5e | 496 | start_lttng_sessiond |
5e83c405 CB |
497 | tests=( test_ust_list_output |
498 | test_ust_local_snapshot | |
499 | test_ust_local_snapshot_max_size | |
500 | test_ust_per_uid_local_snapshot | |
501 | test_ust_per_uid_local_snapshot_post_mortem | |
502 | test_ust_local_snapshot_large_metadata | |
ae779dd6 MD |
503 | test_ust_local_snapshots |
504 | test_ust_local_snapshot_small_discard_buffers | |
505 | test_ust_local_snapshot_small_overwrite_buffers | |
506 | ) | |
ebaaaf5e | 507 | |
c1896e2d | 508 | for fct_test in "${tests[@]}"; |
ebaaaf5e JD |
509 | do |
510 | SESSION_NAME=$(randstring 16 0) | |
511 | ${fct_test} | |
ebaaaf5e JD |
512 | done |
513 | ||
c1896e2d | 514 | # shellcheck disable=SC2119 |
ebaaaf5e | 515 | stop_lttng_sessiond |