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 enable_ust_lttng_channel_ok
$sess_name $channel_name --buffers-pid
49 # MUST set TESTDIR before calling those functions
51 function rotate_ust_test
()
57 start_lttng_tracing_ok
$SESSION_NAME
60 $TESTAPP_BIN 10 $NR_USEC_WAIT /dev
/null
2>&1
61 rotate_session_ok
$SESSION_NAME
63 $TESTAPP_BIN 20 $NR_USEC_WAIT /dev
/null
2>&1
64 stop_lttng_tracing_ok
$SESSION_NAME
66 # Third chunk contains no event (rotate after stop).
67 rotate_session_ok
$SESSION_NAME
69 destroy_lttng_session_ok
$SESSION_NAME
71 # The tests on the chunk folder rely on the date staying the same during
72 # the duration of the test, if this fail we will now why the other checks
73 # fail afterwards. There is a short window of time where an automated test
74 # could fail because of that.
77 ok $?
"Date did not change during the test"
79 validate_test_chunks
"${local_path}" $today $app_path ust
$per_pid
82 function test_ust_streaming_uid
()
84 diag
"Test UST streaming with session rotation per UID"
85 create_lttng_session_uri
$SESSION_NAME net
://localhost
86 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
88 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
89 clean_path
$TRACE_PATH
92 function test_ust_local_uid
()
94 diag
"Test UST local with session rotation per UID"
95 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
96 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
98 rotate_ust_test
"${TRACE_PATH}" "ust/uid/*/*/" 0
99 clean_path
$TRACE_PATH
102 function test_ust_streaming_pid
()
104 diag
"Test UST streaming with session rotation per PID"
105 create_lttng_session_uri
$SESSION_NAME net
://localhost
106 enable_channel_per_pid
$SESSION_NAME "channel0"
107 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
109 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
110 clean_path
$TRACE_PATH
113 function test_ust_local_pid
()
115 diag
"Test UST local with session rotation per PID"
116 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
117 enable_channel_per_pid
$SESSION_NAME "channel0"
118 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
120 rotate_ust_test
"${TRACE_PATH}" "ust/pid/*/" 1
121 clean_path
$TRACE_PATH
124 function test_ust_local_timer_uid
()
126 diag
"Test ust local with session rotation timer per-uid"
127 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
128 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
129 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
130 start_lttng_tracing_ok
$SESSION_NAME
131 # We just want the app to register, no event generated
132 $TESTAPP_BIN 0 0 /dev
/null
2>&1
134 rotate_timer_test
"${TRACE_PATH}" 0
135 clean_path
$TRACE_PATH
138 function test_ust_streaming_timer_uid
()
140 diag
"Test ust remote with session rotation timer per-uid"
141 create_lttng_session_uri
$SESSION_NAME net
://localhost
142 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
143 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
144 start_lttng_tracing_ok
$SESSION_NAME
145 # We just want the app to register, no event generated
146 $TESTAPP_BIN 0 0 /dev
/null
2>&1
148 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
149 clean_path
$TRACE_PATH
152 function test_ust_local_timer_pid
()
154 diag
"Test ust local with session rotation timer per-pid"
155 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
156 enable_channel_per_pid
$SESSION_NAME "channel0"
157 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
158 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
159 start_lttng_tracing_ok
$SESSION_NAME
160 # We just want the app to register, no event generated
161 $TESTAPP_BIN 0 0 /dev
/null
2>&1
163 rotate_timer_test
"${TRACE_PATH}" 1
164 clean_path
$TRACE_PATH
167 function test_ust_streaming_timer_pid
()
169 diag
"Test ust remote with session rotation timer per-pid"
170 create_lttng_session_uri
$SESSION_NAME net
://localhost
171 enable_channel_per_pid
$SESSION_NAME "channel0"
172 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
173 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
174 start_lttng_tracing_ok
$SESSION_NAME
175 # We just want the app to register, no event generated
176 $TESTAPP_BIN 0 0 /dev
/null
2>&1
178 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
179 clean_path
$TRACE_PATH
182 function test_incompatible_sessions
()
184 diag
"Check incompatible session types with rotation"
186 diag
"Live session with rotate timer"
187 # Should not be able to enable a rotation timer with a live session
188 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live >/dev
/null
2>&1
189 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
190 destroy_lttng_session_ok
$SESSION_NAME
192 diag
"Snapshot session with rotate timer"
193 # Should not be able to enable a rotation timer with a snapshot session
194 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --snapshot >/dev
/null
2>&1
195 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
196 destroy_lttng_session_ok
$SESSION_NAME
198 diag
"Live session with rotate"
199 # Should not be able to rotate a live session
200 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live >/dev
/null
2>&1
201 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
202 start_lttng_tracing_ok
$SESSION_NAME
203 rotate_session_fail
$SESSION_NAME
204 destroy_lttng_session_ok
$SESSION_NAME
206 diag
"Snapshot session with rotate"
207 # Should not be able to rotate a snapshot session
208 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --snapshot >/dev
/null
2>&1
209 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
210 start_lttng_tracing_ok
$SESSION_NAME
211 rotate_session_fail
$SESSION_NAME
212 destroy_lttng_session_ok
$SESSION_NAME
216 plan_tests
$NUM_TESTS
218 print_test_banner
"$TEST_DESC"
220 start_lttng_relayd
"-o $TRACE_PATH"
223 tests
=( test_ust_streaming_uid test_ust_local_uid \
224 test_ust_streaming_pid test_ust_local_pid \
225 test_ust_local_timer_uid test_ust_streaming_timer_uid \
226 test_ust_local_timer_pid test_ust_streaming_timer_pid \
227 test_incompatible_sessions
)
229 for fct_test
in ${tests[@]};
231 SESSION_NAME
=$
(randstring
16 0)