Commit | Line | Data |
---|---|---|
c28fcefd JR |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2019 Jonathan Rajotte-Julien <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="Clear - Kernel tracing" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../../.. | |
22 | EVENT_NAME="lttng_test_filter_event" | |
23 | ||
24 | PAGE_SIZE=$(getconf PAGE_SIZE) | |
25 | TRACE_PATH=$(mktemp -d) | |
26 | ||
27 | NUM_TESTS=837 | |
28 | ||
29 | source $TESTDIR/utils/utils.sh | |
30 | ||
31 | function signal_cleanup () | |
32 | { | |
33 | stop_lttng_sessiond | |
34 | modprobe -r lttng-test | |
35 | full_cleanup | |
36 | } | |
37 | ||
38 | function clean_path () | |
39 | { | |
40 | local trace_path=$1 | |
41 | set -u | |
42 | rm -rf $trace_path/* | |
43 | set +u | |
44 | } | |
45 | ||
46 | function cond_start_tracing () | |
47 | { | |
48 | local session_name=$1 | |
49 | local tracing_active=$2 | |
50 | ||
51 | if [[ $tracing_active -ne 1 ]]; then | |
52 | start_lttng_tracing_ok $session_name | |
53 | fi | |
54 | } | |
55 | ||
56 | function cond_stop_tracing () | |
57 | { | |
58 | local session_name=$1 | |
59 | local tracing_active=$2 | |
60 | ||
61 | if [[ $tracing_active -ne 1 ]]; then | |
62 | stop_lttng_tracing_ok $session_name | |
63 | fi | |
64 | } | |
65 | ||
66 | function do_clear_session () | |
67 | { | |
68 | local session_name=$1 | |
69 | local tracing_active=$2 | |
70 | local clear_twice=$3 | |
71 | local rotate_before=$4 | |
72 | local rotate_after=$5 | |
73 | ||
74 | cond_stop_tracing $session_name $tracing_active | |
75 | if [[ $rotate_before -eq 1 ]]; then | |
76 | rotate_session_ok $SESSION_NAME | |
77 | fi | |
78 | lttng_clear_session_ok $SESSION_NAME | |
79 | if [[ $clear_twice -eq 1 ]]; then | |
80 | lttng_clear_session_ok $SESSION_NAME | |
81 | fi | |
82 | if [[ $rotate_after -eq 1 ]]; then | |
83 | if [[ $tracing_active -eq 1 ]]; then | |
84 | rotate_session_ok $SESSION_NAME | |
85 | else | |
86 | # Expect failure | |
87 | rotate_session_fail $SESSION_NAME | |
88 | fi | |
89 | fi | |
90 | cond_start_tracing $session_name $tracing_active | |
91 | } | |
92 | ||
93 | function test_kernel_streaming () | |
94 | { | |
95 | local tracing_active=$1 | |
96 | local clear_twice=$2 | |
97 | local rotate_before=$3 | |
98 | local rotate_after=$4 | |
99 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
100 | ||
101 | diag "Test kernel streaming clear" | |
102 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
103 | create_lttng_session_uri $SESSION_NAME net://localhost | |
104 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
105 | start_lttng_tracing_ok $SESSION_NAME | |
106 | # Generate 10 events that will sit in the buffers. | |
107 | echo -n "10" > /proc/lttng-test-filter-event | |
108 | ||
109 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
110 | ||
111 | stop_lttng_tracing_ok $SESSION_NAME | |
112 | ||
113 | if [[ $rotate_before -eq 1 ]]; then | |
114 | validate_trace_count $EVENT_NAME $local_path 10 | |
115 | else | |
116 | validate_trace_empty $local_path | |
117 | fi | |
118 | ||
119 | destroy_lttng_session_ok $SESSION_NAME | |
120 | } | |
121 | ||
122 | function test_kernel_streaming_rotate_clear () | |
123 | { | |
124 | local tracing_active=$1 | |
125 | local clear_twice=$2 | |
126 | local rotate_before=$3 | |
127 | local rotate_after=$4 | |
128 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
129 | ||
130 | diag "Test kernel streaming rotate-clear" | |
131 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
132 | create_lttng_session_uri $SESSION_NAME net://localhost | |
133 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
134 | start_lttng_tracing_ok $SESSION_NAME | |
135 | echo -n "1" > /proc/lttng-test-filter-event | |
136 | rotate_session_ok $SESSION_NAME | |
137 | echo -n "2" > /proc/lttng-test-filter-event | |
138 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
139 | echo -n "3" > /proc/lttng-test-filter-event | |
140 | ||
141 | stop_lttng_tracing_ok $SESSION_NAME | |
142 | ||
143 | if [[ $rotate_before -eq 1 ]]; then | |
144 | local expect_count=6 | |
145 | else | |
146 | local expect_count=4 | |
147 | fi | |
148 | validate_trace_count $EVENT_NAME $local_path $expect_count | |
149 | ||
150 | destroy_lttng_session_ok $SESSION_NAME | |
151 | } | |
152 | ||
153 | function test_kernel_streaming_clear_rotate() | |
154 | { | |
155 | local tracing_active=$1 | |
156 | local clear_twice=$2 | |
157 | local rotate_before=$3 | |
158 | local rotate_after=$4 | |
159 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
160 | ||
161 | diag "Test kernel streaming clear-rotate" | |
162 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
163 | create_lttng_session_uri $SESSION_NAME net://localhost | |
164 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
165 | start_lttng_tracing_ok $SESSION_NAME | |
166 | echo -n "1" > /proc/lttng-test-filter-event | |
167 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
168 | echo -n "2" > /proc/lttng-test-filter-event | |
169 | rotate_session_ok $SESSION_NAME | |
170 | echo -n "3" > /proc/lttng-test-filter-event | |
171 | ||
172 | stop_lttng_tracing_ok $SESSION_NAME | |
173 | ||
174 | if [[ $rotate_before -eq 1 ]]; then | |
175 | local expect_count=6 | |
176 | else | |
177 | local expect_count=5 | |
178 | fi | |
179 | validate_trace_count $EVENT_NAME $local_path $expect_count | |
180 | ||
181 | destroy_lttng_session_ok $SESSION_NAME | |
182 | } | |
183 | ||
184 | function test_kernel_streaming_live () | |
185 | { | |
186 | local tracing_active=$1 | |
187 | local clear_twice=$2 | |
188 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
189 | ||
190 | diag "Test kernel streaming live clear" | |
191 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice" | |
192 | create_lttng_session_uri $SESSION_NAME net://localhost "--live" | |
193 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
194 | start_lttng_tracing_ok $SESSION_NAME | |
195 | # Generate 10 events that will sit in the buffers. | |
196 | echo -n "10" > /proc/lttng-test-filter-event | |
197 | do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0 | |
198 | stop_lttng_tracing_ok $SESSION_NAME | |
199 | ||
200 | validate_trace_empty $local_path | |
201 | ||
202 | destroy_lttng_session_ok $SESSION_NAME | |
203 | } | |
204 | ||
205 | #no clear | |
206 | function test_kernel_basic_streaming_live_viewer () | |
207 | { | |
208 | local tracing_active=$1 | |
209 | local clear_twice=$2 | |
210 | # 3, 4 unused | |
211 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
212 | local remote_trace_path="${HOSTNAME}/${SESSION_NAME}" | |
213 | local channel_name="chan" | |
214 | local bt_output_path=$(mktemp -u) | |
215 | local file_sync_before_exit=$(mktemp -u) | |
216 | ||
217 | diag "Test kernel basic streaming live with viewer" | |
218 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice" | |
219 | create_lttng_session_uri $SESSION_NAME net://localhost "--live" | |
220 | enable_kernel_lttng_channel_ok $SESSION_NAME $channel_name | |
221 | enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name | |
222 | start_lttng_tracing_ok $SESSION_NAME | |
223 | ||
224 | wait_live_trace_ready net://localhost | |
225 | ||
226 | # Connect a live viewer | |
227 | $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path & | |
228 | local viewer_pid=$! | |
229 | ||
230 | wait_live_viewer_connect net://localhost | |
231 | ||
232 | echo -n "10" > /proc/lttng-test-filter-event | |
233 | ||
234 | diag "Wait until viewer sees all 10 expected events" | |
235 | local evcount=0 | |
236 | while [ $evcount -ne 10 ]; do | |
237 | evcount=$(cat $bt_output_path | wc -l) | |
238 | sleep 0.5 | |
239 | done | |
240 | pass "Live viewer read $evcount events, expect 10" | |
241 | ||
242 | destroy_lttng_session_ok $SESSION_NAME | |
243 | touch $file_sync_before_exit | |
244 | diag "Wait for viewer to exit" | |
245 | wait $viewer_pid | |
246 | ok $? "Babeltrace succeeds" | |
247 | pass "Wait for viewer to exit" | |
248 | ||
249 | rm -f $bt_output_path | |
250 | rm -f $file_sync_before_exit | |
251 | } | |
252 | ||
253 | function test_kernel_streaming_live_viewer () | |
254 | { | |
255 | local tracing_active=$1 | |
256 | local clear_twice=$2 | |
257 | # 3, 4 unused | |
258 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
259 | local remote_trace_path="${HOSTNAME}/${SESSION_NAME}" | |
260 | local channel_name="chan" | |
261 | local bt_output_path=$(mktemp -d)/bt-output.txt | |
262 | ||
263 | diag "Test kernel streaming live clear with viewer" | |
264 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice" | |
265 | create_lttng_session_uri $SESSION_NAME net://localhost "--live" | |
266 | enable_kernel_lttng_channel_ok $SESSION_NAME $channel_name | |
267 | enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name | |
268 | start_lttng_tracing_ok $SESSION_NAME | |
269 | ||
270 | wait_live_trace_ready net://localhost | |
271 | ||
272 | # Connect a live viewer | |
273 | $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path & | |
274 | local viewer_pid=$! | |
275 | ||
276 | wait_live_viewer_connect net://localhost | |
277 | ||
278 | echo -n "10" > /proc/lttng-test-filter-event | |
279 | do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0 | |
280 | stop_lttng_tracing_ok $SESSION_NAME | |
281 | ||
282 | destroy_lttng_session_ok $SESSION_NAME | |
283 | diag "Wait for viewer to exit" | |
284 | wait $viewer_pid | |
285 | ok $? "Babeltrace succeeds" | |
286 | pass "Wait for viewer to exit" | |
287 | ||
288 | clean_path $bt_output_path | |
289 | } | |
290 | ||
291 | function test_kernel_local () | |
292 | { | |
293 | local tracing_active=$1 | |
294 | local clear_twice=$2 | |
295 | local rotate_before=$3 | |
296 | local rotate_after=$4 | |
297 | ||
298 | diag "Test kernel local" | |
299 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
300 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
301 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
302 | start_lttng_tracing_ok $SESSION_NAME | |
303 | # Generate 10 events that will sit in the buffers. | |
304 | echo -n "10" > /proc/lttng-test-filter-event | |
305 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
306 | stop_lttng_tracing_ok $SESSION_NAME | |
307 | ||
308 | if [[ $rotate_before -eq 1 ]]; then | |
309 | validate_trace_count $EVENT_NAME $TRACE_PATH 10 | |
310 | else | |
311 | validate_trace_empty $TRACE_PATH | |
312 | fi | |
313 | ||
314 | destroy_lttng_session_ok $SESSION_NAME | |
315 | } | |
316 | ||
317 | function test_kernel_local_rotate_clear () | |
318 | { | |
319 | local tracing_active=$1 | |
320 | local clear_twice=$2 | |
321 | local rotate_before=$3 | |
322 | local rotate_after=$4 | |
323 | ||
324 | diag "Test kernel local rotate-clear" | |
325 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
326 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
327 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
328 | start_lttng_tracing_ok $SESSION_NAME | |
329 | echo -n "1" > /proc/lttng-test-filter-event | |
330 | rotate_session_ok $SESSION_NAME | |
331 | echo -n "2" > /proc/lttng-test-filter-event | |
332 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
333 | echo -n "3" > /proc/lttng-test-filter-event | |
334 | stop_lttng_tracing_ok $SESSION_NAME | |
335 | ||
336 | if [[ $rotate_before -eq 1 ]]; then | |
337 | local expect_count=6 | |
338 | else | |
339 | local expect_count=4 | |
340 | fi | |
341 | validate_trace_count $EVENT_NAME $TRACE_PATH $expect_count | |
342 | ||
343 | destroy_lttng_session_ok $SESSION_NAME | |
344 | } | |
345 | ||
346 | function test_kernel_local_clear_rotate() | |
347 | { | |
348 | local tracing_active=$1 | |
349 | local clear_twice=$2 | |
350 | local rotate_before=$3 | |
351 | local rotate_after=$4 | |
352 | ||
353 | diag "Test kernel local clear-rotate" | |
354 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
355 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
356 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
357 | start_lttng_tracing_ok $SESSION_NAME | |
358 | echo -n "1" > /proc/lttng-test-filter-event | |
359 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
360 | echo -n "2" > /proc/lttng-test-filter-event | |
361 | rotate_session_ok $SESSION_NAME | |
362 | echo -n "3" > /proc/lttng-test-filter-event | |
363 | stop_lttng_tracing_ok $SESSION_NAME | |
364 | ||
365 | if [[ $rotate_before -eq 1 ]]; then | |
366 | local expect_count=6 | |
367 | else | |
368 | local expect_count=5 | |
369 | fi | |
370 | validate_trace_count $EVENT_NAME $TRACE_PATH $expect_count | |
371 | ||
372 | destroy_lttng_session_ok $SESSION_NAME | |
373 | } | |
374 | ||
375 | function do_kernel_snapshot () | |
376 | { | |
377 | local session_name=$1 | |
378 | local trace_path=$2 | |
379 | local tracing_active=$3 | |
380 | local clear_twice=$4 | |
381 | local rotate_before=$5 | |
382 | local rotate_after=$6 | |
383 | ||
384 | lttng_enable_kernel_event $session_name $EVENT_NAME | |
385 | start_lttng_tracing_ok $session_name | |
386 | ||
387 | # Generate 10 events that will sit in the buffers. | |
388 | echo -n "10" > /proc/lttng-test-filter-event | |
389 | ||
390 | # Take a first snapshot and validate that the events are present. | |
391 | lttng_snapshot_record $session_name | |
392 | stop_lttng_tracing_ok $session_name | |
393 | validate_trace_count $EVENT_NAME $trace_path 10 | |
394 | ||
395 | # Clean the output path | |
396 | clean_path $trace_path | |
397 | start_lttng_tracing_ok $session_name | |
398 | ||
399 | do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0 | |
400 | ||
401 | # Make sure the subsequent snapshot is empty and valid. | |
402 | lttng_snapshot_record $session_name | |
403 | stop_lttng_tracing_ok $session_name | |
404 | validate_trace_empty $trace_path | |
405 | ||
406 | # Clean the output path | |
407 | clean_path $trace_path | |
408 | start_lttng_tracing_ok $session_name | |
409 | ||
410 | # Make sure that everything still works, generate events and take a | |
411 | # snapshot. | |
412 | echo -n "10" > /proc/lttng-test-filter-event | |
413 | lttng_snapshot_record $session_name | |
414 | stop_lttng_tracing_ok $session_name | |
415 | validate_trace_count $EVENT_NAME $trace_path 10 | |
416 | } | |
417 | ||
418 | function test_kernel_streaming_snapshot () | |
419 | { | |
420 | local tracing_active=$1 | |
421 | local clear_twice=$2 | |
422 | ||
423 | diag "Test kernel streaming snapshot clear" | |
424 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice" | |
425 | ||
426 | create_lttng_session_uri $SESSION_NAME net://localhost "--snapshot" | |
427 | do_kernel_snapshot $SESSION_NAME $TRACE_PATH $tracing_active $clear_twice | |
428 | destroy_lttng_session_ok $SESSION_NAME | |
429 | } | |
430 | ||
431 | function test_kernel_local_snapshot () | |
432 | { | |
433 | local tracing_active=$1 | |
434 | local clear_twice=$2 | |
435 | ||
436 | diag "Test kernel local snapshot clear" | |
437 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice" | |
438 | ||
439 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH "--snapshot" | |
440 | do_kernel_snapshot $SESSION_NAME $TRACE_PATH $tracing_active $clear_twice | |
441 | destroy_lttng_session_ok $SESSION_NAME | |
442 | } | |
443 | ||
444 | function test_kernel_streaming_tracefile_rotation () | |
445 | { | |
446 | local tracing_active=$1 | |
447 | local clear_twice=$2 | |
448 | local rotate_before=$3 | |
449 | local rotate_after=$4 | |
450 | local channel_name="rotchan" | |
451 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
452 | ||
453 | diag "Test kernel streaming clear with tracefile rotation" | |
454 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
455 | create_lttng_session_uri $SESSION_NAME net://localhost | |
456 | enable_kernel_lttng_channel_ok $SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \ | |
457 | --tracefile-size=$PAGE_SIZE --tracefile-count=2 | |
458 | enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name | |
459 | start_lttng_tracing_ok $SESSION_NAME | |
460 | echo -n "10" > /proc/lttng-test-filter-event | |
461 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
462 | stop_lttng_tracing_ok $SESSION_NAME | |
463 | ||
464 | if [[ $rotate_before -eq 1 ]]; then | |
465 | validate_trace_count $EVENT_NAME $local_path 10 | |
466 | else | |
467 | validate_trace_empty $local_path | |
468 | fi | |
469 | ||
470 | start_lttng_tracing_ok $SESSION_NAME | |
471 | echo -n "20" > /proc/lttng-test-filter-event | |
472 | stop_lttng_tracing_ok | |
473 | ||
474 | if [[ $rotate_before -eq 1 ]]; then | |
475 | validate_trace_count $EVENT_NAME $local_path 30 | |
476 | else | |
477 | validate_trace_count $EVENT_NAME $local_path 20 | |
478 | fi | |
479 | ||
480 | destroy_lttng_session_ok $SESSION_NAME | |
481 | } | |
482 | ||
483 | # With 1 byte per event (as strict minimum), generating 200000 events | |
484 | # guarantees filling up 2 files of 64k in size, which is the maximum | |
485 | # page size known on Linux | |
486 | function test_kernel_streaming_tracefile_rotation_overwrite_files () | |
487 | { | |
488 | local tracing_active=$1 | |
489 | local clear_twice=$2 | |
490 | local rotate_before=$3 | |
491 | local rotate_after=$4 | |
492 | local channel_name="rotchan" | |
493 | local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" | |
494 | ||
495 | diag "Test kernel streaming clear with tracefile rotation, overwrite files" | |
496 | diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after" | |
497 | create_lttng_session_uri $SESSION_NAME net://localhost | |
498 | enable_kernel_lttng_channel_ok $SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \ | |
499 | --tracefile-size=$PAGE_SIZE --tracefile-count=2 | |
500 | enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name | |
501 | start_lttng_tracing_ok $SESSION_NAME | |
502 | taskset -c 0 echo -n "200000" > /proc/lttng-test-filter-event | |
503 | do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after | |
504 | stop_lttng_tracing_ok $SESSION_NAME | |
505 | ||
506 | if [[ $rotate_before -eq 1 ]]; then | |
507 | validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 200000 | |
508 | else | |
509 | validate_trace_empty $local_path | |
510 | fi | |
511 | ||
512 | start_lttng_tracing_ok $SESSION_NAME | |
513 | taskset -c 0 echo -n "400000" > /proc/lttng-test-filter-event | |
514 | stop_lttng_tracing_ok | |
515 | ||
516 | if [[ $rotate_before -eq 1 ]]; then | |
517 | validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 600000 | |
518 | else | |
519 | validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 200000 | |
520 | fi | |
521 | ||
522 | destroy_lttng_session_ok $SESSION_NAME | |
523 | } | |
524 | ||
525 | function test_kernel_disallow_clear () | |
526 | { | |
527 | diag "Test kernel disallow clear on relay daemon" | |
528 | SESSION_NAME=$(randstring 16 0) | |
529 | ||
530 | LTTNG_RELAYD_DISALLOW_CLEAR=1 start_lttng_relayd "-o $TRACE_PATH" | |
531 | ||
532 | start_lttng_sessiond | |
533 | ||
534 | create_lttng_session_uri $SESSION_NAME net://localhost | |
535 | enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME | |
536 | start_lttng_tracing_ok $SESSION_NAME | |
537 | lttng_clear_session_fail $SESSION_NAME | |
538 | destroy_lttng_session_ok $SESSION_NAME | |
539 | ||
540 | stop_lttng_sessiond | |
541 | stop_lttng_relayd | |
542 | clean_path $TRACE_PATH | |
543 | } | |
544 | ||
545 | plan_tests $NUM_TESTS | |
546 | ||
547 | print_test_banner "$TEST_DESC" | |
548 | ||
549 | if [ "$(id -u)" == "0" ]; then | |
550 | isroot=1 | |
551 | else | |
552 | isroot=0 | |
553 | fi | |
554 | ||
555 | streaming_tests=(test_kernel_streaming | |
556 | test_kernel_streaming_rotate_clear | |
557 | test_kernel_streaming_clear_rotate | |
558 | test_kernel_streaming_tracefile_rotation | |
559 | test_kernel_streaming_tracefile_rotation_overwrite_files | |
560 | ) | |
561 | ||
562 | live_tests=(test_kernel_streaming_live | |
563 | test_kernel_basic_streaming_live_viewer | |
564 | test_kernel_streaming_live_viewer | |
565 | ) | |
566 | ||
567 | local_tests=(test_kernel_local | |
568 | test_kernel_local_rotate_clear | |
569 | test_kernel_local_clear_rotate | |
570 | ) | |
571 | ||
572 | snapshot_tests=(test_kernel_streaming_snapshot | |
573 | test_kernel_local_snapshot | |
574 | ) | |
575 | ||
576 | skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || | |
577 | { | |
578 | trap signal_cleanup SIGTERM SIGINT | |
579 | ||
580 | validate_lttng_modules_present | |
581 | ||
582 | start_lttng_relayd "-o $TRACE_PATH" | |
583 | start_lttng_sessiond | |
584 | modprobe lttng-test | |
585 | ||
586 | # Clear with tracing active, clear once | |
587 | for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_tests[@]}; | |
588 | do | |
589 | SESSION_NAME=$(randstring 16 0) | |
590 | ${fct_test} 1 0 0 0 | |
591 | clean_path $TRACE_PATH | |
592 | done | |
593 | ||
594 | # Clear with tracing active, clear twice | |
595 | for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_tests[@]}; | |
596 | do | |
597 | SESSION_NAME=$(randstring 16 0) | |
598 | ${fct_test} 1 1 0 0 | |
599 | clean_path $TRACE_PATH | |
600 | done | |
601 | ||
602 | # Clear with tracing inactive, clear once | |
603 | for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_tests[@]}; | |
604 | do | |
605 | SESSION_NAME=$(randstring 16 0) | |
606 | ${fct_test} 0 0 0 0 | |
607 | clean_path $TRACE_PATH | |
608 | done | |
609 | ||
610 | # Clear with tracing inactive, clear twice | |
611 | for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_tests[@]}; | |
612 | do | |
613 | SESSION_NAME=$(randstring 16 0) | |
614 | ${fct_test} 0 1 0 0 | |
615 | clean_path $TRACE_PATH | |
616 | done | |
617 | ||
618 | # Clear with tracing inactive, rotate-clear once | |
619 | for fct_test in ${streaming_tests[@]} ${local_tests[@]}; | |
620 | do | |
621 | SESSION_NAME=$(randstring 16 0) | |
622 | ${fct_test} 0 0 1 0 | |
623 | clean_path $TRACE_PATH | |
624 | done | |
625 | ||
626 | # Clear with tracing inactive, clear once-rotate(fail) | |
627 | for fct_test in ${streaming_tests[@]} ${local_tests[@]}; | |
628 | do | |
629 | SESSION_NAME=$(randstring 16 0) | |
630 | ${fct_test} 0 0 0 1 | |
631 | clean_path $TRACE_PATH | |
632 | done | |
633 | ||
634 | rmmod lttng-test | |
635 | stop_lttng_sessiond | |
636 | stop_lttng_relayd | |
637 | ||
638 | test_kernel_disallow_clear | |
639 | } | |
640 | ||
641 | clean_path $TRACE_PATH |