Tests: use modprobe to test for the presence of lttng-modules
[lttng-tools.git] / tests / regression / tools / rotation / test_ust
1 #!/bin/bash
2 #
3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
4 #
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.
8 #
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
12 # details.
13 #
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"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../../..
21 NR_ITER=1
22 NR_USEC_WAIT=0
23 TESTAPP_PATH="$TESTDIR/utils/testapp"
24 TESTAPP_NAME="gen-ust-events"
25 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26 SESSION_NAME="stream"
27 EVENT_NAME="tp:tptest"
28 PID_RELAYD=0
29
30 TRACE_PATH=$(mktemp -d)
31
32 NUM_TESTS=146
33
34 source $TESTDIR/utils/utils.sh
35 source $CURDIR/rotate_utils.sh
36
37 if [ ! -x "$TESTAPP_BIN" ]; then
38 BAIL_OUT "No UST events binary detected."
39 fi
40
41 function enable_channel_per_pid ()
42 {
43 sess_name=$1
44 channel_name=$2
45
46 enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid
47 }
48
49 function lttng_create_session_uri ()
50 {
51 # Create session with default path
52 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
53
54 ok $? "Create session $SESSION_NAME"
55 }
56
57 # MUST set TESTDIR before calling those functions
58
59 function rotate_ust_test ()
60 {
61 local_path=$1
62 app_path=$2
63 per_pid=$3
64
65 start_lttng_tracing_ok $SESSION_NAME
66 today=$(date +%Y%m%d)
67
68 $TESTAPP_BIN 10 $NR_USEC_WAIT /dev/null 2>&1
69 rotate_session_ok $SESSION_NAME
70
71 $TESTAPP_BIN 20 $NR_USEC_WAIT /dev/null 2>&1
72 stop_lttng_tracing_ok $SESSION_NAME
73
74 # Third chunk contains no event (rotate after stop).
75 rotate_session_ok $SESSION_NAME
76
77 destroy_lttng_session_ok $SESSION_NAME
78
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.
83 now=$(date +%Y%m%d)
84 test $today = $now
85 ok $? "Date did not change during the test"
86
87 validate_test_chunks "${local_path}" $today $app_path ust $per_pid
88 }
89
90 function test_ust_streaming_uid ()
91 {
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
95
96 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
97 clean_path $TRACE_PATH
98 }
99
100 function test_ust_local_uid ()
101 {
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
105
106 rotate_ust_test "${TRACE_PATH}" "ust/uid/*/*/" 0
107 clean_path $TRACE_PATH
108 }
109
110 function test_ust_streaming_pid ()
111 {
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"
116
117 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
118 clean_path $TRACE_PATH
119 }
120
121 function test_ust_local_pid ()
122 {
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"
127
128 rotate_ust_test "${TRACE_PATH}" "ust/pid/*/" 1
129 clean_path $TRACE_PATH
130 }
131
132 function test_ust_local_timer_uid ()
133 {
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
141
142 rotate_timer_test "${TRACE_PATH}" 0
143 clean_path $TRACE_PATH
144 }
145
146 function test_ust_streaming_timer_uid ()
147 {
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
155
156 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
157 clean_path $TRACE_PATH
158 }
159
160 function test_ust_local_timer_pid ()
161 {
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
170
171 rotate_timer_test "${TRACE_PATH}" 1
172 clean_path $TRACE_PATH
173 }
174
175 function test_ust_streaming_timer_pid ()
176 {
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
185
186 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
187 clean_path $TRACE_PATH
188 }
189
190 function test_incompatible_sessions ()
191 {
192 diag "Check incompatible session types with rotation"
193
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
199
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
205
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
213
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
221
222 }
223
224 plan_tests $NUM_TESTS
225
226 print_test_banner "$TEST_DESC"
227
228 start_lttng_relayd "-o $TRACE_PATH"
229 start_lttng_sessiond
230
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 )
236
237 for fct_test in ${tests[@]};
238 do
239 SESSION_NAME=$(randstring 16 0)
240 ${fct_test}
241 done
242
243 stop_lttng_sessiond
244 stop_lttng_relayd
245
246 # Remove tmp dir
247 rm -rf $TRACE_PATH
This page took 0.035689 seconds and 4 git commands to generate.