Fix: sessiond: domain subdirectory not deleted on empty clear
[lttng-tools.git] / tests / regression / tools / clear / test_ust
CommitLineData
c28fcefd
JR
1#!/bin/bash
2#
9d16b343 3# Copyright (C) 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
c28fcefd 4#
9d16b343 5# SPDX-License-Identifier: LGPL-2.1-only
c28fcefd
JR
6
7TEST_DESC="Clear - UST tracing"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
11EVENT_NAME="tp:tptest"
12SESSION_NAME=""
13TESTAPP_PATH="$TESTDIR/utils/testapp"
14TESTAPP_NAME="gen-ust-events"
15TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16
69ebf37e 17NUM_TESTS=1915
c28fcefd
JR
18
19PAGE_SIZE=$(getconf PAGE_SIZE)
20TRACE_PATH=$(mktemp -d)
21
22source $TESTDIR/utils/utils.sh
23
24if [ ! -x "$TESTAPP_BIN" ]; then
25 BAIL_OUT "No UST events binary detected."
26fi
27
28function clean_path ()
29{
30 local trace_path=$1
31 set -u
32 rm -rf $trace_path/*
33 set +u
34}
35
36function 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
46function 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
56function 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
83function test_ust_streaming ()
84{
85 local tracing_active=$1
86 local clear_twice=$2
87 local rotate_before=$3
88 local rotate_after=$4
89 local buffer_type=$5
90 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
91 local channel_name="chan"
92
93 diag "Test ust streaming clear"
94 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
95 create_lttng_session_uri $SESSION_NAME net://localhost
96 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
97 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
98 start_lttng_tracing_ok $SESSION_NAME
99 $TESTAPP_BIN -i 10
100 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
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 if [[ "$buffer_type" == "uid" ]]; then
107 validate_trace_empty $local_path
108 else # pid
109 validate_directory_empty $local_path
110 fi
111 fi
112
113 destroy_lttng_session_ok $SESSION_NAME
114}
115
69ebf37e
JR
116function test_ust_streaming_no_event ()
117{
118 local tracing_active=$1
119 local clear_twice=$2
120 #local rotate_before=$3 ignored
121 #local rotate_after=$4
122 local buffer_type=uid
123 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
124 local channel_name="chan"
125
126 diag "Test ust streaming clear no event"
127 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
128 create_lttng_session_uri $SESSION_NAME net://localhost
129 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
130 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
131 start_lttng_tracing_ok $SESSION_NAME
132
133 do_clear_session $SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
134 stop_lttng_tracing_ok $SESSION_NAME
135
136 validate_directory_empty "$local_path"
137
138 destroy_lttng_session_ok $SESSION_NAME
139}
140
c28fcefd
JR
141function test_ust_streaming_rotate_clear ()
142{
143 local tracing_active=$1
144 local clear_twice=$2
145 local rotate_before=$3
146 local rotate_after=$4
147 local buffer_type=$5
148 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
149 local channel_name="chan"
150
151 diag "Test ust streaming rotate-clear"
152 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
153 create_lttng_session_uri $SESSION_NAME net://localhost
154 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
155 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
156 start_lttng_tracing_ok $SESSION_NAME
157 $TESTAPP_BIN -i 1
158 rotate_session_ok $SESSION_NAME
159 $TESTAPP_BIN -i 2
160 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
161 $TESTAPP_BIN -i 3
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=4
168 fi
169 validate_trace_count $EVENT_NAME $local_path $expect_count
170
171 destroy_lttng_session_ok $SESSION_NAME
172}
173
174function test_ust_streaming_clear_rotate ()
175{
176 local tracing_active=$1
177 local clear_twice=$2
178 local rotate_before=$3
179 local rotate_after=$4
180 local buffer_type=$5
181 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
182 local channel_name="chan"
183
184 diag "Test ust streaming clear-rotate"
185 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
186 create_lttng_session_uri $SESSION_NAME net://localhost
187 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
188 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
189 start_lttng_tracing_ok $SESSION_NAME
190 $TESTAPP_BIN -i 1
191 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
192 $TESTAPP_BIN -i 2
193 rotate_session_ok $SESSION_NAME
194 $TESTAPP_BIN -i 3
195 stop_lttng_tracing_ok $SESSION_NAME
196
197 if [[ $rotate_before -eq 1 ]]; then
198 local expect_count=6
199 else
200 local expect_count=5
201 fi
202 validate_trace_count $EVENT_NAME $local_path $expect_count
203
204 destroy_lttng_session_ok $SESSION_NAME
205}
206
207function test_ust_streaming_live ()
208{
209 local tracing_active=$1
210 local clear_twice=$2
211 # 3, 4 unused
212 local buffer_type=$5
213 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
214 local channel_name="chan"
215
216 diag "Test ust streaming live clear"
217 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
218 create_lttng_session_uri $SESSION_NAME net://localhost "--live"
219 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
220 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
221 start_lttng_tracing_ok $SESSION_NAME
222 $TESTAPP_BIN -i 10
223 do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0
224 stop_lttng_tracing_ok $SESSION_NAME
225
226 validate_directory_empty $local_path
227
228 destroy_lttng_session_ok $SESSION_NAME
229}
230
231#no clear
232function test_ust_basic_streaming_live_viewer ()
233{
234 local tracing_active=$1
235 local clear_twice=$2
236 # 3, 4 unused
237 local buffer_type=$5
238 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
239 local remote_trace_path="${HOSTNAME}/${SESSION_NAME}"
240 local channel_name="chan"
241 local bt_output_path=$(mktemp -u)
242 local file_sync_before_exit=$(mktemp -u)
243
244 diag "Test ust basic streaming live with viewer"
245 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
246 create_lttng_session_uri $SESSION_NAME net://localhost "--live"
247 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
248 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
249 start_lttng_tracing_ok $SESSION_NAME
250
251 wait_live_trace_ready net://localhost
252
253 # Connect a live viewer
254 $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path &
255 local viewer_pid=$!
256
257 wait_live_viewer_connect net://localhost
258
259 $TESTAPP_BIN -i 10 --sync-before-exit $file_sync_before_exit &
260 local app_pid=$!
261
262 diag "Wait until viewer sees all 10 expected events"
263 local evcount=0
264 while [ $evcount -ne 10 ]; do
265 evcount=$(cat $bt_output_path | wc -l)
266 sleep 0.5
267 done
268 pass "Live viewer read $evcount events, expect 10"
269
270 destroy_lttng_session_ok $SESSION_NAME
271 touch $file_sync_before_exit
272 diag "Wait for application to exit"
273 wait $app_pid
274 pass "Wait for application to exit"
275 diag "Wait for viewer to exit"
276 wait $viewer_pid
277 ok $? "Babeltrace succeeds"
278 pass "Wait for viewer to exit"
279
280 rm -f $bt_output_path
281 rm -f $file_sync_before_exit
282}
283
284function test_ust_streaming_live_viewer ()
285{
286 local tracing_active=$1
287 local clear_twice=$2
288 # 3, 4 unused
289 local buffer_type=$5
290 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
291 local remote_trace_path="${HOSTNAME}/${SESSION_NAME}"
292 local channel_name="chan"
293 local bt_output_path=$(mktemp -d)/bt-output.txt
294
295 diag "Test ust streaming live clear with viewer"
296 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
297 create_lttng_session_uri $SESSION_NAME net://localhost "--live"
298 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
299 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
300 start_lttng_tracing_ok $SESSION_NAME
301
302 wait_live_trace_ready net://localhost
303
304 # Connect a live viewer
305 $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path &
306 local viewer_pid=$!
307
308 wait_live_viewer_connect net://localhost
309
310 $TESTAPP_BIN -i 10
311 do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0
312 stop_lttng_tracing_ok $SESSION_NAME
313
314 destroy_lttng_session_ok $SESSION_NAME
315 diag "Wait for viewer to exit"
316 wait $viewer_pid
317 ok $? "Babeltrace succeeds"
318 pass "Wait for viewer to exit"
319
320 clean_path $bt_output_path
321}
322
323function test_ust_local ()
324{
325 local tracing_active=$1
326 local clear_twice=$2
327 local rotate_before=$3
328 local rotate_after=$4
329 local buffer_type=$5
330 local channel_name="chan"
331
332 diag "Test ust local"
333 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
334 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
335 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
336 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
337 start_lttng_tracing_ok $SESSION_NAME
338 $TESTAPP_BIN -i 10
339 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
340 stop_lttng_tracing_ok $SESSION_NAME
341
342 if [[ $rotate_before -eq 1 ]]; then
343 validate_trace_count $EVENT_NAME $TRACE_PATH 10
344 else
345 if [[ "$buffer_type" == "uid" ]]; then
346 validate_trace_empty $TRACE_PATH
347 else # pid
348 validate_directory_empty $TRACE_PATH
349 fi
350 fi
351
352 destroy_lttng_session_ok $SESSION_NAME
353}
354
69ebf37e
JR
355function test_ust_local_no_event ()
356{
357 local tracing_active=$1
358 local clear_twice=$2
359 #local rotate_before=$3 ignored
360 #local rotate_after=$4 ignored
361 local buffer_type=$5
362 local channel_name="chan"
363
364 diag "Test ust local no event"
365 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
366 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
367 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name "--buffers-$buffer_type"
368 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
369 start_lttng_tracing_ok $SESSION_NAME
370
371 do_clear_session $SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
372 stop_lttng_tracing_ok $SESSION_NAME
373
374 validate_directory_empty "$TRACE_PATH"
375
376 destroy_lttng_session_ok $SESSION_NAME
377}
378
c28fcefd
JR
379function test_ust_local_rotate_clear ()
380{
381 local tracing_active=$1
382 local clear_twice=$2
383 local rotate_before=$3
384 local rotate_after=$4
385 local buffer_type=$5
386 local channel_name="chan"
387
388 diag "Test ust local rotate-clear"
389 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
390 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
391 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
392 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
393 start_lttng_tracing_ok $SESSION_NAME
394 $TESTAPP_BIN -i 1
395 rotate_session_ok $SESSION_NAME
396 $TESTAPP_BIN -i 2
397 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
398 $TESTAPP_BIN -i 3
399 stop_lttng_tracing_ok $SESSION_NAME
400
401 if [[ $rotate_before -eq 1 ]]; then
402 local expect_count=6
403 else
404 local expect_count=4
405 fi
406 validate_trace_count $EVENT_NAME $TRACE_PATH $expect_count
407
408 destroy_lttng_session_ok $SESSION_NAME
409}
410
411function test_ust_local_clear_rotate ()
412{
413 local tracing_active=$1
414 local clear_twice=$2
415 local rotate_before=$3
416 local rotate_after=$4
417 local buffer_type=$5
418 local channel_name="chan"
419
420 diag "Test ust local clear-rotate"
421 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
422 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
423 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
424 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
425 start_lttng_tracing_ok $SESSION_NAME
426 $TESTAPP_BIN -i 1
427 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
428 $TESTAPP_BIN -i 2
429 rotate_session_ok $SESSION_NAME
430 $TESTAPP_BIN -i 3
431 stop_lttng_tracing_ok $SESSION_NAME
432
433 if [[ $rotate_before -eq 1 ]]; then
434 local expect_count=6
435 else
436 local expect_count=5
437 fi
438 validate_trace_count $EVENT_NAME $TRACE_PATH $expect_count
439
440 destroy_lttng_session_ok $SESSION_NAME
441}
442
443function do_ust_snapshot ()
444{
445 local session_name=$1
446 local trace_path=$2
447 local tracing_active=$3
448 local clear_twice=$4
449 local buffer_type=$5
450 local channel_name="snapshot"
451
452 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
453 enable_ust_lttng_event_ok $session_name $EVENT_NAME $channel_name
454 start_lttng_tracing_ok $session_name
455
456 # Generate 10 events that will sit in the buffers.
457 $TESTAPP_BIN -i 10
458
459 # Take a first snapshot and validate that the events are present.
460 lttng_snapshot_record $session_name
461 stop_lttng_tracing_ok $session_name
462 validate_trace_count $EVENT_NAME $trace_path 10
463
464 # Clean the output path
465 clean_path $trace_path
466 start_lttng_tracing_ok $session_name
467
468 do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0
469
470 # Make sure the subsequent snapshot is empty and valid.
471 lttng_snapshot_record $session_name
472 stop_lttng_tracing_ok $session_name
473 validate_trace_empty $trace_path
474
475 # Clean the output path
476 clean_path $trace_path
477 start_lttng_tracing_ok $session_name
478
479 # Make sure that everything still works, generate events and take a
480 # snapshot.
481 $TESTAPP_BIN -i 10
482 lttng_snapshot_record $session_name
483 stop_lttng_tracing_ok $session_name
484 validate_trace_count $EVENT_NAME $trace_path 10
485}
486
487function test_ust_streaming_snapshot ()
488{
489 local tracing_active=$1
490 local clear_twice=$2
491 # 3, 4 unused.
492 local buffer_type=$5
493
494 diag "Test ust streaming snapshot clear"
495 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
496
497 create_lttng_session_uri $SESSION_NAME net://localhost "--snapshot"
498 do_ust_snapshot $SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
499 destroy_lttng_session_ok $SESSION_NAME
500}
501
502function test_ust_local_snapshot ()
503{
504 local tracing_active=$1
505 local clear_twice=$2
506 # 3, 4 unused.
507 local buffer_type=$5
508
509 diag "Test ust local snapshot clear"
510 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
511
512 create_lttng_session_ok $SESSION_NAME $TRACE_PATH "--snapshot"
513 do_ust_snapshot $SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
514 destroy_lttng_session_ok $SESSION_NAME
515}
516
517# snapshot for per-pid is tested independently of the "buffer type" parameter
518# because an application needs to be live to appear in a snapshot.
519function test_ust_local_snapshot_per_pid ()
520{
521 local tracing_active=$1
522 local clear_twice=$2
523 # 3, 4 unused.
524 local buffer_type=$5
525 local channel_name="channel0"
526 local file_sync_before_last=$(mktemp -u)
527 local file_sync_before_last_touch=$(mktemp -u)
528 local file_sync_before_exit=$(mktemp -u)
529 local file_sync_before_exit_touch=$(mktemp -u)
530
531 diag "Test ust local snapshot clear per pid"
532 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
533
534 create_lttng_session_ok $SESSION_NAME $TRACE_PATH "--snapshot"
535 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
536 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
537 start_lttng_tracing_ok $SESSION_NAME
538
539 # Generate 10 events that will sit in the buffers.
540 $TESTAPP_BIN -i 10 -w 0 \
541 --sync-before-last-event ${file_sync_before_last} \
542 --sync-before-last-event-touch ${file_sync_before_last_touch} \
543 --sync-before-exit ${file_sync_before_exit} \
544 --sync-before-exit-touch ${file_sync_before_exit_touch} >/dev/null 2>&1 &
545
546 # Continue only when there is only the last event remaining.
547 while [ ! -f "${file_sync_before_last_touch}" ]; do
548 sleep 0.5
549 done
550
551 # Take a first snapshot and validate that the events are present.
552 lttng_snapshot_record $SESSION_NAME
553 stop_lttng_tracing_ok $SESSION_NAME
554 validate_trace_count $EVENT_NAME $TRACE_PATH 9
555
556 # Clean the output path
557 clean_path $TRACE_PATH
558 start_lttng_tracing_ok $SESSION_NAME
559
560 do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0
561
562 # Make sure the subsequent snapshot is empty and valid.
563 lttng_snapshot_record $SESSION_NAME
564 stop_lttng_tracing_ok $SESSION_NAME
565 validate_trace_empty $TRACE_PATH
566
567 # Validate that tracing still works and subsequent snapshots are valid.
568 # Clean the output path.
569 clean_path $TRACE_PATH
570 start_lttng_tracing_ok $SESSION_NAME
571
572 # Continue over the last event.
573 touch ${file_sync_before_last}
574
575 # Wait for the before exit sync point. This ensure that we went over the
576 # last tracepoint.
577 while [ ! -f "${file_sync_before_exit_touch}" ]; do
578 sleep 0.5
579 done
580
581 # Make sure the snapshot contains the last event.
582 lttng_snapshot_record $SESSION_NAME
583 stop_lttng_tracing_ok $SESSION_NAME
584 validate_trace_count $EVENT_NAME $TRACE_PATH 1
585
586 # Release the application.
587 touch ${file_sync_before_exit}
588 wait
589 destroy_lttng_session_ok $SESSION_NAME
590
591 rm -f ${file_sync_before_last}
592 rm -f ${file_sync_before_last_touch}
593 rm -f ${file_sync_before_exit}
594 rm -f ${file_sync_before_exit_touch}
595}
596
597function test_ust_streaming_tracefile_rotation ()
598{
599 local tracing_active=$1
600 local clear_twice=$2
601 local rotate_before=$3
602 local rotate_after=$4
603 local buffer_type=$5
604 local channel_name="rotchan"
605 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
606
607 diag "Test ust streaming clear with tracefile rotation"
608 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
609 create_lttng_session_uri $SESSION_NAME net://localhost
610 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
611 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
612 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
613 start_lttng_tracing_ok $SESSION_NAME
614 $TESTAPP_BIN -i 10
615 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
616 stop_lttng_tracing_ok $SESSION_NAME
617
618 if [[ $rotate_before -eq 1 ]]; then
619 validate_trace_count $EVENT_NAME $local_path 10
620 else
621 if [[ "$buffer_type" == "uid" ]]; then
622 validate_trace_empty $local_path
623 else # pid
624 validate_directory_empty $local_path
625 fi
626 fi
627
628 start_lttng_tracing_ok $SESSION_NAME
629 $TESTAPP_BIN -i 20
630 stop_lttng_tracing_ok
631
632 if [[ $rotate_before -eq 1 ]]; then
633 validate_trace_count $EVENT_NAME $local_path 30
634 else
635 validate_trace_count $EVENT_NAME $local_path 20
636 fi
637
638 destroy_lttng_session_ok $SESSION_NAME
639}
640
641# With 1 byte per event (as strict minimum), generating 200000 events
642# guarantees filling up 2 files of 64k in size, which is the maximum
643# page size known on Linux
644function test_ust_streaming_tracefile_rotation_overwrite_files ()
645{
646 local tracing_active=$1
647 local clear_twice=$2
648 local rotate_before=$3
649 local rotate_after=$4
650 local buffer_type=$5
651 local channel_name="rotchan"
652 local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
653
654 diag "Test ust streaming clear with tracefile rotation, overwrite files"
655 diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
656 create_lttng_session_uri $SESSION_NAME net://localhost
657 enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --subbuf-size=$PAGE_SIZE \
658 --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
659 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
660 start_lttng_tracing_ok $SESSION_NAME
661 taskset -c 0 $TESTAPP_BIN -i 200000
662 do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
663 stop_lttng_tracing_ok $SESSION_NAME
664
665 if [[ $rotate_before -eq 1 ]]; then
666 validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 200000
667 else
668 if [[ "$buffer_type" == "uid" ]]; then
669 validate_trace_empty $local_path
670 else # pid
671 validate_directory_empty $local_path
672 fi
673 fi
674
675 start_lttng_tracing_ok $SESSION_NAME
676 taskset -c 0 $TESTAPP_BIN -i 400000
677 stop_lttng_tracing_ok
678
679 if [[ $rotate_before -eq 1 ]]; then
680 validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 600000
681 else
682 validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 200000
683 fi
684
685 destroy_lttng_session_ok $SESSION_NAME
686}
687
688function test_ust_disallow_clear ()
689{
690 diag "Test ust disallow clear on relay daemon"
691 SESSION_NAME=$(randstring 16 0)
692
693 LTTNG_RELAYD_DISALLOW_CLEAR=1 start_lttng_relayd "-o $TRACE_PATH"
694
695 start_lttng_sessiond
696
697 create_lttng_session_uri $SESSION_NAME net://localhost
698 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
699 start_lttng_tracing_ok $SESSION_NAME
700 lttng_clear_session_fail $SESSION_NAME
701 destroy_lttng_session_ok $SESSION_NAME
702
703 stop_lttng_sessiond
704 stop_lttng_relayd
705 clean_path $TRACE_PATH
706}
707
708plan_tests $NUM_TESTS
709
710print_test_banner "$TEST_DESC"
711
712streaming_tests=(test_ust_streaming
713 test_ust_streaming_rotate_clear
714 test_ust_streaming_clear_rotate
715 test_ust_streaming_tracefile_rotation
716 test_ust_streaming_tracefile_rotation_overwrite_files
69ebf37e 717 test_ust_streaming_no_event
c28fcefd
JR
718)
719
720live_tests=(test_ust_streaming_live
721 test_ust_basic_streaming_live_viewer
722 test_ust_streaming_live_viewer
723)
724
725local_tests=(test_ust_local
726 test_ust_local_rotate_clear
727 test_ust_local_clear_rotate
69ebf37e 728 test_ust_local_no_event
c28fcefd
JR
729)
730
731snapshot_uid_tests=(test_ust_streaming_snapshot
732 test_ust_local_snapshot
733)
734
735snapshot_pid_tests=(test_ust_local_snapshot_per_pid)
736
737start_lttng_relayd "-o $TRACE_PATH"
738start_lttng_sessiond
739
740# Per-UID buffers
741
742# Clear with tracing active, clear once
743for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
744do
745 SESSION_NAME=$(randstring 16 0)
746 ${fct_test} 1 0 0 0 uid
747 clean_path $TRACE_PATH
748done
749
750# Clear with tracing active, clear twice
751for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
752do
753 SESSION_NAME=$(randstring 16 0)
754 ${fct_test} 1 1 0 0 uid
755 clean_path $TRACE_PATH
756done
757
758# Clear with tracing inactive, clear once
759for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
760do
761 SESSION_NAME=$(randstring 16 0)
762 ${fct_test} 0 0 0 0 uid
763 clean_path $TRACE_PATH
764done
765
766# Clear with tracing inactive, clear twice
767for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_uid_tests[@]};
768do
769 SESSION_NAME=$(randstring 16 0)
770 ${fct_test} 0 1 0 0 uid
771 clean_path $TRACE_PATH
772done
773
774# Clear with tracing inactive, rotate-clear once
775for fct_test in ${streaming_tests[@]} ${local_tests[@]};
776do
777 SESSION_NAME=$(randstring 16 0)
778 ${fct_test} 0 0 1 0 uid
779 clean_path $TRACE_PATH
780done
781
782# Clear with tracing inactive, clear once-rotate(fail)
783for fct_test in ${streaming_tests[@]} ${local_tests[@]};
784do
785 SESSION_NAME=$(randstring 16 0)
786 ${fct_test} 0 0 0 1 uid
787 clean_path $TRACE_PATH
788done
789
790
791# Per-PID buffers.
792
793# Clear with tracing active, clear once
794for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
795do
796 SESSION_NAME=$(randstring 16 0)
797 ${fct_test} 1 0 0 0 pid
798 clean_path $TRACE_PATH
799done
800
801# Clear with tracing active, clear twice
802for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
803do
804 SESSION_NAME=$(randstring 16 0)
805 ${fct_test} 1 1 0 0 pid
806 clean_path $TRACE_PATH
807done
808
809# Clear with tracing inactive, clear once
810for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
811do
812 SESSION_NAME=$(randstring 16 0)
813 ${fct_test} 0 0 0 0 pid
814 clean_path $TRACE_PATH
815done
816
817# Clear with tracing inactive, clear twice
818for fct_test in ${streaming_tests[@]} ${live_tests[@]} ${local_tests[@]} ${snapshot_pid_tests[@]};
819do
820 SESSION_NAME=$(randstring 16 0)
821 ${fct_test} 0 1 0 0 pid
822 clean_path $TRACE_PATH
823done
824
825# Clear with tracing inactive, rotate-clear once
826for fct_test in ${streaming_tests[@]} ${local_tests[@]};
827do
828 SESSION_NAME=$(randstring 16 0)
829 ${fct_test} 0 0 1 0 pid
830 clean_path $TRACE_PATH
831done
832
833# Clear with tracing inactive, clear once-rotate(fail)
834for fct_test in ${streaming_tests[@]} ${local_tests[@]};
835do
836 SESSION_NAME=$(randstring 16 0)
837 ${fct_test} 0 0 0 1 pid
838 clean_path $TRACE_PATH
839done
840
841stop_lttng_sessiond
842stop_lttng_relayd
843
844test_ust_disallow_clear
This page took 0.08441 seconds and 4 git commands to generate.