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
77 # Check pgrep from env, default to pgrep if none
78 if [ -z "$PGREP" ]; then
82 # Due to the renaming of threads we need to use the full command (pgrep -f) to
83 # identify the pids for multiple lttng related processes. The problem with "pgrep
84 # -f" is that it ends up also looking at the arguments. We use a two stage
85 # lookup. The first one is using "pgrep -f" yielding potential candidate.
86 # The second on perform grep on the basename of the first field of the
87 # /proc/pid/cmdline of the previously identified pids. The first field
88 # correspond to the actual command.
89 function lttng_pgrep
()
93 local full_command_no_argument
94 local command_basename
96 possible_pids
=$
($PGREP -f "$pattern")
97 if [ -z "$possible_pids" ]; then
101 while IFS
= read -r pid
; do
102 # /proc/pid/cmdline is null separated.
103 if full_command_no_argument
=$
(cut
-d '' -f 1 2>/dev
/null
< /proc
/"$pid"/cmdline
); then
104 command_basename
=$
(basename "$full_command_no_argument")
105 if grep -q "$pattern" <<< "$command_basename"; then
109 done <<< "$possible_pids"
115 # Check if we are a terminal
117 echo -e "\e[1;32mOK\e[0m"
123 function print_fail
()
125 # Check if we are a terminal
127 echo -e "\e[1;31mFAIL\e[0m"
133 function print_test_banner
()
139 function validate_kernel_version
()
141 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
142 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
145 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
148 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
154 # Generate a random string
155 # $1 = number of characters; defaults to 16
156 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
157 function randstring
()
159 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
160 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
164 # Return the number of _configured_ CPUs.
165 function conf_proc_count
()
167 getconf _NPROCESSORS_CONF
168 if [ $?
-ne 0 ]; then
169 diag
"Failed to get the number of configured CPUs"
174 # Check if base lttng-modules are present.
175 # Bail out on failure
176 function validate_lttng_modules_present
()
178 # Check for loadable modules.
179 modprobe
-n lttng-tracer
2>/dev
/null
180 if [ $?
-eq 0 ]; then
184 # Check for builtin modules.
185 ls /proc
/lttng
> /dev
/null
2>&1
186 if [ $?
-eq 0 ]; then
190 BAIL_OUT
"LTTng modules not detected."
193 function enable_kernel_lttng_event
196 local expected_to_fail
="$2"
198 local event_name
="$4"
199 local channel_name
="$5"
201 if [ -z "$event_name" ]; then
202 # Enable all event if no event name specified
206 if [ -z "$channel_name" ]; then
207 # default channel if none specified
210 chan
="-c $channel_name"
213 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
215 if [[ $expected_to_fail -eq "1" ]]; then
218 if [ $withtap -eq "1" ]; then
219 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
222 if [ $withtap -eq "1" ]; then
223 ok
$ret "Enable kernel event $event_name for session $sess_name"
228 function enable_kernel_lttng_event_ok
()
230 enable_kernel_lttng_event
1 0 "$@"
233 function enable_kernel_lttng_event_fail
()
235 enable_kernel_lttng_event
1 1 "$@"
238 function enable_kernel_lttng_event_notap
()
240 enable_kernel_lttng_event
0 0 "$@"
244 function lttng_enable_kernel_event
246 enable_kernel_lttng_event_ok
"$@"
249 function lttng_enable_kernel_syscall
()
251 local expected_to_fail
=$1
253 local syscall_name
=$3
254 local channel_name
=$4
256 if [ -z $syscall_name ]; then
257 # Enable all event if no syscall name specified
261 if [ -z $channel_name ]; then
262 # default channel if none specified
265 chan
="-c $channel_name"
268 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
270 if [[ $expected_to_fail -eq "1" ]]; then
272 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
274 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
278 function lttng_enable_kernel_syscall_ok
()
280 lttng_enable_kernel_syscall
0 "$@"
283 function lttng_enable_kernel_syscall_fail
()
285 lttng_enable_kernel_syscall
1 "$@"
288 function lttng_disable_kernel_syscall
()
290 local expected_to_fail
=$1
292 local syscall_name
=$3
293 local channel_name
=$4
295 if [ -z $syscall_name ]; then
296 # Enable all event if no syscall name specified
300 if [ -z $channel_name ]; then
301 # default channel if none specified
304 chan
="-c $channel_name"
307 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
310 if [[ $expected_to_fail -eq "1" ]]; then
312 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
314 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
318 function lttng_disable_kernel_syscall_ok
()
320 lttng_disable_kernel_syscall
0 "$@"
323 function lttng_disable_kernel_syscall_fail
()
325 lttng_disable_kernel_syscall
1 "$@"
328 function lttng_enable_kernel_userspace_probe_event
()
330 local expected_to_fail
="$1"
333 local event_name
="$4"
335 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
337 if [[ $expected_to_fail -eq "1" ]]; then
339 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
341 ok
$ret "Enable kernel userspace probe event for session $sess_name"
345 function lttng_enable_kernel_userspace_probe_event_fail
()
347 lttng_enable_kernel_userspace_probe_event
1 "$@"
350 function lttng_enable_kernel_userspace_probe_event_ok
()
352 lttng_enable_kernel_userspace_probe_event
0 "$@"
355 function disable_kernel_lttng_userspace_probe_event_ok
()
358 local event_name
="$2"
360 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
361 ok $?
"Disable kernel event $target for session $sess_name"
363 function lttng_enable_kernel_channel
()
366 local expected_to_fail
=$2
368 local channel_name
=$4
371 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
373 if [[ $expected_to_fail -eq "1" ]]; then
376 if [ $withtap -eq "1" ]; then
377 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
380 if [ $withtap -eq "1" ]; then
381 ok
$ret "Enable channel $channel_name for session $sess_name"
386 function lttng_enable_kernel_channel_ok
()
388 lttng_enable_kernel_channel
1 0 "$@"
391 function lttng_enable_kernel_channel_fail
()
393 lttng_enable_kernel_channel
1 1 "$@"
396 function lttng_enable_kernel_channel_notap
()
398 lttng_enable_kernel_channel
0 0 "$@"
401 function enable_kernel_lttng_channel_ok
()
403 lttng_enable_kernel_channel
1 0 "$@"
406 function lttng_disable_kernel_channel
()
408 local expected_to_fail
=$1
410 local channel_name
=$3
412 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
414 if [[ $expected_to_fail -eq "1" ]]; then
416 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
418 ok
$ret "Disable channel $channel_name for session $sess_name"
422 function lttng_disable_kernel_channel_ok
()
424 lttng_disable_kernel_channel
0 "$@"
427 function lttng_disable_kernel_channel_fail
()
429 lttng_disable_kernel_channel
1 "$@"
432 function start_lttng_relayd_opt
()
435 local process_mode
=$2
438 DIR
=$
(readlink
-f "$TESTDIR")
440 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
441 # shellcheck disable=SC2086
442 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
443 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
444 if [ $?
-eq 1 ]; then
445 if [ $withtap -eq "1" ]; then
446 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
450 if [ $withtap -eq "1" ]; then
451 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
455 pass
"Start lttng-relayd (opt: $opt)"
459 function start_lttng_relayd
()
461 start_lttng_relayd_opt
1 "-b" "$@"
464 function start_lttng_relayd_notap
()
466 start_lttng_relayd_opt
0 "-b" "$@"
469 function stop_lttng_relayd_opt
()
474 if [ -z "$signal" ]; then
481 # Multiply time by 2 to simplify integer arithmetic
482 if [ -n "$timeout_s" ]; then
483 dtimeleft_s
=$
((timeout_s
* 2))
489 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
490 if [ -z "$pids" ]; then
491 if [ "$withtap" -eq "1" ]; then
492 pass
"No relay daemon to kill"
497 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
499 # shellcheck disable=SC2086
500 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
502 if [ "$withtap" -eq "1" ]; then
503 fail
"Kill relay daemon"
507 while [ -n "$out" ]; do
508 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
509 if [ -n "$dtimeleft_s" ]; then
510 if [ $dtimeleft_s -lt 0 ]; then
514 dtimeleft_s
=$
((dtimeleft_s
- 1))
518 if [ "$withtap" -eq "1" ]; then
519 if [ "$retval" -eq "0" ]; then
520 pass
"Wait after kill relay daemon"
522 fail
"Wait after kill relay daemon"
529 function stop_lttng_relayd
()
531 stop_lttng_relayd_opt
1 "$@"
534 function stop_lttng_relayd_notap
()
536 stop_lttng_relayd_opt
0 "$@"
539 #First arg: show tap output
540 #Second argument: load path for automatic loading
541 function start_lttng_sessiond_opt
()
549 local long_bit_value
=
550 long_bit_value
=$
(getconf LONG_BIT
)
552 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
553 # Env variable requested no session daemon
557 DIR
=$
(readlink
-f "$TESTDIR")
559 # Get long_bit value for 32/64 consumerd
560 case "$long_bit_value" in
562 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
565 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
572 # Check for env. variable. Allow the use of LD_PRELOAD etc.
573 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
574 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
576 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
578 if ! validate_kernel_version
; then
579 fail
"Start session daemon"
580 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
583 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
584 export LTTNG_SESSION_CONFIG_XSD_PATH
586 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
588 if [ -n "$load_path" ]; then
589 # shellcheck disable=SC2086
590 env
$env_vars --load "$load_path" --background "$consumerd"
592 # shellcheck disable=SC2086
593 env
$env_vars --background "$consumerd"
595 #$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
597 if [ "$withtap" -eq "1" ]; then
598 ok
$status "Start session daemon"
603 function start_lttng_sessiond
()
605 start_lttng_sessiond_opt
1 "$@"
608 function start_lttng_sessiond_notap
()
610 start_lttng_sessiond_opt
0 "$@"
613 function stop_lttng_sessiond_opt
()
618 if [ -z "$signal" ]; then
625 # Multiply time by 2 to simplify integer arithmetic
626 if [ -n "$timeout_s" ]; then
627 dtimeleft_s
=$
((timeout_s
* 2))
630 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
631 # Env variable requested no session daemon
638 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
641 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
643 if [ -n "$runas_pids" ]; then
644 pids
="$pids $runas_pids"
647 if [ -z "$pids" ]; then
648 if [ "$withtap" -eq "1" ]; then
649 fail
"No session daemon to kill"
651 BAIL_OUT
"No session daemon to kill"
656 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
658 # shellcheck disable=SC2086
659 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
661 if [ "$withtap" -eq "1" ]; then
662 fail
"Kill sessions daemon"
666 while [ -n "$out" ]; do
667 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
668 if [ -n "$dtimeleft_s" ]; then
669 if [ $dtimeleft_s -lt 0 ]; then
673 dtimeleft_s
=$
((dtimeleft_s
- 1))
678 while [ -n "$out" ]; do
679 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
680 if [ -n "$dtimeleft_s" ]; then
681 if [ $dtimeleft_s -lt 0 ]; then
685 dtimeleft_s
=$
((dtimeleft_s
- 1))
690 if [ "$withtap" -eq "1" ]; then
691 if [ "$retval" -eq "0" ]; then
692 pass
"Wait after kill session daemon"
694 fail
"Wait after kill session daemon"
698 if [ "$signal" = "SIGKILL" ]; then
699 if [ "$(id -u)" -eq "0" ]; then
701 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
703 if [ -n "$modules" ]; then
704 diag
"Unloading all LTTng modules"
705 modprobe
--remove "$modules"
713 function stop_lttng_sessiond
()
715 stop_lttng_sessiond_opt
1 "$@"
718 function stop_lttng_sessiond_notap
()
720 stop_lttng_sessiond_opt
0 "$@"
723 function sigstop_lttng_sessiond_opt
()
728 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
729 # Env variable requested no session daemon
733 PID_SESSIOND
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
735 if [ "$withtap" -eq "1" ]; then
736 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$PID_SESSIOND" | tr '\n' ' ')"
739 # shellcheck disable=SC2086
740 if ! kill -s $signal $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
741 if [ "$withtap" -eq "1" ]; then
742 fail
"Sending SIGSTOP to session daemon"
746 while [ $out -ne 0 ]; do
747 pid
="$(lttng_pgrep "$SESSIOND_MATCH")"
749 # Wait until state becomes stopped for session
752 for sessiond_pid
in $pid; do
753 state
="$(ps -p "$sessiond_pid" -o state= )"
754 if [[ -n "$state" && "$state" != "T" ]]; then
760 if [ "$withtap" -eq "1" ]; then
761 pass
"Sending SIGSTOP to session daemon"
766 function sigstop_lttng_sessiond
()
768 sigstop_lttng_sessiond_opt
1 "$@"
771 function sigstop_lttng_sessiond_notap
()
773 sigstop_lttng_sessiond_opt
0 "$@"
776 function stop_lttng_consumerd_opt
()
781 if [ -z "$signal" ]; then
788 # Multiply time by 2 to simplify integer arithmetic
789 if [ -n "$timeout_s" ]; then
790 dtimeleft_s
=$
((timeout_s
* 2))
795 PID_CONSUMERD
="$(lttng_pgrep "$CONSUMERD_MATCH")"
797 if [ -z "$PID_CONSUMERD" ]; then
798 if [ "$withtap" -eq "1" ]; then
799 pass
"No consumer daemon to kill"
804 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
806 # shellcheck disable=SC2086
807 if ! kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
809 if [ "$withtap" -eq "1" ]; then
810 fail
"Kill consumer daemon"
814 while [ $out -ne 0 ]; do
815 pid
="$(lttng_pgrep "$CONSUMERD_MATCH")"
817 # If consumerds are still present check their status.
818 # A zombie status qualifies the consumerd as *killed*
820 for consumer_pid
in $pid; do
821 state
="$(ps -p "$consumer_pid" -o state= )"
822 if [[ -n "$state" && "$state" != "Z" ]]; then
826 if [ -n "$dtimeleft_s" ]; then
827 if [ $dtimeleft_s -lt 0 ]; then
831 dtimeleft_s
=$
((dtimeleft_s
- 1))
835 if [ "$withtap" -eq "1" ]; then
836 if [ "$retval" -eq "0" ]; then
837 pass
"Wait after kill consumer daemon"
839 fail
"Wait after kill consumer daemon"
847 function stop_lttng_consumerd
()
849 stop_lttng_consumerd_opt
1 "$@"
852 function stop_lttng_consumerd_notap
()
854 stop_lttng_consumerd_opt
0 "$@"
857 function sigstop_lttng_consumerd_opt
()
862 PID_CONSUMERD
="$(lttng_pgrep "$CONSUMERD_MATCH")"
864 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
866 # shellcheck disable=SC2086
867 kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
870 if [ $retval -eq 1 ]; then
871 if [ "$withtap" -eq "1" ]; then
872 fail
"Sending SIGSTOP to consumer daemon"
877 while [ $out -ne 0 ]; do
878 pid
="$(lttng_pgrep "$CONSUMERD_MATCH")"
880 # Wait until state becomes stopped for all
883 for consumer_pid
in $pid; do
884 state
="$(ps -p "$consumer_pid" -o state= )"
885 if [[ -n "$state" && "$state" != "T" ]]; then
891 if [ "$withtap" -eq "1" ]; then
892 pass
"Sending SIGSTOP to consumer daemon"
898 function sigstop_lttng_consumerd
()
900 sigstop_lttng_consumerd_opt
1 "$@"
903 function sigstop_lttng_consumerd_notap
()
905 sigstop_lttng_consumerd_opt
0 "$@"
908 function list_lttng_with_opts
()
911 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
912 ok $?
"Lttng-tool list command with option $opts"
915 function create_lttng_session_no_output
()
920 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
921 ok $?
"Create session $sess_name in no-output mode"
924 function create_lttng_session_uri
() {
929 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
930 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
933 function create_lttng_session
()
936 local expected_to_fail
=$2
941 if [ -z "$trace_path" ]; then
942 # Use lttng-sessiond default output.
945 trace_path
="-o $trace_path"
948 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
950 if [ $expected_to_fail -eq "1" ]; then
953 if [ $withtap -eq "1" ]; then
954 ok
$ret "Create session $sess_name in $trace_path failed as expected"
957 if [ $withtap -eq "1" ]; then
958 ok
$ret "Create session $sess_name in $trace_path"
964 function create_lttng_session_ok
()
966 create_lttng_session
1 0 "$@"
969 function create_lttng_session_fail
()
971 create_lttng_session
1 1 "$@"
974 function create_lttng_session_notap
()
976 create_lttng_session
0 0 "$@"
980 function enable_ust_lttng_channel
()
983 local expected_to_fail
=$2
985 local channel_name
=$4
988 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
990 if [[ $expected_to_fail -eq "1" ]]; then
993 if [ $withtap -eq "1" ]; then
994 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
997 if [ $withtap -eq "1" ]; then
998 ok
$ret "Enable channel $channel_name for session $sess_name"
1004 function enable_ust_lttng_channel_ok
()
1006 enable_ust_lttng_channel
1 0 "$@"
1009 function enable_ust_lttng_channel_fail
()
1011 enable_ust_lttng_channel
1 1 "$@"
1014 function enable_ust_lttng_channel_notap
()
1016 enable_ust_lttng_channel
0 0 "$@"
1019 function disable_ust_lttng_channel
()
1022 local channel_name
=$2
1024 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1025 ok $?
"Disable channel $channel_name for session $sess_name"
1028 function enable_lttng_mmap_overwrite_kernel_channel
()
1031 local channel_name
=$2
1033 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1034 ok $?
"Enable channel $channel_name for session $sess_name"
1037 function enable_lttng_mmap_discard_small_kernel_channel
()
1040 local channel_name
=$2
1042 $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
1043 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1046 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1049 local channel_name
=$2
1051 $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
1052 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1055 function enable_lttng_mmap_overwrite_ust_channel
()
1058 local channel_name
=$2
1060 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1061 ok $?
"Enable channel $channel_name for session $sess_name"
1064 function enable_ust_lttng_event
()
1067 local expected_to_fail
=$2
1069 local event_name
="$4"
1070 local channel_name
=$5
1072 if [ -z $channel_name ]; then
1073 # default channel if none specified
1076 chan
="-c $channel_name"
1079 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1081 if [[ $expected_to_fail -eq "1" ]]; then
1084 if [[ $withtap -eq "1" ]]; then
1085 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1088 if [[ $withtap -eq "1" ]]; then
1089 ok
$ret "Enable ust event $event_name for session $sess_name"
1095 function enable_ust_lttng_event_ok
()
1097 enable_ust_lttng_event
1 0 "$@"
1100 function enable_ust_lttng_event_fail
()
1102 enable_ust_lttng_event
1 1 "$@"
1105 function enable_ust_lttng_event_notap
()
1107 enable_ust_lttng_event
0 0 "$@"
1110 function enable_jul_lttng_event
()
1116 if [ -z $channel_name ]; then
1117 # default channel if none specified
1120 chan
="-c $channel_name"
1123 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1124 ok $?
"Enable JUL event $event_name for session $sess_name"
1127 function enable_jul_lttng_event_loglevel
()
1130 local event_name
="$2"
1132 local channel_name
=$4
1134 if [ -z $channel_name ]; then
1135 # default channel if none specified
1138 chan
="-c $channel_name"
1141 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1142 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1145 function enable_log4j_lttng_event
()
1151 if [ -z $channel_name ]; then
1152 # default channel if none specified
1155 chan
="-c $channel_name"
1158 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1159 ok $?
"Enable LOG4J event $event_name for session $sess_name"
1162 function enable_log4j_lttng_event_loglevel
()
1165 local event_name
="$2"
1167 local channel_name
=$4
1169 if [ -z $channel_name ]; then
1170 # default channel if none specified
1173 chan
="-c $channel_name"
1176 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1177 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
1180 function enable_python_lttng_event
()
1186 if [ -z $channel_name ]; then
1187 # default channel if none specified
1190 chan
="-c $channel_name"
1193 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1194 ok $?
"Enable Python event $event_name for session $sess_name"
1197 function enable_python_lttng_event_loglevel
()
1200 local event_name
="$2"
1202 local channel_name
=$4
1204 if [ -z $channel_name ]; then
1205 # default channel if none specified
1208 chan
="-c $channel_name"
1211 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1212 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1215 function enable_ust_lttng_event_filter
()
1217 local sess_name
="$1"
1218 local event_name
="$2"
1220 local channel_name
=$4
1222 if [ -z $channel_name ]; then
1223 # default channel if none specified
1226 chan
="-c $channel_name"
1229 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1230 ok $?
"Enable event $event_name with filtering for session $sess_name"
1233 function enable_ust_lttng_event_loglevel
()
1235 local sess_name
="$1"
1236 local event_name
="$2"
1239 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1240 ok $?
"Enable event $event_name with loglevel $loglevel"
1243 function enable_ust_lttng_event_loglevel_only
()
1245 local sess_name
="$1"
1246 local event_name
="$2"
1249 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1250 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1253 function disable_ust_lttng_event
()
1255 local sess_name
="$1"
1256 local event_name
="$2"
1257 local channel_name
="$3"
1259 if [ -z $channel_name ]; then
1260 # default channel if none specified
1263 chan
="-c $channel_name"
1266 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1267 ok $?
"Disable event $event_name for session $sess_name"
1270 function disable_jul_lttng_event
()
1272 local sess_name
="$1"
1273 local event_name
="$2"
1275 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1276 ok $?
"Disable JUL event $event_name for session $sess_name"
1279 function disable_log4j_lttng_event
()
1281 local sess_name
="$1"
1282 local event_name
="$2"
1284 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1285 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1288 function disable_python_lttng_event
()
1290 local sess_name
="$1"
1291 local event_name
="$2"
1293 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1294 ok $?
"Disable Python event $event_name for session $sess_name"
1297 function start_lttng_tracing_opt
()
1300 local expected_to_fail
=$2
1303 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1305 if [[ $expected_to_fail -eq "1" ]]; then
1308 if [ $withtap -eq "1" ]; then
1309 ok $?
"Start tracing for session $sess_name failed as expected"
1312 if [ $withtap -eq "1" ]; then
1313 ok
$ret "Start tracing for session $sess_name"
1318 function start_lttng_tracing_ok
()
1320 start_lttng_tracing_opt
1 0 "$@"
1323 function start_lttng_tracing_fail
()
1325 start_lttng_tracing_opt
1 1 "$@"
1328 function start_lttng_tracing_notap
()
1330 start_lttng_tracing_opt
0 1 "$@"
1333 function stop_lttng_tracing_opt
()
1336 local expected_to_fail
=$2
1339 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1341 if [[ $expected_to_fail -eq "1" ]]; then
1344 if [ $withtap -eq "1" ]; then
1345 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1348 if [ $withtap -eq "1" ]; then
1349 ok
$ret "Stop lttng tracing for session $sess_name"
1354 function stop_lttng_tracing_ok
()
1356 stop_lttng_tracing_opt
1 0 "$@"
1359 function stop_lttng_tracing_fail
()
1361 stop_lttng_tracing_opt
1 1 "$@"
1364 function stop_lttng_tracing_notap
()
1366 stop_lttng_tracing_opt
0 0 "$@"
1369 function destroy_lttng_session
()
1372 local expected_to_fail
=$2
1375 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1377 if [[ $expected_to_fail -eq "1" ]]; then
1380 if [ $withtap -eq "1" ]; then
1381 ok
$ret "Destroy session $sess_name failed as expected"
1384 if [ $withtap -eq "1" ]; then
1385 ok
$ret "Destroy session $sess_name"
1390 function destroy_lttng_session_ok
()
1392 destroy_lttng_session
1 0 "$@"
1396 function destroy_lttng_session_fail
()
1398 destroy_lttng_session
1 1 "$@"
1401 function destroy_lttng_session_notap
()
1403 destroy_lttng_session
0 0 "$@"
1406 function destroy_lttng_sessions
()
1408 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1409 ok $?
"Destroy all lttng sessions"
1412 function lttng_snapshot_add_output
()
1414 local expected_to_fail
=$1
1419 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1421 if [[ $expected_to_fail -eq 1 ]]; then
1423 ok $?
"Added snapshot output $trace_path failed as expected"
1425 ok
$ret "Added snapshot output $trace_path"
1429 function lttng_snapshot_add_output_ok
()
1431 lttng_snapshot_add_output
0 "$@"
1434 function lttng_snapshot_add_output_fail
()
1436 lttng_snapshot_add_output
1 "$@"
1439 function lttng_snapshot_del_output
()
1441 local expected_to_fail
=$1
1445 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1447 if [[ $expected_to_fail -eq "1" ]]; then
1449 ok $?
"Deleted snapshot output id $id failed as expected"
1451 ok
$ret "Deleted snapshot output id $id"
1455 function lttng_snapshot_del_output_ok
()
1457 lttng_snapshot_del_output
0 "$@"
1460 function lttng_snapshot_del_output_fail
()
1462 lttng_snapshot_del_output
1 "$@"
1465 function lttng_snapshot_record
()
1469 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1470 ok $?
"Snapshot recorded"
1473 function lttng_snapshot_list
()
1476 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1477 ok $?
"Snapshot list"
1480 function lttng_save
()
1485 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1486 ok $?
"Session saved"
1489 function lttng_load
()
1491 local expected_to_fail
=$1
1494 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1496 if [[ $expected_to_fail -eq "1" ]]; then
1498 ok $?
"Load command failed as expected with opts: $opts"
1500 ok
$ret "Load command with opts: $opts"
1504 function lttng_load_ok
()
1509 function lttng_load_fail
()
1514 function lttng_track
()
1516 local expected_to_fail
="$1"
1519 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1521 if [[ $expected_to_fail -eq "1" ]]; then
1523 ok $?
"Track command failed as expected with opts: $opts"
1525 ok
$ret "Track command with opts: $opts"
1529 function lttng_track_ok
()
1534 function lttng_track_fail
()
1539 function lttng_untrack
()
1541 local expected_to_fail
="$1"
1544 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1546 if [[ $expected_to_fail -eq "1" ]]; then
1548 ok $?
"Untrack command failed as expected with opts: $opts"
1550 ok
$ret "Untrack command with opts: $opts"
1554 function lttng_untrack_ok
()
1556 lttng_untrack
0 "$@"
1559 function lttng_untrack_fail
()
1561 lttng_untrack
1 "$@"
1564 function lttng_track_pid_ok
()
1567 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1568 ok $?
"Lttng track pid on the kernel domain"
1571 function lttng_untrack_kernel_all_ok
()
1573 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1574 ok $?
"Lttng untrack all pid on the kernel domain"
1577 function lttng_track_ust_ok
()
1579 lttng_track_ok
-u "$@"
1582 function lttng_track_ust_fail
()
1584 lttng_track_fail
-u "$@"
1587 function lttng_track_kernel_ok
()
1589 lttng_track_ok
-k "$@"
1592 function lttng_track_kernel_fail
()
1594 lttng_track_fail
-k "$@"
1597 function lttng_untrack_ust_ok
()
1599 lttng_untrack_ok
-u "$@"
1602 function lttng_untrack_ust_fail
()
1604 lttng_untrack_fail
-u "$@"
1607 function lttng_untrack_kernel_ok
()
1609 lttng_untrack_ok
-k "$@"
1612 function lttng_untrack_kernel_fail
()
1614 lttng_untrack_fail
-k "$@"
1617 function lttng_add_context_list
()
1619 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1621 ok
$ret "Context listing"
1624 function add_context_lttng
()
1626 local expected_to_fail
="$1"
1628 local session_name
="$3"
1629 local channel_name
="$4"
1632 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1634 if [[ $expected_to_fail -eq "1" ]]; then
1636 ok $?
"Add context command failed as expected for type: $type"
1638 ok
$ret "Add context command for type: $type"
1642 function add_context_ust_ok
()
1644 add_context_lttng
0 -u "$@"
1647 function add_context_ust_fail
()
1649 add_context_lttng
1 -u "$@"
1652 function add_context_kernel_ok
()
1654 add_context_lttng
0 -k "$@"
1657 function add_context_kernel_fail
()
1659 add_context_lttng
1 -k "$@"
1662 function wait_live_trace_ready
()
1665 local zero_client_match
=0
1667 diag
"Waiting for live trace at url: $url"
1668 while [ $zero_client_match -eq 0 ]; do
1669 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
1672 pass
"Waiting for live trace at url: $url"
1675 function wait_live_viewer_connect
()
1678 local one_client_match
=0
1680 diag
"Waiting for live viewers on url: $url"
1681 while [ $one_client_match -eq 0 ]; do
1682 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
1685 pass
"Waiting for live viewers on url: $url"
1688 function validate_metadata_event
()
1691 local nr_event_id
=$2
1694 local metadata_file
=$
(find $trace_path |
grep metadata
)
1695 local metadata_path
=$
(dirname $metadata_file)
1697 which $BABELTRACE_BIN >/dev
/null
1698 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1700 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1702 if [ "$count" -ne "$nr_event_id" ]; then
1703 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1704 diag
"$count matching event id found in metadata"
1706 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1711 function trace_matches
()
1717 which $BABELTRACE_BIN >/dev
/null
1718 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1720 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1722 if [ "$count" -ne "$nr_iter" ]; then
1724 diag
"$count matching events found in trace"
1730 function trace_match_only
()
1736 which $BABELTRACE_BIN >/dev
/null
1737 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1739 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1740 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1742 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1743 pass
"Trace match with $total event $event_name"
1746 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1750 function validate_trace
1755 which $BABELTRACE_BIN >/dev
/null
1756 if [ $?
-ne 0 ]; then
1757 skip
0 "Babeltrace binary not found. Skipping trace validation"
1762 for i
in $event_name; do
1763 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1764 if [ "$traced" -ne 0 ]; then
1765 pass
"Validate trace for event $i, $traced events"
1767 fail
"Validate trace for event $i"
1768 diag
"Found $traced occurences of $i"
1776 function validate_trace_count
1780 local expected_count
=$3
1782 which $BABELTRACE_BIN >/dev
/null
1783 if [ $?
-ne 0 ]; then
1784 skip
0 "Babeltrace binary not found. Skipping trace validation"
1790 for i
in $event_name; do
1791 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1792 if [ "$traced" -ne 0 ]; then
1793 pass
"Validate trace for event $i, $traced events"
1795 fail
"Validate trace for event $i"
1796 diag
"Found $traced occurences of $i"
1798 cnt
=$
(($cnt + $traced))
1801 test $cnt -eq $expected_count
1802 ok $?
"Read a total of $cnt events, expected $expected_count"
1805 function validate_trace_count_range_incl_min_excl_max
1809 local expected_min
=$3
1810 local expected_max
=$4
1812 which $BABELTRACE_BIN >/dev
/null
1813 if [ $?
-ne 0 ]; then
1814 skip
0 "Babeltrace binary not found. Skipping trace validation"
1820 for i
in $event_name; do
1821 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1822 if [ "$traced" -ge $expected_min ]; then
1823 pass
"Validate trace for event $i, $traced events"
1825 fail
"Validate trace for event $i"
1826 diag
"Found $traced occurences of $i"
1828 cnt
=$
(($cnt + $traced))
1831 test $cnt -lt $expected_max
1832 ok $?
"Read a total of $cnt events, expected between [$expected_min, $expected_max["
1835 function trace_first_line
1839 which $BABELTRACE_BIN >/dev
/null
1840 if [ $?
-ne 0 ]; then
1841 skip
0 "Babeltrace binary not found. Skipping trace validation"
1844 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1847 function validate_trace_exp
()
1852 which $BABELTRACE_BIN >/dev
/null
1853 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1855 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
1856 if [ "$traced" -ne 0 ]; then
1857 pass
"Validate trace for expression '${event_exp}', $traced events"
1859 fail
"Validate trace for expression '${event_exp}'"
1860 diag
"Found $traced occurences of '${event_exp}'"
1866 function validate_trace_only_exp
()
1871 which $BABELTRACE_BIN >/dev
/null
1872 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1874 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
1875 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1877 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1878 pass
"Trace match with $total for expression '${event_exp}'"
1881 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1887 function validate_trace_empty
()
1891 which $BABELTRACE_BIN >/dev
/null
1892 if [ $?
-ne 0 ]; then
1893 skip
0 "Babeltrace binary not found. Skipping trace validation"
1896 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1898 if [ $ret -ne 0 ]; then
1899 fail
"Failed to parse trace"
1903 traced
=$
(echo -n "$events" |
wc -l)
1904 if [ "$traced" -eq 0 ]; then
1905 pass
"Validate empty trace"
1907 fail
"Validate empty trace"
1908 diag
"Found $traced events in trace"
1914 function validate_directory_empty
()
1916 local trace_path
="$1"
1918 # Do not double quote `$trace_path` below as we want wildcards to be
1920 files
="$(ls -A $trace_path)"
1922 if [ $ret -ne 0 ]; then
1923 fail
"Failed to list content of directory \"$trace_path\""
1927 nb_files
="$(echo -n "$files" | wc -l)"
1928 ok
$nb_files "Directory \"$trace_path\" is empty"
1931 function validate_trace_session_ust_empty
()
1933 validate_directory_empty
"$1"/ust
1936 function validate_trace_session_kernel_empty
()
1938 validate_trace_empty
"$1"/kernel
1941 function regenerate_metadata
()
1943 local expected_to_fail
=$1
1946 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1948 if [[ $expected_to_fail -eq "1" ]]; then
1950 ok $?
"Expected fail on regenerate metadata $sess_name"
1952 ok
$ret "Metadata regenerate $sess_name"
1956 function regenerate_metadata_ok
()
1958 regenerate_metadata
0 "$@"
1961 function regenerate_metadata_fail
()
1963 regenerate_metadata
1 "$@"
1966 function regenerate_statedump
()
1968 local expected_to_fail
=$1
1971 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1973 if [[ $expected_to_fail -eq "1" ]]; then
1975 ok $?
"Expected fail on regenerate statedump $sess_name"
1977 ok
$ret "Statedump regenerate $sess_name"
1981 function regenerate_statedump_ok
()
1983 regenerate_statedump
0 "$@"
1986 function regenerate_statedump_fail
()
1988 regenerate_statedump
1 "$@"
1991 function rotate_session
()
1993 local expected_to_fail
=$1
1996 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1998 if [[ $expected_to_fail -eq "1" ]]; then
2000 ok $?
"Expected fail on rotate session $sess_name"
2002 ok
$ret "Rotate session $sess_name"
2006 function rotate_session_ok
()
2008 rotate_session
0 "$@"
2011 function rotate_session_fail
()
2013 rotate_session
1 "$@"
2016 function destructive_tests_enabled
()
2018 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
2025 function lttng_enable_rotation_timer
()
2027 local expected_to_fail
=$1
2031 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2033 if [[ $expected_to_fail -eq "1" ]]; then
2035 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2037 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2041 function lttng_enable_rotation_timer_ok
()
2043 lttng_enable_rotation_timer
0 $@
2046 function lttng_enable_rotation_timer_fail
()
2048 lttng_enable_rotation_timer
1 $@
2051 function lttng_enable_rotation_size
()
2053 local expected_to_fail
=$1
2057 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2059 if [[ $expected_to_fail -eq "1" ]]; then
2061 ok $?
"Expected fail on rotate session $sess_name"
2063 ok
$ret "Rotate session $sess_name"
2067 function lttng_enable_rotation_size_ok
()
2069 lttng_enable_rotation_size
0 $@
2072 function lttng_enable_rotation_size_fail
()
2074 lttng_enable_rotation_size
1 $@
2077 function lttng_clear_session
()
2079 local expected_to_fail
=$1
2082 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2084 if [[ $expected_to_fail -eq "1" ]]; then
2086 ok $?
"Expected fail on clear session $sess_name"
2088 ok
$ret "Clear session $sess_name"
2092 function lttng_clear_session_ok
()
2094 lttng_clear_session
0 $@
2097 function lttng_clear_session_fail
()
2099 lttng_clear_session
1 $@
2102 function lttng_clear_all
()
2104 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2105 ok $?
"Clear all lttng sessions"