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