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
--tmpdir -d tmp.test_clear_ust_trace_path.XXXXXX
)
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
--tmpdir -u tmp.test_
${FUNCNAME[0]}_bt_output_path.XXXXXX
)
248 local file_sync_before_exit
=$
(mktemp
--tmpdir -u tmp.test_
${FUNCNAME[0]}_sync_before_exit.XXXXXX
)
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
--tmpdir -u tmp.test_
${FUNCNAME[0]}_bt_output_path.XXXXXX
)
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"
339 local bt_output_path
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_bt_output.XXXXXX")
340 local bt_error_path
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_bt_error.XXXXXX")
341 local file_sync_before_exit
=$
(mktemp
--tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
343 diag
"Test ust streaming live clear with viewer with new metadata after clear"
344 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
345 create_lttng_session_uri
"$SESSION_NAME" net
://localhost
"--live"
346 enable_ust_lttng_channel_ok
"$SESSION_NAME" $channel_name "--buffers-$buffer_type"
348 # The vpid context is added to filter events based on the vpid of the
349 # test application as state dump events are used. Regenerating a
350 # state dump will cause other instrumented application on the system
351 # to trigger a state dump which would throw off checks that rely on an
353 add_context_ust_ok
"$SESSION_NAME" $channel_name "vpid"
354 enable_ust_lttng_event_ok
"$SESSION_NAME" $EVENT_NAME $channel_name
355 start_lttng_tracing_ok
"$SESSION_NAME"
357 wait_live_trace_ready net
://localhost
359 # Connect a live viewer
360 $BABELTRACE_BIN -i lttng-live
"net://localhost/host/$remote_trace_path" 1> "$bt_output_path" 2> "$bt_error_path" &
363 wait_live_viewer_connect net
://localhost
365 $TESTAPP_BIN -i 10 --sync-before-exit "$file_sync_before_exit" &
368 diag
"Wait until viewer sees all 10 expected events"
370 while [ $evcount -ne 10 ]; do
371 evcount
=$
(wc -l < "$bt_output_path")
374 pass
"Live viewer read $evcount events, expect 10"
376 do_clear_session
"$SESSION_NAME" "$tracing_active" "$clear_twice" 0 0
378 # Enable new events which will add their descriptions to the metadata
379 # file. This validates that, following a clear, the relay daemon rotates
380 # the metadata viewer stream to the new metadata file.
381 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_START "\$ctx.vpid == $app_pid" $channel_name
382 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_END "\$ctx.vpid == $app_pid" $channel_name
384 # Forcing a state dump to produce the two events enabled above
385 regenerate_statedump_ok
"$SESSION_NAME"
387 diag
"Wait until viewer sees all 12 expected events"
389 while [ $evcount -ne 12 ]; do
390 evcount
=$
(wc -l < "$bt_output_path")
393 pass
"Live viewer read $evcount events, expect 12"
395 stop_lttng_tracing_ok
"$SESSION_NAME"
397 destroy_lttng_session_ok
"$SESSION_NAME"
399 touch "$file_sync_before_exit"
400 diag
"Waiting for application to exit"
402 pass
"Wait for application to exit"
404 diag
"Wait for viewer to exit"
406 ok $?
"Babeltrace succeeds"
407 pass
"Wait for viewer to exit"
409 clean_path
"$bt_output_path"
410 clean_path
"$bt_error_path"
411 rm -f "$file_sync_before_exit"
414 function test_ust_local
()
416 local tracing_active
=$1
418 local rotate_before
=$3
419 local rotate_after
=$4
421 local channel_name
="chan"
423 diag
"Test ust local"
424 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
425 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
426 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
427 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
428 start_lttng_tracing_ok
$SESSION_NAME
430 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
431 stop_lttng_tracing_ok
$SESSION_NAME
433 if [[ $rotate_before -eq 1 ]]; then
434 validate_trace_count
$EVENT_NAME $TRACE_PATH 10
436 if [[ "$buffer_type" == "uid" ]]; then
437 validate_trace_empty
$TRACE_PATH
440 # The sessiond always created a `ust/ directory
441 # whenever the UST domain is active
442 validate_directory_empty
$TRACE_PATH/ust
/
446 destroy_lttng_session_ok
$SESSION_NAME
449 function test_ust_local_no_event
()
451 local tracing_active
=$1
453 #local rotate_before=$3 ignored
454 #local rotate_after=$4 ignored
456 local channel_name
="chan"
458 diag
"Test ust local no event"
459 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
460 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
461 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name "--buffers-$buffer_type"
462 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
463 start_lttng_tracing_ok
$SESSION_NAME
465 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
466 stop_lttng_tracing_ok
$SESSION_NAME
468 validate_directory_empty
"$TRACE_PATH"
470 destroy_lttng_session_ok
$SESSION_NAME
473 function test_ust_local_rotate_clear
()
475 local tracing_active
=$1
477 local rotate_before
=$3
478 local rotate_after
=$4
480 local channel_name
="chan"
482 diag
"Test ust local rotate-clear"
483 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
484 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
485 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
486 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
487 start_lttng_tracing_ok
$SESSION_NAME
489 rotate_session_ok
$SESSION_NAME
491 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
493 stop_lttng_tracing_ok
$SESSION_NAME
495 if [[ $rotate_before -eq 1 ]]; then
500 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
502 destroy_lttng_session_ok
$SESSION_NAME
505 function test_ust_local_clear_rotate
()
507 local tracing_active
=$1
509 local rotate_before
=$3
510 local rotate_after
=$4
512 local channel_name
="chan"
514 diag
"Test ust local clear-rotate"
515 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
516 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
517 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
518 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
519 start_lttng_tracing_ok
$SESSION_NAME
521 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
523 rotate_session_ok
$SESSION_NAME
525 stop_lttng_tracing_ok
$SESSION_NAME
527 if [[ $rotate_before -eq 1 ]]; then
532 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
534 destroy_lttng_session_ok
$SESSION_NAME
537 function do_ust_snapshot
()
539 local session_name
=$1
541 local tracing_active
=$3
544 local channel_name
="snapshot"
546 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
547 enable_ust_lttng_event_ok
$session_name $EVENT_NAME $channel_name
548 start_lttng_tracing_ok
$session_name
550 # Generate 10 events that will sit in the buffers.
553 # Take a first snapshot and validate that the events are present.
554 lttng_snapshot_record
$session_name
555 stop_lttng_tracing_ok
$session_name
556 validate_trace_count
$EVENT_NAME $trace_path 10
558 # Clean the output path
559 clean_path
$trace_path
560 start_lttng_tracing_ok
$session_name
562 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
564 # Make sure the subsequent snapshot is empty and valid.
565 lttng_snapshot_record
$session_name
566 stop_lttng_tracing_ok
$session_name
567 validate_trace_empty
$trace_path
569 # Clean the output path
570 clean_path
$trace_path
571 start_lttng_tracing_ok
$session_name
573 # Make sure that everything still works, generate events and take a
576 lttng_snapshot_record
$session_name
577 stop_lttng_tracing_ok
$session_name
578 validate_trace_count
$EVENT_NAME $trace_path 10
581 function test_ust_streaming_snapshot
()
583 local tracing_active
=$1
588 diag
"Test ust streaming snapshot clear"
589 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
591 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
592 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
593 destroy_lttng_session_ok
$SESSION_NAME
596 function test_ust_local_snapshot
()
598 local tracing_active
=$1
603 diag
"Test ust local snapshot clear"
604 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
606 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
607 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
608 destroy_lttng_session_ok
$SESSION_NAME
611 # snapshot for per-pid is tested independently of the "buffer type" parameter
612 # because an application needs to be live to appear in a snapshot.
613 function test_ust_local_snapshot_per_pid
()
615 local tracing_active
=$1
619 local channel_name
="channel0"
620 local file_sync_before_last
=$
(mktemp
--tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
621 local file_sync_before_last_touch
=$
(mktemp
--tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last_touch.XXXXXX")
622 local file_sync_before_exit
=$
(mktemp
--tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
623 local file_sync_before_exit_touch
=$
(mktemp
--tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")
625 diag
"Test ust local snapshot clear per pid"
626 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
628 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
629 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
630 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
631 start_lttng_tracing_ok
$SESSION_NAME
633 # Generate 10 events that will sit in the buffers.
634 $TESTAPP_BIN -i 10 -w 0 \
635 --sync-before-last-event ${file_sync_before_last} \
636 --sync-before-last-event-touch ${file_sync_before_last_touch} \
637 --sync-before-exit ${file_sync_before_exit} \
638 --sync-before-exit-touch ${file_sync_before_exit_touch} >/dev
/null
2>&1 &
640 # Continue only when there is only the last event remaining.
641 while [ ! -f "${file_sync_before_last_touch}" ]; do
645 # Take a first snapshot and validate that the events are present.
646 lttng_snapshot_record
$SESSION_NAME
647 stop_lttng_tracing_ok
$SESSION_NAME
648 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
650 # Clean the output path
651 clean_path
$TRACE_PATH
652 start_lttng_tracing_ok
$SESSION_NAME
654 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
656 # Make sure the subsequent snapshot is empty and valid.
657 lttng_snapshot_record
$SESSION_NAME
658 stop_lttng_tracing_ok
$SESSION_NAME
659 validate_trace_empty
$TRACE_PATH
661 # Validate that tracing still works and subsequent snapshots are valid.
662 # Clean the output path.
663 clean_path
$TRACE_PATH
664 start_lttng_tracing_ok
$SESSION_NAME
666 # Continue over the last event.
667 touch ${file_sync_before_last}
669 # Wait for the before exit sync point. This ensure that we went over the
671 while [ ! -f "${file_sync_before_exit_touch}" ]; do
675 # Make sure the snapshot contains the last event.
676 lttng_snapshot_record
$SESSION_NAME
677 stop_lttng_tracing_ok
$SESSION_NAME
678 validate_trace_count
$EVENT_NAME $TRACE_PATH 1
680 # Release the application.
681 touch ${file_sync_before_exit}
683 destroy_lttng_session_ok
$SESSION_NAME
685 rm -f ${file_sync_before_last}
686 rm -f ${file_sync_before_last_touch}
687 rm -f ${file_sync_before_exit}
688 rm -f ${file_sync_before_exit_touch}
691 function test_ust_streaming_tracefile_rotation
()
693 local tracing_active
=$1
695 local rotate_before
=$3
696 local rotate_after
=$4
698 local channel_name
="rotchan"
699 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
701 diag
"Test ust streaming clear with tracefile rotation"
702 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
703 create_lttng_session_uri
$SESSION_NAME net
://localhost
704 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
705 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
706 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
707 start_lttng_tracing_ok
$SESSION_NAME
709 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
710 stop_lttng_tracing_ok
$SESSION_NAME
712 if [[ $rotate_before -eq 1 ]]; then
713 validate_trace_count
$EVENT_NAME $local_path 10
715 if [[ "$buffer_type" == "uid" ]]; then
716 validate_trace_empty
$local_path
718 validate_directory_empty
$local_path
722 start_lttng_tracing_ok
$SESSION_NAME
724 stop_lttng_tracing_ok
726 if [[ $rotate_before -eq 1 ]]; then
727 validate_trace_count
$EVENT_NAME $local_path 30
729 validate_trace_count
$EVENT_NAME $local_path 20
732 destroy_lttng_session_ok
$SESSION_NAME
735 # With 1 byte per event (as strict minimum), generating 200000 events
736 # guarantees filling up 2 files of 64k in size, which is the maximum
737 # page size known on Linux
738 function test_ust_streaming_tracefile_rotation_overwrite_files
()
740 local tracing_active
=$1
742 local rotate_before
=$3
743 local rotate_after
=$4
745 local channel_name
="rotchan"
746 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
748 diag
"Test ust streaming clear with tracefile rotation, overwrite files"
749 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
750 create_lttng_session_uri
$SESSION_NAME net
://localhost
751 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
752 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
753 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
754 start_lttng_tracing_ok
$SESSION_NAME
755 taskset
-c 0 $TESTAPP_BIN -i 200000
756 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
757 stop_lttng_tracing_ok
$SESSION_NAME
759 if [[ $rotate_before -eq 1 ]]; then
760 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
762 if [[ "$buffer_type" == "uid" ]]; then
763 validate_trace_empty
$local_path
765 validate_directory_empty
$local_path
769 start_lttng_tracing_ok
$SESSION_NAME
770 taskset
-c 0 $TESTAPP_BIN -i 400000
771 stop_lttng_tracing_ok
773 if [[ $rotate_before -eq 1 ]]; then
774 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 600000
776 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
779 destroy_lttng_session_ok
$SESSION_NAME
782 function test_ust_disallow_clear
()
784 diag
"Test ust disallow clear on relay daemon"
785 SESSION_NAME
=$
(randstring
16 0)
787 LTTNG_RELAYD_DISALLOW_CLEAR
=1 start_lttng_relayd
"-o $TRACE_PATH"
791 create_lttng_session_uri
$SESSION_NAME net
://localhost
792 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
793 start_lttng_tracing_ok
$SESSION_NAME
794 lttng_clear_session_fail
$SESSION_NAME
795 destroy_lttng_session_ok
$SESSION_NAME
799 clean_path
$TRACE_PATH
802 plan_tests
$NUM_TESTS
804 print_test_banner
"$TEST_DESC"
806 bail_out_if_no_babeltrace
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