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 function lttng_create_session_uri
()
51 # Create session with default path
52 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME -U net
://localhost
>/dev
/null
2>&1
54 ok $?
"Create session $SESSION_NAME"
57 # MUST set TESTDIR before calling those functions
59 function rotate_ust_test
()
65 start_lttng_tracing_ok
$SESSION_NAME
68 $TESTAPP_BIN 10 $NR_USEC_WAIT /dev
/null
2>&1
69 rotate_session_ok
$SESSION_NAME
71 $TESTAPP_BIN 20 $NR_USEC_WAIT /dev
/null
2>&1
72 stop_lttng_tracing_ok
$SESSION_NAME
74 # Third chunk contains no event (rotate after stop).
75 rotate_session_ok
$SESSION_NAME
77 destroy_lttng_session_ok
$SESSION_NAME
79 # The tests on the chunk folder rely on the date staying the same during
80 # the duration of the test, if this fail we will now why the other checks
81 # fail afterwards. There is a short window of time where an automated test
82 # could fail because of that.
85 ok $?
"Date did not change during the test"
87 validate_test_chunks
"${local_path}" $today $app_path ust
$per_pid
90 function test_ust_streaming_uid
()
92 diag
"Test UST streaming with session rotation per UID"
93 lttng_create_session_uri
94 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
96 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
97 clean_path
$TRACE_PATH
100 function test_ust_local_uid
()
102 diag
"Test UST local with session rotation per UID"
103 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
104 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
106 rotate_ust_test
"${TRACE_PATH}" "ust/uid/*/*/" 0
107 clean_path
$TRACE_PATH
110 function test_ust_streaming_pid
()
112 diag
"Test UST streaming with session rotation per PID"
113 lttng_create_session_uri
114 enable_channel_per_pid
$SESSION_NAME "channel0"
115 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
117 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
118 clean_path
$TRACE_PATH
121 function test_ust_local_pid
()
123 diag
"Test UST local with session rotation per PID"
124 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
125 enable_channel_per_pid
$SESSION_NAME "channel0"
126 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
128 rotate_ust_test
"${TRACE_PATH}" "ust/pid/*/" 1
129 clean_path
$TRACE_PATH
132 function test_ust_local_timer_uid
()
134 diag
"Test ust local with session rotation timer per-uid"
135 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
136 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
137 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
138 start_lttng_tracing_ok
$SESSION_NAME
139 # We just want the app to register, no event generated
140 $TESTAPP_BIN 0 0 /dev
/null
2>&1
142 rotate_timer_test
"${TRACE_PATH}" 0
143 clean_path
$TRACE_PATH
146 function test_ust_streaming_timer_uid
()
148 diag
"Test ust remote with session rotation timer per-uid"
149 lttng_create_session_uri
150 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
151 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
152 start_lttng_tracing_ok
$SESSION_NAME
153 # We just want the app to register, no event generated
154 $TESTAPP_BIN 0 0 /dev
/null
2>&1
156 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
157 clean_path
$TRACE_PATH
160 function test_ust_local_timer_pid
()
162 diag
"Test ust local with session rotation timer per-pid"
163 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
164 enable_channel_per_pid
$SESSION_NAME "channel0"
165 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
166 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
167 start_lttng_tracing_ok
$SESSION_NAME
168 # We just want the app to register, no event generated
169 $TESTAPP_BIN 0 0 /dev
/null
2>&1
171 rotate_timer_test
"${TRACE_PATH}" 1
172 clean_path
$TRACE_PATH
175 function test_ust_streaming_timer_pid
()
177 diag
"Test ust remote with session rotation timer per-pid"
178 lttng_create_session_uri
179 enable_channel_per_pid
$SESSION_NAME "channel0"
180 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
181 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
182 start_lttng_tracing_ok
$SESSION_NAME
183 # We just want the app to register, no event generated
184 $TESTAPP_BIN 0 0 /dev
/null
2>&1
186 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
187 clean_path
$TRACE_PATH
190 function test_incompatible_sessions
()
192 diag
"Check incompatible session types with rotation"
194 diag
"Live session with rotate timer"
195 # Should not be able to enable a rotation timer with a live session
196 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live >/dev
/null
2>&1
197 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
198 destroy_lttng_session_ok
$SESSION_NAME
200 diag
"Snapshot session with rotate timer"
201 # Should not be able to enable a rotation timer with a snapshot session
202 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --snapshot >/dev
/null
2>&1
203 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
204 destroy_lttng_session_ok
$SESSION_NAME
206 diag
"Live session with rotate"
207 # Should not be able to rotate a live session
208 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live >/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
214 diag
"Snapshot session with rotate"
215 # Should not be able to rotate a snapshot session
216 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --snapshot >/dev
/null
2>&1
217 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
218 start_lttng_tracing_ok
$SESSION_NAME
219 rotate_session_fail
$SESSION_NAME
220 destroy_lttng_session_ok
$SESSION_NAME
224 plan_tests
$NUM_TESTS
226 print_test_banner
"$TEST_DESC"
228 start_lttng_relayd
"-o $TRACE_PATH"
231 tests
=( test_ust_streaming_uid test_ust_local_uid \
232 test_ust_streaming_pid test_ust_local_pid \
233 test_ust_local_timer_uid test_ust_streaming_timer_uid \
234 test_ust_local_timer_pid test_ust_streaming_timer_pid \
235 test_incompatible_sessions
)
237 for fct_test
in ${tests[@]};
239 SESSION_NAME
=$
(randstring
16 0)