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