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