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 # 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)
249 local file_sync_before_exit
=$
(mktemp
-u)
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
-d)/bt-output.txt
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"
341 local file_sync_before_exit
343 bt_output_path
=$
(mktemp
-d)/bt-output.txt
344 bt_error_path
=$
(mktemp
-d)/bt-output.err
345 file_sync_before_exit
=$
(mktemp
-u)
347 diag
"Test ust streaming live clear with viewer with new metadata after clear"
348 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
349 create_lttng_session_uri
"$SESSION_NAME" net
://localhost
"--live"
350 enable_ust_lttng_channel_ok
"$SESSION_NAME" $channel_name "--buffers-$buffer_type"
352 # The vpid context is added to filter events based on the vpid of the
353 # test application as state dump events are used. Regenerating a
354 # state dump will cause other instrumented application on the system
355 # to trigger a state dump which would throw off checks that rely on an
357 add_context_ust_ok
"$SESSION_NAME" $channel_name "vpid"
358 enable_ust_lttng_event_ok
"$SESSION_NAME" $EVENT_NAME $channel_name
359 start_lttng_tracing_ok
"$SESSION_NAME"
361 wait_live_trace_ready net
://localhost
363 # Connect a live viewer
364 $BABELTRACE_BIN -i lttng-live
"net://localhost/host/$remote_trace_path" 1> "$bt_output_path" 2> "$bt_error_path" &
367 wait_live_viewer_connect net
://localhost
369 $TESTAPP_BIN -i 10 --sync-before-exit "$file_sync_before_exit" &
372 diag
"Wait until viewer sees all 10 expected events"
374 while [ $evcount -ne 10 ]; do
375 evcount
=$
(wc -l < "$bt_output_path")
378 pass
"Live viewer read $evcount events, expect 10"
380 do_clear_session
"$SESSION_NAME" "$tracing_active" "$clear_twice" 0 0
382 # Enable new events which will add their descriptions to the metadata
383 # file. This validates that, following a clear, the relay daemon rotates
384 # the metadata viewer stream to the new metadata file.
385 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_START "\$ctx.vpid == $app_pid" $channel_name
386 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_END "\$ctx.vpid == $app_pid" $channel_name
388 # Forcing a state dump to produce the two events enabled above
389 regenerate_statedump_ok
"$SESSION_NAME"
391 diag
"Wait until viewer sees all 12 expected events"
393 while [ $evcount -ne 12 ]; do
394 evcount
=$
(wc -l < "$bt_output_path")
397 pass
"Live viewer read $evcount events, expect 12"
399 stop_lttng_tracing_ok
"$SESSION_NAME"
401 destroy_lttng_session_ok
"$SESSION_NAME"
403 touch "$file_sync_before_exit"
404 diag
"Waiting for application to exit"
406 pass
"Wait for application to exit"
408 diag
"Wait for viewer to exit"
410 ok $?
"Babeltrace succeeds"
411 pass
"Wait for viewer to exit"
413 clean_path
"$bt_output_path"
414 clean_path
"$bt_error_path"
417 function test_ust_local
()
419 local tracing_active
=$1
421 local rotate_before
=$3
422 local rotate_after
=$4
424 local channel_name
="chan"
426 diag
"Test ust local"
427 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
428 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
429 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
430 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
431 start_lttng_tracing_ok
$SESSION_NAME
433 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
434 stop_lttng_tracing_ok
$SESSION_NAME
436 if [[ $rotate_before -eq 1 ]]; then
437 validate_trace_count
$EVENT_NAME $TRACE_PATH 10
439 if [[ "$buffer_type" == "uid" ]]; then
440 validate_trace_empty
$TRACE_PATH
443 # The sessiond always created a `ust/ directory
444 # whenever the UST domain is active
445 validate_directory_empty
$TRACE_PATH/ust
/
449 destroy_lttng_session_ok
$SESSION_NAME
452 function test_ust_local_no_event
()
454 local tracing_active
=$1
456 #local rotate_before=$3 ignored
457 #local rotate_after=$4 ignored
459 local channel_name
="chan"
461 diag
"Test ust local no event"
462 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
463 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
464 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name "--buffers-$buffer_type"
465 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
466 start_lttng_tracing_ok
$SESSION_NAME
468 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
469 stop_lttng_tracing_ok
$SESSION_NAME
471 validate_directory_empty
"$TRACE_PATH"
473 destroy_lttng_session_ok
$SESSION_NAME
476 function test_ust_local_rotate_clear
()
478 local tracing_active
=$1
480 local rotate_before
=$3
481 local rotate_after
=$4
483 local channel_name
="chan"
485 diag
"Test ust local rotate-clear"
486 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
487 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
488 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
489 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
490 start_lttng_tracing_ok
$SESSION_NAME
492 rotate_session_ok
$SESSION_NAME
494 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
496 stop_lttng_tracing_ok
$SESSION_NAME
498 if [[ $rotate_before -eq 1 ]]; then
503 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
505 destroy_lttng_session_ok
$SESSION_NAME
508 function test_ust_local_clear_rotate
()
510 local tracing_active
=$1
512 local rotate_before
=$3
513 local rotate_after
=$4
515 local channel_name
="chan"
517 diag
"Test ust local clear-rotate"
518 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
519 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
520 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
521 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
522 start_lttng_tracing_ok
$SESSION_NAME
524 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
526 rotate_session_ok
$SESSION_NAME
528 stop_lttng_tracing_ok
$SESSION_NAME
530 if [[ $rotate_before -eq 1 ]]; then
535 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
537 destroy_lttng_session_ok
$SESSION_NAME
540 function do_ust_snapshot
()
542 local session_name
=$1
544 local tracing_active
=$3
547 local channel_name
="snapshot"
549 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
550 enable_ust_lttng_event_ok
$session_name $EVENT_NAME $channel_name
551 start_lttng_tracing_ok
$session_name
553 # Generate 10 events that will sit in the buffers.
556 # Take a first snapshot and validate that the events are present.
557 lttng_snapshot_record
$session_name
558 stop_lttng_tracing_ok
$session_name
559 validate_trace_count
$EVENT_NAME $trace_path 10
561 # Clean the output path
562 clean_path
$trace_path
563 start_lttng_tracing_ok
$session_name
565 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
567 # Make sure the subsequent snapshot is empty and valid.
568 lttng_snapshot_record
$session_name
569 stop_lttng_tracing_ok
$session_name
570 validate_trace_empty
$trace_path
572 # Clean the output path
573 clean_path
$trace_path
574 start_lttng_tracing_ok
$session_name
576 # Make sure that everything still works, generate events and take a
579 lttng_snapshot_record
$session_name
580 stop_lttng_tracing_ok
$session_name
581 validate_trace_count
$EVENT_NAME $trace_path 10
584 function test_ust_streaming_snapshot
()
586 local tracing_active
=$1
591 diag
"Test ust streaming snapshot clear"
592 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
594 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
595 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
596 destroy_lttng_session_ok
$SESSION_NAME
599 function test_ust_local_snapshot
()
601 local tracing_active
=$1
606 diag
"Test ust local snapshot clear"
607 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
609 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
610 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
611 destroy_lttng_session_ok
$SESSION_NAME
614 # snapshot for per-pid is tested independently of the "buffer type" parameter
615 # because an application needs to be live to appear in a snapshot.
616 function test_ust_local_snapshot_per_pid
()
618 local tracing_active
=$1
622 local channel_name
="channel0"
623 local file_sync_before_last
=$
(mktemp
-u)
624 local file_sync_before_last_touch
=$
(mktemp
-u)
625 local file_sync_before_exit
=$
(mktemp
-u)
626 local file_sync_before_exit_touch
=$
(mktemp
-u)
628 diag
"Test ust local snapshot clear per pid"
629 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
631 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
632 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
633 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
634 start_lttng_tracing_ok
$SESSION_NAME
636 # Generate 10 events that will sit in the buffers.
637 $TESTAPP_BIN -i 10 -w 0 \
638 --sync-before-last-event ${file_sync_before_last} \
639 --sync-before-last-event-touch ${file_sync_before_last_touch} \
640 --sync-before-exit ${file_sync_before_exit} \
641 --sync-before-exit-touch ${file_sync_before_exit_touch} >/dev
/null
2>&1 &
643 # Continue only when there is only the last event remaining.
644 while [ ! -f "${file_sync_before_last_touch}" ]; do
648 # Take a first snapshot and validate that the events are present.
649 lttng_snapshot_record
$SESSION_NAME
650 stop_lttng_tracing_ok
$SESSION_NAME
651 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
653 # Clean the output path
654 clean_path
$TRACE_PATH
655 start_lttng_tracing_ok
$SESSION_NAME
657 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
659 # Make sure the subsequent snapshot is empty and valid.
660 lttng_snapshot_record
$SESSION_NAME
661 stop_lttng_tracing_ok
$SESSION_NAME
662 validate_trace_empty
$TRACE_PATH
664 # Validate that tracing still works and subsequent snapshots are valid.
665 # Clean the output path.
666 clean_path
$TRACE_PATH
667 start_lttng_tracing_ok
$SESSION_NAME
669 # Continue over the last event.
670 touch ${file_sync_before_last}
672 # Wait for the before exit sync point. This ensure that we went over the
674 while [ ! -f "${file_sync_before_exit_touch}" ]; do
678 # Make sure the snapshot contains the last event.
679 lttng_snapshot_record
$SESSION_NAME
680 stop_lttng_tracing_ok
$SESSION_NAME
681 validate_trace_count
$EVENT_NAME $TRACE_PATH 1
683 # Release the application.
684 touch ${file_sync_before_exit}
686 destroy_lttng_session_ok
$SESSION_NAME
688 rm -f ${file_sync_before_last}
689 rm -f ${file_sync_before_last_touch}
690 rm -f ${file_sync_before_exit}
691 rm -f ${file_sync_before_exit_touch}
694 function test_ust_streaming_tracefile_rotation
()
696 local tracing_active
=$1
698 local rotate_before
=$3
699 local rotate_after
=$4
701 local channel_name
="rotchan"
702 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
704 diag
"Test ust streaming clear with tracefile rotation"
705 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
706 create_lttng_session_uri
$SESSION_NAME net
://localhost
707 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
708 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
709 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
710 start_lttng_tracing_ok
$SESSION_NAME
712 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
713 stop_lttng_tracing_ok
$SESSION_NAME
715 if [[ $rotate_before -eq 1 ]]; then
716 validate_trace_count
$EVENT_NAME $local_path 10
718 if [[ "$buffer_type" == "uid" ]]; then
719 validate_trace_empty
$local_path
721 validate_directory_empty
$local_path
725 start_lttng_tracing_ok
$SESSION_NAME
727 stop_lttng_tracing_ok
729 if [[ $rotate_before -eq 1 ]]; then
730 validate_trace_count
$EVENT_NAME $local_path 30
732 validate_trace_count
$EVENT_NAME $local_path 20
735 destroy_lttng_session_ok
$SESSION_NAME
738 # With 1 byte per event (as strict minimum), generating 200000 events
739 # guarantees filling up 2 files of 64k in size, which is the maximum
740 # page size known on Linux
741 function test_ust_streaming_tracefile_rotation_overwrite_files
()
743 local tracing_active
=$1
745 local rotate_before
=$3
746 local rotate_after
=$4
748 local channel_name
="rotchan"
749 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
751 diag
"Test ust streaming clear with tracefile rotation, overwrite files"
752 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
753 create_lttng_session_uri
$SESSION_NAME net
://localhost
754 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
755 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
756 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
757 start_lttng_tracing_ok
$SESSION_NAME
758 taskset
-c "$(get_any_available_cpu)" $TESTAPP_BIN -i 200000
759 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
760 stop_lttng_tracing_ok
$SESSION_NAME
762 if [[ $rotate_before -eq 1 ]]; then
763 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
765 if [[ "$buffer_type" == "uid" ]]; then
766 validate_trace_empty
$local_path
768 validate_directory_empty
$local_path
772 start_lttng_tracing_ok
$SESSION_NAME
773 taskset
-c "$(get_any_available_cpu)" $TESTAPP_BIN -i 400000
774 stop_lttng_tracing_ok
776 if [[ $rotate_before -eq 1 ]]; then
777 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 600000
779 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
782 destroy_lttng_session_ok
$SESSION_NAME
785 function test_ust_disallow_clear
()
787 diag
"Test ust disallow clear on relay daemon"
788 SESSION_NAME
=$
(randstring
16 0)
790 LTTNG_RELAYD_DISALLOW_CLEAR
=1 start_lttng_relayd
"-o $TRACE_PATH"
794 create_lttng_session_uri
$SESSION_NAME net
://localhost
795 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
796 start_lttng_tracing_ok
$SESSION_NAME
797 lttng_clear_session_fail
$SESSION_NAME
798 destroy_lttng_session_ok
$SESSION_NAME
802 clean_path
$TRACE_PATH
805 plan_tests
$NUM_TESTS
807 print_test_banner
"$TEST_DESC"
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