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
89 function test_ust_local_uid
()
91 diag
"Test UST local with session rotation per UID"
92 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
93 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
95 rotate_ust_test
"${TRACE_PATH}" "ust/uid/*/*/" 0
98 function test_ust_streaming_pid
()
100 diag
"Test UST streaming with session rotation per PID"
101 create_lttng_session_uri
$SESSION_NAME net
://localhost
102 enable_channel_per_pid
$SESSION_NAME "channel0"
103 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
105 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
108 function test_ust_local_pid
()
110 diag
"Test UST local with session rotation per PID"
111 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
112 enable_channel_per_pid
$SESSION_NAME "channel0"
113 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
115 rotate_ust_test
"${TRACE_PATH}" "ust/pid/*/" 1
118 function test_ust_local_timer_uid
()
120 diag
"Test ust local with session rotation timer per-uid"
121 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
122 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
123 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
124 start_lttng_tracing_ok
$SESSION_NAME
125 # We just want the app to register, no event generated
126 $TESTAPP_BIN 0 0 /dev
/null
2>&1
128 rotate_timer_test
"${TRACE_PATH}" 0
131 function test_ust_streaming_timer_uid
()
133 diag
"Test ust remote with session rotation timer per-uid"
134 create_lttng_session_uri
$SESSION_NAME net
://localhost
135 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
136 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
137 start_lttng_tracing_ok
$SESSION_NAME
138 # We just want the app to register, no event generated
139 $TESTAPP_BIN 0 0 /dev
/null
2>&1
141 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
144 function test_ust_local_timer_pid
()
146 diag
"Test ust local with session rotation timer per-pid"
147 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
148 enable_channel_per_pid
$SESSION_NAME "channel0"
149 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
150 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
151 start_lttng_tracing_ok
$SESSION_NAME
152 # We just want the app to register, no event generated
153 $TESTAPP_BIN 0 0 /dev
/null
2>&1
155 rotate_timer_test
"${TRACE_PATH}" 1
158 function test_ust_streaming_timer_pid
()
160 diag
"Test ust remote with session rotation timer per-pid"
161 create_lttng_session_uri
$SESSION_NAME net
://localhost
162 enable_channel_per_pid
$SESSION_NAME "channel0"
163 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
164 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
165 start_lttng_tracing_ok
$SESSION_NAME
166 # We just want the app to register, no event generated
167 $TESTAPP_BIN 0 0 /dev
/null
2>&1
169 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
172 function test_incompatible_sessions
()
174 diag
"Check incompatible session types with rotation"
176 diag
"Live session with rotate timer"
177 # Should not be able to enable a rotation timer with a live session
178 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
179 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
180 destroy_lttng_session_ok
$SESSION_NAME
182 diag
"Snapshot session with rotate timer"
183 # Should not be able to enable a rotation timer with a snapshot session
184 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
185 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
186 destroy_lttng_session_ok
$SESSION_NAME
188 diag
"Live session with rotate"
189 # Should not be able to rotate a live session
190 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
191 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
192 start_lttng_tracing_ok
$SESSION_NAME
193 rotate_session_fail
$SESSION_NAME
194 destroy_lttng_session_ok
$SESSION_NAME
196 diag
"Snapshot session with rotate"
197 # Should not be able to rotate a snapshot session
198 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
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
205 plan_tests
$NUM_TESTS
207 print_test_banner
"$TEST_DESC"
209 start_lttng_relayd
"-o $TRACE_PATH"
212 tests
=( test_ust_streaming_uid test_ust_local_uid \
213 test_ust_streaming_pid test_ust_local_pid \
214 test_ust_local_timer_uid test_ust_streaming_timer_uid \
215 test_ust_local_timer_pid test_ust_streaming_timer_pid \
216 test_incompatible_sessions
)
218 for fct_test
in ${tests[@]};
220 SESSION_NAME
=$
(randstring
16 0)
222 clean_path
$TRACE_PATH