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 &
641 # Continue only when there is only the last event remaining.
642 while [ ! -f "${file_sync_before_last_touch}" ]; do
646 # Take a first snapshot and validate that the events are present.
647 lttng_snapshot_record
$SESSION_NAME
648 stop_lttng_tracing_ok
$SESSION_NAME
649 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
651 # Clean the output path
652 clean_path
$TRACE_PATH
653 start_lttng_tracing_ok
$SESSION_NAME
655 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
657 # Make sure the subsequent snapshot is empty and valid.
658 lttng_snapshot_record
$SESSION_NAME
659 stop_lttng_tracing_ok
$SESSION_NAME
660 validate_trace_empty
$TRACE_PATH
662 # Validate that tracing still works and subsequent snapshots are valid.
663 # Clean the output path.
664 clean_path
$TRACE_PATH
665 start_lttng_tracing_ok
$SESSION_NAME
667 # Continue over the last event.
668 touch ${file_sync_before_last}
670 # Wait for the before exit sync point. This ensure that we went over the
672 while [ ! -f "${file_sync_before_exit_touch}" ]; do
676 # Make sure the snapshot contains the last event.
677 lttng_snapshot_record
$SESSION_NAME
678 stop_lttng_tracing_ok
$SESSION_NAME
679 validate_trace_count
$EVENT_NAME $TRACE_PATH 1
681 # Release the application.
682 touch ${file_sync_before_exit}
684 destroy_lttng_session_ok
$SESSION_NAME
686 rm -f ${file_sync_before_last}
687 rm -f ${file_sync_before_last_touch}
688 rm -f ${file_sync_before_exit}
689 rm -f ${file_sync_before_exit_touch}
692 function test_ust_streaming_tracefile_rotation
()
694 local tracing_active
=$1
696 local rotate_before
=$3
697 local rotate_after
=$4
699 local channel_name
="rotchan"
700 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
702 diag
"Test ust streaming clear with tracefile rotation"
703 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
704 create_lttng_session_uri
$SESSION_NAME net
://localhost
705 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
706 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
707 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
708 start_lttng_tracing_ok
$SESSION_NAME
710 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
711 stop_lttng_tracing_ok
$SESSION_NAME
713 if [[ $rotate_before -eq 1 ]]; then
714 validate_trace_count
$EVENT_NAME $local_path 10
716 if [[ "$buffer_type" == "uid" ]]; then
717 validate_trace_empty
$local_path
719 validate_directory_empty
$local_path
723 start_lttng_tracing_ok
$SESSION_NAME
725 stop_lttng_tracing_ok
727 if [[ $rotate_before -eq 1 ]]; then
728 validate_trace_count
$EVENT_NAME $local_path 30
730 validate_trace_count
$EVENT_NAME $local_path 20
733 destroy_lttng_session_ok
$SESSION_NAME
736 # With 1 byte per event (as strict minimum), generating 200000 events
737 # guarantees filling up 2 files of 64k in size, which is the maximum
738 # page size known on Linux
739 function test_ust_streaming_tracefile_rotation_overwrite_files
()
741 local tracing_active
=$1
743 local rotate_before
=$3
744 local rotate_after
=$4
746 local channel_name
="rotchan"
747 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
749 diag
"Test ust streaming clear with tracefile rotation, overwrite files"
750 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
751 create_lttng_session_uri
$SESSION_NAME net
://localhost
752 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
753 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
754 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
755 start_lttng_tracing_ok
$SESSION_NAME
756 taskset
-c "$(get_any_available_cpu)" $TESTAPP_BIN -i 200000
757 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
758 stop_lttng_tracing_ok
$SESSION_NAME
760 if [[ $rotate_before -eq 1 ]]; then
761 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
763 if [[ "$buffer_type" == "uid" ]]; then
764 validate_trace_empty
$local_path
766 validate_directory_empty
$local_path
770 start_lttng_tracing_ok
$SESSION_NAME
771 taskset
-c "$(get_any_available_cpu)" $TESTAPP_BIN -i 400000
772 stop_lttng_tracing_ok
774 if [[ $rotate_before -eq 1 ]]; then
775 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 600000
777 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
780 destroy_lttng_session_ok
$SESSION_NAME
783 function test_ust_disallow_clear
()
785 diag
"Test ust disallow clear on relay daemon"
786 SESSION_NAME
=$
(randstring
16 0)
788 LTTNG_RELAYD_DISALLOW_CLEAR
=1 start_lttng_relayd
"-o $TRACE_PATH"
792 create_lttng_session_uri
$SESSION_NAME net
://localhost
793 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
794 start_lttng_tracing_ok
$SESSION_NAME
795 lttng_clear_session_fail
$SESSION_NAME
796 destroy_lttng_session_ok
$SESSION_NAME
800 clean_path
$TRACE_PATH
803 plan_tests
$NUM_TESTS
805 print_test_banner
"$TEST_DESC"
807 bail_out_if_no_babeltrace
809 streaming_tests
=(test_ust_streaming
810 test_ust_streaming_rotate_clear
811 test_ust_streaming_clear_rotate
812 test_ust_streaming_tracefile_rotation
813 test_ust_streaming_tracefile_rotation_overwrite_files
814 test_ust_streaming_no_event
817 live_tests
=(test_ust_streaming_live
818 test_ust_basic_streaming_live_viewer
819 test_ust_streaming_live_viewer
820 test_ust_streaming_live_viewer_new_metadata_after_clear
823 local_tests
=(test_ust_local
824 test_ust_local_rotate_clear
825 test_ust_local_clear_rotate
826 test_ust_local_no_event
829 snapshot_uid_tests
=(test_ust_streaming_snapshot
830 test_ust_local_snapshot
833 snapshot_pid_tests
=(test_ust_local_snapshot_per_pid
)
835 start_lttng_relayd
"-o $TRACE_PATH"
840 # Clear with tracing active, clear once
841 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
843 SESSION_NAME
=$
(randstring
16 0)
844 ${fct_test} 1 0 0 0 uid
845 clean_path
$TRACE_PATH
848 # Clear with tracing active, clear twice
849 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
851 SESSION_NAME
=$
(randstring
16 0)
852 ${fct_test} 1 1 0 0 uid
853 clean_path
$TRACE_PATH
856 # Clear with tracing inactive, clear once
857 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
859 SESSION_NAME
=$
(randstring
16 0)
860 ${fct_test} 0 0 0 0 uid
861 clean_path
$TRACE_PATH
864 # Clear with tracing inactive, clear twice
865 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
867 SESSION_NAME
=$
(randstring
16 0)
868 ${fct_test} 0 1 0 0 uid
869 clean_path
$TRACE_PATH
872 # Clear with tracing inactive, rotate-clear once
873 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
875 SESSION_NAME
=$
(randstring
16 0)
876 ${fct_test} 0 0 1 0 uid
877 clean_path
$TRACE_PATH
880 # Clear with tracing inactive, clear once-rotate(fail)
881 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
883 SESSION_NAME
=$
(randstring
16 0)
884 ${fct_test} 0 0 0 1 uid
885 clean_path
$TRACE_PATH
891 # Clear with tracing active, clear once
892 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
894 SESSION_NAME
=$
(randstring
16 0)
895 ${fct_test} 1 0 0 0 pid
896 clean_path
$TRACE_PATH
899 # Clear with tracing active, clear twice
900 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
902 SESSION_NAME
=$
(randstring
16 0)
903 ${fct_test} 1 1 0 0 pid
904 clean_path
$TRACE_PATH
907 # Clear with tracing inactive, clear once
908 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
910 SESSION_NAME
=$
(randstring
16 0)
911 ${fct_test} 0 0 0 0 pid
912 clean_path
$TRACE_PATH
915 # Clear with tracing inactive, clear twice
916 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
918 SESSION_NAME
=$
(randstring
16 0)
919 ${fct_test} 0 1 0 0 pid
920 clean_path
$TRACE_PATH
923 # Clear with tracing inactive, rotate-clear once
924 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
926 SESSION_NAME
=$
(randstring
16 0)
927 ${fct_test} 0 0 1 0 pid
928 clean_path
$TRACE_PATH
931 # Clear with tracing inactive, clear once-rotate(fail)
932 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
934 SESSION_NAME
=$
(randstring
16 0)
935 ${fct_test} 0 0 0 1 pid
936 clean_path
$TRACE_PATH
942 test_ust_disallow_clear