3 # Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Clear - UST tracing"
10 TESTDIR
=$CURDIR/..
/..
/..
11 EVENT_NAME
="tp:tptest"
12 EVENT_STATE_DUMP_START
="lttng_ust_statedump:start"
13 EVENT_STATE_DUMP_END
="lttng_ust_statedump:end"
15 TESTAPP_PATH
="$TESTDIR/utils/testapp"
16 TESTAPP_NAME
="gen-ust-events"
17 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
21 PAGE_SIZE
=$
(getconf PAGE_SIZE
)
22 TRACE_PATH
=$
(mktemp
-d)
24 source $TESTDIR/utils
/utils.sh
26 if [ ! -x "$TESTAPP_BIN" ]; then
27 BAIL_OUT
"No UST events binary detected."
30 function clean_path
()
38 function cond_start_tracing
()
41 local tracing_active
=$2
43 if [[ $tracing_active -ne 1 ]]; then
44 start_lttng_tracing_ok
$session_name
48 function cond_stop_tracing
()
51 local tracing_active
=$2
53 if [[ $tracing_active -ne 1 ]]; then
54 stop_lttng_tracing_ok
$session_name
58 function do_clear_session
()
61 local tracing_active
=$2
63 local rotate_before
=$4
66 cond_stop_tracing
$session_name $tracing_active
67 if [[ $rotate_before -eq 1 ]]; then
68 rotate_session_ok
$SESSION_NAME
70 lttng_clear_session_ok
$SESSION_NAME
71 if [[ $clear_twice -eq 1 ]]; then
72 lttng_clear_session_ok
$SESSION_NAME
74 if [[ $rotate_after -eq 1 ]]; then
75 if [[ $tracing_active -eq 1 ]]; then
76 rotate_session_ok
$SESSION_NAME
79 rotate_session_fail
$SESSION_NAME
82 cond_start_tracing
$session_name $tracing_active
85 function test_ust_streaming
()
87 local tracing_active
=$1
89 local rotate_before
=$3
92 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
93 local channel_name
="chan"
95 diag
"Test ust streaming clear"
96 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
97 create_lttng_session_uri
$SESSION_NAME net
://localhost
98 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
99 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
100 start_lttng_tracing_ok
$SESSION_NAME
102 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
103 stop_lttng_tracing_ok
$SESSION_NAME
105 if [[ $rotate_before -eq 1 ]]; then
106 validate_trace_count
$EVENT_NAME $local_path 10
108 if [[ "$buffer_type" == "uid" ]]; then
109 validate_trace_empty
$local_path
111 validate_directory_empty
$local_path
115 destroy_lttng_session_ok
$SESSION_NAME
118 function test_ust_streaming_no_event
()
120 local tracing_active
=$1
122 #local rotate_before=$3 ignored
123 #local rotate_after=$4
124 local buffer_type
=uid
125 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
126 local channel_name
="chan"
128 diag
"Test ust streaming clear no event"
129 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
130 create_lttng_session_uri
$SESSION_NAME net
://localhost
131 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
132 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
133 start_lttng_tracing_ok
$SESSION_NAME
135 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
136 stop_lttng_tracing_ok
$SESSION_NAME
138 validate_directory_empty
"$local_path"
140 destroy_lttng_session_ok
$SESSION_NAME
143 function test_ust_streaming_rotate_clear
()
145 local tracing_active
=$1
147 local rotate_before
=$3
148 local rotate_after
=$4
150 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
151 local channel_name
="chan"
153 diag
"Test ust streaming rotate-clear"
154 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
155 create_lttng_session_uri
$SESSION_NAME net
://localhost
156 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
157 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
158 start_lttng_tracing_ok
$SESSION_NAME
160 rotate_session_ok
$SESSION_NAME
162 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
164 stop_lttng_tracing_ok
$SESSION_NAME
166 if [[ $rotate_before -eq 1 ]]; then
171 validate_trace_count
$EVENT_NAME $local_path $expect_count
173 destroy_lttng_session_ok
$SESSION_NAME
176 function test_ust_streaming_clear_rotate
()
178 local tracing_active
=$1
180 local rotate_before
=$3
181 local rotate_after
=$4
183 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
184 local channel_name
="chan"
186 diag
"Test ust streaming clear-rotate"
187 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
188 create_lttng_session_uri
$SESSION_NAME net
://localhost
189 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
190 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
191 start_lttng_tracing_ok
$SESSION_NAME
193 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
195 rotate_session_ok
$SESSION_NAME
197 stop_lttng_tracing_ok
$SESSION_NAME
199 if [[ $rotate_before -eq 1 ]]; then
204 validate_trace_count
$EVENT_NAME $local_path $expect_count
206 destroy_lttng_session_ok
$SESSION_NAME
209 function test_ust_streaming_live
()
211 local tracing_active
=$1
215 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
216 local channel_name
="chan"
218 diag
"Test ust streaming live clear"
219 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
220 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
221 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
222 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
223 start_lttng_tracing_ok
$SESSION_NAME
225 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
226 stop_lttng_tracing_ok
$SESSION_NAME
228 if [[ "$buffer_type" == "uid" ]]; then
229 validate_trace_empty
$local_path
231 validate_directory_empty
$local_path
234 destroy_lttng_session_ok
$SESSION_NAME
238 function test_ust_basic_streaming_live_viewer
()
240 local tracing_active
=$1
244 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
245 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
246 local channel_name
="chan"
247 local bt_output_path
=$
(mktemp
-u)
248 local file_sync_before_exit
=$
(mktemp
-u)
250 diag
"Test ust basic streaming live with viewer"
251 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
252 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
253 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
254 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
255 start_lttng_tracing_ok
$SESSION_NAME
257 wait_live_trace_ready net
://localhost
259 # Connect a live viewer
260 $BABELTRACE_BIN -i lttng-live net
://localhost
/host
/$remote_trace_path > $bt_output_path &
263 wait_live_viewer_connect net
://localhost
265 $TESTAPP_BIN -i 10 --sync-before-exit $file_sync_before_exit &
268 diag
"Wait until viewer sees all 10 expected events"
270 while [ $evcount -ne 10 ]; do
271 evcount
=$
(cat $bt_output_path |
wc -l)
274 pass
"Live viewer read $evcount events, expect 10"
276 destroy_lttng_session_ok
$SESSION_NAME
277 touch $file_sync_before_exit
278 diag
"Waiting for application to exit"
280 pass
"Wait for application to exit"
281 diag
"Wait for viewer to exit"
283 ok $?
"Babeltrace succeeds"
284 pass
"Wait for viewer to exit"
286 rm -f $bt_output_path
287 rm -f $file_sync_before_exit
290 function test_ust_streaming_live_viewer
()
292 local tracing_active
=$1
296 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
297 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
298 local channel_name
="chan"
299 local bt_output_path
=$
(mktemp
-d)/bt-output.txt
301 diag
"Test ust streaming live clear with viewer"
302 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
303 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
304 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
305 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
306 start_lttng_tracing_ok
$SESSION_NAME
308 wait_live_trace_ready net
://localhost
310 # Connect a live viewer
311 $BABELTRACE_BIN -i lttng-live net
://localhost
/host
/$remote_trace_path > $bt_output_path &
314 wait_live_viewer_connect net
://localhost
317 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
318 stop_lttng_tracing_ok
$SESSION_NAME
320 destroy_lttng_session_ok
$SESSION_NAME
321 diag
"Wait for viewer to exit"
323 ok $?
"Babeltrace succeeds"
324 pass
"Wait for viewer to exit"
326 clean_path
$bt_output_path
329 function test_ust_streaming_live_viewer_new_metadata_after_clear
()
331 local tracing_active
=$1
335 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
336 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
337 local channel_name
="chan"
340 local file_sync_before_exit
342 bt_output_path
=$
(mktemp
-d)/bt-output.txt
343 bt_error_path
=$
(mktemp
-d)/bt-output.err
344 file_sync_before_exit
=$
(mktemp
-u)
346 diag
"Test ust streaming live clear with viewer with new metadata after clear"
347 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
348 create_lttng_session_uri
"$SESSION_NAME" net
://localhost
"--live"
349 enable_ust_lttng_channel_ok
"$SESSION_NAME" $channel_name "--buffers-$buffer_type"
351 # The vpid context is added to filter events based on the vpid of the
352 # test application as state dump events are used. Regenerating a
353 # state dump will cause other instrumented application on the system
354 # to trigger a state dump which would throw off checks that rely on an
356 add_context_ust_ok
"$SESSION_NAME" $channel_name "vpid"
357 enable_ust_lttng_event_ok
"$SESSION_NAME" $EVENT_NAME $channel_name
358 start_lttng_tracing_ok
"$SESSION_NAME"
360 wait_live_trace_ready net
://localhost
362 # Connect a live viewer
363 $BABELTRACE_BIN -i lttng-live
"net://localhost/host/$remote_trace_path" 1> "$bt_output_path" 2> "$bt_error_path" &
366 wait_live_viewer_connect net
://localhost
368 $TESTAPP_BIN -i 10 --sync-before-exit "$file_sync_before_exit" &
371 diag
"Wait until viewer sees all 10 expected events"
373 while [ $evcount -ne 10 ]; do
374 evcount
=$
(wc -l < "$bt_output_path")
377 pass
"Live viewer read $evcount events, expect 10"
379 do_clear_session
"$SESSION_NAME" "$tracing_active" "$clear_twice" 0 0
381 # Enable new events which will add their descriptions to the metadata
382 # file. This validates that, following a clear, the relay daemon rotates
383 # the metadata viewer stream to the new metadata file.
384 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_START "\$ctx.vpid == $app_pid" $channel_name
385 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_END "\$ctx.vpid == $app_pid" $channel_name
387 # Forcing a state dump to produce the two events enabled above
388 regenerate_statedump_ok
"$SESSION_NAME"
390 diag
"Wait until viewer sees all 12 expected events"
392 while [ $evcount -ne 12 ]; do
393 evcount
=$
(wc -l < "$bt_output_path")
396 pass
"Live viewer read $evcount events, expect 12"
398 stop_lttng_tracing_ok
"$SESSION_NAME"
400 destroy_lttng_session_ok
"$SESSION_NAME"
402 touch "$file_sync_before_exit"
403 diag
"Waiting for application to exit"
405 pass
"Wait for application to exit"
407 diag
"Wait for viewer to exit"
409 ok $?
"Babeltrace succeeds"
410 pass
"Wait for viewer to exit"
412 clean_path
"$bt_output_path"
413 clean_path
"$bt_error_path"
416 function test_ust_local
()
418 local tracing_active
=$1
420 local rotate_before
=$3
421 local rotate_after
=$4
423 local channel_name
="chan"
425 diag
"Test ust local"
426 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
427 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
428 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
429 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
430 start_lttng_tracing_ok
$SESSION_NAME
432 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
433 stop_lttng_tracing_ok
$SESSION_NAME
435 if [[ $rotate_before -eq 1 ]]; then
436 validate_trace_count
$EVENT_NAME $TRACE_PATH 10
438 if [[ "$buffer_type" == "uid" ]]; then
439 validate_trace_empty
$TRACE_PATH
442 # The sessiond always created a `ust/ directory
443 # whenever the UST domain is active
444 validate_directory_empty
$TRACE_PATH/ust
/
448 destroy_lttng_session_ok
$SESSION_NAME
451 function test_ust_local_no_event
()
453 local tracing_active
=$1
455 #local rotate_before=$3 ignored
456 #local rotate_after=$4 ignored
458 local channel_name
="chan"
460 diag
"Test ust local no event"
461 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
462 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
463 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name "--buffers-$buffer_type"
464 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
465 start_lttng_tracing_ok
$SESSION_NAME
467 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
468 stop_lttng_tracing_ok
$SESSION_NAME
470 validate_directory_empty
"$TRACE_PATH"
472 destroy_lttng_session_ok
$SESSION_NAME
475 function test_ust_local_rotate_clear
()
477 local tracing_active
=$1
479 local rotate_before
=$3
480 local rotate_after
=$4
482 local channel_name
="chan"
484 diag
"Test ust local rotate-clear"
485 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
486 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
487 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
488 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
489 start_lttng_tracing_ok
$SESSION_NAME
491 rotate_session_ok
$SESSION_NAME
493 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
495 stop_lttng_tracing_ok
$SESSION_NAME
497 if [[ $rotate_before -eq 1 ]]; then
502 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
504 destroy_lttng_session_ok
$SESSION_NAME
507 function test_ust_local_clear_rotate
()
509 local tracing_active
=$1
511 local rotate_before
=$3
512 local rotate_after
=$4
514 local channel_name
="chan"
516 diag
"Test ust local clear-rotate"
517 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
518 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
519 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
520 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
521 start_lttng_tracing_ok
$SESSION_NAME
523 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
525 rotate_session_ok
$SESSION_NAME
527 stop_lttng_tracing_ok
$SESSION_NAME
529 if [[ $rotate_before -eq 1 ]]; then
534 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
536 destroy_lttng_session_ok
$SESSION_NAME
539 function do_ust_snapshot
()
541 local session_name
=$1
543 local tracing_active
=$3
546 local channel_name
="snapshot"
548 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
549 enable_ust_lttng_event_ok
$session_name $EVENT_NAME $channel_name
550 start_lttng_tracing_ok
$session_name
552 # Generate 10 events that will sit in the buffers.
555 # Take a first snapshot and validate that the events are present.
556 lttng_snapshot_record
$session_name
557 stop_lttng_tracing_ok
$session_name
558 validate_trace_count
$EVENT_NAME $trace_path 10
560 # Clean the output path
561 clean_path
$trace_path
562 start_lttng_tracing_ok
$session_name
564 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
566 # Make sure the subsequent snapshot is empty and valid.
567 lttng_snapshot_record
$session_name
568 stop_lttng_tracing_ok
$session_name
569 validate_trace_empty
$trace_path
571 # Clean the output path
572 clean_path
$trace_path
573 start_lttng_tracing_ok
$session_name
575 # Make sure that everything still works, generate events and take a
578 lttng_snapshot_record
$session_name
579 stop_lttng_tracing_ok
$session_name
580 validate_trace_count
$EVENT_NAME $trace_path 10
583 function test_ust_streaming_snapshot
()
585 local tracing_active
=$1
590 diag
"Test ust streaming snapshot clear"
591 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
593 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
594 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
595 destroy_lttng_session_ok
$SESSION_NAME
598 function test_ust_local_snapshot
()
600 local tracing_active
=$1
605 diag
"Test ust local snapshot clear"
606 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
608 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
609 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
610 destroy_lttng_session_ok
$SESSION_NAME
613 # snapshot for per-pid is tested independently of the "buffer type" parameter
614 # because an application needs to be live to appear in a snapshot.
615 function test_ust_local_snapshot_per_pid
()
617 local tracing_active
=$1
621 local channel_name
="channel0"
622 local file_sync_before_last
=$
(mktemp
-u)
623 local file_sync_before_last_touch
=$
(mktemp
-u)
624 local file_sync_before_exit
=$
(mktemp
-u)
625 local file_sync_before_exit_touch
=$
(mktemp
-u)
627 diag
"Test ust local snapshot clear per pid"
628 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
630 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
631 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
632 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
633 start_lttng_tracing_ok
$SESSION_NAME
635 # Generate 10 events that will sit in the buffers.
636 $TESTAPP_BIN -i 10 -w 0 \
637 --sync-before-last-event ${file_sync_before_last} \
638 --sync-before-last-event-touch ${file_sync_before_last_touch} \
639 --sync-before-exit ${file_sync_before_exit} \
640 --sync-before-exit-touch ${file_sync_before_exit_touch} >/dev
/null
2>&1 &
642 # Continue only when there is only the last event remaining.
643 while [ ! -f "${file_sync_before_last_touch}" ]; do
647 # Take a first snapshot and validate that the events are present.
648 lttng_snapshot_record
$SESSION_NAME
649 stop_lttng_tracing_ok
$SESSION_NAME
650 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
652 # Clean the output path
653 clean_path
$TRACE_PATH
654 start_lttng_tracing_ok
$SESSION_NAME
656 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
658 # Make sure the subsequent snapshot is empty and valid.
659 lttng_snapshot_record
$SESSION_NAME
660 stop_lttng_tracing_ok
$SESSION_NAME
661 validate_trace_empty
$TRACE_PATH
663 # Validate that tracing still works and subsequent snapshots are valid.
664 # Clean the output path.
665 clean_path
$TRACE_PATH
666 start_lttng_tracing_ok
$SESSION_NAME
668 # Continue over the last event.
669 touch ${file_sync_before_last}
671 # Wait for the before exit sync point. This ensure that we went over the
673 while [ ! -f "${file_sync_before_exit_touch}" ]; do
677 # Make sure the snapshot contains the last event.
678 lttng_snapshot_record
$SESSION_NAME
679 stop_lttng_tracing_ok
$SESSION_NAME
680 validate_trace_count
$EVENT_NAME $TRACE_PATH 1
682 # Release the application.
683 touch ${file_sync_before_exit}
685 destroy_lttng_session_ok
$SESSION_NAME
687 rm -f ${file_sync_before_last}
688 rm -f ${file_sync_before_last_touch}
689 rm -f ${file_sync_before_exit}
690 rm -f ${file_sync_before_exit_touch}
693 function test_ust_streaming_tracefile_rotation
()
695 local tracing_active
=$1
697 local rotate_before
=$3
698 local rotate_after
=$4
700 local channel_name
="rotchan"
701 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
703 diag
"Test ust streaming clear with tracefile rotation"
704 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
705 create_lttng_session_uri
$SESSION_NAME net
://localhost
706 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
707 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
708 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
709 start_lttng_tracing_ok
$SESSION_NAME
711 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
712 stop_lttng_tracing_ok
$SESSION_NAME
714 if [[ $rotate_before -eq 1 ]]; then
715 validate_trace_count
$EVENT_NAME $local_path 10
717 if [[ "$buffer_type" == "uid" ]]; then
718 validate_trace_empty
$local_path
720 validate_directory_empty
$local_path
724 start_lttng_tracing_ok
$SESSION_NAME
726 stop_lttng_tracing_ok
728 if [[ $rotate_before -eq 1 ]]; then
729 validate_trace_count
$EVENT_NAME $local_path 30
731 validate_trace_count
$EVENT_NAME $local_path 20
734 destroy_lttng_session_ok
$SESSION_NAME
737 # With 1 byte per event (as strict minimum), generating 200000 events
738 # guarantees filling up 2 files of 64k in size, which is the maximum
739 # page size known on Linux
740 function test_ust_streaming_tracefile_rotation_overwrite_files
()
742 local tracing_active
=$1
744 local rotate_before
=$3
745 local rotate_after
=$4
747 local channel_name
="rotchan"
748 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
750 diag
"Test ust streaming clear with tracefile rotation, overwrite files"
751 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
752 create_lttng_session_uri
$SESSION_NAME net
://localhost
753 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
754 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
755 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
756 start_lttng_tracing_ok
$SESSION_NAME
757 taskset
-c 0 $TESTAPP_BIN -i 200000
758 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
759 stop_lttng_tracing_ok
$SESSION_NAME
761 if [[ $rotate_before -eq 1 ]]; then
762 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
764 if [[ "$buffer_type" == "uid" ]]; then
765 validate_trace_empty
$local_path
767 validate_directory_empty
$local_path
771 start_lttng_tracing_ok
$SESSION_NAME
772 taskset
-c 0 $TESTAPP_BIN -i 400000
773 stop_lttng_tracing_ok
775 if [[ $rotate_before -eq 1 ]]; then
776 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 600000
778 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
781 destroy_lttng_session_ok
$SESSION_NAME
784 function test_ust_disallow_clear
()
786 diag
"Test ust disallow clear on relay daemon"
787 SESSION_NAME
=$
(randstring
16 0)
789 LTTNG_RELAYD_DISALLOW_CLEAR
=1 start_lttng_relayd
"-o $TRACE_PATH"
793 create_lttng_session_uri
$SESSION_NAME net
://localhost
794 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
795 start_lttng_tracing_ok
$SESSION_NAME
796 lttng_clear_session_fail
$SESSION_NAME
797 destroy_lttng_session_ok
$SESSION_NAME
801 clean_path
$TRACE_PATH
804 plan_tests
$NUM_TESTS
806 print_test_banner
"$TEST_DESC"
808 streaming_tests
=(test_ust_streaming
809 test_ust_streaming_rotate_clear
810 test_ust_streaming_clear_rotate
811 test_ust_streaming_tracefile_rotation
812 test_ust_streaming_tracefile_rotation_overwrite_files
813 test_ust_streaming_no_event
816 live_tests
=(test_ust_streaming_live
817 test_ust_basic_streaming_live_viewer
818 test_ust_streaming_live_viewer
819 test_ust_streaming_live_viewer_new_metadata_after_clear
822 local_tests
=(test_ust_local
823 test_ust_local_rotate_clear
824 test_ust_local_clear_rotate
825 test_ust_local_no_event
828 snapshot_uid_tests
=(test_ust_streaming_snapshot
829 test_ust_local_snapshot
832 snapshot_pid_tests
=(test_ust_local_snapshot_per_pid
)
834 start_lttng_relayd
"-o $TRACE_PATH"
839 # Clear with tracing active, clear once
840 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
842 SESSION_NAME
=$
(randstring
16 0)
843 ${fct_test} 1 0 0 0 uid
844 clean_path
$TRACE_PATH
847 # Clear with tracing active, clear twice
848 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
850 SESSION_NAME
=$
(randstring
16 0)
851 ${fct_test} 1 1 0 0 uid
852 clean_path
$TRACE_PATH
855 # Clear with tracing inactive, clear once
856 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
858 SESSION_NAME
=$
(randstring
16 0)
859 ${fct_test} 0 0 0 0 uid
860 clean_path
$TRACE_PATH
863 # Clear with tracing inactive, clear twice
864 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
866 SESSION_NAME
=$
(randstring
16 0)
867 ${fct_test} 0 1 0 0 uid
868 clean_path
$TRACE_PATH
871 # Clear with tracing inactive, rotate-clear once
872 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
874 SESSION_NAME
=$
(randstring
16 0)
875 ${fct_test} 0 0 1 0 uid
876 clean_path
$TRACE_PATH
879 # Clear with tracing inactive, clear once-rotate(fail)
880 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
882 SESSION_NAME
=$
(randstring
16 0)
883 ${fct_test} 0 0 0 1 uid
884 clean_path
$TRACE_PATH
890 # Clear with tracing active, clear once
891 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
893 SESSION_NAME
=$
(randstring
16 0)
894 ${fct_test} 1 0 0 0 pid
895 clean_path
$TRACE_PATH
898 # Clear with tracing active, clear twice
899 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
901 SESSION_NAME
=$
(randstring
16 0)
902 ${fct_test} 1 1 0 0 pid
903 clean_path
$TRACE_PATH
906 # Clear with tracing inactive, clear once
907 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
909 SESSION_NAME
=$
(randstring
16 0)
910 ${fct_test} 0 0 0 0 pid
911 clean_path
$TRACE_PATH
914 # Clear with tracing inactive, clear twice
915 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
917 SESSION_NAME
=$
(randstring
16 0)
918 ${fct_test} 0 1 0 0 pid
919 clean_path
$TRACE_PATH
922 # Clear with tracing inactive, rotate-clear once
923 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
925 SESSION_NAME
=$
(randstring
16 0)
926 ${fct_test} 0 0 1 0 pid
927 clean_path
$TRACE_PATH
930 # Clear with tracing inactive, clear once-rotate(fail)
931 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
933 SESSION_NAME
=$
(randstring
16 0)
934 ${fct_test} 0 0 0 1 pid
935 clean_path
$TRACE_PATH
941 test_ust_disallow_clear