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 LIVEVIEWER_TIMEOUT
=10 # Timeout in seconds
22 PAGE_SIZE
=$
(getconf PAGE_SIZE
)
23 TRACE_PATH
=$
(mktemp
-d -t tmp.test_clear_ust_trace_path.XXXXXX
)
25 # shellcheck source=../utils/utils.sh
26 source "$TESTDIR/utils/utils.sh"
28 if [ ! -x "$TESTAPP_BIN" ]; then
29 BAIL_OUT
"No UST events binary detected."
32 function clean_path
()
40 function cond_start_tracing
()
43 local tracing_active
=$2
45 if [[ $tracing_active -ne 1 ]]; then
46 start_lttng_tracing_ok
$session_name
50 function cond_stop_tracing
()
53 local tracing_active
=$2
55 if [[ $tracing_active -ne 1 ]]; then
56 stop_lttng_tracing_ok
$session_name
60 function do_clear_session
()
63 local tracing_active
=$2
65 local rotate_before
=$4
68 cond_stop_tracing
$session_name $tracing_active
69 if [[ $rotate_before -eq 1 ]]; then
70 rotate_session_ok
$SESSION_NAME
72 lttng_clear_session_ok
$SESSION_NAME
73 if [[ $clear_twice -eq 1 ]]; then
74 lttng_clear_session_ok
$SESSION_NAME
76 if [[ $rotate_after -eq 1 ]]; then
77 if [[ $tracing_active -eq 1 ]]; then
78 rotate_session_ok
$SESSION_NAME
81 rotate_session_fail
$SESSION_NAME
84 cond_start_tracing
$session_name $tracing_active
87 function test_ust_streaming
()
89 local tracing_active
=$1
91 local rotate_before
=$3
94 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
95 local channel_name
="chan"
97 diag
"Test ust streaming clear"
98 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
99 create_lttng_session_uri
$SESSION_NAME net
://localhost
100 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
101 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
102 start_lttng_tracing_ok
$SESSION_NAME
104 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
105 stop_lttng_tracing_ok
$SESSION_NAME
107 if [[ $rotate_before -eq 1 ]]; then
108 validate_trace_count
$EVENT_NAME $local_path 10
110 if [[ "$buffer_type" == "uid" ]]; then
111 validate_trace_empty
$local_path
113 validate_directory_empty
$local_path
117 destroy_lttng_session_ok
$SESSION_NAME --no-wait
120 function test_ust_streaming_no_event
()
122 local tracing_active
=$1
124 #local rotate_before=$3 ignored
125 #local rotate_after=$4
126 local buffer_type
=uid
127 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
128 local channel_name
="chan"
130 diag
"Test ust streaming clear no event"
131 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
132 create_lttng_session_uri
$SESSION_NAME net
://localhost
133 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
134 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
135 start_lttng_tracing_ok
$SESSION_NAME
137 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
138 stop_lttng_tracing_ok
$SESSION_NAME
140 validate_directory_empty
"$local_path"
142 destroy_lttng_session_ok
$SESSION_NAME --no-wait
145 function test_ust_streaming_rotate_clear
()
147 local tracing_active
=$1
149 local rotate_before
=$3
150 local rotate_after
=$4
152 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
153 local channel_name
="chan"
155 diag
"Test ust streaming rotate-clear"
156 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
157 create_lttng_session_uri
$SESSION_NAME net
://localhost
158 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
159 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
160 start_lttng_tracing_ok
$SESSION_NAME
162 rotate_session_ok
$SESSION_NAME
164 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
166 stop_lttng_tracing_ok
$SESSION_NAME
168 if [[ $rotate_before -eq 1 ]]; then
173 validate_trace_count
$EVENT_NAME $local_path $expect_count
175 destroy_lttng_session_ok
$SESSION_NAME --no-wait
178 function test_ust_streaming_clear_rotate
()
180 local tracing_active
=$1
182 local rotate_before
=$3
183 local rotate_after
=$4
185 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
186 local channel_name
="chan"
188 diag
"Test ust streaming clear-rotate"
189 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
190 create_lttng_session_uri
$SESSION_NAME net
://localhost
191 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
192 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
193 start_lttng_tracing_ok
$SESSION_NAME
195 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
197 rotate_session_ok
$SESSION_NAME
199 stop_lttng_tracing_ok
$SESSION_NAME
201 if [[ $rotate_before -eq 1 ]]; then
206 validate_trace_count
$EVENT_NAME $local_path $expect_count
208 destroy_lttng_session_ok
$SESSION_NAME --no-wait
211 function test_ust_streaming_live
()
213 local tracing_active
=$1
217 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
218 local channel_name
="chan"
220 diag
"Test ust streaming live clear"
221 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
222 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live=${DELAYUS}"
223 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
224 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
225 start_lttng_tracing_ok
$SESSION_NAME
227 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
228 stop_lttng_tracing_ok
$SESSION_NAME
230 if [[ "$buffer_type" == "uid" ]]; then
231 validate_trace_empty
$local_path
233 validate_directory_empty
$local_path
236 destroy_lttng_session_ok
$SESSION_NAME --no-wait
240 function test_ust_basic_streaming_live_viewer
()
242 local tracing_active
=$1
246 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
247 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
248 local channel_name
="chan"
249 local bt_output_path
=$
(mktemp
-u -t tmp.test_
${FUNCNAME[0]}_bt_output_path.XXXXXX
)
250 local file_sync_before_exit
=$
(mktemp
-u -t tmp.test_
${FUNCNAME[0]}_sync_before_exit.XXXXXX
)
252 diag
"Test ust basic streaming live with viewer"
253 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
254 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live=${DELAYUS}"
255 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
256 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
257 start_lttng_tracing_ok
$SESSION_NAME
259 wait_live_trace_ready net
://localhost
261 # Connect a live viewer
262 _run_babeltrace_cmd
-i lttng-live net
://localhost
/host
/$remote_trace_path --params=session-not-found-action
=end
1> $bt_output_path &
266 wait_live_viewer_connect net
://localhost
268 $TESTAPP_BIN -i 10 --sync-before-exit $file_sync_before_exit &
271 diag
"Wait until viewer sees all 10 expected events"
273 while [ $evcount -ne 10 ]; do
274 evcount
=$
(cat $bt_output_path |
wc -l)
276 viewer_iter
=$
((viewer_iter
+ 1))
277 if [ "${viewer_iter}" -gt $
((LIVEVIEWER_TIMEOUT
* 10)) ] ; then
281 is
"${evcount}" 10 "Live viewer read $evcount events, expect 10"
283 destroy_lttng_session_ok
$SESSION_NAME --no-wait
284 touch $file_sync_before_exit
285 diag
"Waiting for application to exit"
287 pass
"Wait for application to exit"
288 diag
"Wait for viewer to exit"
290 ok $?
"Babeltrace succeeds"
291 pass
"Wait for viewer to exit"
293 rm -f $bt_output_path
294 rm -f $file_sync_before_exit
297 function test_ust_streaming_live_viewer
()
299 local tracing_active
=$1
303 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
304 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
305 local channel_name
="chan"
306 local bt_output_path
=$
(mktemp
-u -t tmp.test_
${FUNCNAME[0]}_bt_output_path.XXXXXX
)
308 diag
"Test ust streaming live clear with viewer"
309 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
310 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live=${DELAYUS}"
311 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
312 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
313 start_lttng_tracing_ok
$SESSION_NAME
315 wait_live_trace_ready net
://localhost
317 # Connect a live viewer
318 _run_babeltrace_cmd
-i lttng-live net
://localhost
/host
/$remote_trace_path --params=session-not-found-action
=end
1> $bt_output_path &
321 wait_live_viewer_connect net
://localhost
324 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
325 stop_lttng_tracing_ok
$SESSION_NAME
327 destroy_lttng_session_ok
$SESSION_NAME --no-wait
328 diag
"Wait for viewer to exit"
330 ok $?
"Babeltrace succeeds"
331 pass
"Wait for viewer to exit"
333 clean_path
$bt_output_path
336 function test_ust_streaming_live_viewer_new_metadata_after_clear
()
338 local tracing_active
=$1
342 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
343 local remote_trace_path
="${HOSTNAME}/${SESSION_NAME}"
344 local channel_name
="chan"
346 local bt_output_path
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_bt_output.XXXXXX")
347 local file_sync_before_exit
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
349 diag
"Test ust streaming live clear with viewer with new metadata after clear"
350 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
351 create_lttng_session_uri
"$SESSION_NAME" net
://localhost
"--live=${DELAYUS}"
352 enable_ust_lttng_channel_ok
"$SESSION_NAME" $channel_name "--buffers-$buffer_type"
354 # The vpid context is added to filter events based on the vpid of the
355 # test application as state dump events are used. Regenerating a
356 # state dump will cause other instrumented application on the system
357 # to trigger a state dump which would throw off checks that rely on an
359 add_context_ust_ok
"$SESSION_NAME" $channel_name "vpid"
360 enable_ust_lttng_event_ok
"$SESSION_NAME" $EVENT_NAME $channel_name
361 start_lttng_tracing_ok
"$SESSION_NAME"
363 wait_live_trace_ready net
://localhost
365 # Connect a live viewer
366 _run_babeltrace_cmd
-i lttng-live
"net://localhost/host/$remote_trace_path" --params=session-not-found-action
=end
1> "$bt_output_path" &
370 wait_live_viewer_connect net
://localhost
372 $TESTAPP_BIN -i 10 --sync-before-exit "$file_sync_before_exit" &
375 diag
"Wait until viewer sees all 10 expected events"
377 while [ $evcount -ne 10 ]; do
378 evcount
=$
(wc -l < "$bt_output_path")
380 viewer_iter
=$
((viewer_iter
+ 1))
381 if [ "${viewer_iter}" -gt $
((LIVEVIEWER_TIMEOUT
* 10)) ] ; then
385 is
"${evcount}" 10 "Live viewer read $evcount events, expect 10"
387 do_clear_session
"$SESSION_NAME" "$tracing_active" "$clear_twice" 0 0
389 # Enable new events which will add their descriptions to the metadata
390 # file. This validates that, following a clear, the relay daemon rotates
391 # the metadata viewer stream to the new metadata file.
392 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_START "\$ctx.vpid == $app_pid" $channel_name
393 enable_ust_lttng_event_filter
"$SESSION_NAME" $EVENT_STATE_DUMP_END "\$ctx.vpid == $app_pid" $channel_name
395 # Forcing a state dump to produce the two events enabled above
396 regenerate_statedump_ok
"$SESSION_NAME"
398 diag
"Wait until viewer sees all 12 expected events"
401 while [ $evcount -ne 12 ]; do
402 evcount
=$
(wc -l < "$bt_output_path")
404 viewer_iter
=$
((viewer_iter
+ 1))
405 if [ "${viewer_iter}" -gt $
((LIVEVIEWER_TIMEOUT
* 10)) ]; then
409 is
"${evcount}" 12 "Live viewer read $evcount events, expect 12"
411 stop_lttng_tracing_ok
"$SESSION_NAME"
413 destroy_lttng_session_ok
"$SESSION_NAME" --no-wait
415 touch "$file_sync_before_exit"
416 diag
"Waiting for application to exit"
418 pass
"Wait for application to exit"
420 diag
"Wait for viewer to exit"
422 ok $?
"Babeltrace succeeds"
423 pass
"Wait for viewer to exit"
425 clean_path
"$bt_output_path"
426 rm -f "$file_sync_before_exit"
429 function test_ust_local
()
431 local tracing_active
=$1
433 local rotate_before
=$3
434 local rotate_after
=$4
436 local channel_name
="chan"
438 diag
"Test ust local"
439 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
440 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
441 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
442 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
443 start_lttng_tracing_ok
$SESSION_NAME
445 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
446 stop_lttng_tracing_ok
$SESSION_NAME
448 if [[ $rotate_before -eq 1 ]]; then
449 validate_trace_count
$EVENT_NAME $TRACE_PATH 10
451 if [[ "$buffer_type" == "uid" ]]; then
452 validate_trace_empty
$TRACE_PATH
455 # The sessiond always created a `ust/ directory
456 # whenever the UST domain is active
457 validate_directory_empty
$TRACE_PATH/ust
/
461 destroy_lttng_session_ok
$SESSION_NAME --no-wait
464 function test_ust_local_no_event
()
466 local tracing_active
=$1
468 #local rotate_before=$3 ignored
469 #local rotate_after=$4 ignored
471 local channel_name
="chan"
473 diag
"Test ust local no event"
474 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
475 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
476 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name "--buffers-$buffer_type"
477 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
478 start_lttng_tracing_ok
$SESSION_NAME
480 do_clear_session
$SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
481 stop_lttng_tracing_ok
$SESSION_NAME
483 validate_directory_empty
"$TRACE_PATH"
485 destroy_lttng_session_ok
$SESSION_NAME --no-wait
488 function test_ust_local_rotate_clear
()
490 local tracing_active
=$1
492 local rotate_before
=$3
493 local rotate_after
=$4
495 local channel_name
="chan"
497 diag
"Test ust local rotate-clear"
498 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
499 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
500 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
501 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
502 start_lttng_tracing_ok
$SESSION_NAME
504 rotate_session_ok
$SESSION_NAME
506 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
508 stop_lttng_tracing_ok
$SESSION_NAME
510 if [[ $rotate_before -eq 1 ]]; then
515 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
517 destroy_lttng_session_ok
$SESSION_NAME --no-wait
520 function test_ust_local_clear_rotate
()
522 local tracing_active
=$1
524 local rotate_before
=$3
525 local rotate_after
=$4
527 local channel_name
="chan"
529 diag
"Test ust local clear-rotate"
530 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
531 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
532 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
533 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
534 start_lttng_tracing_ok
$SESSION_NAME
536 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
538 rotate_session_ok
$SESSION_NAME
540 stop_lttng_tracing_ok
$SESSION_NAME
542 if [[ $rotate_before -eq 1 ]]; then
547 validate_trace_count
$EVENT_NAME $TRACE_PATH $expect_count
549 destroy_lttng_session_ok
$SESSION_NAME --no-wait
552 function do_ust_snapshot
()
554 local session_name
=$1
556 local tracing_active
=$3
559 local channel_name
="snapshot"
561 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
562 enable_ust_lttng_event_ok
$session_name $EVENT_NAME $channel_name
563 start_lttng_tracing_ok
$session_name
565 # Generate 10 events that will sit in the buffers.
568 # Take a first snapshot and validate that the events are present.
569 lttng_snapshot_record
$session_name
570 stop_lttng_tracing_ok
$session_name
571 validate_trace_count
$EVENT_NAME $trace_path 10
573 # Clean the output path
574 clean_path
$trace_path
575 start_lttng_tracing_ok
$session_name
577 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
579 # Make sure the subsequent snapshot is empty and valid.
580 lttng_snapshot_record
$session_name
581 stop_lttng_tracing_ok
$session_name
582 validate_trace_empty
$trace_path
584 # Clean the output path
585 clean_path
$trace_path
586 start_lttng_tracing_ok
$session_name
588 # Make sure that everything still works, generate events and take a
591 lttng_snapshot_record
$session_name
592 stop_lttng_tracing_ok
$session_name
593 validate_trace_count
$EVENT_NAME $trace_path 10
596 function test_ust_streaming_snapshot
()
598 local tracing_active
=$1
603 diag
"Test ust streaming snapshot clear"
604 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
606 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
607 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
608 destroy_lttng_session_ok
$SESSION_NAME --no-wait
611 function test_ust_local_snapshot
()
613 local tracing_active
=$1
618 diag
"Test ust local snapshot clear"
619 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
621 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
622 do_ust_snapshot
$SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
623 destroy_lttng_session_ok
$SESSION_NAME --no-wait
626 # snapshot for per-pid is tested independently of the "buffer type" parameter
627 # because an application needs to be live to appear in a snapshot.
628 function test_ust_local_snapshot_per_pid
()
630 local tracing_active
=$1
634 local channel_name
="channel0"
635 local file_sync_before_last
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
636 local file_sync_before_last_touch
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_last_touch.XXXXXX")
637 local file_sync_before_exit
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
638 local file_sync_before_exit_touch
=$
(mktemp
-u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")
640 diag
"Test ust local snapshot clear per pid"
641 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
643 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
644 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-$buffer_type
645 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
646 start_lttng_tracing_ok
$SESSION_NAME
648 # Generate 10 events that will sit in the buffers.
649 $TESTAPP_BIN -i 10 -w 0 \
650 --sync-before-last-event ${file_sync_before_last} \
651 --sync-before-last-event-touch ${file_sync_before_last_touch} \
652 --sync-before-exit ${file_sync_before_exit} \
653 --sync-before-exit-touch ${file_sync_before_exit_touch} >/dev
/null
2>&1 &
656 # Continue only when there is only the last event remaining.
657 while [ ! -f "${file_sync_before_last_touch}" ]; do
661 # Take a first snapshot and validate that the events are present.
662 lttng_snapshot_record
$SESSION_NAME
663 stop_lttng_tracing_ok
$SESSION_NAME
664 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
666 # Clean the output path
667 clean_path
$TRACE_PATH
668 start_lttng_tracing_ok
$SESSION_NAME
670 do_clear_session
$SESSION_NAME $tracing_active $clear_twice 0 0
672 # Make sure the subsequent snapshot is empty and valid.
673 lttng_snapshot_record
$SESSION_NAME
674 stop_lttng_tracing_ok
$SESSION_NAME
675 validate_trace_empty
$TRACE_PATH
677 # Validate that tracing still works and subsequent snapshots are valid.
678 # Clean the output path.
679 clean_path
$TRACE_PATH
680 start_lttng_tracing_ok
$SESSION_NAME
682 # Continue over the last event.
683 touch ${file_sync_before_last}
685 # Wait for the before exit sync point. This ensure that we went over the
687 while [ ! -f "${file_sync_before_exit_touch}" ]; do
691 # Make sure the snapshot contains the last event.
692 lttng_snapshot_record
$SESSION_NAME
693 stop_lttng_tracing_ok
$SESSION_NAME
694 validate_trace_count
$EVENT_NAME $TRACE_PATH 1
696 # Release the application.
697 touch ${file_sync_before_exit}
699 destroy_lttng_session_ok
$SESSION_NAME --no-wait
701 rm -f ${file_sync_before_last}
702 rm -f ${file_sync_before_last_touch}
703 rm -f ${file_sync_before_exit}
704 rm -f ${file_sync_before_exit_touch}
707 function test_ust_streaming_tracefile_rotation
()
709 local tracing_active
=$1
711 local rotate_before
=$3
712 local rotate_after
=$4
714 local channel_name
="rotchan"
715 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
717 diag
"Test ust streaming clear with tracefile rotation"
718 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
719 create_lttng_session_uri
$SESSION_NAME net
://localhost
720 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
721 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
722 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
723 start_lttng_tracing_ok
$SESSION_NAME
725 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
726 stop_lttng_tracing_ok
$SESSION_NAME
728 if [[ $rotate_before -eq 1 ]]; then
729 validate_trace_count
$EVENT_NAME $local_path 10
731 if [[ "$buffer_type" == "uid" ]]; then
732 validate_trace_empty
$local_path
734 validate_directory_empty
$local_path
738 start_lttng_tracing_ok
$SESSION_NAME
740 stop_lttng_tracing_ok
742 if [[ $rotate_before -eq 1 ]]; then
743 validate_trace_count
$EVENT_NAME $local_path 30
745 validate_trace_count
$EVENT_NAME $local_path 20
748 destroy_lttng_session_ok
$SESSION_NAME --no-wait
751 # With 1 byte per event (as strict minimum), generating 200000 events
752 # guarantees filling up 2 files of 64k in size, which is the maximum
753 # page size known on Linux
754 function test_ust_streaming_tracefile_rotation_overwrite_files
()
756 local tracing_active
=$1
758 local rotate_before
=$3
759 local rotate_after
=$4
761 local channel_name
="rotchan"
762 local local_path
="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
764 diag
"Test ust streaming clear with tracefile rotation, overwrite files"
765 diag
"Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
766 create_lttng_session_uri
$SESSION_NAME net
://localhost
767 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
768 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
769 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
770 start_lttng_tracing_ok
$SESSION_NAME
771 taskset
-c "$(get_any_available_cpu)" $TESTAPP_BIN -i 200000
772 do_clear_session
$SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
773 stop_lttng_tracing_ok
$SESSION_NAME
775 if [[ $rotate_before -eq 1 ]]; then
776 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
778 if [[ "$buffer_type" == "uid" ]]; then
779 validate_trace_empty
$local_path
781 validate_directory_empty
$local_path
785 start_lttng_tracing_ok
$SESSION_NAME
786 taskset
-c "$(get_any_available_cpu)" $TESTAPP_BIN -i 400000
787 stop_lttng_tracing_ok
789 if [[ $rotate_before -eq 1 ]]; then
790 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 600000
792 validate_trace_count_range_incl_min_excl_max
$EVENT_NAME $local_path 1 200000
795 destroy_lttng_session_ok
$SESSION_NAME --no-wait
798 function test_ust_disallow_clear
()
800 diag
"Test ust disallow clear on relay daemon"
801 SESSION_NAME
=$
(randstring
16 0)
803 LTTNG_RELAYD_DISALLOW_CLEAR
=1 start_lttng_relayd
"-o $TRACE_PATH"
807 create_lttng_session_uri
$SESSION_NAME net
://localhost
808 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
809 start_lttng_tracing_ok
$SESSION_NAME
810 lttng_clear_session_fail
$SESSION_NAME
811 destroy_lttng_session_ok
$SESSION_NAME --no-wait
815 clean_path
$TRACE_PATH
818 plan_tests
$NUM_TESTS
820 print_test_banner
"$TEST_DESC"
822 bail_out_if_no_babeltrace
824 streaming_tests
=(test_ust_streaming
825 test_ust_streaming_rotate_clear
826 test_ust_streaming_clear_rotate
827 test_ust_streaming_tracefile_rotation
828 test_ust_streaming_tracefile_rotation_overwrite_files
829 test_ust_streaming_no_event
832 live_tests
=(test_ust_streaming_live
833 test_ust_basic_streaming_live_viewer
834 test_ust_streaming_live_viewer
835 test_ust_streaming_live_viewer_new_metadata_after_clear
838 local_tests
=(test_ust_local
839 test_ust_local_rotate_clear
840 test_ust_local_clear_rotate
841 test_ust_local_no_event
844 snapshot_uid_tests
=(test_ust_streaming_snapshot
845 test_ust_local_snapshot
848 snapshot_pid_tests
=(test_ust_local_snapshot_per_pid
)
850 start_lttng_relayd
"-o $TRACE_PATH"
855 # Clear with tracing active, 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} 1 0 0 0 uid
860 clean_path
$TRACE_PATH
863 # Clear with tracing active, 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} 1 1 0 0 uid
868 clean_path
$TRACE_PATH
871 # Clear with tracing inactive, clear once
872 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
874 SESSION_NAME
=$
(randstring
16 0)
875 ${fct_test} 0 0 0 0 uid
876 clean_path
$TRACE_PATH
879 # Clear with tracing inactive, clear twice
880 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
882 SESSION_NAME
=$
(randstring
16 0)
883 ${fct_test} 0 1 0 0 uid
884 clean_path
$TRACE_PATH
887 # Clear with tracing inactive, rotate-clear once
888 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
890 SESSION_NAME
=$
(randstring
16 0)
891 ${fct_test} 0 0 1 0 uid
892 clean_path
$TRACE_PATH
895 # Clear with tracing inactive, clear once-rotate(fail)
896 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
898 SESSION_NAME
=$
(randstring
16 0)
899 ${fct_test} 0 0 0 1 uid
900 clean_path
$TRACE_PATH
906 # Clear with tracing active, 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} 1 0 0 0 pid
911 clean_path
$TRACE_PATH
914 # Clear with tracing active, 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} 1 1 0 0 pid
919 clean_path
$TRACE_PATH
922 # Clear with tracing inactive, clear once
923 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
925 SESSION_NAME
=$
(randstring
16 0)
926 ${fct_test} 0 0 0 0 pid
927 clean_path
$TRACE_PATH
930 # Clear with tracing inactive, clear twice
931 for fct_test
in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
933 SESSION_NAME
=$
(randstring
16 0)
934 ${fct_test} 0 1 0 0 pid
935 clean_path
$TRACE_PATH
938 # Clear with tracing inactive, rotate-clear once
939 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
941 SESSION_NAME
=$
(randstring
16 0)
942 ${fct_test} 0 0 1 0 pid
943 clean_path
$TRACE_PATH
946 # Clear with tracing inactive, clear once-rotate(fail)
947 for fct_test
in ${streaming_tests[@]} ${local_tests[@]};
949 SESSION_NAME
=$
(randstring
16 0)
950 ${fct_test} 0 0 0 1 pid
951 clean_path
$TRACE_PATH
957 test_ust_disallow_clear