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 | |
d34e7a4d | 19 | NUM_TESTS=104 |
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" | |
d2456f81 | 212 | taskset -c "$(get_any_available_cpu)" -p $$ 1>/dev/null 2>&1 |
c1896e2d KS |
213 | create_lttng_session_no_output "$SESSION_NAME" |
214 | enable_mmap_small_discard_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
215 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
216 | start_lttng_tracing_ok "$SESSION_NAME" | |
217 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
ae779dd6 MD |
218 | |
219 | # Run test apps, wait for them to complete. | |
220 | start_test_app | |
221 | wait_test_apps | |
222 | ||
223 | # Take first snapshot, remember first line. | |
c1896e2d KS |
224 | lttng_snapshot_record "$SESSION_NAME" |
225 | FIRST_LINE="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 226 | diag "First line (1st snapshot): $FIRST_LINE" |
c1896e2d | 227 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
228 | |
229 | # Run test apps, wait for them to complete. | |
230 | start_test_app | |
231 | wait_test_apps | |
232 | ||
233 | # Take second snapshot, remember first line. | |
c1896e2d KS |
234 | lttng_snapshot_record "$SESSION_NAME" |
235 | FIRST_LINE_2="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 236 | diag "First line (2nd snapshot): $FIRST_LINE_2" |
c1896e2d | 237 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
238 | |
239 | if [ x"$FIRST_LINE" != x"$FIRST_LINE_2" ]; then | |
ce83431d | 240 | fail "First snapshot event do not match" |
ae779dd6 | 241 | else |
ce83431d | 242 | pass "First snapshot event match" |
ae779dd6 MD |
243 | fi |
244 | ||
c1896e2d KS |
245 | stop_lttng_tracing_ok "$SESSION_NAME" |
246 | destroy_lttng_session_ok "$SESSION_NAME" | |
247 | taskset -p "$OLDCPUSET" $$ 1>/dev/null 2>&1 | |
ae779dd6 MD |
248 | } |
249 | ||
250 | function test_ust_local_snapshot_small_overwrite_buffers () | |
251 | { | |
252 | NR_ITER=10000 | |
253 | NR_USEC_WAIT=0 | |
254 | OLDCPUSET=$(taskset -p $$) | |
255 | ||
256 | diag "Test local UST snapshots with small overwrite buffers" | |
d2456f81 | 257 | taskset -p "$(get_any_available_cpu)" $$ 1>/dev/null 2>&1 |
c1896e2d KS |
258 | create_lttng_session_no_output "$SESSION_NAME" |
259 | enable_mmap_small_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
260 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
261 | start_lttng_tracing_ok "$SESSION_NAME" | |
262 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
ae779dd6 MD |
263 | |
264 | # Run test apps, wait for them to complete. | |
265 | start_test_app | |
266 | wait_test_apps | |
267 | ||
268 | # Take first snapshot, remember first line. | |
c1896e2d KS |
269 | lttng_snapshot_record "$SESSION_NAME" |
270 | FIRST_LINE="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 271 | diag "First line (1st snapshot): $FIRST_LINE" |
c1896e2d | 272 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
273 | |
274 | # Run test apps, wait for them to complete. | |
275 | start_test_app | |
276 | wait_test_apps | |
277 | ||
278 | # Take second snapshot, remember first line. | |
c1896e2d KS |
279 | lttng_snapshot_record "$SESSION_NAME" |
280 | FIRST_LINE_2="$(trace_first_line "$TRACE_PATH/")" | |
ae779dd6 | 281 | diag "First line (2nd snapshot): $FIRST_LINE_2" |
c1896e2d | 282 | rm -rf "${TRACE_PATH:?}/" |
ae779dd6 MD |
283 | |
284 | if [ x"$FIRST_LINE" != x"$FIRST_LINE_2" ]; then | |
ce83431d | 285 | pass "First snapshot event do not match" |
ae779dd6 | 286 | else |
ce83431d | 287 | fail "First snapshot event match" |
ae779dd6 MD |
288 | fi |
289 | ||
c1896e2d KS |
290 | stop_lttng_tracing_ok "$SESSION_NAME" |
291 | destroy_lttng_session_ok "$SESSION_NAME" | |
292 | taskset -p "$OLDCPUSET" $$ 1>/dev/null 2>&1 | |
ae779dd6 MD |
293 | } |
294 | ||
5e83c405 CB |
295 | function test_ust_local_snapshot_max_size () |
296 | { | |
d34e7a4d | 297 | local possible_cpus |
3bfde48a | 298 | local cpus_list |
d34e7a4d OD |
299 | local subbuf_size |
300 | local subbuf_count | |
301 | local snapshot_max_size | |
302 | local channel_max_size_per_cpu | |
303 | ||
d2456f81 | 304 | IFS=" " read -r -a cpus_list <<< "$(get_online_cpus)" |
3bfde48a | 305 | |
d34e7a4d | 306 | possible_cpus=$(get_possible_cpus_count) |
d34e7a4d OD |
307 | subbuf_size=$(getconf PAGE_SIZE) |
308 | subbuf_count=8 | |
309 | snapshot_max_size=$((subbuf_size*possible_cpus)) | |
310 | channel_max_size_per_cpu=$((subbuf_size*subbuf_count)) | |
5e83c405 CB |
311 | |
312 | diag "Test local UST snapshots with max size $max_size" | |
d34e7a4d | 313 | create_lttng_session_no_output "$SESSION_NAME" |
5e83c405 | 314 | |
d34e7a4d OD |
315 | enable_mmap_overwrite_subbuf_ust_channel \ |
316 | "$SESSION_NAME" "$CHANNEL_NAME" \ | |
317 | "$subbuf_size" "$subbuf_count" | |
5e83c405 | 318 | |
d34e7a4d OD |
319 | enable_ust_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" "$CHANNEL_NAME" |
320 | start_lttng_tracing_ok "$SESSION_NAME" | |
5e83c405 | 321 | |
d34e7a4d | 322 | snapshot_add_output "$SESSION_NAME" "file://$TRACE_PATH" "" "$snapshot_max_size" |
5e83c405 | 323 | |
d34e7a4d OD |
324 | # Fill all ring-buffers of the channel; assuming event size of at least one |
325 | # byte | |
3bfde48a | 326 | for cpu in "${cpus_list[@]}"; |
d34e7a4d | 327 | do |
3bfde48a OD |
328 | diag "setting affinity to $cpu" |
329 | taskset --cpu-list "$cpu" "$TESTAPP_BIN" \ | |
d34e7a4d OD |
330 | --iter "$channel_max_size_per_cpu" |
331 | done | |
332 | diag "Filled channel ring-buffers" | |
5e83c405 | 333 | |
d34e7a4d | 334 | lttng_snapshot_record "$SESSION_NAME" |
5e83c405 CB |
335 | |
336 | # Check file size | |
d34e7a4d OD |
337 | local snapshot_size |
338 | snapshot_size=$(find "$TRACE_PATH" -name "${CHANNEL_NAME}_*" \ | |
339 | -exec stat -c '%s' {} \; | \ | |
340 | awk '{s = s + $1}END{print s}') | |
5e83c405 | 341 | |
d34e7a4d | 342 | if [ "$snapshot_size" -eq "$snapshot_max_size" ]; then |
b67cdb8c | 343 | pass "Tracefiles size sum validation" |
d34e7a4d OD |
344 | else |
345 | fail "Tracefiles size sum validation" | |
346 | diag "Tracefiles size sum: $snapshot_size Expected max: $snapshot_max_size" | |
5e83c405 CB |
347 | fi |
348 | ||
d34e7a4d OD |
349 | stop_lttng_tracing_ok "$SESSION_NAME" |
350 | destroy_lttng_session_ok "$SESSION_NAME" | |
5e83c405 CB |
351 | |
352 | # Validate test | |
bd666153 | 353 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
5e83c405 | 354 | |
d34e7a4d | 355 | if validate_trace "$EVENT_NAME" "$TRACE_PATH/"; then |
5e83c405 | 356 | # Only delete if successful |
d34e7a4d | 357 | rm -rf "$TRACE_PATH" |
5e83c405 CB |
358 | fi |
359 | ||
0fc2834c | 360 | stop_test_apps |
5e83c405 CB |
361 | } |
362 | ||
a54047ec JD |
363 | function test_ust_local_snapshot_large_metadata () |
364 | { | |
365 | LM_EVENT="tp:tptest1,tp:tptest2,tp:tptest3,tp:tptest4,tp:tptest5" | |
366 | LM_PATH="$TESTDIR/utils/testapp" | |
367 | LM_NAME="gen-ust-nevents" | |
368 | LM_BIN="$LM_PATH/$LM_NAME/$LM_NAME" | |
369 | ||
370 | diag "Test local UST snapshots with > 4kB metadata" | |
c1896e2d KS |
371 | create_lttng_session_no_output "$SESSION_NAME" |
372 | enable_lttng_mmap_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
373 | enable_ust_lttng_event_ok "$SESSION_NAME" $LM_EVENT $CHANNEL_NAME | |
374 | start_lttng_tracing_ok "$SESSION_NAME" | |
375 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
8db430e7 | 376 | $LM_BIN --iter 1 --wait 1 |
a54047ec | 377 | ok $? "Start application to trace" |
c1896e2d KS |
378 | lttng_snapshot_record "$SESSION_NAME" |
379 | stop_lttng_tracing_ok "$SESSION_NAME" | |
380 | destroy_lttng_session_ok "$SESSION_NAME" | |
a54047ec JD |
381 | |
382 | # Validate test | |
bd666153 | 383 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 384 | if validate_trace $LM_EVENT "$TRACE_PATH/" ; then |
a54047ec | 385 | # Only delete if successful |
c1896e2d | 386 | rm -rf "${TRACE_PATH:?}/" |
a54047ec JD |
387 | fi |
388 | } | |
389 | ||
5f4c2d80 JD |
390 | function enable_channel_per_uid_mmap_overwrite() |
391 | { | |
392 | sess_name=$1 | |
393 | channel_name=$2 | |
394 | ||
c1896e2d | 395 | "$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 |
396 | ok $? "Enable channel $channel_name per UID for session $sess_name" |
397 | } | |
398 | ||
399 | function test_ust_per_uid_local_snapshot () | |
400 | { | |
18c9d47c JR |
401 | NR_ITER=-1 |
402 | NR_USEC_WAIT=100 | |
891d74dd | 403 | diag "Test per-uid local UST snapshots" |
c1896e2d KS |
404 | create_lttng_session_no_output "$SESSION_NAME" |
405 | enable_channel_per_uid_mmap_overwrite "$SESSION_NAME" $CHANNEL_NAME | |
406 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
407 | start_lttng_tracing_ok "$SESSION_NAME" | |
408 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
409 | |
410 | # Returns once the application has at least fired ONE tracepoint. | |
411 | start_test_app | |
412 | ||
c1896e2d KS |
413 | lttng_snapshot_record "$SESSION_NAME" |
414 | stop_lttng_tracing_ok "$SESSION_NAME" | |
415 | destroy_lttng_session_ok "$SESSION_NAME" | |
5f4c2d80 JD |
416 | |
417 | # Validate test | |
bd666153 | 418 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 419 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
5f4c2d80 | 420 | # Only delete if successful |
c1896e2d | 421 | rm -rf "${TRACE_PATH:?}/" |
5f4c2d80 | 422 | fi |
209b934f | 423 | |
0fc2834c | 424 | stop_test_apps |
5f4c2d80 JD |
425 | } |
426 | ||
4f03c06d JD |
427 | function test_ust_per_uid_local_snapshot_post_mortem () |
428 | { | |
18c9d47c | 429 | NR_ITER=-1 |
ae779dd6 MD |
430 | NR_USEC_WAIT=100 |
431 | ||
4f03c06d | 432 | diag "Test local UST snapshots post-mortem" |
c1896e2d KS |
433 | create_lttng_session_no_output "$SESSION_NAME" |
434 | enable_channel_per_uid_mmap_overwrite "$SESSION_NAME" $CHANNEL_NAME | |
435 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
436 | start_lttng_tracing_ok "$SESSION_NAME" | |
437 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
438 | |
439 | # Returns once the application has at least fired ONE tracepoint. | |
440 | start_test_app | |
0fc2834c | 441 | stop_test_apps |
209b934f | 442 | |
c1896e2d KS |
443 | lttng_snapshot_record "$SESSION_NAME" |
444 | stop_lttng_tracing_ok "$SESSION_NAME" | |
445 | destroy_lttng_session_ok "$SESSION_NAME" | |
4f03c06d JD |
446 | |
447 | # Validate test | |
bd666153 | 448 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0 |
c1896e2d | 449 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
4f03c06d | 450 | # Only delete if successful |
c1896e2d | 451 | rm -rf "${TRACE_PATH:?}/" |
4f03c06d JD |
452 | fi |
453 | } | |
454 | ||
1d20c959 | 455 | function test_ust_local_snapshots () |
ebaaaf5e | 456 | { |
18c9d47c | 457 | NR_ITER=-1 |
ae779dd6 MD |
458 | NR_USEC_WAIT=100 |
459 | ||
1d20c959 | 460 | diag "Test $NR_SNAPSHOT local UST snapshots" |
c1896e2d KS |
461 | create_lttng_session_no_output "$SESSION_NAME" |
462 | enable_lttng_mmap_overwrite_ust_channel "$SESSION_NAME" $CHANNEL_NAME | |
463 | enable_ust_lttng_event_ok "$SESSION_NAME" $EVENT_NAME $CHANNEL_NAME | |
464 | start_lttng_tracing_ok "$SESSION_NAME" | |
465 | lttng_snapshot_add_output_ok "$SESSION_NAME" "file://$TRACE_PATH" | |
209b934f DG |
466 | |
467 | # Returns once the application has at least fired ONE tracepoint. | |
468 | start_test_app | |
469 | ||
c1896e2d | 470 | for i in $(seq 1 "$NR_SNAPSHOT"); do |
1d20c959 | 471 | diag "Snapshot $i/$NR_SNAPSHOT" |
c1896e2d KS |
472 | rm -rf "$TRACE_PATH/snapshot/*" 2>/dev/null |
473 | lttng_snapshot_record "$SESSION_NAME" | |
ebaaaf5e | 474 | # Validate test |
bd666153 | 475 | validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" $((i - 1)) |
c1896e2d | 476 | if validate_trace $EVENT_NAME "$TRACE_PATH/" ; then |
ebaaaf5e | 477 | # Only delete if successful |
c1896e2d | 478 | rm -rf "${TRACE_PATH:?}/" |
ebaaaf5e JD |
479 | fi |
480 | done | |
c1896e2d KS |
481 | stop_lttng_tracing_ok "$SESSION_NAME" |
482 | destroy_lttng_session_ok "$SESSION_NAME" | |
209b934f | 483 | |
0fc2834c | 484 | stop_test_apps |
ebaaaf5e JD |
485 | } |
486 | ||
487 | plan_tests $NUM_TESTS | |
488 | ||
489 | print_test_banner "$TEST_DESC" | |
490 | ||
c125de8f FD |
491 | bail_out_if_no_babeltrace |
492 | ||
c1896e2d | 493 | # shellcheck disable=SC2119 |
ebaaaf5e | 494 | start_lttng_sessiond |
5e83c405 CB |
495 | tests=( test_ust_list_output |
496 | test_ust_local_snapshot | |
497 | test_ust_local_snapshot_max_size | |
498 | test_ust_per_uid_local_snapshot | |
499 | test_ust_per_uid_local_snapshot_post_mortem | |
500 | test_ust_local_snapshot_large_metadata | |
ae779dd6 MD |
501 | test_ust_local_snapshots |
502 | test_ust_local_snapshot_small_discard_buffers | |
503 | test_ust_local_snapshot_small_overwrite_buffers | |
504 | ) | |
ebaaaf5e | 505 | |
c1896e2d | 506 | for fct_test in "${tests[@]}"; |
ebaaaf5e JD |
507 | do |
508 | SESSION_NAME=$(randstring 16 0) | |
509 | ${fct_test} | |
ebaaaf5e JD |
510 | done |
511 | ||
c1896e2d | 512 | # shellcheck disable=SC2119 |
ebaaaf5e | 513 | stop_lttng_sessiond |