3 # Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Rotation - User space tracing"
10 TESTDIR
=$CURDIR/..
/..
/..
12 TESTAPP_PATH
="$TESTDIR/utils/testapp"
13 TESTAPP_NAME
="gen-ust-events"
14 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16 EVENT_NAME
="tp:tptest"
18 TRACE_PATH
=$
(mktemp
-d)
22 source $TESTDIR/utils
/utils.sh
23 source $CURDIR/rotate_utils.sh
25 if [ ! -x "$TESTAPP_BIN" ]; then
26 BAIL_OUT
"No UST events binary detected."
29 function enable_channel_per_pid
()
34 enable_ust_lttng_channel_ok
$sess_name $channel_name --buffers-pid
37 # MUST set TESTDIR before calling those functions
39 function rotate_ust_test
()
45 start_lttng_tracing_ok
$SESSION_NAME
48 $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT > /dev
/null
2>&1
49 rotate_session_ok
$SESSION_NAME
51 $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT > /dev
/null
2>&1
52 stop_lttng_tracing_ok
$SESSION_NAME
54 # Third chunk contains no event (rotate after stop).
55 rotate_session_ok
$SESSION_NAME
57 destroy_lttng_session_ok
$SESSION_NAME
59 validate_test_chunks
"${local_path}" $today $app_path ust
$per_pid
62 function test_ust_streaming_uid
()
64 diag
"Test UST streaming with session rotation per UID"
65 create_lttng_session_uri
$SESSION_NAME net
://localhost
66 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
68 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/" 0
71 function test_ust_local_uid
()
73 diag
"Test UST local with session rotation per UID"
74 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
75 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
77 rotate_ust_test
"${TRACE_PATH}/archives" "ust/uid/*/*/" 0
80 function test_ust_streaming_pid
()
82 diag
"Test UST streaming with session rotation per PID"
83 create_lttng_session_uri
$SESSION_NAME net
://localhost
84 enable_channel_per_pid
$SESSION_NAME "channel0"
85 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
87 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/pid/*/" 1
90 function test_ust_local_pid
()
92 diag
"Test UST local with session rotation per PID"
93 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
94 enable_channel_per_pid
$SESSION_NAME "channel0"
95 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
97 rotate_ust_test
"${TRACE_PATH}/archives" "ust/pid/*/" 1
100 function test_ust_local_timer_uid
()
102 diag
"Test ust local with session rotation timer per-uid"
103 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
104 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
105 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
106 start_lttng_tracing_ok
$SESSION_NAME
107 # We just want the app to register, no event generated
108 $TESTAPP_BIN -i 0 -w 0 > /dev
/null
2>&1
110 rotate_timer_test
"${TRACE_PATH}/archives" 0
113 function test_ust_streaming_timer_uid
()
115 diag
"Test ust remote with session rotation timer per-uid"
116 create_lttng_session_uri
$SESSION_NAME net
://localhost
117 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
118 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
119 start_lttng_tracing_ok
$SESSION_NAME
120 # We just want the app to register, no event generated
121 $TESTAPP_BIN -i 0 -w 0 > /dev
/null
2>&1
123 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0
126 function test_ust_local_timer_pid
()
128 diag
"Test ust local with session rotation timer per-pid"
129 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
130 enable_channel_per_pid
$SESSION_NAME "channel0"
131 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
132 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
133 start_lttng_tracing_ok
$SESSION_NAME
134 # We just want the app to register, no event generated
135 $TESTAPP_BIN -i 0 -w 0 > /dev
/null
2>&1
137 rotate_timer_test
"${TRACE_PATH}/archives" 1
140 function test_ust_streaming_timer_pid
()
142 diag
"Test ust remote with session rotation timer per-pid"
143 create_lttng_session_uri
$SESSION_NAME net
://localhost
144 enable_channel_per_pid
$SESSION_NAME "channel0"
145 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
146 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
147 start_lttng_tracing_ok
$SESSION_NAME
148 # We just want the app to register, no event generated
149 $TESTAPP_BIN -i 0 -w 0 > /dev
/null
2>&1
151 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 1
154 function test_incompatible_sessions
()
156 diag
"Check incompatible session types with rotation"
158 diag
"Live session with rotate timer"
159 # Should not be able to enable a rotation timer with a live session
160 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
161 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
162 destroy_lttng_session_ok
$SESSION_NAME
164 diag
"Snapshot session with rotate timer"
165 # Should not be able to enable a rotation timer with a snapshot session
166 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
167 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
168 destroy_lttng_session_ok
$SESSION_NAME
170 diag
"Live session with rotate"
171 # Should not be able to rotate a live session
172 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
173 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
174 start_lttng_tracing_ok
$SESSION_NAME
175 rotate_session_fail
$SESSION_NAME
176 destroy_lttng_session_ok
$SESSION_NAME
178 diag
"Snapshot session with rotate"
179 # Should not be able to rotate a snapshot session
180 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
181 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
182 start_lttng_tracing_ok
$SESSION_NAME
183 rotate_session_fail
$SESSION_NAME
184 destroy_lttng_session_ok
$SESSION_NAME
187 plan_tests
$NUM_TESTS
189 print_test_banner
"$TEST_DESC"
191 start_lttng_relayd
"-o $TRACE_PATH"
194 tests
=( test_ust_streaming_uid test_ust_local_uid \
195 test_ust_streaming_pid test_ust_local_pid \
196 test_ust_local_timer_uid test_ust_streaming_timer_uid \
197 test_ust_local_timer_pid test_ust_streaming_timer_pid \
198 test_incompatible_sessions
)
200 for fct_test
in ${tests[@]};
202 SESSION_NAME
=$
(randstring
16 0)
204 clean_path
$TRACE_PATH