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
18 MI_XSD_MAJOR_VERSION
=4
19 MI_XSD_MINOR_VERSION
=1
20 MI_XSD_PATH
="$TESTDIR/../src/common/mi-lttng-${MI_XSD_MAJOR_VERSION}.${MI_XSD_MINOR_VERSION}.xsd"
21 MI_VALIDATE
="$TESTDIR/utils/xml-utils/validate_xml ${MI_XSD_PATH}"
23 XML_PRETTY
="$TESTDIR/utils/xml-utils/pretty_xml"
24 XML_EXTRACT
="$TESTDIR/utils/xml-utils/extract_xml"
25 XML_NODE_CHECK
="${XML_EXTRACT} -e"
27 # To match 20201127-175802
28 date_time_pattern
="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]"
29 # The size of a long on this system
30 system_long_bit_size
=$
(getconf LONG_BIT
)
32 # Minimal kernel version supported for session daemon tests
33 KERNEL_MAJOR_VERSION
=2
34 KERNEL_MINOR_VERSION
=6
35 KERNEL_PATCHLEVEL_VERSION
=27
37 # We set the default UST register timeout and network and app socket timeout to
38 # "wait forever", so that basic tests don't have to worry about hitting
39 # timeouts on busy systems. Specialized tests should test those corner-cases.
40 export LTTNG_UST_REGISTER_TIMEOUT
=-1
41 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
42 export LTTNG_APP_SOCKET_TIMEOUT
=-1
44 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
45 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
46 # its own sessiond if none is running. It also ensures that 'lttng create'
47 # fails when no sessiond is running.
48 export LTTNG_SESSIOND_PATH
="/bin/true"
50 source $TESTDIR/utils
/tap
/tap.sh
52 if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then
53 LTTNG_TEST_TEARDOWN_TIMEOUT
=60
56 # Enable job monitor mode.
57 # Here we are mostly interested in the following from the monitor mode:
58 # All processes run in a separate process group.
59 # This allows us to ensure that all subprocesses from all background tasks are
60 # cleaned up correctly using signal to process group id.
63 kill_background_jobs
()
68 if [ -z "$pids" ]; then
75 # Use negative number to send the signal to the process group.
76 # This ensure that any subprocesses receive the signal.
77 # /dev/null is used since there is an acceptable race between
78 # the moments the pids are listed and the moment we send a
80 kill -SIGTERM -- "-$pid" 2>/dev
/null
86 # Try to kill daemons gracefully
87 stop_lttng_relayd_cleanup SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
88 stop_lttng_sessiond_cleanup SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
90 # If daemons are still present, forcibly kill them
91 stop_lttng_relayd_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
92 stop_lttng_sessiond_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
93 stop_lttng_consumerd_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
98 function full_cleanup
()
104 function LTTNG_BAIL_OUT
()
110 function null_pipes
()
117 trap full_cleanup SIGINT SIGTERM
119 # perl prove closes its child pipes before giving it a chance to run its
120 # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
121 # to allow those trap handlers to proceed.
123 trap null_pipes SIGPIPE
125 # Check pgrep from env, default to pgrep if none
126 if [ -z "$PGREP" ]; then
130 # Due to the renaming of threads we need to use the full command (pgrep -f) to
131 # identify the pids for multiple lttng related processes. The problem with "pgrep
132 # -f" is that it ends up also looking at the arguments. We use a two stage
133 # lookup. The first one is using "pgrep -f" yielding potential candidate.
134 # The second on perform grep on the basename of the first field of the
135 # /proc/pid/cmdline of the previously identified pids. The first field
136 # correspond to the actual command.
137 function lttng_pgrep
()
141 local full_command_no_argument
142 local command_basename
144 possible_pids
=$
($PGREP -f "$pattern")
145 if [ -z "$possible_pids" ]; then
149 while IFS
= read -r pid
; do
150 # /proc/pid/cmdline is null separated.
151 if full_command_no_argument
=$
(cut
-d '' -f 1 2>/dev
/null
< /proc
/"$pid"/cmdline
); then
152 command_basename
=$
(basename "$full_command_no_argument")
153 if grep -q "$pattern" <<< "$command_basename"; then
157 done <<< "$possible_pids"
163 # Check if we are a terminal
165 echo -e "\e[1;32mOK\e[0m"
171 function print_fail
()
173 # Check if we are a terminal
175 echo -e "\e[1;31mFAIL\e[0m"
181 function print_test_banner
()
187 function validate_kernel_version
()
189 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
190 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
193 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
196 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
202 # Generate a random string
203 # $1 = number of characters; defaults to 16
204 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
205 function randstring
()
207 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
208 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
212 # Helpers for get_possible_cpus.
213 function get_possible_cpus_count_from_sysfs_possible_mask
()
215 local max_possible_cpu_id
=$
(cut
-d '-' -f 2 < /sys
/devices
/system
/cpu
/possible
)
216 echo $
((max_possible_cpu_id
+1))
219 function get_max_cpus_count_from_sysfs_cpu_directories
()
221 local max_possible_cpu_id
= \
222 $
(find /sys
/devices
/system
/cpu
/ -mindepth 1 -maxdepth 1 -regex ".+cpu[0-9]+" | \
223 sed -e 's/cpu//g' | \
224 awk -F '/' '{ if ($NF > N) N = $NF } END { print N }')
225 echo $
((max_possible_cpu_id
+1))
228 # Return the number of possible CPUs.
229 function get_possible_cpus_count
()
231 local possible_cpus_count
=$
(get_possible_cpus_count_from_sysfs_possible_mask
)
233 if [ $?
-ne 0 ]; then
234 possible_cpus_count
=$
(get_max_cpus_count_from_sysfs_cpu_directories
)
235 local configured_cpus_count
=$
(getconf _NPROCESSORS_CONF
)
236 possible_cpus_count
=$
(($configured_cpus_count > $possible_cpus_count \
237 ?
$configured_cpus_count \
238 : $possible_cpus_count))
241 echo $possible_cpus_count
244 # Return the number of _configured_ CPUs.
245 function conf_proc_count
()
247 getconf _NPROCESSORS_CONF
248 if [ $?
-ne 0 ]; then
249 diag
"Failed to get the number of configured CPUs"
254 # Check if base lttng-modules are present.
255 # Bail out on failure
256 function validate_lttng_modules_present
()
258 # Check for loadable modules.
259 modprobe
-n lttng-tracer
2>/dev
/null
260 if [ $?
-eq 0 ]; then
264 # Check for builtin modules.
265 ls /proc
/lttng
> /dev
/null
2>&1
266 if [ $?
-eq 0 ]; then
270 LTTNG_BAIL_OUT
"LTTng modules not detected."
273 # Run the lttng binary.
275 # The first two arguments are stdout and stderr redirect paths, respectively.
276 # The rest of the arguments are forwarded to the lttng binary
277 function _run_lttng_cmd
279 local stdout_dest
="$1"
280 local stderr_dest
="$2"
283 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN $*"
284 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"
287 function enable_kernel_lttng_event
290 local expected_to_fail
="$2"
292 local event_name
="$4"
293 local channel_name
="$5"
295 if [ -z "$event_name" ]; then
296 # Enable all event if no event 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 enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
309 if [[ $expected_to_fail -eq "1" ]]; then
312 if [ $withtap -eq "1" ]; then
313 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
316 if [ $withtap -eq "1" ]; then
317 ok
$ret "Enable kernel event $event_name for session $sess_name"
322 function enable_kernel_lttng_event_ok
()
324 enable_kernel_lttng_event
1 0 "$@"
327 function enable_kernel_lttng_event_fail
()
329 enable_kernel_lttng_event
1 1 "$@"
332 function enable_kernel_lttng_event_notap
()
334 enable_kernel_lttng_event
0 0 "$@"
338 function lttng_enable_kernel_event
340 enable_kernel_lttng_event_ok
"$@"
343 function lttng_enable_kernel_syscall
()
345 local expected_to_fail
=$1
347 local syscall_name
=$3
348 local channel_name
=$4
350 if [ -z $syscall_name ]; then
351 # Enable all event if no syscall name specified
355 if [ -z $channel_name ]; then
356 # default channel if none specified
359 chan
="-c $channel_name"
362 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
364 if [[ $expected_to_fail -eq "1" ]]; then
366 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
368 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
372 function lttng_enable_kernel_syscall_ok
()
374 lttng_enable_kernel_syscall
0 "$@"
377 function lttng_enable_kernel_syscall_fail
()
379 lttng_enable_kernel_syscall
1 "$@"
382 function lttng_disable_kernel_syscall
()
384 local expected_to_fail
=$1
386 local syscall_name
=$3
387 local channel_name
=$4
389 if [ -z $syscall_name ]; then
390 # Enable all event if no syscall name specified
394 if [ -z $channel_name ]; then
395 # default channel if none specified
398 chan
="-c $channel_name"
401 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
404 if [[ $expected_to_fail -eq "1" ]]; then
406 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
408 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
412 function lttng_disable_kernel_syscall_ok
()
414 lttng_disable_kernel_syscall
0 "$@"
417 function lttng_disable_kernel_syscall_fail
()
419 lttng_disable_kernel_syscall
1 "$@"
422 function lttng_enable_kernel_function_event
()
424 local expected_to_fail
="$1"
427 local event_name
="$4"
429 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
431 if [[ $expected_to_fail -eq "1" ]]; then
433 ok $?
"Enable kernel function event for session $sess_name failed as expected"
435 ok
$ret "Enable kernel function event for session $sess_name"
439 function lttng_enable_kernel_function_event_ok
()
441 lttng_enable_kernel_function_event
0 "$@"
444 function lttng_enable_kernel_userspace_probe_event
()
446 local expected_to_fail
="$1"
449 local event_name
="$4"
451 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
453 if [[ $expected_to_fail -eq "1" ]]; then
455 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
457 ok
$ret "Enable kernel userspace probe event for session $sess_name"
461 function lttng_enable_kernel_userspace_probe_event_fail
()
463 lttng_enable_kernel_userspace_probe_event
1 "$@"
466 function lttng_enable_kernel_userspace_probe_event_ok
()
468 lttng_enable_kernel_userspace_probe_event
0 "$@"
471 function disable_kernel_lttng_userspace_probe_event_ok
()
474 local event_name
="$2"
476 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
477 ok $?
"Disable kernel event $target for session $sess_name"
479 function lttng_enable_kernel_channel
()
482 local expected_to_fail
=$2
484 local channel_name
=$4
487 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
489 if [[ $expected_to_fail -eq "1" ]]; then
492 if [ $withtap -eq "1" ]; then
493 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
496 if [ $withtap -eq "1" ]; then
497 ok
$ret "Enable channel $channel_name for session $sess_name"
502 function lttng_enable_kernel_channel_ok
()
504 lttng_enable_kernel_channel
1 0 "$@"
507 function lttng_enable_kernel_channel_fail
()
509 lttng_enable_kernel_channel
1 1 "$@"
512 function lttng_enable_kernel_channel_notap
()
514 lttng_enable_kernel_channel
0 0 "$@"
517 function enable_kernel_lttng_channel_ok
()
519 lttng_enable_kernel_channel
1 0 "$@"
522 function lttng_disable_kernel_channel
()
524 local expected_to_fail
=$1
526 local channel_name
=$3
528 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
530 if [[ $expected_to_fail -eq "1" ]]; then
532 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
534 ok
$ret "Disable channel $channel_name for session $sess_name"
538 function lttng_disable_kernel_channel_ok
()
540 lttng_disable_kernel_channel
0 "$@"
543 function lttng_disable_kernel_channel_fail
()
545 lttng_disable_kernel_channel
1 "$@"
548 function start_lttng_relayd_opt
()
551 local process_mode
=$2
554 DIR
=$
(readlink
-f "$TESTDIR")
556 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
557 # shellcheck disable=SC2086
558 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
559 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
560 if [ $?
-eq 1 ]; then
561 if [ $withtap -eq "1" ]; then
562 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
566 if [ $withtap -eq "1" ]; then
567 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
571 pass
"Start lttng-relayd (opt: $opt)"
575 function start_lttng_relayd
()
577 start_lttng_relayd_opt
1 "-b" "$@"
580 function start_lttng_relayd_notap
()
582 start_lttng_relayd_opt
0 "-b" "$@"
585 function stop_lttng_relayd_opt
()
595 if [ -z "$signal" ]; then
600 # Multiply time by 2 to simplify integer arithmetic
601 if [ -n "$timeout_s" ]; then
602 dtimeleft_s
=$
((timeout_s
* 2))
606 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
607 if [ -z "$pids" ]; then
608 if [ "$is_cleanup" -eq 1 ]; then
610 elif [ "$withtap" -eq "1" ]; then
611 fail
"No relay daemon to kill"
613 LTTNG_BAIL_OUT
"No relay daemon to kill"
618 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
620 # shellcheck disable=SC2086
621 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
623 if [ "$withtap" -eq "1" ]; then
624 fail
"Kill relay daemon"
628 while [ -n "$out" ]; do
629 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
630 if [ -n "$dtimeleft_s" ]; then
631 if [ $dtimeleft_s -lt 0 ]; then
635 dtimeleft_s
=$
((dtimeleft_s
- 1))
639 if [ "$withtap" -eq "1" ]; then
640 if [ "$retval" -eq "0" ]; then
641 pass
"Wait after kill relay daemon"
643 fail
"Wait after kill relay daemon"
650 function stop_lttng_relayd
()
652 stop_lttng_relayd_opt
1 0 "$@"
655 function stop_lttng_relayd_notap
()
657 stop_lttng_relayd_opt
0 0 "$@"
660 function stop_lttng_relayd_cleanup
()
662 stop_lttng_relayd_opt
0 1 "$@"
665 #First arg: show tap output
666 #Second argument: load path for automatic loading
667 function start_lttng_sessiond_opt
()
672 # The rest of the arguments will be passed directly to lttng-sessiond.
678 local long_bit_value
=
679 long_bit_value
=$
(getconf LONG_BIT
)
681 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
682 # Env variable requested no session daemon
686 DIR
=$
(readlink
-f "$TESTDIR")
688 # Get long_bit value for 32/64 consumerd
689 case "$long_bit_value" in
691 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
694 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
701 # Check for env. variable. Allow the use of LD_PRELOAD etc.
702 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
703 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
705 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
707 if ! validate_kernel_version
; then
708 fail
"Start session daemon"
709 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
712 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
713 export LTTNG_SESSION_CONFIG_XSD_PATH
715 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
717 if [ -n "$load_path" ]; then
718 # shellcheck disable=SC2086
719 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
721 # shellcheck disable=SC2086
722 env
$env_vars --background "$consumerd" "$@"
724 #$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
726 if [ "$withtap" -eq "1" ]; then
727 ok
$status "Start session daemon"
732 function start_lttng_sessiond
()
734 start_lttng_sessiond_opt
1 "$@"
737 function start_lttng_sessiond_notap
()
739 start_lttng_sessiond_opt
0 "$@"
742 function stop_lttng_sessiond_opt
()
753 if [ -z "$signal" ]; then
757 # Multiply time by 2 to simplify integer arithmetic
758 if [ -n "$timeout_s" ]; then
759 dtimeleft_s
=$
((timeout_s
* 2))
762 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
763 # Env variable requested no session daemon
767 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
768 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
770 if [ -n "$runas_pids" ]; then
771 pids
="$pids $runas_pids"
774 if [ -z "$pids" ]; then
775 if [ "$is_cleanup" -eq 1 ]; then
777 elif [ "$withtap" -eq "1" ]; then
778 fail
"No session daemon to kill"
780 LTTNG_BAIL_OUT
"No session daemon to kill"
785 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
787 # shellcheck disable=SC2086
788 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
790 if [ "$withtap" -eq "1" ]; then
791 fail
"Kill sessions daemon"
795 while [ -n "$out" ]; do
796 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
797 if [ -n "$dtimeleft_s" ]; then
798 if [ $dtimeleft_s -lt 0 ]; then
802 dtimeleft_s
=$
((dtimeleft_s
- 1))
807 while [ -n "$out" ]; do
808 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
809 if [ -n "$dtimeleft_s" ]; then
810 if [ $dtimeleft_s -lt 0 ]; then
814 dtimeleft_s
=$
((dtimeleft_s
- 1))
819 if [ "$withtap" -eq "1" ]; then
820 if [ "$retval" -eq "0" ]; then
821 pass
"Wait after kill session daemon"
823 fail
"Wait after kill session daemon"
827 if [ "$signal" = "SIGKILL" ]; then
828 if [ "$(id -u)" -eq "0" ]; then
830 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
832 if [ -n "$modules" ]; then
833 diag
"Unloading all LTTng modules"
834 modprobe
--remove "$modules"
842 function stop_lttng_sessiond
()
844 stop_lttng_sessiond_opt
1 0 "$@"
847 function stop_lttng_sessiond_notap
()
849 stop_lttng_sessiond_opt
0 0 "$@"
852 function stop_lttng_sessiond_cleanup
()
854 stop_lttng_sessiond_opt
0 1 "$@"
857 function sigstop_lttng_sessiond_opt
()
863 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
864 # Env variable requested no session daemon
868 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
870 if [ "$withtap" -eq "1" ]; then
871 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
874 # shellcheck disable=SC2086
875 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
876 if [ "$withtap" -eq "1" ]; then
877 fail
"Sending SIGSTOP to session daemon"
881 while [ $out -ne 0 ]; do
882 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
884 # Wait until state becomes stopped for session
887 for sessiond_pid
in $pids; do
888 state
="$(ps -p "$sessiond_pid" -o state= )"
889 if [[ -n "$state" && "$state" != "T" ]]; then
895 if [ "$withtap" -eq "1" ]; then
896 pass
"Sending SIGSTOP to session daemon"
901 function sigstop_lttng_sessiond
()
903 sigstop_lttng_sessiond_opt
1 "$@"
906 function sigstop_lttng_sessiond_notap
()
908 sigstop_lttng_sessiond_opt
0 "$@"
911 function stop_lttng_consumerd_opt
()
921 if [ -z "$signal" ]; then
925 # Multiply time by 2 to simplify integer arithmetic
926 if [ -n "$timeout_s" ]; then
927 dtimeleft_s
=$
((timeout_s
* 2))
930 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
932 if [ -z "$pids" ]; then
933 if [ "$is_cleanup" -eq 1 ]; then
935 elif [ "$withtap" -eq "1" ]; then
936 fail
"No consumerd daemon to kill"
938 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
943 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
945 # shellcheck disable=SC2086
946 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
948 if [ "$withtap" -eq "1" ]; then
949 fail
"Kill consumer daemon"
953 while [ $out -ne 0 ]; do
954 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
956 # If consumerds are still present check their status.
957 # A zombie status qualifies the consumerd as *killed*
959 for consumer_pid
in $pids; do
960 state
="$(ps -p "$consumer_pid" -o state= )"
961 if [[ -n "$state" && "$state" != "Z" ]]; then
965 if [ -n "$dtimeleft_s" ]; then
966 if [ $dtimeleft_s -lt 0 ]; then
970 dtimeleft_s
=$
((dtimeleft_s
- 1))
974 if [ "$withtap" -eq "1" ]; then
975 if [ "$retval" -eq "0" ]; then
976 pass
"Wait after kill consumer daemon"
978 fail
"Wait after kill consumer daemon"
986 function stop_lttng_consumerd
()
988 stop_lttng_consumerd_opt
1 0 "$@"
991 function stop_lttng_consumerd_notap
()
993 stop_lttng_consumerd_opt
0 0 "$@"
996 function stop_lttng_consumerd_cleanup
()
998 stop_lttng_consumerd_opt
0 1 "$@"
1001 function sigstop_lttng_consumerd_opt
()
1004 local signal
=SIGSTOP
1007 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1009 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1011 # shellcheck disable=SC2086
1012 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1015 if [ $retval -eq 1 ]; then
1016 if [ "$withtap" -eq "1" ]; then
1017 fail
"Sending SIGSTOP to consumer daemon"
1022 while [ $out -ne 0 ]; do
1023 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1025 # Wait until state becomes stopped for all
1028 for consumer_pid
in $pids; do
1029 state
="$(ps -p "$consumer_pid" -o state= )"
1030 if [[ -n "$state" && "$state" != "T" ]]; then
1036 if [ "$withtap" -eq "1" ]; then
1037 pass
"Sending SIGSTOP to consumer daemon"
1043 function sigstop_lttng_consumerd
()
1045 sigstop_lttng_consumerd_opt
1 "$@"
1048 function sigstop_lttng_consumerd_notap
()
1050 sigstop_lttng_consumerd_opt
0 "$@"
1053 function list_lttng_with_opts
()
1059 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1061 if [ $withtap -eq "1" ]; then
1062 ok
$ret "Lttng-tool list command with option $opts"
1066 function list_lttng_ok
()
1068 list_lttng_with_opts
1 "$@"
1071 function list_lttng_notap
()
1073 list_lttng_with_opts
0 "$@"
1076 function create_lttng_session_no_output
()
1081 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1082 ok $?
"Create session $sess_name in no-output mode"
1085 function create_lttng_session_uri
() {
1090 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1091 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1094 function create_lttng_session
()
1097 local expected_to_fail
=$2
1102 if [ -z "$trace_path" ]; then
1103 # Use lttng-sessiond default output.
1106 trace_path
="-o $trace_path"
1109 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1111 if [ $expected_to_fail -eq "1" ]; then
1114 if [ $withtap -eq "1" ]; then
1115 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1118 if [ $withtap -eq "1" ]; then
1119 ok
$ret "Create session $sess_name in $trace_path"
1125 function create_lttng_session_ok
()
1127 create_lttng_session
1 0 "$@"
1130 function create_lttng_session_fail
()
1132 create_lttng_session
1 1 "$@"
1135 function create_lttng_session_notap
()
1137 create_lttng_session
0 0 "$@"
1141 function enable_ust_lttng_channel
()
1144 local expected_to_fail
=$2
1146 local channel_name
=$4
1149 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1151 if [[ $expected_to_fail -eq "1" ]]; then
1154 if [ $withtap -eq "1" ]; then
1155 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1158 if [ $withtap -eq "1" ]; then
1159 ok
$ret "Enable channel $channel_name for session $sess_name"
1165 function enable_ust_lttng_channel_ok
()
1167 enable_ust_lttng_channel
1 0 "$@"
1170 function enable_ust_lttng_channel_fail
()
1172 enable_ust_lttng_channel
1 1 "$@"
1175 function enable_ust_lttng_channel_notap
()
1177 enable_ust_lttng_channel
0 0 "$@"
1180 function disable_ust_lttng_channel
()
1183 local channel_name
=$2
1185 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1186 ok $?
"Disable channel $channel_name for session $sess_name"
1189 function enable_lttng_mmap_overwrite_kernel_channel
()
1192 local channel_name
=$2
1194 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1195 ok $?
"Enable channel $channel_name for session $sess_name"
1198 function enable_lttng_mmap_discard_small_kernel_channel
()
1201 local channel_name
=$2
1203 $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
1204 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1207 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1210 local channel_name
=$2
1212 $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
1213 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1216 function enable_lttng_mmap_overwrite_ust_channel
()
1219 local channel_name
=$2
1221 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1222 ok $?
"Enable channel $channel_name for session $sess_name"
1225 function enable_ust_lttng_event
()
1228 local expected_to_fail
=$2
1230 local event_name
="$4"
1231 local channel_name
=$5
1233 if [ -z $channel_name ]; then
1234 # default channel if none specified
1237 chan
="-c $channel_name"
1240 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1242 if [[ $expected_to_fail -eq "1" ]]; then
1245 if [[ $withtap -eq "1" ]]; then
1246 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1249 if [[ $withtap -eq "1" ]]; then
1250 ok
$ret "Enable ust event $event_name for session $sess_name"
1256 function enable_ust_lttng_event_ok
()
1258 enable_ust_lttng_event
1 0 "$@"
1261 function enable_ust_lttng_event_fail
()
1263 enable_ust_lttng_event
1 1 "$@"
1266 function enable_ust_lttng_event_notap
()
1268 enable_ust_lttng_event
0 0 "$@"
1271 function enable_jul_lttng_event
()
1277 if [ -z $channel_name ]; then
1278 # default channel if none specified
1281 chan
="-c $channel_name"
1284 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1285 ok $?
"Enable JUL event $event_name for session $sess_name"
1288 function enable_jul_lttng_event_loglevel
()
1291 local event_name
="$2"
1293 local channel_name
=$4
1295 if [ -z $channel_name ]; then
1296 # default channel if none specified
1299 chan
="-c $channel_name"
1302 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1303 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1306 function enable_log4j_lttng_event
()
1310 local channel_name
=$3
1314 # default channel if none specified
1315 if [ -n "$channel_name" ]; then
1316 chan_opt
=("-c" "$channel_name")
1319 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1320 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1321 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1324 function enable_log4j_lttng_event_filter
()
1330 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1331 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1332 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1335 function enable_log4j_lttng_event_filter_loglevel_only
()
1342 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1343 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1344 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1347 function enable_log4j_lttng_event_loglevel
()
1352 local channel_name
=$4
1355 # default channel if none specified
1356 if [ -n "$channel_name" ]; then
1357 chan_opt
=("-c" "$channel_name")
1360 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1361 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1362 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1365 function enable_log4j_lttng_event_loglevel_only
()
1370 local channel_name
=$4
1374 # default channel if none specified
1375 if [ -n "$channel_name" ]; then
1376 chan_opt
=("-c" "$channel_name")
1379 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1380 enable-event
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1381 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1384 function enable_python_lttng_event
()
1390 if [ -z $channel_name ]; then
1391 # default channel if none specified
1394 chan
="-c $channel_name"
1397 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1398 ok $?
"Enable Python event $event_name for session $sess_name"
1401 function enable_python_lttng_event_loglevel
()
1404 local event_name
="$2"
1406 local channel_name
=$4
1408 if [ -z $channel_name ]; then
1409 # default channel if none specified
1412 chan
="-c $channel_name"
1415 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1416 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1419 function enable_ust_lttng_event_filter
()
1421 local sess_name
="$1"
1422 local event_name
="$2"
1424 local channel_name
=$4
1426 if [ -z $channel_name ]; then
1427 # default channel if none specified
1430 chan
="-c $channel_name"
1433 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1434 ok $?
"Enable event $event_name with filtering for session $sess_name"
1437 function enable_ust_lttng_event_loglevel
()
1439 local sess_name
="$1"
1440 local event_name
="$2"
1443 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1444 ok $?
"Enable event $event_name with loglevel $loglevel"
1447 function enable_ust_lttng_event_loglevel_only
()
1449 local sess_name
="$1"
1450 local event_name
="$2"
1453 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1454 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1457 function disable_ust_lttng_event
()
1459 local sess_name
="$1"
1460 local event_name
="$2"
1461 local channel_name
="$3"
1463 if [ -z $channel_name ]; then
1464 # default channel if none specified
1467 chan
="-c $channel_name"
1470 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1471 ok $?
"Disable event $event_name for session $sess_name"
1474 function disable_jul_lttng_event
()
1476 local sess_name
="$1"
1477 local event_name
="$2"
1479 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1480 ok $?
"Disable JUL event $event_name for session $sess_name"
1483 function disable_log4j_lttng_event
()
1485 local sess_name
="$1"
1486 local event_name
="$2"
1488 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1489 disable-event
"$event_name" -s "$sess_name" --log4j
1490 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1493 function disable_python_lttng_event
()
1495 local sess_name
="$1"
1496 local event_name
="$2"
1498 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1499 ok $?
"Disable Python event $event_name for session $sess_name"
1502 function start_lttng_tracing_opt
()
1505 local expected_to_fail
=$2
1508 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1510 if [[ $expected_to_fail -eq "1" ]]; then
1513 if [ $withtap -eq "1" ]; then
1514 ok $?
"Start tracing for session $sess_name failed as expected"
1517 if [ $withtap -eq "1" ]; then
1518 ok
$ret "Start tracing for session $sess_name"
1523 function start_lttng_tracing_ok
()
1525 start_lttng_tracing_opt
1 0 "$@"
1528 function start_lttng_tracing_fail
()
1530 start_lttng_tracing_opt
1 1 "$@"
1533 function start_lttng_tracing_notap
()
1535 start_lttng_tracing_opt
0 1 "$@"
1538 function stop_lttng_tracing_opt
()
1541 local expected_to_fail
=$2
1544 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1546 if [[ $expected_to_fail -eq "1" ]]; then
1549 if [ $withtap -eq "1" ]; then
1550 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1553 if [ $withtap -eq "1" ]; then
1554 ok
$ret "Stop lttng tracing for session $sess_name"
1559 function stop_lttng_tracing_ok
()
1561 stop_lttng_tracing_opt
1 0 "$@"
1564 function stop_lttng_tracing_fail
()
1566 stop_lttng_tracing_opt
1 1 "$@"
1569 function stop_lttng_tracing_notap
()
1571 stop_lttng_tracing_opt
0 0 "$@"
1574 function destroy_lttng_session
()
1577 local expected_to_fail
=$2
1580 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1582 if [[ $expected_to_fail -eq "1" ]]; then
1585 if [ $withtap -eq "1" ]; then
1586 ok
$ret "Destroy session $sess_name failed as expected"
1589 if [ $withtap -eq "1" ]; then
1590 ok
$ret "Destroy session $sess_name"
1595 function destroy_lttng_session_ok
()
1597 destroy_lttng_session
1 0 "$@"
1601 function destroy_lttng_session_fail
()
1603 destroy_lttng_session
1 1 "$@"
1606 function destroy_lttng_session_notap
()
1608 destroy_lttng_session
0 0 "$@"
1611 function destroy_lttng_sessions
()
1613 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1614 ok $?
"Destroy all lttng sessions"
1617 function lttng_snapshot_add_output
()
1619 local expected_to_fail
=$1
1624 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1626 if [[ $expected_to_fail -eq 1 ]]; then
1628 ok $?
"Added snapshot output $trace_path failed as expected"
1630 ok
$ret "Added snapshot output $trace_path"
1634 function lttng_snapshot_add_output_ok
()
1636 lttng_snapshot_add_output
0 "$@"
1639 function lttng_snapshot_add_output_fail
()
1641 lttng_snapshot_add_output
1 "$@"
1644 function lttng_snapshot_del_output
()
1646 local expected_to_fail
=$1
1650 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1652 if [[ $expected_to_fail -eq "1" ]]; then
1654 ok $?
"Deleted snapshot output id $id failed as expected"
1656 ok
$ret "Deleted snapshot output id $id"
1660 function lttng_snapshot_del_output_ok
()
1662 lttng_snapshot_del_output
0 "$@"
1665 function lttng_snapshot_del_output_fail
()
1667 lttng_snapshot_del_output
1 "$@"
1670 function lttng_snapshot_record
()
1675 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s "$sess_name" "$trace_path" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1676 ok $?
"Snapshot recorded"
1679 function lttng_snapshot_list
()
1682 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1683 ok $?
"Snapshot list"
1686 function lttng_save
()
1691 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1692 ok $?
"Session saved"
1695 function lttng_load
()
1697 local expected_to_fail
=$1
1700 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1702 if [[ $expected_to_fail -eq "1" ]]; then
1704 ok $?
"Load command failed as expected with opts: $opts"
1706 ok
$ret "Load command with opts: $opts"
1710 function lttng_load_ok
()
1715 function lttng_load_fail
()
1720 function lttng_track
()
1722 local expected_to_fail
="$1"
1725 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1727 if [[ $expected_to_fail -eq "1" ]]; then
1729 ok $?
"Track command failed as expected with opts: $opts"
1731 ok
$ret "Track command with opts: $opts"
1735 function lttng_track_ok
()
1740 function lttng_track_fail
()
1745 function lttng_untrack
()
1747 local expected_to_fail
="$1"
1750 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1752 if [[ $expected_to_fail -eq "1" ]]; then
1754 ok $?
"Untrack command failed as expected with opts: $opts"
1756 ok
$ret "Untrack command with opts: $opts"
1760 function lttng_untrack_ok
()
1762 lttng_untrack
0 "$@"
1765 function lttng_untrack_fail
()
1767 lttng_untrack
1 "$@"
1770 function lttng_track_pid_ok
()
1773 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1774 ok $?
"Lttng track pid on the kernel domain"
1777 function lttng_untrack_kernel_all_ok
()
1779 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1780 ok $?
"Lttng untrack all pid on the kernel domain"
1783 function lttng_track_ust_ok
()
1785 lttng_track_ok
-u "$@"
1788 function lttng_track_ust_fail
()
1790 lttng_track_fail
-u "$@"
1793 function lttng_track_kernel_ok
()
1795 lttng_track_ok
-k "$@"
1798 function lttng_track_kernel_fail
()
1800 lttng_track_fail
-k "$@"
1803 function lttng_untrack_ust_ok
()
1805 lttng_untrack_ok
-u "$@"
1808 function lttng_untrack_ust_fail
()
1810 lttng_untrack_fail
-u "$@"
1813 function lttng_untrack_kernel_ok
()
1815 lttng_untrack_ok
-k "$@"
1818 function lttng_untrack_kernel_fail
()
1820 lttng_untrack_fail
-k "$@"
1823 function lttng_add_context_list
()
1825 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1827 ok
$ret "Context listing"
1830 function add_context_lttng
()
1832 local expected_to_fail
="$1"
1834 local session_name
="$3"
1835 local channel_name
="$4"
1838 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1840 if [[ $expected_to_fail -eq "1" ]]; then
1842 ok $?
"Add context command failed as expected for type: $type"
1844 ok
$ret "Add context command for type: $type"
1848 function add_context_ust_ok
()
1850 add_context_lttng
0 -u "$@"
1853 function add_context_ust_fail
()
1855 add_context_lttng
1 -u "$@"
1858 function add_context_kernel_ok
()
1860 add_context_lttng
0 -k "$@"
1863 function add_context_kernel_fail
()
1865 add_context_lttng
1 -k "$@"
1868 function wait_live_trace_ready
()
1871 local zero_client_match
=0
1873 diag
"Waiting for live trace at url: $url"
1874 while [ $zero_client_match -eq 0 ]; do
1875 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
1878 pass
"Waiting for live trace at url: $url"
1881 function wait_live_viewer_connect
()
1884 local one_client_match
=0
1886 diag
"Waiting for live viewers on url: $url"
1887 while [ $one_client_match -eq 0 ]; do
1888 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
1891 pass
"Waiting for live viewers on url: $url"
1894 function bail_out_if_no_babeltrace
()
1896 which "$BABELTRACE_BIN" >/dev
/null
1897 if [ $?
-ne 0 ]; then
1898 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
1902 function validate_metadata_event
()
1905 local nr_event_id
=$2
1908 local metadata_file
=$
(find $trace_path -name "metadata")
1909 local metadata_path
=$
(dirname $metadata_file)
1911 which $BABELTRACE_BIN >/dev
/null
1912 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1914 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1916 if [ "$count" -ne "$nr_event_id" ]; then
1917 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1918 diag
"$count matching event id found in metadata"
1920 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1925 function trace_matches
()
1931 which $BABELTRACE_BIN >/dev
/null
1932 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1934 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1936 if [ "$count" -ne "$nr_iter" ]; then
1938 diag
"$count matching events found in trace"
1944 function trace_match_only
()
1950 which $BABELTRACE_BIN >/dev
/null
1951 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1953 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1954 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1956 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1957 pass
"Trace match with $total event $event_name"
1960 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1964 function validate_trace
1969 which $BABELTRACE_BIN >/dev
/null
1970 if [ $?
-ne 0 ]; then
1971 skip
0 "Babeltrace binary not found. Skipping trace validation"
1976 for i
in $event_name; do
1977 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1978 if [ "$traced" -ne 0 ]; then
1979 pass
"Validate trace for event $i, $traced events"
1981 fail
"Validate trace for event $i"
1982 diag
"Found $traced occurrences of $i"
1990 function validate_trace_count
1994 local expected_count
=$3
1996 which $BABELTRACE_BIN >/dev
/null
1997 if [ $?
-ne 0 ]; then
1998 skip
0 "Babeltrace binary not found. Skipping trace validation"
2004 for i
in $event_name; do
2005 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2006 if [ "$traced" -ne 0 ]; then
2007 pass
"Validate trace for event $i, $traced events"
2009 fail
"Validate trace for event $i"
2010 diag
"Found $traced occurrences of $i"
2012 cnt
=$
(($cnt + $traced))
2015 test $cnt -eq $expected_count
2016 ok $?
"Read a total of $cnt events, expected $expected_count"
2019 function validate_trace_count_range_incl_min_excl_max
2023 local expected_min
=$3
2024 local expected_max
=$4
2026 which $BABELTRACE_BIN >/dev
/null
2027 if [ $?
-ne 0 ]; then
2028 skip
0 "Babeltrace binary not found. Skipping trace validation"
2034 for i
in $event_name; do
2035 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2036 if [ "$traced" -ge $expected_min ]; then
2037 pass
"Validate trace for event $i, $traced events"
2039 fail
"Validate trace for event $i"
2040 diag
"Found $traced occurrences of $i"
2042 cnt
=$
(($cnt + $traced))
2045 test $cnt -lt $expected_max
2046 ok $?
"Read a total of $cnt events, expected between [$expected_min, $expected_max["
2049 function trace_first_line
2053 which $BABELTRACE_BIN >/dev
/null
2054 if [ $?
-ne 0 ]; then
2055 skip
0 "Babeltrace binary not found. Skipping trace validation"
2058 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
2061 function validate_trace_exp
()
2066 which $BABELTRACE_BIN >/dev
/null
2067 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
2069 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
2070 if [ "$traced" -ne 0 ]; then
2071 pass
"Validate trace for expression '${event_exp}', $traced events"
2073 fail
"Validate trace for expression '${event_exp}'"
2074 diag
"Found $traced occurrences of '${event_exp}'"
2080 function validate_trace_only_exp
()
2085 which $BABELTRACE_BIN >/dev
/null
2086 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2088 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
2089 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
2091 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
2092 pass
"Trace match with $total for expression '${event_exp}'"
2095 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
2101 function validate_trace_empty
()
2105 which $BABELTRACE_BIN >/dev
/null
2106 if [ $?
-ne 0 ]; then
2107 skip
0 "Babeltrace binary not found. Skipping trace validation"
2110 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
2112 if [ $ret -ne 0 ]; then
2113 fail
"Failed to parse trace"
2117 traced
=$
(echo -n "$events" |
wc -l)
2118 if [ "$traced" -eq 0 ]; then
2119 pass
"Validate empty trace"
2121 fail
"Validate empty trace"
2122 diag
"Found $traced events in trace"
2128 function validate_directory_empty
()
2130 local trace_path
="$1"
2132 # Do not double quote `$trace_path` below as we want wildcards to be
2134 files
="$(ls -A $trace_path)"
2136 if [ $ret -ne 0 ]; then
2137 fail
"Failed to list content of directory \"$trace_path\""
2141 nb_files
="$(echo -n "$files" | wc -l)"
2142 ok
$nb_files "Directory \"$trace_path\" is empty"
2145 function validate_trace_session_ust_empty
()
2147 validate_directory_empty
"$1"/ust
2150 function validate_trace_session_kernel_empty
()
2152 validate_trace_empty
"$1"/kernel
2155 function regenerate_metadata
()
2157 local expected_to_fail
=$1
2160 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2162 if [[ $expected_to_fail -eq "1" ]]; then
2164 ok $?
"Expected fail on regenerate metadata $sess_name"
2166 ok
$ret "Metadata regenerate $sess_name"
2170 function regenerate_metadata_ok
()
2172 regenerate_metadata
0 "$@"
2175 function regenerate_metadata_fail
()
2177 regenerate_metadata
1 "$@"
2180 function regenerate_statedump
()
2182 local expected_to_fail
=$1
2185 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2187 if [[ $expected_to_fail -eq "1" ]]; then
2189 ok $?
"Expected fail on regenerate statedump $sess_name"
2191 ok
$ret "Statedump regenerate $sess_name"
2195 function regenerate_statedump_ok
()
2197 regenerate_statedump
0 "$@"
2200 function regenerate_statedump_fail
()
2202 regenerate_statedump
1 "$@"
2205 function rotate_session
()
2207 local expected_to_fail
=$1
2210 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2212 if [[ $expected_to_fail -eq "1" ]]; then
2214 ok $?
"Expected fail on rotate session $sess_name"
2216 ok
$ret "Rotate session $sess_name"
2220 function rotate_session_ok
()
2222 rotate_session
0 "$@"
2225 function rotate_session_fail
()
2227 rotate_session
1 "$@"
2230 function destructive_tests_enabled
()
2232 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2239 function lttng_enable_rotation_timer
()
2241 local expected_to_fail
=$1
2245 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2247 if [[ $expected_to_fail -eq "1" ]]; then
2249 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2251 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2255 function lttng_enable_rotation_timer_ok
()
2257 lttng_enable_rotation_timer
0 $@
2260 function lttng_enable_rotation_timer_fail
()
2262 lttng_enable_rotation_timer
1 $@
2265 function lttng_enable_rotation_size
()
2267 local expected_to_fail
=$1
2271 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2273 if [[ $expected_to_fail -eq "1" ]]; then
2275 ok $?
"Expected fail on rotate session $sess_name"
2277 ok
$ret "Rotate session $sess_name"
2281 function lttng_enable_rotation_size_ok
()
2283 lttng_enable_rotation_size
0 $@
2286 function lttng_enable_rotation_size_fail
()
2288 lttng_enable_rotation_size
1 $@
2291 function lttng_clear_session
()
2293 local expected_to_fail
=$1
2296 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2298 if [[ $expected_to_fail -eq "1" ]]; then
2300 ok $?
"Expected fail on clear session $sess_name"
2302 ok
$ret "Clear session $sess_name"
2306 function lttng_clear_session_ok
()
2308 lttng_clear_session
0 $@
2311 function lttng_clear_session_fail
()
2313 lttng_clear_session
1 $@
2316 function lttng_clear_all
()
2318 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2319 ok $?
"Clear all lttng sessions"
2322 function lttng_add_trigger
()
2324 local expected_to_fail
="$1"
2325 local trigger_name
="$2"
2329 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2330 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2332 if [[ $expected_to_fail -eq "1" ]]; then
2334 ok $?
"Add trigger $trigger_name failed as expected"
2336 ok
$ret "Add trigger $trigger_name"
2340 function lttng_remove_trigger
()
2342 local expected_to_fail
="$1"
2343 local trigger_name
="$2"
2346 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2347 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2349 if [[ $expected_to_fail -eq "1" ]]; then
2351 ok $?
"Remove trigger $trigger_name failed as expected"
2353 ok
$ret "Remove trigger $trigger_name"
2357 function lttng_add_trigger_ok
()
2359 lttng_add_trigger
0 "$@"
2362 function lttng_add_trigger_fail
()
2364 lttng_add_trigger
1 "$@"
2367 function lttng_remove_trigger_ok
()
2369 lttng_remove_trigger
0 "$@"
2372 function list_triggers_matches_ok
()
2374 local tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2375 local tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2377 local test_name
="$1"
2378 local expected_stdout_file
="$2"
2380 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2382 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2383 ok $?
"${test_name}: exit code is 0"
2385 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2386 ok $?
"${test_name}: expected stdout"
2388 diff -u /dev
/null
"${tmp_stderr}"
2389 ok $?
"${test_name}: expected stderr"
2391 rm -f "${tmp_stdout}"
2392 rm -f "${tmp_stderr}"
2395 function list_triggers_matches_mi_ok
()
2398 local tmp_stdout_raw
2401 local test_name
="$1"
2402 local expected_stdout_file
="$2"
2404 tmp_stdout_raw
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2405 tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2406 tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2408 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2410 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2411 ok $?
"${test_name}: exit code is 0"
2413 # Pretty-fy xml before further test.
2414 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2416 $MI_VALIDATE "${tmp_stdout}"
2417 ok $?
"list-trigger mi is valid"
2419 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2420 ok $?
"${test_name}: expected stdout"
2422 diff -u /dev
/null
"${tmp_stderr}"
2423 ok $?
"${test_name}: expected stderr"
2425 rm -f "${tmp_stdout}"
2426 rm -f "${tmp_stdout_raw}"
2427 rm -f "${tmp_stderr}"
2430 function validate_path_pattern
()
2434 # Base path is only used in error case and is used to list the content
2443 if [ "$ret" -ne "0" ]; then
2444 diag
"Path pattern expected: $pattern"
2445 # List the tracepath for more info. We use find as a recursive
2447 diag
"The base path content:"
2448 find "$base_path" -print
2452 function validate_trace_path_ust_uid
()
2455 local session_name
=$2
2457 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2459 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2462 function validate_trace_path_ust_uid_network
()
2465 local session_name
=$2
2468 local hostname
=$HOSTNAME
2472 # If the session was given a network base path (e.g
2473 # 127.0.0.1/my/custom/path on creation, there is no session name
2474 # component to the path on the relayd side. Caller can simply not pass a
2475 # session name for this scenario.
2476 if [ -n "$session_name" ]; then
2477 session_name
="$session_name-$date_time_pattern"
2478 if [ -n "$base_path" ]; then
2479 fail
"Session name and base path are mutually exclusive"
2484 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2486 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2489 function validate_trace_path_ust_uid_snapshot_network
()
2492 local session_name
=$2
2493 local snapshot_name
=$3
2494 local snapshot_number
=$4
2496 local hostname
=$HOSTNAME
2501 # If the session/output was given a network base path (e.g
2502 # 127.0.0.1/my/custom/path on creation, there is no session name
2503 # component to the path on the relayd side. Caller can simply not pass a
2504 # session name for this scenario.
2505 if [ -n "$session_name" ]; then
2506 session_name
="$session_name-$date_time_pattern"
2507 if [ -n "$base_path" ]; then
2508 fail
"Session name and base path are mutually exclusive"
2513 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2515 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2518 function validate_trace_path_ust_uid_snapshot
()
2521 local session_name
=$2
2522 local snapshot_name
=$3
2523 local snapshot_number
=$4
2529 # If the session/output was given a network base path (e.g
2530 # 127.0.0.1/my/custom/path) on creation, there is no session name
2531 # component to the path on the relayd side. Caller can simply not pass a
2532 # session name for this scenario.
2533 if [ -n "$session_name" ]; then
2534 session_name
="$session_name-$date_time_pattern"
2535 if [ -n "$base_path" ]; then
2536 fail
"Session name and base path are mutually exclusive"
2541 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2543 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2546 function validate_trace_path_ust_pid
()
2549 local session_name
=$2
2555 # If the session was given a trace path on creation, there is no session
2556 # name component to the path. Caller can simply not pass a session name
2557 # for this scenario.
2558 if [ -n "$session_name" ]; then
2559 session_name
="$session_name-$date_time_pattern"
2562 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2564 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2567 function validate_trace_path_kernel
()
2570 local session_name
=$2
2573 # If the session was given a trace path on creation, there is no session
2574 # name component to the path. Caller can simply not pass a session name
2575 # for this scenario.
2576 if [ -n "$session_name" ]; then
2577 session_name
="$session_name-$date_time_pattern"
2580 pattern
="$trace_path/$session_name/kernel/metadata"
2582 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2585 function validate_trace_path_kernel_network
()
2588 local session_name
=$2
2589 local hostname
=$HOSTNAME
2590 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2592 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2595 function validate_trace_path_kernel_snapshot
()
2598 local session_name
=$2
2599 local snapshot_name
=$3
2600 local snapshot_number
=$4
2605 # If the session/output was given a network base path (e.g
2606 # 127.0.0.1/my/custom/path on creation, there is no session name
2607 # component to the path on the relayd side. Caller can simply not pass a
2608 # session name for this scenario.
2609 if [ -n "$session_name" ]; then
2610 session_name
="$session_name-$date_time_pattern"
2611 if [ -n "$base_path" ]; then
2612 fail
"Session name and base path are mutually exclusive"
2617 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2619 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2622 function validate_trace_path_kernel_snapshot_network
()
2625 local session_name
=$2
2626 local snapshot_name
=$3
2627 local snapshot_number
=$4
2629 local hostname
=$HOSTNAME
2633 # If the session/output was given a network base path (e.g
2634 # 127.0.0.1/my/custom/path on creation, there is no session name
2635 # component to the path on the relayd side. Caller can simply not pass a
2636 # session name for this scenario.
2637 if [ -n "$session_name" ]; then
2638 session_name
="$session_name-$date_time_pattern"
2639 if [ -n "$base_path" ]; then
2640 fail
"Session name and base path are mutually exclusive"
2645 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2647 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"