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 -t tmp.test_clear_ust_trace_path.XXXXXX
)
24 # shellcheck source=../utils/utils.sh
25 source "$TESTDIR/utils/utils.sh"
27 if [ ! -x "$TESTAPP_BIN" ]; then
28 BAIL_OUT
"No UST events binary detected."
31 function clean_path
()
39 function cond_start_tracing
()
42 local tracing_active
=$2
44 if [[ $tracing_active -ne 1 ]]; then
45 start_lttng_tracing_ok
$session_name
49 function cond_stop_tracing
()
52 local tracing_active
=$2
54 if [[ $tracing_active -ne 1 ]]; then
55 stop_lttng_tracing_ok
$session_name
59 function do_clear_session
()
62 local tracing_active
=$2
64 local rotate_before
=$4
67 cond_stop_tracing
$session_name $tracing_active
68 if [[ $rotate_before -eq 1 ]]; then
69 rotate_session_ok
$SESSION_NAME
71 lttng_clear_session_ok
$SESSION_NAME
72 if [[ $clear_twice -eq 1 ]]; then
73 lttng_clear_session_ok
$SESSION_NAME
75 if [[ $rotate_after -eq 1 ]]; then
76 if [[ $tracing_active -eq 1 ]]; then
77 rotate_session_ok
$SESSION_NAME
80 rotate_session_fail
$SESSION_NAME
83 cond_start_tracing
$session_name $tracing_active
86 function test_ust_streaming
()
88 local tracing_active
=$1
90 local rotate_before
=$3
93 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
94 local channel_name
="chan"
96 diag
"Test ust streaming clear"
97 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
98 create_lttng_session_uri
$SESSION_NAME net
://localhost
99 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
100 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
101 start_lttng_tracing_ok
$SESSION_NAME
103 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
104 stop_lttng_tracing_ok
$SESSION_NAME
106 if [[ $rotate_before -eq 1 ]]; then
107 validate_trace_count
$EVENT_NAME $local_path 10
109 if [[ "$buffer_type" == "uid" ]]; then
110 validate_trace_empty
$local_path
112 validate_directory_empty
$local_path
116 destroy_lttng_session_ok
$SESSION_NAME
119 function test_ust_streaming_no_event
()
121 local tracing_active
=$1
123 #local rotate_before=$3 ignored
124 #local rotate_after=$4
125 local buffer_type
=uid
126 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
127 local channel_name
="chan"
129 diag
"Test ust streaming clear no event"
130 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
131 create_lttng_session_uri
$SESSION_NAME net
://localhost
132 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
133 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
134 start_lttng_tracing_ok
$SESSION_NAME
136 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
137 stop_lttng_tracing_ok
$SESSION_NAME
139 validate_directory_empty
"$local_path"
141 destroy_lttng_session_ok
$SESSION_NAME
144 function test_ust_streaming_rotate_clear
()
146 local tracing_active
=$1
148 local rotate_before
=$3
149 local rotate_after
=$4
151 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
152 local channel_name
="chan"
154 diag
"Test ust streaming rotate-clear"
155 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
156 create_lttng_session_uri
$SESSION_NAME net
://localhost
157 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
158 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
159 start_lttng_tracing_ok
$SESSION_NAME
161 rotate_session_ok
$SESSION_NAME
163 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
165 stop_lttng_tracing_ok
$SESSION_NAME
167 if [[ $rotate_before -eq 1 ]]; then
172 validate_trace_count
$EVENT_NAME $local_path $expect_count
174 destroy_lttng_session_ok
$SESSION_NAME
177 function test_ust_streaming_clear_rotate
()
179 local tracing_active
=$1
181 local rotate_before
=$3
182 local rotate_after
=$4
184 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
185 local channel_name
="chan"
187 diag
"Test ust streaming clear-rotate"
188 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
189 create_lttng_session_uri
$SESSION_NAME net
://localhost
190 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
191 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
192 start_lttng_tracing_ok
$SESSION_NAME
194 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
196 rotate_session_ok
$SESSION_NAME
198 stop_lttng_tracing_ok
$SESSION_NAME
200 if [[ $rotate_before -eq 1 ]]; then
205 validate_trace_count
$EVENT_NAME $local_path $expect_count
207 destroy_lttng_session_ok
$SESSION_NAME
210 function test_ust_streaming_live
()
212 local tracing_active
=$1
216 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
217 local channel_name
="chan"
219 diag
"Test ust streaming live clear"
220 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
221 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
222 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
223 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
224 start_lttng_tracing_ok
$SESSION_NAME
226 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
227 stop_lttng_tracing_ok
$SESSION_NAME
229 if [[ "$buffer_type" == "uid" ]]; then
230 validate_trace_empty
$local_path
232 validate_directory_empty
$local_path
235 destroy_lttng_session_ok
$SESSION_NAME
239 function test_ust_basic_streaming_live_viewer
()
241 local tracing_active
=$1
245 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
246 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
247 local channel_name
="chan"
248 local bt_output_path
=$
(mktemp
-u -t tmp.test_
${FUNCNAME[0]}_bt_output_path.XXXXXX
)
249 local file_sync_before_exit
=$
(mktemp
-u -t tmp.test_
${FUNCNAME[0]}_sync_before_exit.XXXXXX
)
251 diag
"Test ust basic streaming live with viewer"
252 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
253 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
254 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
255 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
256 start_lttng_tracing_ok
$SESSION_NAME
258 wait_live_trace_ready net
://localhost
260 # Connect a live viewer
261 $BABELTRACE_BIN -i lttng-live net
://localhost
/host
/$remote_trace_path > $bt_output_path &
264 wait_live_viewer_connect net
://localhost
266 $TESTAPP_BIN -i 10 --sync-before-exit $file_sync_before_exit &
269 diag
"Wait until viewer sees all 10 expected events"
271 while [ $evcount -ne 10 ]; do
272 evcount
=$
(cat $bt_output_path |
wc -l)
275 pass
"Live viewer read $evcount events, expect 10"
277 destroy_lttng_session_ok
$SESSION_NAME
278 touch $file_sync_before_exit
279 diag
"Waiting for application to exit"
281 pass
"Wait for application to exit"
282 diag
"Wait for viewer to exit"
284 ok $?
"Babeltrace succeeds"
285 pass
"Wait for viewer to exit"
287 rm -f $bt_output_path
288 rm -f $file_sync_before_exit
291 function test_ust_streaming_live_viewer
()
293 local tracing_active
=$1
297 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
298 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
299 local channel_name
="chan"
300 local bt_output_path
=$
(mktemp
-u -t tmp.test_
${FUNCNAME[0]}_bt_output_path.XXXXXX
)
302 diag
"Test ust streaming live clear with viewer"
303 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
304 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
305 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
306 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
307 start_lttng_tracing_ok
$SESSION_NAME
309 wait_live_trace_ready net
://localhost
311 # Connect a live viewer
312 $BABELTRACE_BIN -i lttng-live net
://localhost
/host
/$remote_trace_path > $bt_output_path &
315 wait_live_viewer_connect net
://localhost
318 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
319 stop_lttng_tracing_ok
$SESSION_NAME
321 destroy_lttng_session_ok
$SESSION_NAME
322 diag
"Wait for viewer to exit"
324 ok $?
"Babeltrace succeeds"
325 pass
"Wait for viewer to exit"
327 clean_path
$bt_output_path
330 function test_ust_streaming_live_viewer_new_metadata_after_clear
()
332 local tracing_active
=$1
336 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
337 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
338 local channel_name
="chan"
340 local bt_output_path
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_bt_output.XXXXXX")
341 local bt_error_path
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_bt_error.XXXXXX")
342 local file_sync_before_exit
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
344 diag
"Test ust streaming live clear with viewer with new metadata after clear"
345 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
346 create_lttng_session_uri
"$SESSION_NAME" net
://localhost
"--live"
347 enable_ust_lttng_channel_ok
"$SESSION_NAME" $channel_name "--buffers-$buffer_type"
349 # The vpid context is added to filter events based on the vpid of the
350 # test application as state dump events are used. Regenerating a
351 # state dump will cause other instrumented application on the system
352 # to trigger a state dump which would throw off checks that rely on an
354 add_context_ust_ok
"$SESSION_NAME" $channel_name "vpid"
355 enable_ust_lttng_event_ok
"$SESSION_NAME" $EVENT_NAME $channel_name
356 start_lttng_tracing_ok
"$SESSION_NAME"
358 wait_live_trace_ready net
://localhost
360 # Connect a live viewer
361 $BABELTRACE_BIN -i lttng-live
"net://localhost/host/$remote_trace_path" 1> "$bt_output_path" 2> "$bt_error_path" &
364 wait_live_viewer_connect net
://localhost
366 $TESTAPP_BIN -i 10 --sync-before-exit "$file_sync_before_exit" &
369 diag
"Wait until viewer sees all 10 expected events"
371 while [ $evcount -ne 10 ]; do
372 evcount
=$
(wc -l < "$bt_output_path")
375 pass
"Live viewer read $evcount events, expect 10"
377 do_clear_session
"$SESSION_NAME" "$tracing_active" "$clear_twice" 0 0
379 # Enable new events which will add their descriptions to the metadata
380 # file. This validates that, following a clear, the relay daemon rotates
381 # the metadata viewer stream to the new metadata file.
382 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_START "\$ctx.vpid == $app_pid" $channel_name
383 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_END "\$ctx.vpid == $app_pid" $channel_name
385 # Forcing a state dump to produce the two events enabled above
386 regenerate_statedump_ok
"$SESSION_NAME"
388 diag
"Wait until viewer sees all 12 expected events"
390 while [ $evcount -ne 12 ]; do
391 evcount
=$
(wc -l < "$bt_output_path")
394 pass
"Live viewer read $evcount events, expect 12"
396 stop_lttng_tracing_ok
"$SESSION_NAME"
398 destroy_lttng_session_ok
"$SESSION_NAME"
400 touch "$file_sync_before_exit"
401 diag
"Waiting for application to exit"
403 pass
"Wait for application to exit"
405 diag
"Wait for viewer to exit"
407 ok $?
"Babeltrace succeeds"
408 pass
"Wait for viewer to exit"
410 clean_path
"$bt_output_path"
411 clean_path
"$bt_error_path"
412 rm -f "$file_sync_before_exit"
415 function test_ust_local
()
417 local tracing_active
=$1
419 local rotate_before
=$3
420 local rotate_after
=$4
422 local channel_name
="chan"
424 diag
"Test ust local"
425 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
426 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
427 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
428 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
429 start_lttng_tracing_ok
$SESSION_NAME
431 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
432 stop_lttng_tracing_ok
$SESSION_NAME
434 if [[ $rotate_before -eq 1 ]]; then
435 validate_trace_count
$EVENT_NAME $TRACE_PATH 10
437 if [[ "$buffer_type" == "uid" ]]; then
438 validate_trace_empty
$TRACE_PATH
441 # The sessiond always created a `ust/ directory
442 # whenever the UST domain is active
443 validate_directory_empty
$TRACE_PATH/ust
/
447 destroy_lttng_session_ok
$SESSION_NAME
450 function test_ust_local_no_event
()
452 local tracing_active
=$1
454 #local rotate_before=$3 ignored
455 #local rotate_after=$4 ignored
457 local channel_name
="chan"
459 diag
"Test ust local no event"
460 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
461 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
462 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name "--buffers-$buffer_type"
463 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
464 start_lttng_tracing_ok
$SESSION_NAME
466 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
467 stop_lttng_tracing_ok
$SESSION_NAME
469 validate_directory_empty
"$TRACE_PATH"
471 destroy_lttng_session_ok
$SESSION_NAME
474 function test_ust_local_rotate_clear
()
476 local tracing_active
=$1
478 local rotate_before
=$3
479 local rotate_after
=$4
481 local channel_name
="chan"
483 diag
"Test ust local rotate-clear"
484 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
485 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
486 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
487 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
488 start_lttng_tracing_ok
$SESSION_NAME
490 rotate_session_ok
$SESSION_NAME
492 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
494 stop_lttng_tracing_ok
$SESSION_NAME
496 if [[ $rotate_before -eq 1 ]]; then
501 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
503 destroy_lttng_session_ok
$SESSION_NAME
506 function test_ust_local_clear_rotate
()
508 local tracing_active
=$1
510 local rotate_before
=$3
511 local rotate_after
=$4
513 local channel_name
="chan"
515 diag
"Test ust local clear-rotate"
516 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
517 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
518 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
519 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
520 start_lttng_tracing_ok
$SESSION_NAME
522 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
524 rotate_session_ok
$SESSION_NAME
526 stop_lttng_tracing_ok
$SESSION_NAME
528 if [[ $rotate_before -eq 1 ]]; then
533 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
535 destroy_lttng_session_ok
$SESSION_NAME
538 function do_ust_snapshot
()
540 local session_name
=$1
542 local tracing_active
=$3
545 local channel_name
="snapshot"
547 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
548 enable_ust_lttng_event_ok
$session_name $EVENT_NAME $channel_name
549 start_lttng_tracing_ok
$session_name
551 # Generate 10 events that will sit in the buffers.
554 # Take a first snapshot and validate that the events are present.
555 lttng_snapshot_record
$session_name
556 stop_lttng_tracing_ok
$session_name
557 validate_trace_count
$EVENT_NAME $trace_path 10
559 # Clean the output path
560 clean_path
$trace_path
561 start_lttng_tracing_ok
$session_name
563 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
565 # Make sure the subsequent snapshot is empty and valid.
566 lttng_snapshot_record
$session_name
567 stop_lttng_tracing_ok
$session_name
568 validate_trace_empty
$trace_path
570 # Clean the output path
571 clean_path
$trace_path
572 start_lttng_tracing_ok
$session_name
574 # Make sure that everything still works, generate events and take a
577 lttng_snapshot_record
$session_name
578 stop_lttng_tracing_ok
$session_name
579 validate_trace_count
$EVENT_NAME $trace_path 10
582 function test_ust_streaming_snapshot
()
584 local tracing_active
=$1
589 diag
"Test ust streaming snapshot clear"
590 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
592 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
593 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
594 destroy_lttng_session_ok
$SESSION_NAME
597 function test_ust_local_snapshot
()
599 local tracing_active
=$1
604 diag
"Test ust local snapshot clear"
605 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
607 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
608 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
609 destroy_lttng_session_ok
$SESSION_NAME
612 # snapshot for per-pid is tested independently of the "buffer type" parameter
613 # because an application needs to be live to appear in a snapshot.
614 function test_ust_local_snapshot_per_pid
()
616 local tracing_active
=$1
620 local channel_name
="channel0"
621 local file_sync_before_last
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
622 local file_sync_before_last_touch
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_last_touch.XXXXXX")
623 local file_sync_before_exit
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
624 local file_sync_before_exit_touch
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")
626 diag
"Test ust local snapshot clear per pid"
627 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
629 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
630 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
631 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
632 start_lttng_tracing_ok
$SESSION_NAME
634 # Generate 10 events that will sit in the buffers.
635 $TESTAPP_BIN -i 10 -w 0 \
636 --sync-before-last-event ${file_sync_before_last} \
637 --sync-before-last-event-touch ${file_sync_before_last_touch} \
638 --sync-before-exit ${file_sync_before_exit} \
639 --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 "$(get_any_available_cpu)" $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 "$(get_any_available_cpu)" $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 bail_out_if_no_babeltrace
810 streaming_tests
=(test_ust_streaming
811 test_ust_streaming_rotate_clear
812 test_ust_streaming_clear_rotate
813 test_ust_streaming_tracefile_rotation
814 test_ust_streaming_tracefile_rotation_overwrite_files
815 test_ust_streaming_no_event
818 live_tests
=(test_ust_streaming_live
819 test_ust_basic_streaming_live_viewer
820 test_ust_streaming_live_viewer
821 test_ust_streaming_live_viewer_new_metadata_after_clear
824 local_tests
=(test_ust_local
825 test_ust_local_rotate_clear
826 test_ust_local_clear_rotate
827 test_ust_local_no_event
830 snapshot_uid_tests
=(test_ust_streaming_snapshot
831 test_ust_local_snapshot
834 snapshot_pid_tests
=(test_ust_local_snapshot_per_pid
)
836 start_lttng_relayd
"-o $TRACE_PATH"
841 # Clear with tracing active, clear once
842 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
844 SESSION_NAME
=$
(randstring
16 0)
845 ${fct_test} 1 0 0 0 uid
846 clean_path
$TRACE_PATH
849 # Clear with tracing active, clear twice
850 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
852 SESSION_NAME
=$
(randstring
16 0)
853 ${fct_test} 1 1 0 0 uid
854 clean_path
$TRACE_PATH
857 # Clear with tracing inactive, clear once
858 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
860 SESSION_NAME
=$
(randstring
16 0)
861 ${fct_test} 0 0 0 0 uid
862 clean_path
$TRACE_PATH
865 # Clear with tracing inactive, clear twice
866 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
868 SESSION_NAME
=$
(randstring
16 0)
869 ${fct_test} 0 1 0 0 uid
870 clean_path
$TRACE_PATH
873 # Clear with tracing inactive, rotate-clear once
874 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
876 SESSION_NAME
=$
(randstring
16 0)
877 ${fct_test} 0 0 1 0 uid
878 clean_path
$TRACE_PATH
881 # Clear with tracing inactive, clear once-rotate(fail)
882 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
884 SESSION_NAME
=$
(randstring
16 0)
885 ${fct_test} 0 0 0 1 uid
886 clean_path
$TRACE_PATH
892 # Clear with tracing active, clear once
893 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
895 SESSION_NAME
=$
(randstring
16 0)
896 ${fct_test} 1 0 0 0 pid
897 clean_path
$TRACE_PATH
900 # Clear with tracing active, clear twice
901 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
903 SESSION_NAME
=$
(randstring
16 0)
904 ${fct_test} 1 1 0 0 pid
905 clean_path
$TRACE_PATH
908 # Clear with tracing inactive, clear once
909 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
911 SESSION_NAME
=$
(randstring
16 0)
912 ${fct_test} 0 0 0 0 pid
913 clean_path
$TRACE_PATH
916 # Clear with tracing inactive, clear twice
917 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
919 SESSION_NAME
=$
(randstring
16 0)
920 ${fct_test} 0 1 0 0 pid
921 clean_path
$TRACE_PATH
924 # Clear with tracing inactive, rotate-clear once
925 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
927 SESSION_NAME
=$
(randstring
16 0)
928 ${fct_test} 0 0 1 0 pid
929 clean_path
$TRACE_PATH
932 # Clear with tracing inactive, clear once-rotate(fail)
933 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
935 SESSION_NAME
=$
(randstring
16 0)
936 ${fct_test} 0 0 0 1 pid
937 clean_path
$TRACE_PATH
943 test_ust_disallow_clear