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