Commit | Line | Data |
---|---|---|
e7716c6a JD |
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/../../.. | |
e7716c6a JD |
21 | NR_USEC_WAIT=0 |
22 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
23 | TESTAPP_NAME="gen-ust-events" | |
24 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
25 | SESSION_NAME="stream" | |
26 | EVENT_NAME="tp:tptest" | |
e7716c6a JD |
27 | |
28 | TRACE_PATH=$(mktemp -d) | |
29 | ||
3050aa92 | 30 | NUM_TESTS=136 |
e7716c6a JD |
31 | |
32 | source $TESTDIR/utils/utils.sh | |
33 | source $CURDIR/rotate_utils.sh | |
34 | ||
35 | if [ ! -x "$TESTAPP_BIN" ]; then | |
36 | BAIL_OUT "No UST events binary detected." | |
37 | fi | |
38 | ||
d09115ee | 39 | function enable_channel_per_pid () |
e7716c6a JD |
40 | { |
41 | sess_name=$1 | |
42 | channel_name=$2 | |
43 | ||
da0e4484 | 44 | enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid |
e7716c6a JD |
45 | } |
46 | ||
e7716c6a JD |
47 | # MUST set TESTDIR before calling those functions |
48 | ||
49 | function rotate_ust_test () | |
50 | { | |
51 | local_path=$1 | |
52 | app_path=$2 | |
53 | per_pid=$3 | |
54 | ||
55 | start_lttng_tracing_ok $SESSION_NAME | |
56 | today=$(date +%Y%m%d) | |
57 | ||
58 | $TESTAPP_BIN 10 $NR_USEC_WAIT /dev/null 2>&1 | |
59 | rotate_session_ok $SESSION_NAME | |
60 | ||
61 | $TESTAPP_BIN 20 $NR_USEC_WAIT /dev/null 2>&1 | |
62 | stop_lttng_tracing_ok $SESSION_NAME | |
63 | ||
64 | # Third chunk contains no event (rotate after stop). | |
65 | rotate_session_ok $SESSION_NAME | |
66 | ||
67 | destroy_lttng_session_ok $SESSION_NAME | |
68 | ||
e7716c6a JD |
69 | validate_test_chunks "${local_path}" $today $app_path ust $per_pid |
70 | } | |
71 | ||
72 | function test_ust_streaming_uid () | |
73 | { | |
74 | diag "Test UST streaming with session rotation per UID" | |
f0d43d3d | 75 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
76 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME |
77 | ||
3b33e9e7 | 78 | rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/" 0 |
e7716c6a JD |
79 | } |
80 | ||
81 | function test_ust_local_uid () | |
82 | { | |
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 | |
86 | ||
3b33e9e7 | 87 | rotate_ust_test "${TRACE_PATH}/archives" "ust/uid/*/*/" 0 |
e7716c6a JD |
88 | } |
89 | ||
90 | function test_ust_streaming_pid () | |
91 | { | |
92 | diag "Test UST streaming with session rotation per PID" | |
f0d43d3d | 93 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
94 | enable_channel_per_pid $SESSION_NAME "channel0" |
95 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" | |
96 | ||
3b33e9e7 | 97 | rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/pid/*/" 1 |
e7716c6a JD |
98 | } |
99 | ||
100 | function test_ust_local_pid () | |
101 | { | |
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" | |
106 | ||
3b33e9e7 | 107 | rotate_ust_test "${TRACE_PATH}/archives" "ust/pid/*/" 1 |
e7716c6a JD |
108 | } |
109 | ||
110 | function test_ust_local_timer_uid () | |
111 | { | |
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 | |
119 | ||
3b33e9e7 | 120 | rotate_timer_test "${TRACE_PATH}/archives" 0 |
e7716c6a JD |
121 | } |
122 | ||
123 | function test_ust_streaming_timer_uid () | |
124 | { | |
125 | diag "Test ust remote with session rotation timer per-uid" | |
f0d43d3d | 126 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
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 | |
132 | ||
3b33e9e7 | 133 | rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0 |
e7716c6a JD |
134 | } |
135 | ||
136 | function test_ust_local_timer_pid () | |
137 | { | |
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 | |
146 | ||
3b33e9e7 | 147 | rotate_timer_test "${TRACE_PATH}/archives" 1 |
e7716c6a JD |
148 | } |
149 | ||
150 | function test_ust_streaming_timer_pid () | |
151 | { | |
152 | diag "Test ust remote with session rotation timer per-pid" | |
f0d43d3d | 153 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
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 | |
160 | ||
3b33e9e7 | 161 | rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 1 |
e7716c6a JD |
162 | } |
163 | ||
164 | function test_incompatible_sessions () | |
165 | { | |
166 | diag "Check incompatible session types with rotation" | |
167 | ||
168 | diag "Live session with rotate timer" | |
169 | # Should not be able to enable a rotation timer with a live session | |
308a8946 | 170 | create_lttng_session_uri $SESSION_NAME net://localhost --live |
e7716c6a JD |
171 | lttng_enable_rotation_timer_fail $SESSION_NAME 500ms |
172 | destroy_lttng_session_ok $SESSION_NAME | |
173 | ||
174 | diag "Snapshot session with rotate timer" | |
175 | # Should not be able to enable a rotation timer with a snapshot session | |
308a8946 | 176 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot |
e7716c6a JD |
177 | lttng_enable_rotation_timer_fail $SESSION_NAME 500ms |
178 | destroy_lttng_session_ok $SESSION_NAME | |
179 | ||
180 | diag "Live session with rotate" | |
181 | # Should not be able to rotate a live session | |
308a8946 | 182 | create_lttng_session_uri $SESSION_NAME net://localhost --live |
e7716c6a JD |
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 | |
187 | ||
188 | diag "Snapshot session with rotate" | |
189 | # Should not be able to rotate a snapshot session | |
308a8946 | 190 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot |
e7716c6a JD |
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 | |
e7716c6a JD |
195 | } |
196 | ||
197 | plan_tests $NUM_TESTS | |
198 | ||
199 | print_test_banner "$TEST_DESC" | |
200 | ||
201 | start_lttng_relayd "-o $TRACE_PATH" | |
202 | start_lttng_sessiond | |
203 | ||
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 ) | |
209 | ||
210 | for fct_test in ${tests[@]}; | |
211 | do | |
212 | SESSION_NAME=$(randstring 16 0) | |
213 | ${fct_test} | |
8f2d0517 | 214 | clean_path $TRACE_PATH |
e7716c6a JD |
215 | done |
216 | ||
217 | stop_lttng_sessiond | |
218 | stop_lttng_relayd | |
9dc506ae JR |
219 | |
220 | # Remove tmp dir | |
221 | rm -rf $TRACE_PATH |