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/..
/..
/..
22 TESTAPP_PATH
="$TESTDIR/utils/testapp"
23 TESTAPP_NAME
="gen-ust-events"
24 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26 EVENT_NAME
="tp:tptest"
28 TRACE_PATH
=$
(mktemp
-d)
32 source $TESTDIR/utils
/utils.sh
33 source $CURDIR/rotate_utils.sh
35 if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT
"No UST events binary detected."
39 function enable_channel_per_pid
()
44 enable_ust_lttng_channel_ok
$sess_name $channel_name --buffers-pid
47 # MUST set TESTDIR before calling those functions
49 function rotate_ust_test
()
55 start_lttng_tracing_ok
$SESSION_NAME
58 $TESTAPP_BIN 10 $NR_USEC_WAIT /dev
/null
2>&1
59 rotate_session_ok
$SESSION_NAME
61 $TESTAPP_BIN 20 $NR_USEC_WAIT /dev
/null
2>&1
62 stop_lttng_tracing_ok
$SESSION_NAME
64 # Third chunk contains no event (rotate after stop).
65 rotate_session_ok
$SESSION_NAME
67 destroy_lttng_session_ok
$SESSION_NAME
69 # The tests on the chunk folder rely on the date staying the same during
70 # the duration of the test, if this fail we will now why the other checks
71 # fail afterwards. There is a short window of time where an automated test
72 # could fail because of that.
75 ok $?
"Date did not change during the test"
77 validate_test_chunks
"${local_path}" $today $app_path ust
$per_pid
80 function test_ust_streaming_uid
()
82 diag
"Test UST streaming with session rotation per UID"
83 create_lttng_session_uri
$SESSION_NAME net
://localhost
84 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
86 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
87 clean_path
$TRACE_PATH
90 function test_ust_local_uid
()
92 diag
"Test UST local with session rotation per UID"
93 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
94 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
96 rotate_ust_test
"${TRACE_PATH}" "ust/uid/*/*/" 0
97 clean_path
$TRACE_PATH
100 function test_ust_streaming_pid
()
102 diag
"Test UST streaming with session rotation per PID"
103 create_lttng_session_uri
$SESSION_NAME net
://localhost
104 enable_channel_per_pid
$SESSION_NAME "channel0"
105 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
107 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
108 clean_path
$TRACE_PATH
111 function test_ust_local_pid
()
113 diag
"Test UST local with session rotation per PID"
114 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
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}" "ust/pid/*/" 1
119 clean_path
$TRACE_PATH
122 function test_ust_local_timer_uid
()
124 diag
"Test ust local with session rotation timer per-uid"
125 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
126 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
127 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
128 start_lttng_tracing_ok
$SESSION_NAME
129 # We just want the app to register, no event generated
130 $TESTAPP_BIN 0 0 /dev
/null
2>&1
132 rotate_timer_test
"${TRACE_PATH}" 0
133 clean_path
$TRACE_PATH
136 function test_ust_streaming_timer_uid
()
138 diag
"Test ust remote with session rotation timer per-uid"
139 create_lttng_session_uri
$SESSION_NAME net
://localhost
140 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
141 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
142 start_lttng_tracing_ok
$SESSION_NAME
143 # We just want the app to register, no event generated
144 $TESTAPP_BIN 0 0 /dev
/null
2>&1
146 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
147 clean_path
$TRACE_PATH
150 function test_ust_local_timer_pid
()
152 diag
"Test ust local with session rotation timer per-pid"
153 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
154 enable_channel_per_pid
$SESSION_NAME "channel0"
155 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
156 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
157 start_lttng_tracing_ok
$SESSION_NAME
158 # We just want the app to register, no event generated
159 $TESTAPP_BIN 0 0 /dev
/null
2>&1
161 rotate_timer_test
"${TRACE_PATH}" 1
162 clean_path
$TRACE_PATH
165 function test_ust_streaming_timer_pid
()
167 diag
"Test ust remote with session rotation timer per-pid"
168 create_lttng_session_uri
$SESSION_NAME net
://localhost
169 enable_channel_per_pid
$SESSION_NAME "channel0"
170 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
171 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
172 start_lttng_tracing_ok
$SESSION_NAME
173 # We just want the app to register, no event generated
174 $TESTAPP_BIN 0 0 /dev
/null
2>&1
176 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
177 clean_path
$TRACE_PATH
180 function test_incompatible_sessions
()
182 diag
"Check incompatible session types with rotation"
184 diag
"Live session with rotate timer"
185 # Should not be able to enable a rotation timer with a live session
186 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
187 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
188 destroy_lttng_session_ok
$SESSION_NAME
190 diag
"Snapshot session with rotate timer"
191 # Should not be able to enable a rotation timer with a snapshot session
192 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
193 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
194 destroy_lttng_session_ok
$SESSION_NAME
196 diag
"Live session with rotate"
197 # Should not be able to rotate a live session
198 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
199 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
200 start_lttng_tracing_ok
$SESSION_NAME
201 rotate_session_fail
$SESSION_NAME
202 destroy_lttng_session_ok
$SESSION_NAME
204 diag
"Snapshot session with rotate"
205 # Should not be able to rotate a snapshot session
206 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
207 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
208 start_lttng_tracing_ok
$SESSION_NAME
209 rotate_session_fail
$SESSION_NAME
210 destroy_lttng_session_ok
$SESSION_NAME
214 plan_tests
$NUM_TESTS
216 print_test_banner
"$TEST_DESC"
218 start_lttng_relayd
"-o $TRACE_PATH"
221 tests
=( test_ust_streaming_uid test_ust_local_uid \
222 test_ust_streaming_pid test_ust_local_pid \
223 test_ust_local_timer_uid test_ust_streaming_timer_uid \
224 test_ust_local_timer_pid test_ust_streaming_timer_pid \
225 test_incompatible_sessions
)
227 for fct_test
in ${tests[@]};
229 SESSION_NAME
=$
(randstring
16 0)