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