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 validate_test_chunks
"${local_path}" $today $app_path ust
$per_pid
72 function test_ust_streaming_uid
()
74 diag
"Test UST streaming with session rotation per UID"
75 create_lttng_session_uri
$SESSION_NAME net
://localhost
76 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
78 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/" 0
81 function test_ust_local_uid
()
83 diag
"Test UST local with session rotation per UID"
84 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
85 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
87 rotate_ust_test
"${TRACE_PATH}/archives" "ust/uid/*/*/" 0
90 function test_ust_streaming_pid
()
92 diag
"Test UST streaming with session rotation per PID"
93 create_lttng_session_uri
$SESSION_NAME net
://localhost
94 enable_channel_per_pid
$SESSION_NAME "channel0"
95 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
97 rotate_ust_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/pid/*/" 1
100 function test_ust_local_pid
()
102 diag
"Test UST local with session rotation per PID"
103 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
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}/archives" "ust/pid/*/" 1
110 function test_ust_local_timer_uid
()
112 diag
"Test ust local with session rotation timer per-uid"
113 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
114 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
115 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
116 start_lttng_tracing_ok
$SESSION_NAME
117 # We just want the app to register, no event generated
118 $TESTAPP_BIN 0 0 /dev
/null
2>&1
120 rotate_timer_test
"${TRACE_PATH}/archives" 0
123 function test_ust_streaming_timer_uid
()
125 diag
"Test ust remote with session rotation timer per-uid"
126 create_lttng_session_uri
$SESSION_NAME net
://localhost
127 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
128 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
129 start_lttng_tracing_ok
$SESSION_NAME
130 # We just want the app to register, no event generated
131 $TESTAPP_BIN 0 0 /dev
/null
2>&1
133 rotate_timer_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0
136 function test_ust_local_timer_pid
()
138 diag
"Test ust local with session rotation timer per-pid"
139 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
140 enable_channel_per_pid
$SESSION_NAME "channel0"
141 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
142 lttng_enable_rotation_timer_ok
$SESSION_NAME 500ms
143 start_lttng_tracing_ok
$SESSION_NAME
144 # We just want the app to register, no event generated
145 $TESTAPP_BIN 0 0 /dev
/null
2>&1
147 rotate_timer_test
"${TRACE_PATH}/archives" 1
150 function test_ust_streaming_timer_pid
()
152 diag
"Test ust remote with session rotation timer per-pid"
153 create_lttng_session_uri
$SESSION_NAME net
://localhost
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}/${HOSTNAME}/${SESSION_NAME}*/archives" 1
164 function test_incompatible_sessions
()
166 diag
"Check incompatible session types with rotation"
168 diag
"Live session with rotate timer"
169 # Should not be able to enable a rotation timer with a live session
170 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
171 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
172 destroy_lttng_session_ok
$SESSION_NAME
174 diag
"Snapshot session with rotate timer"
175 # Should not be able to enable a rotation timer with a snapshot session
176 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
177 lttng_enable_rotation_timer_fail
$SESSION_NAME 500ms
178 destroy_lttng_session_ok
$SESSION_NAME
180 diag
"Live session with rotate"
181 # Should not be able to rotate a live session
182 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
183 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
184 start_lttng_tracing_ok
$SESSION_NAME
185 rotate_session_fail
$SESSION_NAME
186 destroy_lttng_session_ok
$SESSION_NAME
188 diag
"Snapshot session with rotate"
189 # Should not be able to rotate a snapshot session
190 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
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
197 plan_tests
$NUM_TESTS
199 print_test_banner
"$TEST_DESC"
201 start_lttng_relayd
"-o $TRACE_PATH"
204 tests
=( test_ust_streaming_uid test_ust_local_uid \
205 test_ust_streaming_pid test_ust_local_pid \
206 test_ust_local_timer_uid test_ust_streaming_timer_uid \
207 test_ust_local_timer_pid test_ust_streaming_timer_pid \
208 test_incompatible_sessions
)
210 #tests=( test_ust_local_timer_uid )
212 for fct_test
in ${tests[@]};
214 SESSION_NAME
=$
(randstring
16 0)
216 clean_path
$TRACE_PATH