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