Commit | Line | Data |
---|---|---|
629d89b9 JR |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2018 Jonathan Rajotte <jonathan.rajotte-julien@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 | ||
18 | TEST_DESC="LTTng relayd filesystem grouping - Kernel tracing" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../../.. | |
22 | EVENT_NAME="lttng_test_filter_event" | |
23 | ||
24 | TRACE_PATH=$(mktemp -d) | |
25 | ||
26 | NUM_TESTS=67 | |
27 | ||
28 | source $TESTDIR/utils/utils.sh | |
29 | ||
30 | function test_kernel_live_static_name () | |
31 | { | |
32 | local session_name=$(randstring 16 0) | |
33 | local channel_name=$(randstring 8 0) | |
34 | ||
35 | diag "Test kernel live with session name" | |
36 | ||
37 | create_lttng_session_uri $session_name net://localhost --live | |
38 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
39 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
40 | start_lttng_tracing_ok $session_name | |
41 | ||
42 | echo -n "10" > /proc/lttng-test-filter-event | |
43 | ||
44 | stop_lttng_tracing_ok $session_name | |
45 | destroy_lttng_session_ok $session_name | |
46 | ||
47 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME* | |
48 | } | |
49 | ||
50 | function test_kernel_live_static_name_custom_output () | |
51 | { | |
52 | local session_name=$(randstring 16 0) | |
53 | local channel_name=$(randstring 8 0) | |
54 | local custom_output="my_live_custom_output" | |
55 | ||
56 | diag "Test kernel live with session name, custom output" | |
57 | ||
58 | create_lttng_session_uri $session_name net://localhost/$custom_output --live | |
59 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
60 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
61 | start_lttng_tracing_ok $session_name | |
62 | ||
63 | echo -n "10" > /proc/lttng-test-filter-event | |
64 | ||
65 | stop_lttng_tracing_ok $session_name | |
66 | destroy_lttng_session_ok $session_name | |
67 | ||
68 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output | |
69 | } | |
70 | ||
71 | function test_kernel_streaming_static_name () | |
72 | { | |
73 | local session_name=$(randstring 16 0) | |
74 | local channel_name=$(randstring 8 0) | |
75 | ||
76 | diag "Test kernel streaming with session name" | |
77 | ||
78 | create_lttng_session_uri $session_name net://localhost | |
79 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
80 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
81 | start_lttng_tracing_ok $session_name | |
82 | ||
83 | echo -n "10" > /proc/lttng-test-filter-event | |
84 | ||
85 | stop_lttng_tracing_ok $session_name | |
86 | destroy_lttng_session_ok $session_name | |
87 | ||
88 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME* | |
89 | } | |
90 | ||
91 | function test_kernel_streaming_static_name_custom_output () | |
92 | { | |
93 | local session_name=$(randstring 16 0) | |
94 | local channel_name=$(randstring 8 0) | |
95 | local custom_output="custom_second_token" | |
96 | ||
97 | diag "Test kernel streaming with session name, custom output" | |
98 | ||
99 | create_lttng_session_uri $session_name net://localhost/$custom_output | |
100 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
101 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
102 | start_lttng_tracing_ok $session_name | |
103 | ||
104 | echo -n "10" > /proc/lttng-test-filter-event | |
105 | ||
106 | stop_lttng_tracing_ok $session_name | |
107 | destroy_lttng_session_ok $session_name | |
108 | ||
109 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output | |
110 | } | |
111 | ||
112 | function test_kernel_streaming_rotate_static_name () | |
113 | { | |
114 | local session_name=$(randstring 16 0) | |
115 | local channel_name=$(randstring 8 0) | |
116 | ||
117 | diag "Test kernel rotate with session name" | |
118 | ||
119 | create_lttng_session_uri $session_name net://localhost | |
120 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
121 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
122 | start_lttng_tracing_ok $session_name | |
123 | ||
124 | echo -n "10" > /proc/lttng-test-filter-event | |
125 | rotate_session_ok $session_name | |
126 | ||
127 | stop_lttng_tracing_ok $session_name | |
128 | destroy_lttng_session_ok $session_name | |
129 | ||
130 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME* | |
131 | } | |
132 | ||
133 | function test_kernel_streaming_rotate_static_name_custom_output () | |
134 | { | |
135 | local session_name=$(randstring 16 0) | |
136 | local channel_name=$(randstring 8 0) | |
137 | local custom_output="rotate_custom_path" | |
138 | ||
139 | diag "Test kernel rotate with session name, custom output" | |
140 | ||
141 | create_lttng_session_uri $session_name net://localhost/$custom_output | |
142 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
143 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
144 | start_lttng_tracing_ok $session_name | |
145 | ||
146 | echo -n "10" > /proc/lttng-test-filter-event | |
147 | rotate_session_ok $session_name | |
148 | ||
149 | stop_lttng_tracing_ok $session_name | |
150 | destroy_lttng_session_ok $session_name | |
151 | ||
152 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output | |
153 | } | |
154 | ||
155 | function test_kernel_streaming_snapshot_static_name () | |
156 | { | |
157 | local session_name=$(randstring 16 0) | |
158 | local channel_name=$(randstring 8 0) | |
159 | ||
160 | diag "Test kernel snapshot streaming with session name using 'create --snapshot'" | |
161 | ||
162 | create_lttng_session_uri $session_name net://localhost --snapshot | |
163 | lttng_enable_kernel_channel_ok $session_name $channel_name | |
164 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
165 | start_lttng_tracing_ok $session_name | |
166 | ||
167 | echo -n "10" > /proc/lttng-test-filter-event | |
168 | lttng_snapshot_record $session_name | |
169 | ||
170 | stop_lttng_tracing_ok $session_name | |
171 | destroy_lttng_session_ok $session_name | |
172 | ||
173 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/snapshot-1* | |
174 | } | |
175 | ||
176 | function test_kernel_streaming_snapshot_add_output_default_name () | |
177 | { | |
178 | local session_name=$(randstring 16 0) | |
179 | local channel_name=$(randstring 8 0) | |
180 | diag "Test kernel snapshot using 'add-output' with default snapshot name" | |
181 | ||
182 | create_lttng_session_no_output $session_name | |
183 | enable_lttng_mmap_overwrite_kernel_channel $session_name $channel_name | |
184 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
185 | start_lttng_tracing_ok $session_name | |
186 | ||
187 | echo -n "10" > /proc/lttng-test-filter-event | |
188 | ||
189 | lttng_snapshot_add_output_ok $session_name "net://localhost" | |
190 | lttng_snapshot_record $session_name | |
191 | ||
192 | stop_lttng_tracing_ok $session_name | |
193 | destroy_lttng_session_ok $session_name | |
194 | ||
195 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/snapshot-1* | |
196 | } | |
197 | ||
198 | function test_kernel_streaming_snapshot_add_output_custom_name () | |
199 | { | |
200 | local session_name=$(randstring 16 0) | |
201 | local channel_name=$(randstring 8 0) | |
202 | local snapshot_name="this_is_my_snapshot" | |
203 | diag "Test kernel snapshot using 'add-output' with custom snapshot name" | |
204 | ||
205 | create_lttng_session_no_output $session_name | |
206 | enable_lttng_mmap_overwrite_kernel_channel $session_name $channel_name | |
207 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
208 | start_lttng_tracing_ok $session_name | |
209 | ||
210 | echo -n "10" > /proc/lttng-test-filter-event | |
211 | ||
212 | lttng_snapshot_add_output_ok $session_name "net://localhost" "-n $snapshot_name" | |
213 | lttng_snapshot_record $session_name | |
214 | ||
215 | stop_lttng_tracing_ok $session_name | |
216 | destroy_lttng_session_ok $session_name | |
217 | ||
218 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$snapshot_name* | |
219 | } | |
220 | ||
221 | function test_kernel_streaming_snapshot_add_output_custom_name_custom_output () | |
222 | { | |
223 | local session_name=$(randstring 16 0) | |
224 | local channel_name=$(randstring 8 0) | |
225 | local snapshot_name="this_is_my_snapshot" | |
226 | local custom_output="this/is/my/custom/path" | |
227 | diag "Test kernel snapshot using 'add-output' with custom snapshot name and custom output" | |
228 | ||
229 | create_lttng_session_no_output $session_name | |
230 | enable_lttng_mmap_overwrite_kernel_channel $session_name $channel_name | |
231 | enable_kernel_lttng_event_ok $session_name $EVENT_NAME $channel_name | |
232 | start_lttng_tracing_ok $session_name | |
233 | ||
234 | echo -n "10" > /proc/lttng-test-filter-event | |
235 | ||
236 | lttng_snapshot_add_output_ok $session_name "net://localhost/$custom_output" "-n $snapshot_name" | |
237 | lttng_snapshot_record $session_name | |
238 | ||
239 | stop_lttng_tracing_ok $session_name | |
240 | destroy_lttng_session_ok $session_name | |
241 | ||
242 | validate_trace $EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output/$snapshot_name* | |
243 | } | |
244 | ||
245 | plan_tests $NUM_TESTS | |
246 | ||
247 | print_test_banner "$TEST_DESC" | |
248 | ||
249 | if [ "$(id -u)" == "0" ]; then | |
250 | isroot=1 | |
251 | else | |
252 | isroot=0 | |
253 | fi | |
254 | ||
255 | skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || | |
256 | { | |
257 | validate_lttng_modules_present | |
258 | ||
259 | start_lttng_relayd "-o $TRACE_PATH --group-output-by-session" | |
260 | start_lttng_sessiond | |
261 | modprobe lttng-test | |
262 | ||
263 | tests=( | |
264 | test_kernel_live_static_name | |
265 | test_kernel_live_static_name_custom_output | |
266 | test_kernel_streaming_static_name | |
267 | test_kernel_streaming_static_name_custom_output | |
268 | # Rotation does not exists on stable 2.9 | |
269 | # test_kernel_streaming_rotate_static_name | |
270 | # test_kernel_streaming_rotate_static_name_custom_output | |
271 | test_kernel_streaming_snapshot_static_name | |
272 | test_kernel_streaming_snapshot_add_output_default_name | |
273 | test_kernel_streaming_snapshot_add_output_custom_name | |
274 | test_kernel_streaming_snapshot_add_output_custom_name_custom_output | |
275 | ) | |
276 | for fct_test in ${tests[@]}; | |
277 | do | |
278 | ${fct_test} | |
279 | done | |
280 | ||
281 | rm -rf $TRACE_PATH | |
282 | ||
283 | rmmod lttng-test | |
284 | stop_lttng_sessiond | |
285 | stop_lttng_relayd | |
286 | } |