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 $process_mode $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 # Multiply time by 5 to adjust for sleeping every 0.1s
679 if [ -n "$timeout_s" ]; then
680 dtimeleft_s
=$
((timeout_s
* 2 * 5))
684 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
685 if [ -z "$pids" ]; then
686 if [ "$is_cleanup" -eq 1 ]; then
688 elif [ "$withtap" -eq "1" ]; then
689 fail
"No relay daemon to kill"
691 LTTNG_BAIL_OUT
"No relay daemon to kill"
696 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
698 # shellcheck disable=SC2086
699 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
701 if [ "$withtap" -eq "1" ]; then
702 fail
"Kill relay daemon"
706 while [ -n "$out" ]; do
707 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
708 if [ -n "$dtimeleft_s" ]; then
709 if [ $dtimeleft_s -lt 0 ]; then
713 dtimeleft_s
=$
((dtimeleft_s
- 1))
717 if [ "$withtap" -eq "1" ]; then
718 if [ "$retval" -eq "0" ]; then
719 pass
"Wait after kill relay daemon"
721 fail
"Wait after kill relay daemon"
728 function stop_lttng_relayd
()
730 stop_lttng_relayd_opt
1 0 "$@"
733 function stop_lttng_relayd_notap
()
735 stop_lttng_relayd_opt
0 0 "$@"
738 function stop_lttng_relayd_cleanup
()
740 stop_lttng_relayd_opt
0 1 "$@"
743 #First arg: show tap output
744 #Second argument: load path for automatic loading
745 function start_lttng_sessiond_opt
()
750 # The rest of the arguments will be passed directly to lttng-sessiond.
756 local long_bit_value
=
757 long_bit_value
=$
(getconf LONG_BIT
)
759 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
760 # Env variable requested no session daemon
764 DIR
=$
(readlink
-f "$TESTDIR")
766 # Get long_bit value for 32/64 consumerd
767 case "$long_bit_value" in
769 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
772 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
779 # Check for env. variable. Allow the use of LD_PRELOAD etc.
780 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
781 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
783 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
785 if ! validate_kernel_version
; then
786 fail
"Start session daemon"
787 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
790 diag
"export LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/"
791 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/"}"
792 export LTTNG_SESSION_CONFIG_XSD_PATH
794 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
796 if [ -n "$load_path" ]; then
797 diag
"env $env_vars --load $load_path --background $consumerd $@"
798 # shellcheck disable=SC2086
799 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
801 diag
"env $env_vars --background $consumerd $@"
802 # shellcheck disable=SC2086
803 env
$env_vars --background "$consumerd" "$@"
805 #$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
807 if [ "$withtap" -eq "1" ]; then
808 ok
$status "Start session daemon"
813 function start_lttng_sessiond
()
815 start_lttng_sessiond_opt
1 "$@"
818 function start_lttng_sessiond_notap
()
820 start_lttng_sessiond_opt
0 "$@"
823 function stop_lttng_sessiond_opt
()
834 if [ -z "$signal" ]; then
838 # Multiply time by 2 to simplify integer arithmetic
839 # Multiply time by 5 to adjust for sleeping every 0.1s
840 if [ -n "$timeout_s" ]; then
841 dtimeleft_s
=$
((timeout_s
* 2 * 5))
844 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
845 # Env variable requested no session daemon
849 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
850 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
852 if [ -n "$runas_pids" ]; then
853 pids
="$pids $runas_pids"
856 if [ -z "$pids" ]; then
857 if [ "$is_cleanup" -eq 1 ]; then
859 elif [ "$withtap" -eq "1" ]; then
860 fail
"No session daemon to kill"
862 LTTNG_BAIL_OUT
"No session daemon to kill"
867 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
869 # shellcheck disable=SC2086
870 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
872 if [ "$withtap" -eq "1" ]; then
873 fail
"Kill sessions daemon"
877 while [ -n "$out" ]; do
878 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
879 if [ -n "$dtimeleft_s" ]; then
880 if [ $dtimeleft_s -lt 0 ]; then
884 dtimeleft_s
=$
((dtimeleft_s
- 1))
889 while [ -n "$out" ]; do
890 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
891 if [ -n "$dtimeleft_s" ]; then
892 if [ $dtimeleft_s -lt 0 ]; then
896 dtimeleft_s
=$
((dtimeleft_s
- 1))
901 if [ "$withtap" -eq "1" ]; then
902 if [ "$retval" -eq "0" ]; then
903 pass
"Wait after kill session daemon"
905 fail
"Wait after kill session daemon"
909 if [ "$signal" = "SIGKILL" ]; then
910 if [ "$(id -u)" -eq "0" ]; then
912 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
914 if [ -n "$modules" ]; then
915 diag
"Unloading all LTTng modules"
916 modprobe
--remove "$modules"
924 function stop_lttng_sessiond
()
926 stop_lttng_sessiond_opt
1 0 "$@"
929 function stop_lttng_sessiond_notap
()
931 stop_lttng_sessiond_opt
0 0 "$@"
934 function stop_lttng_sessiond_cleanup
()
936 stop_lttng_sessiond_opt
0 1 "$@"
939 function sigstop_lttng_sessiond_opt
()
945 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
946 # Env variable requested no session daemon
950 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
952 if [ "$withtap" -eq "1" ]; then
953 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
956 # shellcheck disable=SC2086
957 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
958 if [ "$withtap" -eq "1" ]; then
959 fail
"Sending SIGSTOP to session daemon"
963 while [ $out -ne 0 ]; do
964 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
966 # Wait until state becomes stopped for session
969 for sessiond_pid
in $pids; do
970 state
="$(ps -p "$sessiond_pid" -o state= )"
971 if [[ -n "$state" && "$state" != "T" ]]; then
977 if [ "$withtap" -eq "1" ]; then
978 pass
"Sending SIGSTOP to session daemon"
983 function sigstop_lttng_sessiond
()
985 sigstop_lttng_sessiond_opt
1 "$@"
988 function sigstop_lttng_sessiond_notap
()
990 sigstop_lttng_sessiond_opt
0 "$@"
993 function stop_lttng_consumerd_opt
()
1003 if [ -z "$signal" ]; then
1007 # Multiply time by 2 to simplify integer arithmetic
1008 # Multiply time by 5 to adjust for sleeping every 0.1s
1009 if [ -n "$timeout_s" ]; then
1010 dtimeleft_s
=$
((timeout_s
* 2 * 5))
1013 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1015 if [ -z "$pids" ]; then
1016 if [ "$is_cleanup" -eq 1 ]; then
1018 elif [ "$withtap" -eq "1" ]; then
1019 fail
"No consumerd daemon to kill"
1021 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
1026 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1028 # shellcheck disable=SC2086
1029 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
1031 if [ "$withtap" -eq "1" ]; then
1032 fail
"Kill consumer daemon"
1036 while [ $out -ne 0 ]; do
1037 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1039 # If consumerds are still present check their status.
1040 # A zombie status qualifies the consumerd as *killed*
1042 for consumer_pid
in $pids; do
1043 state
="$(ps -p "$consumer_pid" -o state= )"
1044 if [[ -n "$state" && "$state" != "Z" ]]; then
1048 if [ -n "$dtimeleft_s" ]; then
1049 if [ $dtimeleft_s -lt 0 ]; then
1053 dtimeleft_s
=$
((dtimeleft_s
- 1))
1057 if [ "$withtap" -eq "1" ]; then
1058 if [ "$retval" -eq "0" ]; then
1059 pass
"Wait after kill consumer daemon"
1061 fail
"Wait after kill consumer daemon"
1069 function stop_lttng_consumerd
()
1071 stop_lttng_consumerd_opt
1 0 "$@"
1074 function stop_lttng_consumerd_notap
()
1076 stop_lttng_consumerd_opt
0 0 "$@"
1079 function stop_lttng_consumerd_cleanup
()
1081 stop_lttng_consumerd_opt
0 1 "$@"
1084 function sigstop_lttng_consumerd_opt
()
1087 local signal
=SIGSTOP
1090 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1092 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1094 # shellcheck disable=SC2086
1095 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1098 if [ $retval -eq 1 ]; then
1099 if [ "$withtap" -eq "1" ]; then
1100 fail
"Sending SIGSTOP to consumer daemon"
1105 while [ $out -ne 0 ]; do
1106 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1108 # Wait until state becomes stopped for all
1111 for consumer_pid
in $pids; do
1112 state
="$(ps -p "$consumer_pid" -o state= )"
1113 if [[ -n "$state" && "$state" != "T" ]]; then
1119 if [ "$withtap" -eq "1" ]; then
1120 pass
"Sending SIGSTOP to consumer daemon"
1126 function sigstop_lttng_consumerd
()
1128 sigstop_lttng_consumerd_opt
1 "$@"
1131 function sigstop_lttng_consumerd_notap
()
1133 sigstop_lttng_consumerd_opt
0 "$@"
1136 function list_lttng_with_opts
()
1142 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1145 if [ $withtap -eq "1" ]; then
1146 ok
$ret "Lttng-tool list command with option $opts"
1150 function list_lttng_ok
()
1152 list_lttng_with_opts
1 "$@"
1155 function list_lttng_notap
()
1157 list_lttng_with_opts
0 "$@"
1160 function create_lttng_session_no_output
()
1165 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1166 create
$sess_name --no-output $opts
1167 ok $?
"Create session $sess_name in no-output mode"
1170 function create_lttng_session_uri
() {
1175 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1176 create
$sess_name -U $uri $opts
1177 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1180 function create_lttng_session
()
1183 local expected_to_fail
=$2
1188 if [ -z "$trace_path" ]; then
1189 # Use lttng-sessiond default output.
1192 trace_path
="-o $trace_path"
1195 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1196 create
"$sess_name" $trace_path $opt
1198 if [ $expected_to_fail -eq "1" ]; then
1201 if [ $withtap -eq "1" ]; then
1202 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1205 if [ $withtap -eq "1" ]; then
1206 ok
$ret "Create session $sess_name in $trace_path"
1212 function create_lttng_session_ok
()
1214 create_lttng_session
1 0 "$@"
1217 function create_lttng_session_fail
()
1219 create_lttng_session
1 1 "$@"
1222 function create_lttng_session_notap
()
1224 create_lttng_session
0 0 "$@"
1228 function enable_ust_lttng_channel
()
1231 local expected_to_fail
=$2
1233 local channel_name
=$4
1236 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1237 enable-channel
-u $channel_name -s $sess_name $opts
1239 if [[ $expected_to_fail -eq "1" ]]; then
1242 if [ $withtap -eq "1" ]; then
1243 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1246 if [ $withtap -eq "1" ]; then
1247 ok
$ret "Enable channel $channel_name for session $sess_name"
1253 function enable_ust_lttng_channel_ok
()
1255 enable_ust_lttng_channel
1 0 "$@"
1258 function enable_ust_lttng_channel_fail
()
1260 enable_ust_lttng_channel
1 1 "$@"
1263 function enable_ust_lttng_channel_notap
()
1265 enable_ust_lttng_channel
0 0 "$@"
1268 function disable_ust_lttng_channel
()
1271 local channel_name
=$2
1273 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1274 disable-channel
-u $channel_name -s $sess_name
1275 ok $?
"Disable channel $channel_name for session $sess_name"
1278 function enable_lttng_mmap_overwrite_kernel_channel
()
1281 local channel_name
=$2
1283 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1284 enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite
1285 ok $?
"Enable channel $channel_name for session $sess_name"
1288 function enable_lttng_mmap_discard_small_kernel_channel
()
1291 local channel_name
=$2
1293 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1294 enable-channel
-s $sess_name $channel_name -k --output mmap
--discard --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2
1295 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1298 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1301 local channel_name
=$2
1303 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1304 enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2
1305 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1308 function enable_lttng_mmap_overwrite_ust_channel
()
1311 local channel_name
=$2
1313 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1314 enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite
1315 ok $?
"Enable channel $channel_name for session $sess_name"
1318 function enable_ust_lttng_event
()
1321 local expected_to_fail
=$2
1323 local event_name
="$4"
1324 local channel_name
=$5
1326 if [ -z $channel_name ]; then
1327 # default channel if none specified
1330 chan
="-c $channel_name"
1333 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1334 enable-event
"$event_name" $chan -s "$sess_name" -u
1336 if [[ $expected_to_fail -eq "1" ]]; then
1339 if [[ $withtap -eq "1" ]]; then
1340 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1343 if [[ $withtap -eq "1" ]]; then
1344 ok
$ret "Enable ust event $event_name for session $sess_name"
1350 function enable_ust_lttng_event_ok
()
1352 enable_ust_lttng_event
1 0 "$@"
1355 function enable_ust_lttng_event_fail
()
1357 enable_ust_lttng_event
1 1 "$@"
1360 function enable_ust_lttng_event_notap
()
1362 enable_ust_lttng_event
0 0 "$@"
1365 function enable_jul_lttng_event
()
1371 if [ -z $channel_name ]; then
1372 # default channel if none specified
1375 chan
="-c $channel_name"
1378 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1379 enable-event
"$event_name" $chan -s $sess_name -j
1380 ok $?
"Enable JUL event $event_name for session $sess_name"
1383 function enable_jul_lttng_event_loglevel
()
1386 local event_name
="$2"
1388 local channel_name
=$4
1390 if [ -z $channel_name ]; then
1391 # default channel if none specified
1394 chan
="-c $channel_name"
1397 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1398 enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j
1399 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1402 function enable_log4j_lttng_event
()
1406 local channel_name
=$3
1410 # default channel if none specified
1411 if [ -n "$channel_name" ]; then
1412 chan_opt
=("-c" "$channel_name")
1415 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1416 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1417 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1420 function enable_log4j_lttng_event_filter
()
1426 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1427 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1428 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1431 function enable_log4j_lttng_event_filter_loglevel_only
()
1438 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1439 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1440 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1443 function enable_log4j_lttng_event_loglevel
()
1448 local channel_name
=$4
1451 # default channel if none specified
1452 if [ -n "$channel_name" ]; then
1453 chan_opt
=("-c" "$channel_name")
1456 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1457 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1458 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1461 function enable_log4j_lttng_event_loglevel_only
()
1466 local channel_name
=$4
1470 # default channel if none specified
1471 if [ -n "$channel_name" ]; then
1472 chan_opt
=("-c" "$channel_name")
1475 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1476 enable-event
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1477 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1480 function enable_python_lttng_event
()
1486 if [ -z $channel_name ]; then
1487 # default channel if none specified
1490 chan
="-c $channel_name"
1493 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1494 enable-event
"$event_name" $chan -s $sess_name -p
1495 ok $?
"Enable Python event $event_name for session $sess_name"
1498 function enable_python_lttng_event_loglevel
()
1501 local event_name
="$2"
1503 local channel_name
=$4
1505 if [ -z $channel_name ]; then
1506 # default channel if none specified
1509 chan
="-c $channel_name"
1512 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1513 enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p
1514 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1517 function enable_ust_lttng_event_filter
()
1519 local sess_name
="$1"
1520 local event_name
="$2"
1522 local channel_name
=$4
1524 if [ -z $channel_name ]; then
1525 # default channel if none specified
1528 chan
="-c $channel_name"
1531 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1532 enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter"
1533 ok $?
"Enable event $event_name with filtering for session $sess_name"
1536 function enable_ust_lttng_event_loglevel
()
1538 local sess_name
="$1"
1539 local event_name
="$2"
1541 local channel_name
="$4"
1543 if [ -n "${channel_name}" ] ; then
1544 chan
=('-c' "${channel_name}")
1547 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1548 enable-event
"${chan[@]}" "$event_name" -s "${sess_name}" -u --loglevel="${loglevel}"
1549 ok $?
"Enable event $event_name with loglevel $loglevel"
1552 function enable_ust_lttng_event_loglevel_only
()
1554 local sess_name
="$1"
1555 local event_name
="$2"
1557 local channel_name
="$4"
1559 if [ -n "${channel_name}" ] ; then
1560 chan
=('-c' "${channel_name}")
1563 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1564 enable-event
"${chan[@]}" "$event_name" -s "${sess_name}" -u --loglevel-only "${loglevel}"
1565 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1568 function disable_ust_lttng_event
()
1570 local sess_name
="$1"
1571 local event_name
="$2"
1572 local channel_name
="$3"
1574 if [ -z $channel_name ]; then
1575 # default channel if none specified
1578 chan
="-c $channel_name"
1581 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1582 disable-event
"$event_name" -s $sess_name $chan -u
1583 ok $?
"Disable event $event_name for session $sess_name"
1586 function disable_jul_lttng_event
()
1588 local sess_name
="$1"
1589 local event_name
="$2"
1591 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1592 ok $?
"Disable JUL event $event_name for session $sess_name"
1595 function disable_log4j_lttng_event
()
1597 local sess_name
="$1"
1598 local event_name
="$2"
1600 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1601 disable-event
"$event_name" -s "$sess_name" --log4j
1602 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1605 function disable_python_lttng_event
()
1607 local sess_name
="$1"
1608 local event_name
="$2"
1610 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1611 disable-event
"$event_name" -s $sess_name -p
1612 ok $?
"Disable Python event $event_name for session $sess_name"
1615 function start_lttng_tracing_opt
()
1618 local expected_to_fail
=$2
1621 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1624 if [[ $expected_to_fail -eq "1" ]]; then
1627 if [ $withtap -eq "1" ]; then
1628 ok $?
"Start tracing for session $sess_name failed as expected"
1631 if [ $withtap -eq "1" ]; then
1632 ok
$ret "Start tracing for session $sess_name"
1637 function start_lttng_tracing_ok
()
1639 start_lttng_tracing_opt
1 0 "$@"
1642 function start_lttng_tracing_fail
()
1644 start_lttng_tracing_opt
1 1 "$@"
1647 function start_lttng_tracing_notap
()
1649 start_lttng_tracing_opt
0 1 "$@"
1652 function stop_lttng_tracing_opt
()
1655 local expected_to_fail
=$2
1658 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1661 if [[ $expected_to_fail -eq "1" ]]; then
1664 if [ $withtap -eq "1" ]; then
1665 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1668 if [ $withtap -eq "1" ]; then
1669 ok
$ret "Stop lttng tracing for session $sess_name"
1674 function stop_lttng_tracing_ok
()
1676 stop_lttng_tracing_opt
1 0 "$@"
1679 function stop_lttng_tracing_fail
()
1681 stop_lttng_tracing_opt
1 1 "$@"
1684 function stop_lttng_tracing_notap
()
1686 stop_lttng_tracing_opt
0 0 "$@"
1689 function destroy_lttng_session
()
1692 local expected_to_fail
=$2
1695 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1698 if [[ $expected_to_fail -eq "1" ]]; then
1701 if [ $withtap -eq "1" ]; then
1702 ok
$ret "Destroy session $sess_name failed as expected"
1705 if [ $withtap -eq "1" ]; then
1706 ok
$ret "Destroy session $sess_name"
1711 function destroy_lttng_session_ok
()
1713 destroy_lttng_session
1 0 "$@"
1717 function destroy_lttng_session_fail
()
1719 destroy_lttng_session
1 1 "$@"
1722 function destroy_lttng_session_notap
()
1724 destroy_lttng_session
0 0 "$@"
1727 function destroy_lttng_sessions
()
1729 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1731 ok $?
"Destroy all lttng sessions"
1734 function lttng_snapshot_add_output
()
1736 local expected_to_fail
=$1
1741 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1742 snapshot add-output
-s $sess_name $trace_path $opts
1744 if [[ $expected_to_fail -eq 1 ]]; then
1746 ok $?
"Added snapshot output $trace_path failed as expected"
1748 ok
$ret "Added snapshot output $trace_path"
1752 function lttng_snapshot_add_output_ok
()
1754 lttng_snapshot_add_output
0 "$@"
1757 function lttng_snapshot_add_output_fail
()
1759 lttng_snapshot_add_output
1 "$@"
1762 function lttng_snapshot_del_output
()
1764 local expected_to_fail
=$1
1768 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1769 snapshot del-output
-s $sess_name $id
1771 if [[ $expected_to_fail -eq "1" ]]; then
1773 ok $?
"Deleted snapshot output id $id failed as expected"
1775 ok
$ret "Deleted snapshot output id $id"
1779 function lttng_snapshot_del_output_ok
()
1781 lttng_snapshot_del_output
0 "$@"
1784 function lttng_snapshot_del_output_fail
()
1786 lttng_snapshot_del_output
1 "$@"
1789 function lttng_snapshot_record
()
1794 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1795 snapshot record
-s "$sess_name" "$trace_path"
1796 ok $?
"Snapshot recorded"
1799 function lttng_snapshot_list
()
1802 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1803 snapshot list-output
-s $sess_name
1804 ok $?
"Snapshot list"
1807 function lttng_save
()
1812 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1813 save
$sess_name $opts
1814 ok $?
"Session saved"
1817 function lttng_load
()
1819 local expected_to_fail
=$1
1822 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1825 if [[ $expected_to_fail -eq "1" ]]; then
1827 ok $?
"Load command failed as expected with opts: $opts"
1829 ok
$ret "Load command with opts: $opts"
1833 function lttng_load_ok
()
1838 function lttng_load_fail
()
1843 function lttng_track
()
1845 local expected_to_fail
="$1"
1848 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1850 if [[ $expected_to_fail -eq "1" ]]; then
1852 ok $?
"Track command failed as expected with opts: $opts"
1854 ok
$ret "Track command with opts: $opts"
1858 function lttng_track_ok
()
1863 function lttng_track_fail
()
1868 function lttng_untrack
()
1870 local expected_to_fail
="$1"
1873 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1875 if [[ $expected_to_fail -eq "1" ]]; then
1877 ok $?
"Untrack command failed as expected with opts: $opts"
1879 ok
$ret "Untrack command with opts: $opts"
1883 function lttng_untrack_ok
()
1885 lttng_untrack
0 "$@"
1888 function lttng_untrack_fail
()
1890 lttng_untrack
1 "$@"
1893 function lttng_track_pid_ok
()
1896 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1897 ok $?
"Lttng track pid on the kernel domain"
1900 function lttng_untrack_kernel_all_ok
()
1902 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1903 ok $?
"Lttng untrack all pid on the kernel domain"
1906 function lttng_track_ust_ok
()
1908 lttng_track_ok
-u "$@"
1911 function lttng_track_ust_fail
()
1913 lttng_track_fail
-u "$@"
1916 function lttng_track_kernel_ok
()
1918 lttng_track_ok
-k "$@"
1921 function lttng_track_kernel_fail
()
1923 lttng_track_fail
-k "$@"
1926 function lttng_untrack_ust_ok
()
1928 lttng_untrack_ok
-u "$@"
1931 function lttng_untrack_ust_fail
()
1933 lttng_untrack_fail
-u "$@"
1936 function lttng_untrack_kernel_ok
()
1938 lttng_untrack_ok
-k "$@"
1941 function lttng_untrack_kernel_fail
()
1943 lttng_untrack_fail
-k "$@"
1946 function lttng_add_context_list
()
1948 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1951 ok
$ret "Context listing"
1954 function add_context_lttng
()
1956 local expected_to_fail
="$1"
1958 local session_name
="$3"
1959 local channel_name
="$4"
1962 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1963 add-context
-s $session_name -c $channel_name -t $type $domain
1965 if [[ $expected_to_fail -eq "1" ]]; then
1967 ok $?
"Add context command failed as expected for type: $type"
1969 ok
$ret "Add context command for type: $type"
1973 function add_context_ust_ok
()
1975 add_context_lttng
0 -u "$@"
1978 function add_context_ust_fail
()
1980 add_context_lttng
1 -u "$@"
1983 function add_context_kernel_ok
()
1985 add_context_lttng
0 -k "$@"
1988 function add_context_kernel_fail
()
1990 add_context_lttng
1 -k "$@"
1993 function wait_live_trace_ready
()
1996 local zero_client_match
=0
1998 diag
"Waiting for live trace at url: $url"
1999 while [ $zero_client_match -eq 0 ]; do
2000 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
2003 pass
"Waiting for live trace at url: $url"
2006 function wait_live_viewer_connect
()
2009 local one_client_match
=0
2011 diag
"Waiting for live viewers on url: $url"
2012 while [ $one_client_match -eq 0 ]; do
2013 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
2016 pass
"Waiting for live viewers on url: $url"
2019 function bail_out_if_no_babeltrace
()
2021 which "$BABELTRACE_BIN" >/dev
/null
2022 if [ $?
-ne 0 ]; then
2023 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
2027 # Check that the trace metadata contains '$expected' event ids matching '$event_name'.
2028 function validate_metadata_event
()
2038 metadata_file
=$
(find "$trace_path" -name "metadata")
2039 metadata_path
=$
(dirname "$metadata_file")
2041 bail_out_if_no_babeltrace
2043 count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
"$metadata_path" |
grep -c "$event_name")
2045 test "$count" -eq "$expected"
2046 ok $?
"Found $count / $expected metadata event id matching '$event_name'"
2049 # Check that the trace contains '$expected' events matching '$event_name', other
2050 # events not matching '$event_name' can be present.
2051 function trace_matches
()
2060 bail_out_if_no_babeltrace
2062 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2063 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2065 test "$count" -eq "$expected"
2067 ok $?
"Found $count / $expected events matching '$event_name' out of $total events"
2070 # Check that the trace contains '$expected' events matching '$event_name' and no
2072 function trace_match_only
()
2081 bail_out_if_no_babeltrace
2083 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2084 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2086 test "$expected" -eq "$count" && test "$total" -eq "$expected"
2088 ok $?
"Found $count / $expected events matching '$event_name' amongst $total events"
2091 # Check that the trace contains at least 1 event matching each name in the
2092 # comma separated list '$event_names'.
2093 function validate_trace
()
2095 local event_names
=$1
2100 bail_out_if_no_babeltrace
2104 for event_name
in $event_names; do
2105 # trace_path is unquoted since callers make use of globbing
2106 count
=$
($BABELTRACE_BIN $trace_path |
grep -c "$event_name")
2108 ok $?
"Found $count events matching '$event_name'"
2113 # Check that the trace contains at least 1 event matching each name in the
2114 # comma separated list '$event_names' and a total of '$expected' events.
2115 function validate_trace_count
()
2117 local event_names
=$1
2124 bail_out_if_no_babeltrace
2128 for event_name
in $event_names; do
2129 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2131 ok $?
"Found '$count' events matching '$event_name'"
2132 total
=$
(( total
+ count
))
2135 test $total -eq "$expected"
2136 ok $?
"Found $total events, expected $expected events"
2139 # Check that the trace contains at least '$expected_min' event matching each
2140 # name in the comma separated list '$event_names' and a total at least
2141 # '$expected_min' and less than '$expected_max' events.
2142 function validate_trace_count_range_incl_min_excl_max
()
2144 local event_names
=$1
2146 local expected_min
=$3
2147 local expected_max
=$4
2152 bail_out_if_no_babeltrace
2156 for event_name
in $event_names; do
2157 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2158 test "$count" -ge "$expected_min"
2159 ok $?
"Found $count events matching '$event_name', expected at least $expected_min"
2160 total
=$
(( total
+ count
))
2163 test $total -ge "$expected_min" && test $total -lt "$expected_max"
2164 ok $?
"Found a total of $total events, expected at least $expected_min and less than $expected_max"
2167 function trace_first_line
()
2171 $BABELTRACE_BIN "$trace_path" |
head -n 1
2174 # Check that the trace contains at least 1 event matching the grep extended
2175 # regexp '$event_exp'.
2176 function validate_trace_exp
()
2183 bail_out_if_no_babeltrace
2185 # event_exp is unquoted since it contains multiple grep arguments
2186 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c --extended-regexp $event_exp)
2188 ok $?
"Found $count events matching expression '$event_exp'"
2191 # Check that the trace contains at least 1 event matching the grep extended
2192 # regexp '$event_exp' and zero event not matching it.
2193 function validate_trace_only_exp
()
2201 bail_out_if_no_babeltrace
2203 # event_exp is unquoted since it contains multiple grep arguments
2204 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c --extended-regexp $event_exp)
2205 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2207 test "$count" -gt 0 && test "$total" -eq "$count"
2208 ok $?
"Found $count events matching expression '$event_exp' amongst $total events"
2211 # Check that the trace is valid and contains 0 event.
2212 function validate_trace_empty
()
2219 bail_out_if_no_babeltrace
2221 events
=$
($BABELTRACE_BIN "$trace_path")
2223 if [ $ret -ne 0 ]; then
2224 fail
"Failed to parse trace"
2228 count
=$
(echo -n "$events" |
wc -l)
2230 ok $?
"Validate trace is empty, found $count events"
2233 function validate_directory_empty
()
2235 local trace_path
="$1"
2241 # Do not double quote `$trace_path` below as we want wildcards to be
2243 files
="$(ls -A $trace_path)"
2245 if [ $ret -ne 0 ]; then
2246 fail
"Failed to list content of directory \"$trace_path\""
2250 nb_files
="$(echo -n "$files" | wc -l)"
2251 test "$nb_files" -eq 0
2252 ok $?
"Directory \"$trace_path\" is empty"
2255 function validate_trace_session_ust_empty
()
2257 validate_directory_empty
"$1"/ust
2260 function validate_trace_session_kernel_empty
()
2262 validate_trace_empty
"$1"/kernel
2265 function regenerate_metadata
()
2267 local expected_to_fail
=$1
2270 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2271 regenerate metadata
-s $sess_name
2273 if [[ $expected_to_fail -eq "1" ]]; then
2275 ok $?
"Expected fail on regenerate metadata $sess_name"
2277 ok
$ret "Metadata regenerate $sess_name"
2281 function regenerate_metadata_ok
()
2283 regenerate_metadata
0 "$@"
2286 function regenerate_metadata_fail
()
2288 regenerate_metadata
1 "$@"
2291 function regenerate_statedump
()
2293 local expected_to_fail
=$1
2296 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2297 regenerate statedump
-s $sess_name
2299 if [[ $expected_to_fail -eq "1" ]]; then
2301 ok $?
"Expected fail on regenerate statedump $sess_name"
2303 ok
$ret "Statedump regenerate $sess_name"
2307 function regenerate_statedump_ok
()
2309 regenerate_statedump
0 "$@"
2312 function regenerate_statedump_fail
()
2314 regenerate_statedump
1 "$@"
2317 function rotate_session
()
2319 local expected_to_fail
=$1
2322 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2325 if [[ $expected_to_fail -eq "1" ]]; then
2327 ok $?
"Expected fail on rotate session $sess_name"
2329 ok
$ret "Rotate session $sess_name"
2333 function rotate_session_ok
()
2335 rotate_session
0 "$@"
2338 function rotate_session_fail
()
2340 rotate_session
1 "$@"
2343 function destructive_tests_enabled
()
2345 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2352 function lttng_enable_rotation_timer
()
2354 local expected_to_fail
=$1
2358 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2359 enable-rotation
-s $sess_name --timer $period
2361 if [[ $expected_to_fail -eq "1" ]]; then
2363 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2365 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2369 function lttng_enable_rotation_timer_ok
()
2371 lttng_enable_rotation_timer
0 $@
2374 function lttng_enable_rotation_timer_fail
()
2376 lttng_enable_rotation_timer
1 $@
2379 function lttng_enable_rotation_size
()
2381 local expected_to_fail
=$1
2385 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2386 enable-rotation
-s $sess_name --size $size
2388 if [[ $expected_to_fail -eq "1" ]]; then
2390 ok $?
"Expected to fail to set a periodic rotation of session $sess_name" "every " $size " bytes"
2392 ok
$ret "Set a scheduled rotation of session $sess_name" "every " $size " bytes"
2396 function lttng_enable_rotation_size_ok
()
2398 lttng_enable_rotation_size
0 $@
2401 function lttng_enable_rotation_size_fail
()
2403 lttng_enable_rotation_size
1 $@
2406 function lttng_clear_session
()
2408 local expected_to_fail
=$1
2411 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2414 if [[ $expected_to_fail -eq "1" ]]; then
2416 ok $?
"Expected fail on clear session $sess_name"
2418 ok
$ret "Clear session $sess_name"
2422 function lttng_clear_session_ok
()
2424 lttng_clear_session
0 $@
2427 function lttng_clear_session_fail
()
2429 lttng_clear_session
1 $@
2432 function lttng_clear_all
()
2434 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2436 ok $?
"Clear all lttng sessions"
2439 function lttng_add_trigger
()
2441 local expected_to_fail
="$1"
2442 local trigger_name
="$2"
2446 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2447 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2449 if [[ $expected_to_fail -eq "1" ]]; then
2451 ok $?
"Add trigger $trigger_name failed as expected"
2453 ok
$ret "Add trigger $trigger_name"
2457 function lttng_remove_trigger
()
2459 local expected_to_fail
="$1"
2460 local trigger_name
="$2"
2463 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2464 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2466 if [[ $expected_to_fail -eq "1" ]]; then
2468 ok $?
"Remove trigger $trigger_name failed as expected"
2470 ok
$ret "Remove trigger $trigger_name"
2474 function lttng_add_trigger_ok
()
2476 lttng_add_trigger
0 "$@"
2479 function lttng_add_trigger_fail
()
2481 lttng_add_trigger
1 "$@"
2484 function lttng_remove_trigger_ok
()
2486 lttng_remove_trigger
0 "$@"
2489 function list_triggers_matches_ok
()
2491 local tmp_stdout
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2492 local tmp_stderr
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2494 local test_name
="$1"
2495 local expected_stdout_file
="$2"
2497 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2499 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2500 ok $?
"${test_name}: exit code is 0"
2502 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2503 ok $?
"${test_name}: expected stdout"
2505 diff -u /dev
/null
"${tmp_stderr}"
2506 ok $?
"${test_name}: expected stderr"
2508 rm -f "${tmp_stdout}"
2509 rm -f "${tmp_stderr}"
2512 function list_triggers_matches_mi_ok
()
2515 local tmp_stdout_raw
2518 local test_name
="$1"
2519 local expected_stdout_file
="$2"
2521 tmp_stdout_raw
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2522 tmp_stdout
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2523 tmp_stderr
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2525 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2527 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2528 ok $?
"${test_name}: exit code is 0"
2530 # Pretty-fy xml before further test.
2531 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2533 $MI_VALIDATE "${tmp_stdout}"
2534 ok $?
"list-trigger mi is valid"
2536 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2537 ok $?
"${test_name}: expected stdout"
2539 diff -u /dev
/null
"${tmp_stderr}"
2540 ok $?
"${test_name}: expected stderr"
2542 rm -f "${tmp_stdout}"
2543 rm -f "${tmp_stdout_raw}"
2544 rm -f "${tmp_stderr}"
2547 function validate_path_pattern
()
2551 # Base path is only used in error case and is used to list the content
2560 if [ "$ret" -ne "0" ]; then
2561 diag
"Path pattern expected: $pattern"
2562 # List the tracepath for more info. We use find as a recursive
2564 diag
"The base path content:"
2565 find "$base_path" -print
2569 function validate_trace_path_ust_uid
()
2572 local session_name
=$2
2574 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2576 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2579 function validate_trace_path_ust_uid_network
()
2582 local session_name
=$2
2585 local hostname
=$HOSTNAME
2589 # If the session was given a network base path (e.g
2590 # 127.0.0.1/my/custom/path on creation, there is no session name
2591 # component to the path on the relayd side. Caller can simply not pass a
2592 # session name for this scenario.
2593 if [ -n "$session_name" ]; then
2594 session_name
="$session_name-$date_time_pattern"
2595 if [ -n "$base_path" ]; then
2596 fail
"Session name and base path are mutually exclusive"
2601 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2603 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2606 function validate_trace_path_ust_uid_snapshot_network
()
2609 local session_name
=$2
2610 local snapshot_name
=$3
2611 local snapshot_number
=$4
2613 local hostname
=$HOSTNAME
2618 # If the session/output was given a network base path (e.g
2619 # 127.0.0.1/my/custom/path on creation, there is no session name
2620 # component to the path on the relayd side. Caller can simply not pass a
2621 # session name for this scenario.
2622 if [ -n "$session_name" ]; then
2623 session_name
="$session_name-$date_time_pattern"
2624 if [ -n "$base_path" ]; then
2625 fail
"Session name and base path are mutually exclusive"
2630 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2632 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2635 function validate_trace_path_ust_uid_snapshot
()
2638 local session_name
=$2
2639 local snapshot_name
=$3
2640 local snapshot_number
=$4
2646 # If the session/output was given a network base path (e.g
2647 # 127.0.0.1/my/custom/path) on creation, there is no session name
2648 # component to the path on the relayd side. Caller can simply not pass a
2649 # session name for this scenario.
2650 if [ -n "$session_name" ]; then
2651 session_name
="$session_name-$date_time_pattern"
2652 if [ -n "$base_path" ]; then
2653 fail
"Session name and base path are mutually exclusive"
2658 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2660 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2663 function validate_trace_path_ust_pid
()
2666 local session_name
=$2
2672 # If the session was given a trace path on creation, there is no session
2673 # name component to the path. Caller can simply not pass a session name
2674 # for this scenario.
2675 if [ -n "$session_name" ]; then
2676 session_name
="$session_name-$date_time_pattern"
2679 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2681 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2684 function validate_trace_path_kernel
()
2687 local session_name
=$2
2690 # If the session was given a trace path on creation, there is no session
2691 # name component to the path. Caller can simply not pass a session name
2692 # for this scenario.
2693 if [ -n "$session_name" ]; then
2694 session_name
="$session_name-$date_time_pattern"
2697 pattern
="$trace_path/$session_name/kernel/metadata"
2699 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2702 function validate_trace_path_kernel_network
()
2705 local session_name
=$2
2706 local hostname
=$HOSTNAME
2707 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2709 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2712 function validate_trace_path_kernel_snapshot
()
2715 local session_name
=$2
2716 local snapshot_name
=$3
2717 local snapshot_number
=$4
2722 # If the session/output was given a network base path (e.g
2723 # 127.0.0.1/my/custom/path on creation, there is no session name
2724 # component to the path on the relayd side. Caller can simply not pass a
2725 # session name for this scenario.
2726 if [ -n "$session_name" ]; then
2727 session_name
="$session_name-$date_time_pattern"
2728 if [ -n "$base_path" ]; then
2729 fail
"Session name and base path are mutually exclusive"
2734 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2736 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2739 function validate_trace_path_kernel_snapshot_network
()
2742 local session_name
=$2
2743 local snapshot_name
=$3
2744 local snapshot_number
=$4
2746 local hostname
=$HOSTNAME
2750 # If the session/output was given a network base path (e.g
2751 # 127.0.0.1/my/custom/path on creation, there is no session name
2752 # component to the path on the relayd side. Caller can simply not pass a
2753 # session name for this scenario.
2754 if [ -n "$session_name" ]; then
2755 session_name
="$session_name-$date_time_pattern"
2756 if [ -n "$base_path" ]; then
2757 fail
"Session name and base path are mutually exclusive"
2762 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2764 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"