3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 TEST_DESC
="Rotation - User space tracing"
20 TESTDIR
=$CURDIR/..
/..
/..
23 TESTAPP_PATH
="$TESTDIR/utils/testapp"
24 TESTAPP_NAME
="gen-ust-events"
25 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27 EVENT_NAME
="tp:tptest"
30 TRACE_PATH
=$
(mktemp
-d)
34 source $TESTDIR/utils
/utils.sh
35 source $CURDIR/rotate_utils.sh
37 if [ ! -x "$TESTAPP_BIN" ]; then
38 BAIL_OUT
"No UST events binary detected."
41 function enable_channel_per_pid
()
46 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name >/dev
/null
2>&1
47 ok $?
"Enable channel $channel_name per PID for session $sess_name"
50 function lttng_create_session_uri
52 # Create session with default path
53 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME -U net
://localhost
>/dev
/null
2>&1
55 ok $?
"Create session $SESSION_NAME"
58 # MUST set TESTDIR before calling those functions
60 function rotate_ust_test
()
66 start_lttng_tracing_ok
$SESSION_NAME
69 $TESTAPP_BIN 10 $NR_USEC_WAIT /dev
/null
2>&1
70 rotate_session_ok
$SESSION_NAME
72 $TESTAPP_BIN 20 $NR_USEC_WAIT /dev
/null
2>&1
73 stop_lttng_tracing_ok
$SESSION_NAME
75 # Third chunk contains no event (rotate after stop).
76 rotate_session_ok
$SESSION_NAME
78 destroy_lttng_session_ok
$SESSION_NAME
80 # The tests on the chunk folder rely on the date staying the same during
81 # the duration of the test, if this fail we will now why the other checks
82 # fail afterwards. There is a short window of time where an automated test
83 # could fail because of that.
86 ok $?
"Date did not change during the test"
88 validate_test_chunks
"${local_path}" $today $app_path ust
$per_pid
91 function test_ust_streaming_uid
()
93 diag
"Test UST streaming with session rotation per UID"
94 lttng_create_session_uri
95 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
97 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
98 clean_path
$TRACE_PATH
101 function test_ust_local_uid
()
103 diag
"Test UST local with session rotation per UID"
104 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
105 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
107 rotate_ust_test
"${TRACE_PATH}" "ust/uid/*/*/" 0
108 clean_path
$TRACE_PATH
111 function test_ust_streaming_pid
()
113 diag
"Test UST streaming with session rotation per PID"
114 lttng_create_session_uri
115 enable_channel_per_pid
$SESSION_NAME "channel0"
116 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
118 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
119 clean_path
$TRACE_PATH
122 function test_ust_local_pid
()
124 diag
"Test UST local with session rotation per PID"
125 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
126 enable_channel_per_pid
$SESSION_NAME "channel0"
127 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
129 rotate_ust_test
"${TRACE_PATH}" "ust/pid/*/" 1
130 clean_path
$TRACE_PATH
133 function test_ust_local_timer_uid
()
135 diag
"Test ust local with session rotation timer per-uid"
136 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
137 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
138 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
139 start_lttng_tracing_ok
$SESSION_NAME
140 # We just want the app to register, no event generated
141 $TESTAPP_BIN 0 0 /dev
/null
2>&1
143 rotate_timer_test
"${TRACE_PATH}" 0
144 clean_path
$TRACE_PATH
147 function test_ust_streaming_timer_uid
()
149 diag
"Test ust remote with session rotation timer per-uid"
150 lttng_create_session_uri
151 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
152 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
153 start_lttng_tracing_ok
$SESSION_NAME
154 # We just want the app to register, no event generated
155 $TESTAPP_BIN 0 0 /dev
/null
2>&1
157 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
158 clean_path
$TRACE_PATH
161 function test_ust_local_timer_pid
()
163 diag
"Test ust local with session rotation timer per-pid"
164 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
165 enable_channel_per_pid
$SESSION_NAME "channel0"
166 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
167 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
168 start_lttng_tracing_ok
$SESSION_NAME
169 # We just want the app to register, no event generated
170 $TESTAPP_BIN 0 0 /dev
/null
2>&1
172 rotate_timer_test
"${TRACE_PATH}" 1
173 clean_path
$TRACE_PATH
176 function test_ust_streaming_timer_pid
()
178 diag
"Test ust remote with session rotation timer per-pid"
179 lttng_create_session_uri
180 enable_channel_per_pid
$SESSION_NAME "channel0"
181 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
182 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
183 start_lttng_tracing_ok
$SESSION_NAME
184 # We just want the app to register, no event generated
185 $TESTAPP_BIN 0 0 /dev
/null
2>&1
187 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
188 clean_path
$TRACE_PATH
191 function test_incompatible_sessions
()
193 diag
"Check incompatible session types with rotation"
195 diag
"Live session with rotate timer"
196 # Should not be able to enable a rotation timer with a live session
197 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live >/dev
/null
2>&1
198 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
199 destroy_lttng_session_ok
$SESSION_NAME
201 diag
"Snapshot session with rotate timer"
202 # Should not be able to enable a rotation timer with a snapshot session
203 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --snapshot >/dev
/null
2>&1
204 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
205 destroy_lttng_session_ok
$SESSION_NAME
207 diag
"Live session with rotate"
208 # Should not be able to rotate a live session
209 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live >/dev
/null
2>&1
210 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
211 start_lttng_tracing_ok
$SESSION_NAME
212 rotate_session_fail
$SESSION_NAME
213 destroy_lttng_session_ok
$SESSION_NAME
215 diag
"Snapshot session with rotate"
216 # Should not be able to rotate a snapshot session
217 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --snapshot >/dev
/null
2>&1
218 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
219 start_lttng_tracing_ok
$SESSION_NAME
220 rotate_session_fail
$SESSION_NAME
221 destroy_lttng_session_ok
$SESSION_NAME
225 plan_tests
$NUM_TESTS
227 print_test_banner
"$TEST_DESC"
229 start_lttng_relayd
"-o $TRACE_PATH"
232 tests
=( test_ust_streaming_uid test_ust_local_uid \
233 test_ust_streaming_pid test_ust_local_pid \
234 test_ust_local_timer_uid test_ust_streaming_timer_uid \
235 test_ust_local_timer_pid test_ust_streaming_timer_pid \
236 test_incompatible_sessions
)
238 for fct_test
in ${tests[@]};
240 SESSION_NAME
=$
(randstring
16 0)