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
="babeltrace2"
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
=$
( (tr '\0' '\n' < /proc
/"$pid"/cmdline
) 2>/dev
/null |
head -n1); 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
()
209 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
210 # /dev/urandom isn't guaranteed to generate valid multi-byte characters.
211 # Specifying the C locale eliminates the "Illegal byte sequence" error
212 # that 'tr' outputs in such cases.
213 LC_CTYPE
=C
tr -cd "$CHAR" < /dev
/urandom
2>/dev
/null |
head -c "$len" 2>/dev
/null
217 # Return a space-separated string of online CPU IDs, based on
218 # /sys/devices/system/cpu/online, or from 0 to nproc - 1 otherwise.
219 function get_online_cpus
()
223 if [ -f /sys
/devices
/system
/cpu
/online
]; then
224 range_re
='([0-9]+)-([0-9]+)'
225 while read -r range
; do
226 if [[ "${range}" =~
${range_re} ]] ; then
227 mapfile
-t -O "${#cpus[*]}" cpus <<< $(seq "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
231 done < <(tr ',' $
'\n' < /sys
/devices
/system
/cpu
/online
)
233 read -r -a cpus
<<< $
(seq 0 $
(( $
(conf_proc_count
) - 1 )) )
238 # Helpers for get_possible_cpus.
239 function get_possible_cpus_count_from_sysfs_possible_mask
()
241 local max_possible_cpu_id
243 # The Awk script extracts the highest CPU id from the possible CPU
244 # mask. Assuming a numerical order, a field separator '-' and a record
245 # separator ','. The last value parsed is the highest id.
246 if [ -f /sys
/devices
/system
/cpu
/possible
]; then
247 max_possible_cpu_id
=$
(awk -F '-' 'BEGIN { RS = ","} { last = $NF } END { printf("%d\n", last) }' \
248 /sys
/devices
/system
/cpu
/possible
)
249 echo "$((max_possible_cpu_id+1))"
255 # This is a fallback if the possible CPU mask is not available. This will not
256 # take into account unplugged CPUs.
257 function get_max_cpus_count_from_sysfs_cpu_directories
()
259 local max_possible_cpu_id
=0
262 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
263 current_cpu_id
="${i#/sys/devices/system/cpu/cpu}"
264 if [ "$current_cpu_id" -gt "$max_possible_cpu_id" ]; then
265 max_possible_cpu_id
="$current_cpu_id"
269 echo "$((max_possible_cpu_id+1))"
272 # Return the number of possible CPUs.
273 function get_possible_cpus_count
()
275 local possible_cpus_count
276 possible_cpus_count
=$
(get_possible_cpus_count_from_sysfs_possible_mask
)
278 if [ "$possible_cpus_count" -eq "0" ]; then
279 local configured_cpus_count
280 configured_cpus_count
=$
(getconf _NPROCESSORS_CONF
)
281 possible_cpus_count
=$
(get_max_cpus_count_from_sysfs_cpu_directories
)
282 possible_cpus_count
=$
((configured_cpus_count
> possible_cpus_count \
283 ? configured_cpus_count \
284 : possible_cpus_count
))
287 echo "$possible_cpus_count"
290 # Return the list of exposed CPU.
292 # NOTE! Use it like so:
294 # IFS=" " read -r -a VARIABLE <<< "$(get_exposed_cpus_list)"
295 function get_exposed_cpus_list
()
299 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
300 list
+=("${i#/sys/devices/system/cpu/cpu}")
306 # Return any available CPU found. Do not make assumption about the returned
307 # value, e.g. that it could be 0.
308 function get_any_available_cpu
()
310 for cpu
in $
(get_online_cpus
); do
316 # Return the number of _configured_ CPUs.
317 function conf_proc_count
()
319 getconf _NPROCESSORS_CONF
320 if [ $?
-ne 0 ]; then
321 diag
"Failed to get the number of configured CPUs"
326 # Check if base lttng-modules are present.
327 # Bail out on failure
328 function validate_lttng_modules_present
()
330 # Check for loadable modules.
331 modprobe
-n lttng-tracer
2>/dev
/null
332 if [ $?
-eq 0 ]; then
336 # Check for builtin modules.
337 ls /proc
/lttng
> /dev
/null
2>&1
338 if [ $?
-eq 0 ]; then
342 LTTNG_BAIL_OUT
"LTTng modules not detected."
345 # Run the lttng binary.
347 # The first two arguments are stdout and stderr redirect paths, respectively.
348 # The rest of the arguments are forwarded to the lttng binary
349 function _run_lttng_cmd
351 local stdout_dest
="$1"
352 local stderr_dest
="$2"
355 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN $*"
356 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"
359 function enable_kernel_lttng_event
362 local expected_to_fail
="$2"
364 local event_name
="$4"
365 local channel_name
="$5"
367 if [ -z "$event_name" ]; then
368 # Enable all event if no event name specified
372 if [ -z "$channel_name" ]; then
373 # default channel if none specified
376 chan
="-c $channel_name"
379 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
380 enable-event
"$event_name" $chan -s $sess_name -k
382 if [[ $expected_to_fail -eq "1" ]]; then
385 if [ $withtap -eq "1" ]; then
386 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
389 if [ $withtap -eq "1" ]; then
390 ok
$ret "Enable kernel event $event_name for session $sess_name"
395 function enable_kernel_lttng_event_ok
()
397 enable_kernel_lttng_event
1 0 "$@"
400 function enable_kernel_lttng_event_fail
()
402 enable_kernel_lttng_event
1 1 "$@"
405 function enable_kernel_lttng_event_notap
()
407 enable_kernel_lttng_event
0 0 "$@"
411 function lttng_enable_kernel_event
413 enable_kernel_lttng_event_ok
"$@"
416 function lttng_enable_kernel_syscall
()
418 local expected_to_fail
=$1
420 local syscall_name
=$3
421 local channel_name
=$4
423 if [ -z $syscall_name ]; then
424 # Enable all event if no syscall name specified
428 if [ -z $channel_name ]; then
429 # default channel if none specified
432 chan
="-c $channel_name"
435 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
436 enable-event
--syscall "$syscall_name" $chan -s $sess_name -k
438 if [[ $expected_to_fail -eq "1" ]]; then
440 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
442 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
446 function lttng_enable_kernel_syscall_ok
()
448 lttng_enable_kernel_syscall
0 "$@"
451 function lttng_enable_kernel_syscall_fail
()
453 lttng_enable_kernel_syscall
1 "$@"
456 function lttng_disable_kernel_syscall
()
458 local expected_to_fail
=$1
460 local syscall_name
=$3
461 local channel_name
=$4
463 if [ -z $syscall_name ]; then
464 # Enable all event if no syscall name specified
468 if [ -z $channel_name ]; then
469 # default channel if none specified
472 chan
="-c $channel_name"
475 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
476 disable-event
--syscall "$syscall_name" $chan -s $sess_name -k
479 if [[ $expected_to_fail -eq "1" ]]; then
481 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
483 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
487 function lttng_disable_kernel_syscall_ok
()
489 lttng_disable_kernel_syscall
0 "$@"
492 function lttng_disable_kernel_syscall_fail
()
494 lttng_disable_kernel_syscall
1 "$@"
497 function lttng_enable_kernel_function_event
()
499 local expected_to_fail
="$1"
502 local event_name
="$4"
504 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
506 if [[ $expected_to_fail -eq "1" ]]; then
508 ok $?
"Enable kernel function event for session $sess_name failed as expected"
510 ok
$ret "Enable kernel function event for session $sess_name"
514 function lttng_enable_kernel_function_event_ok
()
516 lttng_enable_kernel_function_event
0 "$@"
519 function lttng_enable_kernel_userspace_probe_event
()
521 local expected_to_fail
="$1"
524 local event_name
="$4"
526 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
528 if [[ $expected_to_fail -eq "1" ]]; then
530 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
532 ok
$ret "Enable kernel userspace probe event for session $sess_name"
536 function lttng_enable_kernel_userspace_probe_event_fail
()
538 lttng_enable_kernel_userspace_probe_event
1 "$@"
541 function lttng_enable_kernel_userspace_probe_event_ok
()
543 lttng_enable_kernel_userspace_probe_event
0 "$@"
546 function disable_kernel_lttng_userspace_probe_event_ok
()
549 local event_name
="$2"
551 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
552 ok $?
"Disable kernel event $target for session $sess_name"
554 function lttng_enable_kernel_channel
()
557 local expected_to_fail
=$2
559 local channel_name
=$4
562 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
563 enable-channel
-k $channel_name -s $sess_name $opts
565 if [[ $expected_to_fail -eq "1" ]]; then
568 if [ $withtap -eq "1" ]; then
569 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
572 if [ $withtap -eq "1" ]; then
573 ok
$ret "Enable channel $channel_name for session $sess_name"
578 function lttng_enable_kernel_channel_ok
()
580 lttng_enable_kernel_channel
1 0 "$@"
583 function lttng_enable_kernel_channel_fail
()
585 lttng_enable_kernel_channel
1 1 "$@"
588 function lttng_enable_kernel_channel_notap
()
590 lttng_enable_kernel_channel
0 0 "$@"
593 function enable_kernel_lttng_channel_ok
()
595 lttng_enable_kernel_channel
1 0 "$@"
598 function lttng_disable_kernel_channel
()
600 local expected_to_fail
=$1
602 local channel_name
=$3
604 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
605 disable-channel
-k $channel_name -s $sess_name
607 if [[ $expected_to_fail -eq "1" ]]; then
609 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
611 ok
$ret "Disable channel $channel_name for session $sess_name"
615 function lttng_disable_kernel_channel_ok
()
617 lttng_disable_kernel_channel
0 "$@"
620 function lttng_disable_kernel_channel_fail
()
622 lttng_disable_kernel_channel
1 "$@"
625 function start_lttng_relayd_opt
()
628 local process_mode
=$2
631 DIR
=$
(readlink
-f "$TESTDIR")
633 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
634 # shellcheck disable=SC2086
635 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
636 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
637 if [ $?
-eq 1 ]; then
638 if [ $withtap -eq "1" ]; then
639 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
643 if [ $withtap -eq "1" ]; then
644 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
648 pass
"Start lttng-relayd (opt: $opt)"
652 function start_lttng_relayd
()
654 start_lttng_relayd_opt
1 "-b" "$@"
657 function start_lttng_relayd_notap
()
659 start_lttng_relayd_opt
0 "-b" "$@"
662 function stop_lttng_relayd_opt
()
672 if [ -z "$signal" ]; then
677 # Multiply time by 2 to simplify integer arithmetic
678 if [ -n "$timeout_s" ]; then
679 dtimeleft_s
=$
((timeout_s
* 2))
683 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
684 if [ -z "$pids" ]; then
685 if [ "$is_cleanup" -eq 1 ]; then
687 elif [ "$withtap" -eq "1" ]; then
688 fail
"No relay daemon to kill"
690 LTTNG_BAIL_OUT
"No relay daemon to kill"
695 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
697 # shellcheck disable=SC2086
698 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
700 if [ "$withtap" -eq "1" ]; then
701 fail
"Kill relay daemon"
705 while [ -n "$out" ]; do
706 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
707 if [ -n "$dtimeleft_s" ]; then
708 if [ $dtimeleft_s -lt 0 ]; then
712 dtimeleft_s
=$
((dtimeleft_s
- 1))
716 if [ "$withtap" -eq "1" ]; then
717 if [ "$retval" -eq "0" ]; then
718 pass
"Wait after kill relay daemon"
720 fail
"Wait after kill relay daemon"
727 function stop_lttng_relayd
()
729 stop_lttng_relayd_opt
1 0 "$@"
732 function stop_lttng_relayd_notap
()
734 stop_lttng_relayd_opt
0 0 "$@"
737 function stop_lttng_relayd_cleanup
()
739 stop_lttng_relayd_opt
0 1 "$@"
742 #First arg: show tap output
743 #Second argument: load path for automatic loading
744 function start_lttng_sessiond_opt
()
749 # The rest of the arguments will be passed directly to lttng-sessiond.
755 local long_bit_value
=
756 long_bit_value
=$
(getconf LONG_BIT
)
758 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
759 # Env variable requested no session daemon
763 DIR
=$
(readlink
-f "$TESTDIR")
765 # Get long_bit value for 32/64 consumerd
766 case "$long_bit_value" in
768 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
771 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
778 # Check for env. variable. Allow the use of LD_PRELOAD etc.
779 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
780 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
782 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
784 if ! validate_kernel_version
; then
785 fail
"Start session daemon"
786 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
789 diag
"export LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/"
790 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/"}"
791 export LTTNG_SESSION_CONFIG_XSD_PATH
793 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
795 if [ -n "$load_path" ]; then
796 diag
"env $env_vars --load $load_path --background $consumerd $@"
797 # shellcheck disable=SC2086
798 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
800 diag
"env $env_vars --background $consumerd $@"
801 # shellcheck disable=SC2086
802 env
$env_vars --background "$consumerd" "$@"
804 #$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
806 if [ "$withtap" -eq "1" ]; then
807 ok
$status "Start session daemon"
812 function start_lttng_sessiond
()
814 start_lttng_sessiond_opt
1 "$@"
817 function start_lttng_sessiond_notap
()
819 start_lttng_sessiond_opt
0 "$@"
822 function stop_lttng_sessiond_opt
()
833 if [ -z "$signal" ]; then
837 # Multiply time by 2 to simplify integer arithmetic
838 if [ -n "$timeout_s" ]; then
839 dtimeleft_s
=$
((timeout_s
* 2))
842 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
843 # Env variable requested no session daemon
847 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
848 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
850 if [ -n "$runas_pids" ]; then
851 pids
="$pids $runas_pids"
854 if [ -z "$pids" ]; then
855 if [ "$is_cleanup" -eq 1 ]; then
857 elif [ "$withtap" -eq "1" ]; then
858 fail
"No session daemon to kill"
860 LTTNG_BAIL_OUT
"No session daemon to kill"
865 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
867 # shellcheck disable=SC2086
868 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
870 if [ "$withtap" -eq "1" ]; then
871 fail
"Kill sessions daemon"
875 while [ -n "$out" ]; do
876 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
877 if [ -n "$dtimeleft_s" ]; then
878 if [ $dtimeleft_s -lt 0 ]; then
882 dtimeleft_s
=$
((dtimeleft_s
- 1))
887 while [ -n "$out" ]; do
888 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
889 if [ -n "$dtimeleft_s" ]; then
890 if [ $dtimeleft_s -lt 0 ]; then
894 dtimeleft_s
=$
((dtimeleft_s
- 1))
899 if [ "$withtap" -eq "1" ]; then
900 if [ "$retval" -eq "0" ]; then
901 pass
"Wait after kill session daemon"
903 fail
"Wait after kill session daemon"
907 if [ "$signal" = "SIGKILL" ]; then
908 if [ "$(id -u)" -eq "0" ]; then
910 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
912 if [ -n "$modules" ]; then
913 diag
"Unloading all LTTng modules"
914 modprobe
--remove "$modules"
922 function stop_lttng_sessiond
()
924 stop_lttng_sessiond_opt
1 0 "$@"
927 function stop_lttng_sessiond_notap
()
929 stop_lttng_sessiond_opt
0 0 "$@"
932 function stop_lttng_sessiond_cleanup
()
934 stop_lttng_sessiond_opt
0 1 "$@"
937 function sigstop_lttng_sessiond_opt
()
943 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
944 # Env variable requested no session daemon
948 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
950 if [ "$withtap" -eq "1" ]; then
951 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
954 # shellcheck disable=SC2086
955 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
956 if [ "$withtap" -eq "1" ]; then
957 fail
"Sending SIGSTOP to session daemon"
961 while [ $out -ne 0 ]; do
962 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
964 # Wait until state becomes stopped for session
967 for sessiond_pid
in $pids; do
968 state
="$(ps -p "$sessiond_pid" -o state= )"
969 if [[ -n "$state" && "$state" != "T" ]]; then
975 if [ "$withtap" -eq "1" ]; then
976 pass
"Sending SIGSTOP to session daemon"
981 function sigstop_lttng_sessiond
()
983 sigstop_lttng_sessiond_opt
1 "$@"
986 function sigstop_lttng_sessiond_notap
()
988 sigstop_lttng_sessiond_opt
0 "$@"
991 function stop_lttng_consumerd_opt
()
1001 if [ -z "$signal" ]; then
1005 # Multiply time by 2 to simplify integer arithmetic
1006 if [ -n "$timeout_s" ]; then
1007 dtimeleft_s
=$
((timeout_s
* 2))
1010 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1012 if [ -z "$pids" ]; then
1013 if [ "$is_cleanup" -eq 1 ]; then
1015 elif [ "$withtap" -eq "1" ]; then
1016 fail
"No consumerd daemon to kill"
1018 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
1023 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1025 # shellcheck disable=SC2086
1026 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
1028 if [ "$withtap" -eq "1" ]; then
1029 fail
"Kill consumer daemon"
1033 while [ $out -ne 0 ]; do
1034 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1036 # If consumerds are still present check their status.
1037 # A zombie status qualifies the consumerd as *killed*
1039 for consumer_pid
in $pids; do
1040 state
="$(ps -p "$consumer_pid" -o state= )"
1041 if [[ -n "$state" && "$state" != "Z" ]]; then
1045 if [ -n "$dtimeleft_s" ]; then
1046 if [ $dtimeleft_s -lt 0 ]; then
1050 dtimeleft_s
=$
((dtimeleft_s
- 1))
1054 if [ "$withtap" -eq "1" ]; then
1055 if [ "$retval" -eq "0" ]; then
1056 pass
"Wait after kill consumer daemon"
1058 fail
"Wait after kill consumer daemon"
1066 function stop_lttng_consumerd
()
1068 stop_lttng_consumerd_opt
1 0 "$@"
1071 function stop_lttng_consumerd_notap
()
1073 stop_lttng_consumerd_opt
0 0 "$@"
1076 function stop_lttng_consumerd_cleanup
()
1078 stop_lttng_consumerd_opt
0 1 "$@"
1081 function sigstop_lttng_consumerd_opt
()
1084 local signal
=SIGSTOP
1087 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1089 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1091 # shellcheck disable=SC2086
1092 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1095 if [ $retval -eq 1 ]; then
1096 if [ "$withtap" -eq "1" ]; then
1097 fail
"Sending SIGSTOP to consumer daemon"
1102 while [ $out -ne 0 ]; do
1103 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1105 # Wait until state becomes stopped for all
1108 for consumer_pid
in $pids; do
1109 state
="$(ps -p "$consumer_pid" -o state= )"
1110 if [[ -n "$state" && "$state" != "T" ]]; then
1116 if [ "$withtap" -eq "1" ]; then
1117 pass
"Sending SIGSTOP to consumer daemon"
1123 function sigstop_lttng_consumerd
()
1125 sigstop_lttng_consumerd_opt
1 "$@"
1128 function sigstop_lttng_consumerd_notap
()
1130 sigstop_lttng_consumerd_opt
0 "$@"
1133 function list_lttng_with_opts
()
1139 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1142 if [ $withtap -eq "1" ]; then
1143 ok
$ret "Lttng-tool list command with option $opts"
1147 function list_lttng_ok
()
1149 list_lttng_with_opts
1 "$@"
1152 function list_lttng_notap
()
1154 list_lttng_with_opts
0 "$@"
1157 function create_lttng_session_no_output
()
1162 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1163 create
$sess_name --no-output $opts
1164 ok $?
"Create session $sess_name in no-output mode"
1167 function create_lttng_session_uri
() {
1172 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1173 create
$sess_name -U $uri $opts
1174 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1177 function create_lttng_session
()
1180 local expected_to_fail
=$2
1185 if [ -z "$trace_path" ]; then
1186 # Use lttng-sessiond default output.
1189 trace_path
="-o $trace_path"
1192 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1193 create
"$sess_name" $trace_path $opt
1195 if [ $expected_to_fail -eq "1" ]; then
1198 if [ $withtap -eq "1" ]; then
1199 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1202 if [ $withtap -eq "1" ]; then
1203 ok
$ret "Create session $sess_name in $trace_path"
1209 function create_lttng_session_ok
()
1211 create_lttng_session
1 0 "$@"
1214 function create_lttng_session_fail
()
1216 create_lttng_session
1 1 "$@"
1219 function create_lttng_session_notap
()
1221 create_lttng_session
0 0 "$@"
1225 function enable_ust_lttng_channel
()
1228 local expected_to_fail
=$2
1230 local channel_name
=$4
1233 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1234 enable-channel
-u $channel_name -s $sess_name $opts
1236 if [[ $expected_to_fail -eq "1" ]]; then
1239 if [ $withtap -eq "1" ]; then
1240 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1243 if [ $withtap -eq "1" ]; then
1244 ok
$ret "Enable channel $channel_name for session $sess_name"
1250 function enable_ust_lttng_channel_ok
()
1252 enable_ust_lttng_channel
1 0 "$@"
1255 function enable_ust_lttng_channel_fail
()
1257 enable_ust_lttng_channel
1 1 "$@"
1260 function enable_ust_lttng_channel_notap
()
1262 enable_ust_lttng_channel
0 0 "$@"
1265 function disable_ust_lttng_channel
()
1268 local channel_name
=$2
1270 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1271 disable-channel
-u $channel_name -s $sess_name
1272 ok $?
"Disable channel $channel_name for session $sess_name"
1275 function enable_lttng_mmap_overwrite_kernel_channel
()
1278 local channel_name
=$2
1280 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1281 enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite
1282 ok $?
"Enable channel $channel_name for session $sess_name"
1285 function enable_lttng_mmap_discard_small_kernel_channel
()
1288 local channel_name
=$2
1290 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1291 enable-channel
-s $sess_name $channel_name -k --output mmap
--discard --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2
1292 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1295 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1298 local channel_name
=$2
1300 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1301 enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2
1302 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1305 function enable_lttng_mmap_overwrite_ust_channel
()
1308 local channel_name
=$2
1310 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1311 enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite
1312 ok $?
"Enable channel $channel_name for session $sess_name"
1315 function enable_ust_lttng_event
()
1318 local expected_to_fail
=$2
1320 local event_name
="$4"
1321 local channel_name
=$5
1323 if [ -z $channel_name ]; then
1324 # default channel if none specified
1327 chan
="-c $channel_name"
1330 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1331 enable-event
"$event_name" $chan -s "$sess_name" -u
1333 if [[ $expected_to_fail -eq "1" ]]; then
1336 if [[ $withtap -eq "1" ]]; then
1337 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1340 if [[ $withtap -eq "1" ]]; then
1341 ok
$ret "Enable ust event $event_name for session $sess_name"
1347 function enable_ust_lttng_event_ok
()
1349 enable_ust_lttng_event
1 0 "$@"
1352 function enable_ust_lttng_event_fail
()
1354 enable_ust_lttng_event
1 1 "$@"
1357 function enable_ust_lttng_event_notap
()
1359 enable_ust_lttng_event
0 0 "$@"
1362 function enable_jul_lttng_event
()
1368 if [ -z $channel_name ]; then
1369 # default channel if none specified
1372 chan
="-c $channel_name"
1375 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1376 enable-event
"$event_name" $chan -s $sess_name -j
1377 ok $?
"Enable JUL event $event_name for session $sess_name"
1380 function enable_jul_lttng_event_loglevel
()
1383 local event_name
="$2"
1385 local channel_name
=$4
1387 if [ -z $channel_name ]; then
1388 # default channel if none specified
1391 chan
="-c $channel_name"
1394 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1395 enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j
1396 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1399 function enable_log4j_lttng_event
()
1403 local channel_name
=$3
1407 # default channel if none specified
1408 if [ -n "$channel_name" ]; then
1409 chan_opt
=("-c" "$channel_name")
1412 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1413 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1414 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1417 function enable_log4j_lttng_event_filter
()
1423 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1424 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1425 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1428 function enable_log4j_lttng_event_filter_loglevel_only
()
1435 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1436 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1437 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1440 function enable_log4j_lttng_event_loglevel
()
1445 local channel_name
=$4
1448 # default channel if none specified
1449 if [ -n "$channel_name" ]; then
1450 chan_opt
=("-c" "$channel_name")
1453 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1454 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1455 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1458 function enable_log4j_lttng_event_loglevel_only
()
1463 local channel_name
=$4
1467 # default channel if none specified
1468 if [ -n "$channel_name" ]; then
1469 chan_opt
=("-c" "$channel_name")
1472 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1473 enable-event
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1474 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1477 function enable_python_lttng_event
()
1483 if [ -z $channel_name ]; then
1484 # default channel if none specified
1487 chan
="-c $channel_name"
1490 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1491 enable-event
"$event_name" $chan -s $sess_name -p
1492 ok $?
"Enable Python event $event_name for session $sess_name"
1495 function enable_python_lttng_event_loglevel
()
1498 local event_name
="$2"
1500 local channel_name
=$4
1502 if [ -z $channel_name ]; then
1503 # default channel if none specified
1506 chan
="-c $channel_name"
1509 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1510 enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p
1511 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1514 function enable_ust_lttng_event_filter
()
1516 local sess_name
="$1"
1517 local event_name
="$2"
1519 local channel_name
=$4
1521 if [ -z $channel_name ]; then
1522 # default channel if none specified
1525 chan
="-c $channel_name"
1528 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1529 enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter"
1530 ok $?
"Enable event $event_name with filtering for session $sess_name"
1533 function enable_ust_lttng_event_loglevel
()
1535 local sess_name
="$1"
1536 local event_name
="$2"
1538 local channel_name
="$4"
1540 if [ -n "${channel_name}" ] ; then
1541 chan
=('-c' "${channel_name}")
1544 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1545 enable-event
"${chan[@]}" "$event_name" -s "${sess_name}" -u --loglevel="${loglevel}"
1546 ok $?
"Enable event $event_name with loglevel $loglevel"
1549 function enable_ust_lttng_event_loglevel_only
()
1551 local sess_name
="$1"
1552 local event_name
="$2"
1554 local channel_name
="$4"
1556 if [ -n "${channel_name}" ] ; then
1557 chan
=('-c' "${channel_name}")
1560 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1561 enable-event
"${chan[@]}" "$event_name" -s "${sess_name}" -u --loglevel-only "${loglevel}"
1562 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1565 function disable_ust_lttng_event
()
1567 local sess_name
="$1"
1568 local event_name
="$2"
1569 local channel_name
="$3"
1571 if [ -z $channel_name ]; then
1572 # default channel if none specified
1575 chan
="-c $channel_name"
1578 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1579 disable-event
"$event_name" -s $sess_name $chan -u
1580 ok $?
"Disable event $event_name for session $sess_name"
1583 function disable_jul_lttng_event
()
1585 local sess_name
="$1"
1586 local event_name
="$2"
1588 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1589 ok $?
"Disable JUL event $event_name for session $sess_name"
1592 function disable_log4j_lttng_event
()
1594 local sess_name
="$1"
1595 local event_name
="$2"
1597 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1598 disable-event
"$event_name" -s "$sess_name" --log4j
1599 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1602 function disable_python_lttng_event
()
1604 local sess_name
="$1"
1605 local event_name
="$2"
1607 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1608 disable-event
"$event_name" -s $sess_name -p
1609 ok $?
"Disable Python event $event_name for session $sess_name"
1612 function start_lttng_tracing_opt
()
1615 local expected_to_fail
=$2
1618 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1621 if [[ $expected_to_fail -eq "1" ]]; then
1624 if [ $withtap -eq "1" ]; then
1625 ok $?
"Start tracing for session $sess_name failed as expected"
1628 if [ $withtap -eq "1" ]; then
1629 ok
$ret "Start tracing for session $sess_name"
1634 function start_lttng_tracing_ok
()
1636 start_lttng_tracing_opt
1 0 "$@"
1639 function start_lttng_tracing_fail
()
1641 start_lttng_tracing_opt
1 1 "$@"
1644 function start_lttng_tracing_notap
()
1646 start_lttng_tracing_opt
0 1 "$@"
1649 function stop_lttng_tracing_opt
()
1652 local expected_to_fail
=$2
1655 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1658 if [[ $expected_to_fail -eq "1" ]]; then
1661 if [ $withtap -eq "1" ]; then
1662 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1665 if [ $withtap -eq "1" ]; then
1666 ok
$ret "Stop lttng tracing for session $sess_name"
1671 function stop_lttng_tracing_ok
()
1673 stop_lttng_tracing_opt
1 0 "$@"
1676 function stop_lttng_tracing_fail
()
1678 stop_lttng_tracing_opt
1 1 "$@"
1681 function stop_lttng_tracing_notap
()
1683 stop_lttng_tracing_opt
0 0 "$@"
1686 function destroy_lttng_session
()
1689 local expected_to_fail
=$2
1692 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1695 if [[ $expected_to_fail -eq "1" ]]; then
1698 if [ $withtap -eq "1" ]; then
1699 ok
$ret "Destroy session $sess_name failed as expected"
1702 if [ $withtap -eq "1" ]; then
1703 ok
$ret "Destroy session $sess_name"
1708 function destroy_lttng_session_ok
()
1710 destroy_lttng_session
1 0 "$@"
1714 function destroy_lttng_session_fail
()
1716 destroy_lttng_session
1 1 "$@"
1719 function destroy_lttng_session_notap
()
1721 destroy_lttng_session
0 0 "$@"
1724 function destroy_lttng_sessions
()
1726 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1728 ok $?
"Destroy all lttng sessions"
1731 function lttng_snapshot_add_output
()
1733 local expected_to_fail
=$1
1738 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1739 snapshot add-output
-s $sess_name $trace_path $opts
1741 if [[ $expected_to_fail -eq 1 ]]; then
1743 ok $?
"Added snapshot output $trace_path failed as expected"
1745 ok
$ret "Added snapshot output $trace_path"
1749 function lttng_snapshot_add_output_ok
()
1751 lttng_snapshot_add_output
0 "$@"
1754 function lttng_snapshot_add_output_fail
()
1756 lttng_snapshot_add_output
1 "$@"
1759 function lttng_snapshot_del_output
()
1761 local expected_to_fail
=$1
1765 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1766 snapshot del-output
-s $sess_name $id
1768 if [[ $expected_to_fail -eq "1" ]]; then
1770 ok $?
"Deleted snapshot output id $id failed as expected"
1772 ok
$ret "Deleted snapshot output id $id"
1776 function lttng_snapshot_del_output_ok
()
1778 lttng_snapshot_del_output
0 "$@"
1781 function lttng_snapshot_del_output_fail
()
1783 lttng_snapshot_del_output
1 "$@"
1786 function lttng_snapshot_record
()
1791 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1792 snapshot record
-s "$sess_name" "$trace_path"
1793 ok $?
"Snapshot recorded"
1796 function lttng_snapshot_list
()
1799 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1800 snapshot list-output
-s $sess_name
1801 ok $?
"Snapshot list"
1804 function lttng_save
()
1809 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1810 save
$sess_name $opts
1811 ok $?
"Session saved"
1814 function lttng_load
()
1816 local expected_to_fail
=$1
1819 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1822 if [[ $expected_to_fail -eq "1" ]]; then
1824 ok $?
"Load command failed as expected with opts: $opts"
1826 ok
$ret "Load command with opts: $opts"
1830 function lttng_load_ok
()
1835 function lttng_load_fail
()
1840 function lttng_track
()
1842 local expected_to_fail
="$1"
1845 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1847 if [[ $expected_to_fail -eq "1" ]]; then
1849 ok $?
"Track command failed as expected with opts: $opts"
1851 ok
$ret "Track command with opts: $opts"
1855 function lttng_track_ok
()
1860 function lttng_track_fail
()
1865 function lttng_untrack
()
1867 local expected_to_fail
="$1"
1870 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1872 if [[ $expected_to_fail -eq "1" ]]; then
1874 ok $?
"Untrack command failed as expected with opts: $opts"
1876 ok
$ret "Untrack command with opts: $opts"
1880 function lttng_untrack_ok
()
1882 lttng_untrack
0 "$@"
1885 function lttng_untrack_fail
()
1887 lttng_untrack
1 "$@"
1890 function lttng_track_pid_ok
()
1893 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1894 ok $?
"Lttng track pid on the kernel domain"
1897 function lttng_untrack_kernel_all_ok
()
1899 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1900 ok $?
"Lttng untrack all pid on the kernel domain"
1903 function lttng_track_ust_ok
()
1905 lttng_track_ok
-u "$@"
1908 function lttng_track_ust_fail
()
1910 lttng_track_fail
-u "$@"
1913 function lttng_track_kernel_ok
()
1915 lttng_track_ok
-k "$@"
1918 function lttng_track_kernel_fail
()
1920 lttng_track_fail
-k "$@"
1923 function lttng_untrack_ust_ok
()
1925 lttng_untrack_ok
-u "$@"
1928 function lttng_untrack_ust_fail
()
1930 lttng_untrack_fail
-u "$@"
1933 function lttng_untrack_kernel_ok
()
1935 lttng_untrack_ok
-k "$@"
1938 function lttng_untrack_kernel_fail
()
1940 lttng_untrack_fail
-k "$@"
1943 function lttng_add_context_list
()
1945 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1948 ok
$ret "Context listing"
1951 function add_context_lttng
()
1953 local expected_to_fail
="$1"
1955 local session_name
="$3"
1956 local channel_name
="$4"
1959 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1960 add-context
-s $session_name -c $channel_name -t $type $domain
1962 if [[ $expected_to_fail -eq "1" ]]; then
1964 ok $?
"Add context command failed as expected for type: $type"
1966 ok
$ret "Add context command for type: $type"
1970 function add_context_ust_ok
()
1972 add_context_lttng
0 -u "$@"
1975 function add_context_ust_fail
()
1977 add_context_lttng
1 -u "$@"
1980 function add_context_kernel_ok
()
1982 add_context_lttng
0 -k "$@"
1985 function add_context_kernel_fail
()
1987 add_context_lttng
1 -k "$@"
1990 function wait_live_trace_ready
()
1993 local zero_client_match
=0
1995 diag
"Waiting for live trace at url: $url"
1996 while [ $zero_client_match -eq 0 ]; do
1997 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
2000 pass
"Waiting for live trace at url: $url"
2003 function wait_live_viewer_connect
()
2006 local one_client_match
=0
2008 diag
"Waiting for live viewers on url: $url"
2009 while [ $one_client_match -eq 0 ]; do
2010 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
2013 pass
"Waiting for live viewers on url: $url"
2016 function bail_out_if_no_babeltrace
()
2018 which "$BABELTRACE_BIN" >/dev
/null
2019 if [ $?
-ne 0 ]; then
2020 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
2024 # Check that the trace metadata contains '$expected' event ids matching '$event_name'.
2025 function validate_metadata_event
()
2035 metadata_file
=$
(find "$trace_path" -name "metadata")
2036 metadata_path
=$
(dirname "$metadata_file")
2038 bail_out_if_no_babeltrace
2040 count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
"$metadata_path" |
grep -c "$event_name")
2042 test "$count" -eq "$expected"
2043 ok $?
"Found $count / $expected metadata event id matching '$event_name'"
2046 # Check that the trace contains '$expected' events matching '$event_name', other
2047 # events not matching '$event_name' can be present.
2048 function trace_matches
()
2057 bail_out_if_no_babeltrace
2059 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2060 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2062 test "$count" -eq "$expected"
2064 ok $?
"Found $count / $expected events matching '$event_name' out of $total events"
2067 # Check that the trace contains '$expected' events matching '$event_name' and no
2069 function trace_match_only
()
2078 bail_out_if_no_babeltrace
2080 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2081 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2083 test "$expected" -eq "$count" && test "$total" -eq "$expected"
2085 ok $?
"Found $count / $expected events matching '$event_name' amongst $total events"
2088 # Check that the trace contains at least 1 event matching each name in the
2089 # comma separated list '$event_names'.
2090 function validate_trace
()
2092 local event_names
=$1
2097 bail_out_if_no_babeltrace
2101 for event_name
in $event_names; do
2102 # trace_path is unquoted since callers make use of globbing
2103 count
=$
($BABELTRACE_BIN $trace_path |
grep -c "$event_name")
2105 ok $?
"Found $count events matching '$event_name'"
2110 # Check that the trace contains at least 1 event matching each name in the
2111 # comma separated list '$event_names' and a total of '$expected' events.
2112 function validate_trace_count
()
2114 local event_names
=$1
2121 bail_out_if_no_babeltrace
2125 for event_name
in $event_names; do
2126 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2128 ok $?
"Found '$count' events matching '$event_name'"
2129 total
=$
(( total
+ count
))
2132 test $total -eq "$expected"
2133 ok $?
"Found $total events, expected $expected events"
2136 # Check that the trace contains at least '$expected_min' event matching each
2137 # name in the comma separated list '$event_names' and a total at least
2138 # '$expected_min' and less than '$expected_max' events.
2139 function validate_trace_count_range_incl_min_excl_max
()
2141 local event_names
=$1
2143 local expected_min
=$3
2144 local expected_max
=$4
2149 bail_out_if_no_babeltrace
2153 for event_name
in $event_names; do
2154 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2155 test "$count" -ge "$expected_min"
2156 ok $?
"Found $count events matching '$event_name', expected at least $expected_min"
2157 total
=$
(( total
+ count
))
2160 test $total -ge "$expected_min" && test $total -lt "$expected_max"
2161 ok $?
"Found a total of $total events, expected at least $expected_min and less than $expected_max"
2164 function trace_first_line
()
2168 $BABELTRACE_BIN "$trace_path" |
head -n 1
2171 # Check that the trace contains at least 1 event matching the grep extended
2172 # regexp '$event_exp'.
2173 function validate_trace_exp
()
2180 bail_out_if_no_babeltrace
2182 # event_exp is unquoted since it contains multiple grep arguments
2183 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c --extended-regexp $event_exp)
2185 ok $?
"Found $count events matching expression '$event_exp'"
2188 # Check that the trace contains at least 1 event matching the grep extended
2189 # regexp '$event_exp' and zero event not matching it.
2190 function validate_trace_only_exp
()
2198 bail_out_if_no_babeltrace
2200 # event_exp is unquoted since it contains multiple grep arguments
2201 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c --extended-regexp $event_exp)
2202 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2204 test "$count" -gt 0 && test "$total" -eq "$count"
2205 ok $?
"Found $count events matching expression '$event_exp' amongst $total events"
2208 # Check that the trace is valid and contains 0 event.
2209 function validate_trace_empty
()
2216 bail_out_if_no_babeltrace
2218 events
=$
($BABELTRACE_BIN "$trace_path")
2220 if [ $ret -ne 0 ]; then
2221 fail
"Failed to parse trace"
2225 count
=$
(echo -n "$events" |
wc -l)
2227 ok $?
"Validate trace is empty, found $count events"
2230 function validate_directory_empty
()
2232 local trace_path
="$1"
2238 # Do not double quote `$trace_path` below as we want wildcards to be
2240 files
="$(ls -A $trace_path)"
2242 if [ $ret -ne 0 ]; then
2243 fail
"Failed to list content of directory \"$trace_path\""
2247 nb_files
="$(echo -n "$files" | wc -l)"
2248 test "$nb_files" -eq 0
2249 ok $?
"Directory \"$trace_path\" is empty"
2252 function validate_trace_session_ust_empty
()
2254 validate_directory_empty
"$1"/ust
2257 function validate_trace_session_kernel_empty
()
2259 validate_trace_empty
"$1"/kernel
2262 function regenerate_metadata
()
2264 local expected_to_fail
=$1
2267 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2268 regenerate metadata
-s $sess_name
2270 if [[ $expected_to_fail -eq "1" ]]; then
2272 ok $?
"Expected fail on regenerate metadata $sess_name"
2274 ok
$ret "Metadata regenerate $sess_name"
2278 function regenerate_metadata_ok
()
2280 regenerate_metadata
0 "$@"
2283 function regenerate_metadata_fail
()
2285 regenerate_metadata
1 "$@"
2288 function regenerate_statedump
()
2290 local expected_to_fail
=$1
2293 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2294 regenerate statedump
-s $sess_name
2296 if [[ $expected_to_fail -eq "1" ]]; then
2298 ok $?
"Expected fail on regenerate statedump $sess_name"
2300 ok
$ret "Statedump regenerate $sess_name"
2304 function regenerate_statedump_ok
()
2306 regenerate_statedump
0 "$@"
2309 function regenerate_statedump_fail
()
2311 regenerate_statedump
1 "$@"
2314 function rotate_session
()
2316 local expected_to_fail
=$1
2319 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2322 if [[ $expected_to_fail -eq "1" ]]; then
2324 ok $?
"Expected fail on rotate session $sess_name"
2326 ok
$ret "Rotate session $sess_name"
2330 function rotate_session_ok
()
2332 rotate_session
0 "$@"
2335 function rotate_session_fail
()
2337 rotate_session
1 "$@"
2340 function destructive_tests_enabled
()
2342 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2349 function lttng_enable_rotation_timer
()
2351 local expected_to_fail
=$1
2355 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2356 enable-rotation
-s $sess_name --timer $period
2358 if [[ $expected_to_fail -eq "1" ]]; then
2360 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2362 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2366 function lttng_enable_rotation_timer_ok
()
2368 lttng_enable_rotation_timer
0 $@
2371 function lttng_enable_rotation_timer_fail
()
2373 lttng_enable_rotation_timer
1 $@
2376 function lttng_enable_rotation_size
()
2378 local expected_to_fail
=$1
2382 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2383 enable-rotation
-s $sess_name --size $size
2385 if [[ $expected_to_fail -eq "1" ]]; then
2387 ok $?
"Expected to fail to set a periodic rotation of session $sess_name" "every " $size " bytes"
2389 ok
$ret "Set a scheduled rotation of session $sess_name" "every " $size " bytes"
2393 function lttng_enable_rotation_size_ok
()
2395 lttng_enable_rotation_size
0 $@
2398 function lttng_enable_rotation_size_fail
()
2400 lttng_enable_rotation_size
1 $@
2403 function lttng_clear_session
()
2405 local expected_to_fail
=$1
2408 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2411 if [[ $expected_to_fail -eq "1" ]]; then
2413 ok $?
"Expected fail on clear session $sess_name"
2415 ok
$ret "Clear session $sess_name"
2419 function lttng_clear_session_ok
()
2421 lttng_clear_session
0 $@
2424 function lttng_clear_session_fail
()
2426 lttng_clear_session
1 $@
2429 function lttng_clear_all
()
2431 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2433 ok $?
"Clear all lttng sessions"
2436 function lttng_add_trigger
()
2438 local expected_to_fail
="$1"
2439 local trigger_name
="$2"
2443 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2444 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2446 if [[ $expected_to_fail -eq "1" ]]; then
2448 ok $?
"Add trigger $trigger_name failed as expected"
2450 ok
$ret "Add trigger $trigger_name"
2454 function lttng_remove_trigger
()
2456 local expected_to_fail
="$1"
2457 local trigger_name
="$2"
2460 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2461 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2463 if [[ $expected_to_fail -eq "1" ]]; then
2465 ok $?
"Remove trigger $trigger_name failed as expected"
2467 ok
$ret "Remove trigger $trigger_name"
2471 function lttng_add_trigger_ok
()
2473 lttng_add_trigger
0 "$@"
2476 function lttng_add_trigger_fail
()
2478 lttng_add_trigger
1 "$@"
2481 function lttng_remove_trigger_ok
()
2483 lttng_remove_trigger
0 "$@"
2486 function list_triggers_matches_ok
()
2488 local tmp_stdout
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2489 local tmp_stderr
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2491 local test_name
="$1"
2492 local expected_stdout_file
="$2"
2494 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2496 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2497 ok $?
"${test_name}: exit code is 0"
2499 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2500 ok $?
"${test_name}: expected stdout"
2502 diff -u /dev
/null
"${tmp_stderr}"
2503 ok $?
"${test_name}: expected stderr"
2505 rm -f "${tmp_stdout}"
2506 rm -f "${tmp_stderr}"
2509 function list_triggers_matches_mi_ok
()
2512 local tmp_stdout_raw
2515 local test_name
="$1"
2516 local expected_stdout_file
="$2"
2518 tmp_stdout_raw
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2519 tmp_stdout
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2520 tmp_stderr
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2522 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2524 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2525 ok $?
"${test_name}: exit code is 0"
2527 # Pretty-fy xml before further test.
2528 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2530 $MI_VALIDATE "${tmp_stdout}"
2531 ok $?
"list-trigger mi is valid"
2533 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2534 ok $?
"${test_name}: expected stdout"
2536 diff -u /dev
/null
"${tmp_stderr}"
2537 ok $?
"${test_name}: expected stderr"
2539 rm -f "${tmp_stdout}"
2540 rm -f "${tmp_stdout_raw}"
2541 rm -f "${tmp_stderr}"
2544 function validate_path_pattern
()
2548 # Base path is only used in error case and is used to list the content
2557 if [ "$ret" -ne "0" ]; then
2558 diag
"Path pattern expected: $pattern"
2559 # List the tracepath for more info. We use find as a recursive
2561 diag
"The base path content:"
2562 find "$base_path" -print
2566 function validate_trace_path_ust_uid
()
2569 local session_name
=$2
2571 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2573 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2576 function validate_trace_path_ust_uid_network
()
2579 local session_name
=$2
2582 local hostname
=$HOSTNAME
2586 # If the session was given a network base path (e.g
2587 # 127.0.0.1/my/custom/path on creation, there is no session name
2588 # component to the path on the relayd side. Caller can simply not pass a
2589 # session name for this scenario.
2590 if [ -n "$session_name" ]; then
2591 session_name
="$session_name-$date_time_pattern"
2592 if [ -n "$base_path" ]; then
2593 fail
"Session name and base path are mutually exclusive"
2598 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2600 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2603 function validate_trace_path_ust_uid_snapshot_network
()
2606 local session_name
=$2
2607 local snapshot_name
=$3
2608 local snapshot_number
=$4
2610 local hostname
=$HOSTNAME
2615 # If the session/output was given a network base path (e.g
2616 # 127.0.0.1/my/custom/path on creation, there is no session name
2617 # component to the path on the relayd side. Caller can simply not pass a
2618 # session name for this scenario.
2619 if [ -n "$session_name" ]; then
2620 session_name
="$session_name-$date_time_pattern"
2621 if [ -n "$base_path" ]; then
2622 fail
"Session name and base path are mutually exclusive"
2627 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2629 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2632 function validate_trace_path_ust_uid_snapshot
()
2635 local session_name
=$2
2636 local snapshot_name
=$3
2637 local snapshot_number
=$4
2643 # If the session/output was given a network base path (e.g
2644 # 127.0.0.1/my/custom/path) on creation, there is no session name
2645 # component to the path on the relayd side. Caller can simply not pass a
2646 # session name for this scenario.
2647 if [ -n "$session_name" ]; then
2648 session_name
="$session_name-$date_time_pattern"
2649 if [ -n "$base_path" ]; then
2650 fail
"Session name and base path are mutually exclusive"
2655 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2657 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2660 function validate_trace_path_ust_pid
()
2663 local session_name
=$2
2669 # If the session was given a trace path on creation, there is no session
2670 # name component to the path. Caller can simply not pass a session name
2671 # for this scenario.
2672 if [ -n "$session_name" ]; then
2673 session_name
="$session_name-$date_time_pattern"
2676 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2678 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2681 function validate_trace_path_kernel
()
2684 local session_name
=$2
2687 # If the session was given a trace path on creation, there is no session
2688 # name component to the path. Caller can simply not pass a session name
2689 # for this scenario.
2690 if [ -n "$session_name" ]; then
2691 session_name
="$session_name-$date_time_pattern"
2694 pattern
="$trace_path/$session_name/kernel/metadata"
2696 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2699 function validate_trace_path_kernel_network
()
2702 local session_name
=$2
2703 local hostname
=$HOSTNAME
2704 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2706 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2709 function validate_trace_path_kernel_snapshot
()
2712 local session_name
=$2
2713 local snapshot_name
=$3
2714 local snapshot_number
=$4
2719 # If the session/output was given a network base path (e.g
2720 # 127.0.0.1/my/custom/path on creation, there is no session name
2721 # component to the path on the relayd side. Caller can simply not pass a
2722 # session name for this scenario.
2723 if [ -n "$session_name" ]; then
2724 session_name
="$session_name-$date_time_pattern"
2725 if [ -n "$base_path" ]; then
2726 fail
"Session name and base path are mutually exclusive"
2731 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2733 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2736 function validate_trace_path_kernel_snapshot_network
()
2739 local session_name
=$2
2740 local snapshot_name
=$3
2741 local snapshot_number
=$4
2743 local hostname
=$HOSTNAME
2747 # If the session/output was given a network base path (e.g
2748 # 127.0.0.1/my/custom/path on creation, there is no session name
2749 # component to the path on the relayd side. Caller can simply not pass a
2750 # session name for this scenario.
2751 if [ -n "$session_name" ]; then
2752 session_name
="$session_name-$date_time_pattern"
2753 if [ -n "$base_path" ]; then
2754 fail
"Session name and base path are mutually exclusive"
2759 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2761 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"