1 # Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
3 # SPDX-License-Identifier: LGPL-2.1-only
6 SESSIOND_BIN
="lttng-sessiond"
7 SESSIOND_MATCH
=".*lttng-sess.*"
8 RUNAS_BIN
="lttng-runas"
9 RUNAS_MATCH
=".*lttng-runas.*"
10 CONSUMERD_BIN
="lttng-consumerd"
11 CONSUMERD_MATCH
=".*lttng-consumerd.*"
12 RELAYD_BIN
="lttng-relayd"
13 RELAYD_MATCH
=".*lttng-relayd.*"
15 BABELTRACE_BIN
="babeltrace"
17 ERROR_OUTPUT_DEST
=/dev
/null
19 # Minimal kernel version supported for session daemon tests
20 KERNEL_MAJOR_VERSION
=2
21 KERNEL_MINOR_VERSION
=6
22 KERNEL_PATCHLEVEL_VERSION
=27
24 # We set the default UST register timeout and network and app socket timeout to
25 # "wait forever", so that basic tests don't have to worry about hitting
26 # timeouts on busy systems. Specialized tests should test those corner-cases.
27 export LTTNG_UST_REGISTER_TIMEOUT
=-1
28 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
29 export LTTNG_APP_SOCKET_TIMEOUT
=-1
31 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
32 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
33 # its own sessiond if none is running. It also ensures that 'lttng create'
34 # fails when no sessiond is running.
35 export LTTNG_SESSIOND_PATH
="/bin/true"
37 source $TESTDIR/utils
/tap
/tap.sh
39 if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then
40 LTTNG_TEST_TEARDOWN_TIMEOUT
=60
43 function full_cleanup
()
45 # Try to kill daemons gracefully
46 stop_lttng_relayd_notap SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
47 stop_lttng_sessiond_notap SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
49 # If daemons are still present, forcibly kill them
50 stop_lttng_relayd_notap SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
51 stop_lttng_sessiond_notap SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
52 stop_lttng_consumerd_notap SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
54 # Disable trap for SIGTERM since the following kill to the
55 # pidgroup will be SIGTERM. Otherwise it loops.
56 # The '-' before the pid number ($$) indicates 'kill' to signal the
57 # whole process group.
58 trap - SIGTERM
&& kill -- -$$
62 function null_pipes
()
69 trap full_cleanup SIGINT SIGTERM
71 # perl prove closes its child pipes before giving it a chance to run its
72 # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
73 # to allow those trap handlers to proceed.
75 trap null_pipes SIGPIPE
79 # Check if we are a terminal
81 echo -e "\e[1;32mOK\e[0m"
87 function print_fail
()
89 # Check if we are a terminal
91 echo -e "\e[1;31mFAIL\e[0m"
97 function print_test_banner
()
103 function validate_kernel_version
()
105 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
106 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
109 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
112 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
118 # Generate a random string
119 # $1 = number of characters; defaults to 16
120 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
121 function randstring
()
123 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
124 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
128 # Return the number of _configured_ CPUs.
129 function conf_proc_count
()
131 getconf _NPROCESSORS_CONF
132 if [ $?
-ne 0 ]; then
133 diag
"Failed to get the number of configured CPUs"
138 # Check if base lttng-modules are present.
139 # Bail out on failure
140 function validate_lttng_modules_present
()
142 modprobe
-n lttng-tracer
2>/dev
/null
143 if [ $?
-ne 0 ]; then
144 BAIL_OUT
"LTTng modules not detected."
148 function enable_kernel_lttng_event
151 local expected_to_fail
="$2"
153 local event_name
="$4"
154 local channel_name
="$5"
156 if [ -z "$event_name" ]; then
157 # Enable all event if no event name specified
161 if [ -z "$channel_name" ]; then
162 # default channel if none specified
165 chan
="-c $channel_name"
168 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
170 if [[ $expected_to_fail -eq "1" ]]; then
173 if [ $withtap -eq "1" ]; then
174 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
177 if [ $withtap -eq "1" ]; then
178 ok
$ret "Enable kernel event $event_name for session $sess_name"
183 function enable_kernel_lttng_event_ok
()
185 enable_kernel_lttng_event
1 0 "$@"
188 function enable_kernel_lttng_event_fail
()
190 enable_kernel_lttng_event
1 1 "$@"
193 function enable_kernel_lttng_event_notap
()
195 enable_kernel_lttng_event
0 0 "$@"
199 function lttng_enable_kernel_event
201 enable_kernel_lttng_event_ok
"$@"
204 function lttng_enable_kernel_syscall
()
206 local expected_to_fail
=$1
208 local syscall_name
=$3
209 local channel_name
=$4
211 if [ -z $syscall_name ]; then
212 # Enable all event if no syscall name specified
216 if [ -z $channel_name ]; then
217 # default channel if none specified
220 chan
="-c $channel_name"
223 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
225 if [[ $expected_to_fail -eq "1" ]]; then
227 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
229 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
233 function lttng_enable_kernel_syscall_ok
()
235 lttng_enable_kernel_syscall
0 "$@"
238 function lttng_enable_kernel_syscall_fail
()
240 lttng_enable_kernel_syscall
1 "$@"
243 function lttng_disable_kernel_syscall
()
245 local expected_to_fail
=$1
247 local syscall_name
=$3
248 local channel_name
=$4
250 if [ -z $syscall_name ]; then
251 # Enable all event if no syscall name specified
255 if [ -z $channel_name ]; then
256 # default channel if none specified
259 chan
="-c $channel_name"
262 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
265 if [[ $expected_to_fail -eq "1" ]]; then
267 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
269 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
273 function lttng_disable_kernel_syscall_ok
()
275 lttng_disable_kernel_syscall
0 "$@"
278 function lttng_disable_kernel_syscall_fail
()
280 lttng_disable_kernel_syscall
1 "$@"
283 function lttng_enable_kernel_userspace_probe_event
()
285 local expected_to_fail
="$1"
288 local event_name
="$4"
290 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
292 if [[ $expected_to_fail -eq "1" ]]; then
294 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
296 ok
$ret "Enable kernel userspace probe event for session $sess_name"
300 function lttng_enable_kernel_userspace_probe_event_fail
()
302 lttng_enable_kernel_userspace_probe_event
1 "$@"
305 function lttng_enable_kernel_userspace_probe_event_ok
()
307 lttng_enable_kernel_userspace_probe_event
0 "$@"
310 function disable_kernel_lttng_userspace_probe_event_ok
()
313 local event_name
="$2"
315 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
316 ok $?
"Disable kernel event $target for session $sess_name"
318 function lttng_enable_kernel_channel
()
321 local expected_to_fail
=$2
323 local channel_name
=$4
326 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
328 if [[ $expected_to_fail -eq "1" ]]; then
331 if [ $withtap -eq "1" ]; then
332 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
335 if [ $withtap -eq "1" ]; then
336 ok
$ret "Enable channel $channel_name for session $sess_name"
341 function lttng_enable_kernel_channel_ok
()
343 lttng_enable_kernel_channel
1 0 "$@"
346 function lttng_enable_kernel_channel_fail
()
348 lttng_enable_kernel_channel
1 1 "$@"
351 function lttng_enable_kernel_channel_notap
()
353 lttng_enable_kernel_channel
0 0 "$@"
356 function enable_kernel_lttng_channel_ok
()
358 lttng_enable_kernel_channel
1 0 "$@"
361 function lttng_disable_kernel_channel
()
363 local expected_to_fail
=$1
365 local channel_name
=$3
367 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
369 if [[ $expected_to_fail -eq "1" ]]; then
371 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
373 ok
$ret "Disable channel $channel_name for session $sess_name"
377 function lttng_disable_kernel_channel_ok
()
379 lttng_disable_kernel_channel
0 "$@"
382 function lttng_disable_kernel_channel_fail
()
384 lttng_disable_kernel_channel
1 "$@"
387 function start_lttng_relayd_opt
()
390 local process_mode
=$2
393 DIR
=$
(readlink
-f "$TESTDIR")
395 if [ -z $
(pgrep
$RELAYD_MATCH) ]; then
396 # shellcheck disable=SC2086
397 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
398 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
399 if [ $?
-eq 1 ]; then
400 if [ $withtap -eq "1" ]; then
401 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
405 if [ $withtap -eq "1" ]; then
406 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
410 pass
"Start lttng-relayd (opt: $opt)"
414 function start_lttng_relayd
()
416 start_lttng_relayd_opt
1 "-b" "$@"
419 function start_lttng_relayd_notap
()
421 start_lttng_relayd_opt
0 "-b" "$@"
424 function stop_lttng_relayd_opt
()
429 if [ -z "$signal" ]; then
436 # Multiply time by 2 to simplify integer arithmetic
437 if [ -n "$timeout_s" ]; then
438 dtimeleft_s
=$
((timeout_s
* 2))
444 pids
=$
(pgrep
"$RELAYD_MATCH")
445 if [ -z "$pids" ]; then
446 if [ "$withtap" -eq "1" ]; then
447 pass
"No relay daemon to kill"
452 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
454 # shellcheck disable=SC2086
455 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
457 if [ "$withtap" -eq "1" ]; then
458 fail
"Kill relay daemon"
462 while [ -n "$out" ]; do
463 out
=$
(pgrep
"$RELAYD_MATCH")
464 if [ -n "$dtimeleft_s" ]; then
465 if [ $dtimeleft_s -lt 0 ]; then
469 dtimeleft_s
=$
((dtimeleft_s
- 1))
473 if [ "$withtap" -eq "1" ]; then
474 if [ "$retval" -eq "0" ]; then
475 pass
"Wait after kill relay daemon"
477 fail
"Wait after kill relay daemon"
484 function stop_lttng_relayd
()
486 stop_lttng_relayd_opt
1 "$@"
489 function stop_lttng_relayd_notap
()
491 stop_lttng_relayd_opt
0 "$@"
494 #First arg: show tap output
495 #Second argument: load path for automatic loading
496 function start_lttng_sessiond_opt
()
504 local long_bit_value
=
505 long_bit_value
=$
(getconf LONG_BIT
)
507 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
508 # Env variable requested no session daemon
512 DIR
=$
(readlink
-f "$TESTDIR")
514 # Get long_bit value for 32/64 consumerd
515 case "$long_bit_value" in
517 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
520 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
527 # Check for env. variable. Allow the use of LD_PRELOAD etc.
528 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
529 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
531 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
533 if ! validate_kernel_version
; then
534 fail
"Start session daemon"
535 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
538 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
539 export LTTNG_SESSION_CONFIG_XSD_PATH
541 if [ -z "$(pgrep "${SESSIOND_MATCH}")" ]; then
543 if [ -n "$load_path" ]; then
544 # shellcheck disable=SC2086
545 env
$env_vars --load "$load_path" --background "$consumerd"
547 # shellcheck disable=SC2086
548 env
$env_vars --background "$consumerd"
550 #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1
552 if [ "$withtap" -eq "1" ]; then
553 ok
$status "Start session daemon"
558 function start_lttng_sessiond
()
560 start_lttng_sessiond_opt
1 "$@"
563 function start_lttng_sessiond_notap
()
565 start_lttng_sessiond_opt
0 "$@"
568 function stop_lttng_sessiond_opt
()
573 if [ -z "$signal" ]; then
580 # Multiply time by 2 to simplify integer arithmetic
581 if [ -n "$timeout_s" ]; then
582 dtimeleft_s
=$
((timeout_s
* 2))
585 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
586 # Env variable requested no session daemon
593 runas_pids
=$
(pgrep
"$RUNAS_MATCH")
596 pids
=$
(pgrep
"$SESSIOND_MATCH")
598 if [ -n "$runas_pids" ]; then
599 pids
="$pids $runas_pids"
602 if [ -z "$pids" ]; then
603 if [ "$withtap" -eq "1" ]; then
604 pass
"No session daemon to kill"
609 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
611 # shellcheck disable=SC2086
612 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
614 if [ "$withtap" -eq "1" ]; then
615 fail
"Kill sessions daemon"
619 while [ -n "$out" ]; do
620 out
=$
(pgrep
"${SESSIOND_MATCH}")
621 if [ -n "$dtimeleft_s" ]; then
622 if [ $dtimeleft_s -lt 0 ]; then
626 dtimeleft_s
=$
((dtimeleft_s
- 1))
631 while [ -n "$out" ]; do
632 out
=$
(pgrep
"$CONSUMERD_MATCH")
633 if [ -n "$dtimeleft_s" ]; then
634 if [ $dtimeleft_s -lt 0 ]; then
638 dtimeleft_s
=$
((dtimeleft_s
- 1))
643 if [ "$withtap" -eq "1" ]; then
644 if [ "$retval" -eq "0" ]; then
645 pass
"Wait after kill session daemon"
647 fail
"Wait after kill session daemon"
651 if [ "$signal" = "SIGKILL" ]; then
652 if [ "$(id -u)" -eq "0" ]; then
654 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
656 if [ -n "$modules" ]; then
657 diag
"Unloading all LTTng modules"
658 modprobe
-r "$modules"
666 function stop_lttng_sessiond
()
668 stop_lttng_sessiond_opt
1 "$@"
671 function stop_lttng_sessiond_notap
()
673 stop_lttng_sessiond_opt
0 "$@"
676 function sigstop_lttng_sessiond_opt
()
681 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
682 # Env variable requested no session daemon
686 PID_SESSIOND
="$(pgrep "${SESSIOND_MATCH}") $(pgrep "$RUNAS_MATCH")"
688 if [ "$withtap" -eq "1" ]; then
689 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$PID_SESSIOND" | tr '\n' ' ')"
692 # shellcheck disable=SC2086
693 if ! kill -s $signal $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
694 if [ "$withtap" -eq "1" ]; then
695 fail
"Sending SIGSTOP to session daemon"
699 while [ $out -ne 0 ]; do
700 pid
="$(pgrep "$SESSIOND_MATCH")"
702 # Wait until state becomes stopped for session
705 for sessiond_pid
in $pid; do
706 state
="$(ps -p "$sessiond_pid" -o state= )"
707 if [[ -n "$state" && "$state" != "T" ]]; then
713 if [ "$withtap" -eq "1" ]; then
714 pass
"Sending SIGSTOP to session daemon"
719 function sigstop_lttng_sessiond
()
721 sigstop_lttng_sessiond_opt
1 "$@"
724 function sigstop_lttng_sessiond_notap
()
726 sigstop_lttng_sessiond_opt
0 "$@"
729 function stop_lttng_consumerd_opt
()
734 if [ -z "$signal" ]; then
741 # Multiply time by 2 to simplify integer arithmetic
742 if [ -n "$timeout_s" ]; then
743 dtimeleft_s
=$
((timeout_s
* 2))
748 PID_CONSUMERD
="$(pgrep "$CONSUMERD_MATCH")"
750 if [ -z "$PID_CONSUMERD" ]; then
751 if [ "$withtap" -eq "1" ]; then
752 pass
"No consumer daemon to kill"
757 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
759 # shellcheck disable=SC2086
760 if ! kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
762 if [ "$withtap" -eq "1" ]; then
763 fail
"Kill consumer daemon"
767 while [ $out -ne 0 ]; do
768 pid
="$(pgrep "$CONSUMERD_MATCH")"
770 # If consumerds are still present check their status.
771 # A zombie status qualifies the consumerd as *killed*
773 for consumer_pid
in $pid; do
774 state
="$(ps -p "$consumer_pid" -o state= )"
775 if [[ -n "$state" && "$state" != "Z" ]]; then
779 if [ -n "$dtimeleft_s" ]; then
780 if [ $dtimeleft_s -lt 0 ]; then
784 dtimeleft_s
=$
((dtimeleft_s
- 1))
788 if [ "$withtap" -eq "1" ]; then
789 if [ "$retval" -eq "0" ]; then
790 pass
"Wait after kill consumer daemon"
792 fail
"Wait after kill consumer daemon"
800 function stop_lttng_consumerd
()
802 stop_lttng_consumerd_opt
1 "$@"
805 function stop_lttng_consumerd_notap
()
807 stop_lttng_consumerd_opt
0 "$@"
810 function sigstop_lttng_consumerd_opt
()
815 PID_CONSUMERD
="$(pgrep "$CONSUMERD_MATCH")"
817 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
819 # shellcheck disable=SC2086
820 kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
823 if [ $retval -eq 1 ]; then
824 if [ "$withtap" -eq "1" ]; then
825 fail
"Sending SIGSTOP to consumer daemon"
830 while [ $out -ne 0 ]; do
831 pid
="$(pgrep "$CONSUMERD_MATCH")"
833 # Wait until state becomes stopped for all
836 for consumer_pid
in $pid; do
837 state
="$(ps -p "$consumer_pid" -o state= )"
838 if [[ -n "$state" && "$state" != "T" ]]; then
844 if [ "$withtap" -eq "1" ]; then
845 pass
"Sending SIGSTOP to consumer daemon"
851 function sigstop_lttng_consumerd
()
853 sigstop_lttng_consumerd_opt
1 "$@"
856 function sigstop_lttng_consumerd_notap
()
858 sigstop_lttng_consumerd_opt
0 "$@"
861 function list_lttng_with_opts
()
864 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
865 ok $?
"Lttng-tool list command with option $opts"
868 function create_lttng_session_no_output
()
873 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
874 ok $?
"Create session $sess_name in no-output mode"
877 function create_lttng_session_uri
() {
882 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
883 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
886 function create_lttng_session
()
889 local expected_to_fail
=$2
894 if [ -z "$trace_path" ]; then
895 # Use lttng-sessiond default output.
898 trace_path
="-o $trace_path"
901 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
903 if [ $expected_to_fail -eq "1" ]; then
906 if [ $withtap -eq "1" ]; then
907 ok
$ret "Create session $sess_name in $trace_path failed as expected"
910 if [ $withtap -eq "1" ]; then
911 ok
$ret "Create session $sess_name in $trace_path"
917 function create_lttng_session_ok
()
919 create_lttng_session
1 0 "$@"
922 function create_lttng_session_fail
()
924 create_lttng_session
1 1 "$@"
927 function create_lttng_session_notap
()
929 create_lttng_session
0 0 "$@"
933 function enable_ust_lttng_channel
()
936 local expected_to_fail
=$2
938 local channel_name
=$4
941 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
943 if [[ $expected_to_fail -eq "1" ]]; then
946 if [ $withtap -eq "1" ]; then
947 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
950 if [ $withtap -eq "1" ]; then
951 ok
$ret "Enable channel $channel_name for session $sess_name"
957 function enable_ust_lttng_channel_ok
()
959 enable_ust_lttng_channel
1 0 "$@"
962 function enable_ust_lttng_channel_fail
()
964 enable_ust_lttng_channel
1 1 "$@"
967 function enable_ust_lttng_channel_notap
()
969 enable_ust_lttng_channel
0 0 "$@"
972 function disable_ust_lttng_channel
()
975 local channel_name
=$2
977 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
978 ok $?
"Disable channel $channel_name for session $sess_name"
981 function enable_lttng_mmap_overwrite_kernel_channel
()
984 local channel_name
=$2
986 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
987 ok $?
"Enable channel $channel_name for session $sess_name"
990 function enable_lttng_mmap_discard_small_kernel_channel
()
993 local channel_name
=$2
995 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--discard --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
996 ok $?
"Enable small discard channel $channel_name for session $sess_name"
999 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1002 local channel_name
=$2
1004 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1005 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1008 function enable_lttng_mmap_overwrite_ust_channel
()
1011 local channel_name
=$2
1013 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1014 ok $?
"Enable channel $channel_name for session $sess_name"
1017 function enable_ust_lttng_event
()
1020 local expected_to_fail
=$2
1022 local event_name
="$4"
1023 local channel_name
=$5
1025 if [ -z $channel_name ]; then
1026 # default channel if none specified
1029 chan
="-c $channel_name"
1032 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1034 if [[ $expected_to_fail -eq "1" ]]; then
1037 if [[ $withtap -eq "1" ]]; then
1038 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1041 if [[ $withtap -eq "1" ]]; then
1042 ok
$ret "Enable ust event $event_name for session $sess_name"
1048 function enable_ust_lttng_event_ok
()
1050 enable_ust_lttng_event
1 0 "$@"
1053 function enable_ust_lttng_event_fail
()
1055 enable_ust_lttng_event
1 1 "$@"
1058 function enable_ust_lttng_event_notap
()
1060 enable_ust_lttng_event
0 0 "$@"
1063 function enable_jul_lttng_event
()
1069 if [ -z $channel_name ]; then
1070 # default channel if none specified
1073 chan
="-c $channel_name"
1076 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1077 ok $?
"Enable JUL event $event_name for session $sess_name"
1080 function enable_jul_lttng_event_loglevel
()
1083 local event_name
="$2"
1085 local channel_name
=$4
1087 if [ -z $channel_name ]; then
1088 # default channel if none specified
1091 chan
="-c $channel_name"
1094 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1095 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1098 function enable_log4j_lttng_event
()
1104 if [ -z $channel_name ]; then
1105 # default channel if none specified
1108 chan
="-c $channel_name"
1111 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1112 ok $?
"Enable LOG4J event $event_name for session $sess_name"
1115 function enable_log4j_lttng_event_loglevel
()
1118 local event_name
="$2"
1120 local channel_name
=$4
1122 if [ -z $channel_name ]; then
1123 # default channel if none specified
1126 chan
="-c $channel_name"
1129 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1130 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
1133 function enable_python_lttng_event
()
1139 if [ -z $channel_name ]; then
1140 # default channel if none specified
1143 chan
="-c $channel_name"
1146 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1147 ok $?
"Enable Python event $event_name for session $sess_name"
1150 function enable_python_lttng_event_loglevel
()
1153 local event_name
="$2"
1155 local channel_name
=$4
1157 if [ -z $channel_name ]; then
1158 # default channel if none specified
1161 chan
="-c $channel_name"
1164 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1165 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1168 function enable_ust_lttng_event_filter
()
1170 local sess_name
="$1"
1171 local event_name
="$2"
1174 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1175 ok $?
"Enable event $event_name with filtering for session $sess_name"
1178 function enable_ust_lttng_event_loglevel
()
1180 local sess_name
="$1"
1181 local event_name
="$2"
1184 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1185 ok $?
"Enable event $event_name with loglevel $loglevel"
1188 function enable_ust_lttng_event_loglevel_only
()
1190 local sess_name
="$1"
1191 local event_name
="$2"
1194 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1195 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1198 function disable_ust_lttng_event
()
1200 local sess_name
="$1"
1201 local event_name
="$2"
1202 local channel_name
="$3"
1204 if [ -z $channel_name ]; then
1205 # default channel if none specified
1208 chan
="-c $channel_name"
1211 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1212 ok $?
"Disable event $event_name for session $sess_name"
1215 function disable_jul_lttng_event
()
1217 local sess_name
="$1"
1218 local event_name
="$2"
1220 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1221 ok $?
"Disable JUL event $event_name for session $sess_name"
1224 function disable_log4j_lttng_event
()
1226 local sess_name
="$1"
1227 local event_name
="$2"
1229 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1230 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1233 function disable_python_lttng_event
()
1235 local sess_name
="$1"
1236 local event_name
="$2"
1238 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1239 ok $?
"Disable Python event $event_name for session $sess_name"
1242 function start_lttng_tracing_opt
()
1245 local expected_to_fail
=$2
1248 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1250 if [[ $expected_to_fail -eq "1" ]]; then
1253 if [ $withtap -eq "1" ]; then
1254 ok $?
"Start tracing for session $sess_name failed as expected"
1257 if [ $withtap -eq "1" ]; then
1258 ok
$ret "Start tracing for session $sess_name"
1263 function start_lttng_tracing_ok
()
1265 start_lttng_tracing_opt
1 0 "$@"
1268 function start_lttng_tracing_fail
()
1270 start_lttng_tracing_opt
1 1 "$@"
1273 function start_lttng_tracing_notap
()
1275 start_lttng_tracing_opt
0 1 "$@"
1278 function stop_lttng_tracing_opt
()
1281 local expected_to_fail
=$2
1284 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1286 if [[ $expected_to_fail -eq "1" ]]; then
1289 if [ $withtap -eq "1" ]; then
1290 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1293 if [ $withtap -eq "1" ]; then
1294 ok
$ret "Stop lttng tracing for session $sess_name"
1299 function stop_lttng_tracing_ok
()
1301 stop_lttng_tracing_opt
1 0 "$@"
1304 function stop_lttng_tracing_fail
()
1306 stop_lttng_tracing_opt
1 1 "$@"
1309 function stop_lttng_tracing_notap
()
1311 stop_lttng_tracing_opt
0 0 "$@"
1314 function destroy_lttng_session
()
1317 local expected_to_fail
=$2
1320 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1322 if [[ $expected_to_fail -eq "1" ]]; then
1325 if [ $withtap -eq "1" ]; then
1326 ok
$ret "Destroy session $sess_name failed as expected"
1329 if [ $withtap -eq "1" ]; then
1330 ok
$ret "Destroy session $sess_name"
1335 function destroy_lttng_session_ok
()
1337 destroy_lttng_session
1 0 "$@"
1341 function destroy_lttng_session_fail
()
1343 destroy_lttng_session
1 1 "$@"
1346 function destroy_lttng_session_notap
()
1348 destroy_lttng_session
0 0 "$@"
1351 function destroy_lttng_sessions
()
1353 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1354 ok $?
"Destroy all lttng sessions"
1357 function lttng_snapshot_add_output
()
1359 local expected_to_fail
=$1
1364 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1366 if [[ $expected_to_fail -eq 1 ]]; then
1368 ok $?
"Added snapshot output $trace_path failed as expected"
1370 ok
$ret "Added snapshot output $trace_path"
1374 function lttng_snapshot_add_output_ok
()
1376 lttng_snapshot_add_output
0 "$@"
1379 function lttng_snapshot_add_output_fail
()
1381 lttng_snapshot_add_output
1 "$@"
1384 function lttng_snapshot_del_output
()
1386 local expected_to_fail
=$1
1390 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1392 if [[ $expected_to_fail -eq "1" ]]; then
1394 ok $?
"Deleted snapshot output id $id failed as expected"
1396 ok
$ret "Deleted snapshot output id $id"
1400 function lttng_snapshot_del_output_ok
()
1402 lttng_snapshot_del_output
0 "$@"
1405 function lttng_snapshot_del_output_fail
()
1407 lttng_snapshot_del_output
1 "$@"
1410 function lttng_snapshot_record
()
1414 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1415 ok $?
"Snapshot recorded"
1418 function lttng_snapshot_list
()
1421 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1422 ok $?
"Snapshot list"
1425 function lttng_save
()
1430 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1431 ok $?
"Session saved"
1434 function lttng_load
()
1436 local expected_to_fail
=$1
1439 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1441 if [[ $expected_to_fail -eq "1" ]]; then
1443 ok $?
"Load command failed as expected with opts: $opts"
1445 ok
$ret "Load command with opts: $opts"
1449 function lttng_load_ok
()
1454 function lttng_load_fail
()
1459 function lttng_track
()
1461 local expected_to_fail
="$1"
1464 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1466 if [[ $expected_to_fail -eq "1" ]]; then
1468 ok $?
"Track command failed as expected with opts: $opts"
1470 ok
$ret "Track command with opts: $opts"
1474 function lttng_track_ok
()
1479 function lttng_track_fail
()
1484 function lttng_untrack
()
1486 local expected_to_fail
="$1"
1489 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1491 if [[ $expected_to_fail -eq "1" ]]; then
1493 ok $?
"Untrack command failed as expected with opts: $opts"
1495 ok
$ret "Untrack command with opts: $opts"
1499 function lttng_untrack_ok
()
1501 lttng_untrack
0 "$@"
1504 function lttng_untrack_fail
()
1506 lttng_untrack
1 "$@"
1509 function lttng_track_pid_ok
()
1512 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1513 ok $?
"Lttng track pid on the kernel domain"
1516 function lttng_untrack_kernel_all_ok
()
1518 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1519 ok $?
"Lttng untrack all pid on the kernel domain"
1522 function lttng_track_ust_ok
()
1524 lttng_track_ok
-u "$@"
1527 function lttng_track_ust_fail
()
1529 lttng_track_fail
-u "$@"
1532 function lttng_track_kernel_ok
()
1534 lttng_track_ok
-k "$@"
1537 function lttng_track_kernel_fail
()
1539 lttng_track_fail
-k "$@"
1542 function lttng_untrack_ust_ok
()
1544 lttng_untrack_ok
-u "$@"
1547 function lttng_untrack_ust_fail
()
1549 lttng_untrack_fail
-u "$@"
1552 function lttng_untrack_kernel_ok
()
1554 lttng_untrack_ok
-k "$@"
1557 function lttng_untrack_kernel_fail
()
1559 lttng_untrack_fail
-k "$@"
1562 function lttng_add_context_list
()
1564 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1566 ok
$ret "Context listing"
1569 function add_context_lttng
()
1571 local expected_to_fail
="$1"
1573 local session_name
="$3"
1574 local channel_name
="$4"
1577 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1579 if [[ $expected_to_fail -eq "1" ]]; then
1581 ok $?
"Add context command failed as expected for type: $type"
1583 ok
$ret "Add context command for type: $type"
1587 function add_context_ust_ok
()
1589 add_context_lttng
0 -u "$@"
1592 function add_context_ust_fail
()
1594 add_context_lttng
1 -u "$@"
1597 function add_context_kernel_ok
()
1599 add_context_lttng
0 -k "$@"
1602 function add_context_kernel_fail
()
1604 add_context_lttng
1 -k "$@"
1607 function validate_directory_empty
()
1611 ls -A $local_path > /dev
/null
2>&1
1612 if [ $?
-eq 0 ]; then
1613 pass
"Directory empty"
1615 fail
"Directory empty"
1619 function wait_live_trace_ready
()
1622 local zero_client_match
=0
1624 diag
"Waiting for live trace at url: $url"
1625 while [ $zero_client_match -eq 0 ]; do
1626 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
1629 pass
"Waiting for live trace at url: $url"
1632 function wait_live_viewer_connect
()
1635 local one_client_match
=0
1637 diag
"Waiting for live viewers on url: $url"
1638 while [ $one_client_match -eq 0 ]; do
1639 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
1642 pass
"Waiting for live viewers on url: $url"
1645 function validate_metadata_event
()
1648 local nr_event_id
=$2
1651 local metadata_file
=$
(find $trace_path |
grep metadata
)
1652 local metadata_path
=$
(dirname $metadata_file)
1654 which $BABELTRACE_BIN >/dev
/null
1655 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1657 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1659 if [ "$count" -ne "$nr_event_id" ]; then
1660 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1661 diag
"$count matching event id found in metadata"
1663 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1668 function trace_matches
()
1674 which $BABELTRACE_BIN >/dev
/null
1675 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1677 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1679 if [ "$count" -ne "$nr_iter" ]; then
1681 diag
"$count matching events found in trace"
1687 function trace_match_only
()
1693 which $BABELTRACE_BIN >/dev
/null
1694 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1696 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1697 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1699 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1700 pass
"Trace match with $total event $event_name"
1703 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1707 function validate_trace
1712 which $BABELTRACE_BIN >/dev
/null
1713 if [ $?
-ne 0 ]; then
1714 skip
0 "Babeltrace binary not found. Skipping trace validation"
1719 for i
in $event_name; do
1720 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1721 if [ "$traced" -ne 0 ]; then
1722 pass
"Validate trace for event $i, $traced events"
1724 fail
"Validate trace for event $i"
1725 diag
"Found $traced occurences of $i"
1733 function validate_trace_count
1737 local expected_count
=$3
1739 which $BABELTRACE_BIN >/dev
/null
1740 if [ $?
-ne 0 ]; then
1741 skip
0 "Babeltrace binary not found. Skipping trace validation"
1747 for i
in $event_name; do
1748 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1749 if [ "$traced" -ne 0 ]; then
1750 pass
"Validate trace for event $i, $traced events"
1752 fail
"Validate trace for event $i"
1753 diag
"Found $traced occurences of $i"
1755 cnt
=$
(($cnt + $traced))
1758 test $cnt -eq $expected_count
1759 ok $?
"Read a total of $cnt events, expected $expected_count"
1762 function validate_trace_count_range_incl_min_excl_max
1766 local expected_min
=$3
1767 local expected_max
=$4
1769 which $BABELTRACE_BIN >/dev
/null
1770 if [ $?
-ne 0 ]; then
1771 skip
0 "Babeltrace binary not found. Skipping trace validation"
1777 for i
in $event_name; do
1778 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1779 if [ "$traced" -ge $expected_min ]; then
1780 pass
"Validate trace for event $i, $traced events"
1782 fail
"Validate trace for event $i"
1783 diag
"Found $traced occurences of $i"
1785 cnt
=$
(($cnt + $traced))
1788 test $cnt -lt $expected_max
1789 ok $?
"Read a total of $cnt events, expected between [$expected_min, $expected_max["
1792 function trace_first_line
1796 which $BABELTRACE_BIN >/dev
/null
1797 if [ $?
-ne 0 ]; then
1798 skip
0 "Babeltrace binary not found. Skipping trace validation"
1801 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1804 function validate_trace_exp
()
1809 which $BABELTRACE_BIN >/dev
/null
1810 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1812 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
1813 if [ "$traced" -ne 0 ]; then
1814 pass
"Validate trace for expression '${event_exp}', $traced events"
1816 fail
"Validate trace for expression '${event_exp}'"
1817 diag
"Found $traced occurences of '${event_exp}'"
1823 function validate_trace_only_exp
()
1828 which $BABELTRACE_BIN >/dev
/null
1829 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1831 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
1832 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1834 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1835 pass
"Trace match with $total for expression '${event_exp}'"
1838 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1844 function validate_trace_empty
()
1848 which $BABELTRACE_BIN >/dev
/null
1849 if [ $?
-ne 0 ]; then
1850 skip
0 "Babeltrace binary not found. Skipping trace validation"
1853 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1855 if [ $ret -ne 0 ]; then
1856 fail
"Failed to parse trace"
1860 traced
=$
(echo -n "$events" |
wc -l)
1861 if [ "$traced" -eq 0 ]; then
1862 pass
"Validate empty trace"
1864 fail
"Validate empty trace"
1865 diag
"Found $traced events in trace"
1871 function validate_folder_is_empty
()
1875 test -z "$(ls -A "$folder")"
1876 ok $?
"Folder ${folder} is empty"
1879 function validate_trace_session_ust_empty
()
1881 validate_folder_is_empty
"$1"/ust
1884 function validate_trace_session_kernel_empty
()
1886 validate_trace_empty
"$1"/kernel
1889 function regenerate_metadata
()
1891 local expected_to_fail
=$1
1894 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1896 if [[ $expected_to_fail -eq "1" ]]; then
1898 ok $?
"Expected fail on regenerate metadata $sess_name"
1900 ok
$ret "Metadata regenerate $sess_name"
1904 function regenerate_metadata_ok
()
1906 regenerate_metadata
0 "$@"
1909 function regenerate_metadata_fail
()
1911 regenerate_metadata
1 "$@"
1914 function regenerate_statedump
()
1916 local expected_to_fail
=$1
1919 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1921 if [[ $expected_to_fail -eq "1" ]]; then
1923 ok $?
"Expected fail on regenerate statedump $sess_name"
1925 ok
$ret "Statedump regenerate $sess_name"
1929 function regenerate_statedump_ok
()
1931 regenerate_statedump
0 "$@"
1934 function regenerate_statedump_fail
()
1936 regenerate_statedump
1 "$@"
1939 function rotate_session
()
1941 local expected_to_fail
=$1
1944 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1946 if [[ $expected_to_fail -eq "1" ]]; then
1948 ok $?
"Expected fail on rotate session $sess_name"
1950 ok
$ret "Rotate session $sess_name"
1954 function rotate_session_ok
()
1956 rotate_session
0 "$@"
1959 function rotate_session_fail
()
1961 rotate_session
1 "$@"
1964 function destructive_tests_enabled
()
1966 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
1973 function lttng_enable_rotation_timer
()
1975 local expected_to_fail
=$1
1979 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1981 if [[ $expected_to_fail -eq "1" ]]; then
1983 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
1985 ok
$ret "Set periodic rotation ($period) of session $sess_name"
1989 function lttng_enable_rotation_timer_ok
()
1991 lttng_enable_rotation_timer
0 $@
1994 function lttng_enable_rotation_timer_fail
()
1996 lttng_enable_rotation_timer
1 $@
1999 function lttng_enable_rotation_size
()
2001 local expected_to_fail
=$1
2005 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2007 if [[ $expected_to_fail -eq "1" ]]; then
2009 ok $?
"Expected fail on rotate session $sess_name"
2011 ok
$ret "Rotate session $sess_name"
2015 function lttng_enable_rotation_size_ok
()
2017 lttng_enable_rotation_size
0 $@
2020 function lttng_enable_rotation_size_fail
()
2022 lttng_enable_rotation_size
1 $@
2025 function lttng_clear_session
()
2027 local expected_to_fail
=$1
2030 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2032 if [[ $expected_to_fail -eq "1" ]]; then
2034 ok $?
"Expected fail on clear session $sess_name"
2036 ok
$ret "Clear session $sess_name"
2040 function lttng_clear_session_ok
()
2042 lttng_clear_session
0 $@
2045 function lttng_clear_session_fail
()
2047 lttng_clear_session
1 $@
2050 function lttng_clear_all
()
2052 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2053 ok $?
"Clear all lttng sessions"