1 # Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
3 # SPDX-License-Identifier: LGPL-2.1-only
6 SESSIOND_BIN
="lttng-sessiond"
7 SESSIOND_MATCH
=".*lttng-sess.*"
8 RUNAS_BIN
="lttng-runas"
9 RUNAS_MATCH
=".*lttng-runas.*"
10 CONSUMERD_BIN
="lttng-consumerd"
11 CONSUMERD_MATCH
=".*lttng-consumerd.*"
12 RELAYD_BIN
="lttng-relayd"
13 RELAYD_MATCH
=".*lttng-relayd.*"
15 BABELTRACE_BIN
="babeltrace"
17 ERROR_OUTPUT_DEST
=/dev
/null
18 MI_XSD_MAJOR_VERSION
=4
19 MI_XSD_MINOR_VERSION
=1
20 MI_XSD_PATH
="$TESTDIR/../src/common/mi-lttng-${MI_XSD_MAJOR_VERSION}.${MI_XSD_MINOR_VERSION}.xsd"
21 MI_VALIDATE
="$TESTDIR/utils/xml-utils/validate_xml ${MI_XSD_PATH}"
23 XML_PRETTY
="$TESTDIR/utils/xml-utils/pretty_xml"
24 XML_EXTRACT
="$TESTDIR/utils/xml-utils/extract_xml"
25 XML_NODE_CHECK
="${XML_EXTRACT} -e"
27 # To match 20201127-175802
28 date_time_pattern
="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]"
29 # The size of a long on this system
30 system_long_bit_size
=$
(getconf LONG_BIT
)
32 # Minimal kernel version supported for session daemon tests
33 KERNEL_MAJOR_VERSION
=2
34 KERNEL_MINOR_VERSION
=6
35 KERNEL_PATCHLEVEL_VERSION
=27
37 # We set the default UST register timeout and network and app socket timeout to
38 # "wait forever", so that basic tests don't have to worry about hitting
39 # timeouts on busy systems. Specialized tests should test those corner-cases.
40 export LTTNG_UST_REGISTER_TIMEOUT
=-1
41 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
42 export LTTNG_APP_SOCKET_TIMEOUT
=-1
44 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
45 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
46 # its own sessiond if none is running. It also ensures that 'lttng create'
47 # fails when no sessiond is running.
48 export LTTNG_SESSIOND_PATH
="/bin/true"
50 source $TESTDIR/utils
/tap
/tap.sh
52 if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then
53 LTTNG_TEST_TEARDOWN_TIMEOUT
=60
56 # Enable job monitor mode.
57 # Here we are mostly interested in the following from the monitor mode:
58 # All processes run in a separate process group.
59 # This allows us to ensure that all subprocesses from all background tasks are
60 # cleaned up correctly using signal to process group id.
63 kill_background_jobs
()
68 if [ -z "$pids" ]; then
75 # Use negative number to send the signal to the process group.
76 # This ensure that any subprocesses receive the signal.
77 # /dev/null is used since there is an acceptable race between
78 # the moments the pids are listed and the moment we send a
80 kill -SIGTERM -- "-$pid" 2>/dev
/null
86 # Try to kill daemons gracefully
87 stop_lttng_relayd_cleanup SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
88 stop_lttng_sessiond_cleanup SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
90 # If daemons are still present, forcibly kill them
91 stop_lttng_relayd_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
92 stop_lttng_sessiond_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
93 stop_lttng_consumerd_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
98 function full_cleanup
()
104 function LTTNG_BAIL_OUT
()
110 function null_pipes
()
117 trap full_cleanup SIGINT SIGTERM
119 # perl prove closes its child pipes before giving it a chance to run its
120 # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
121 # to allow those trap handlers to proceed.
123 trap null_pipes SIGPIPE
125 # Check pgrep from env, default to pgrep if none
126 if [ -z "$PGREP" ]; then
130 # Due to the renaming of threads we need to use the full command (pgrep -f) to
131 # identify the pids for multiple lttng related processes. The problem with "pgrep
132 # -f" is that it ends up also looking at the arguments. We use a two stage
133 # lookup. The first one is using "pgrep -f" yielding potential candidate.
134 # The second on perform grep on the basename of the first field of the
135 # /proc/pid/cmdline of the previously identified pids. The first field
136 # correspond to the actual command.
137 function lttng_pgrep
()
141 local full_command_no_argument
142 local command_basename
144 possible_pids
=$
($PGREP -f "$pattern")
145 if [ -z "$possible_pids" ]; then
149 while IFS
= read -r pid
; do
150 # /proc/pid/cmdline is null separated.
151 if full_command_no_argument
=$
(cut
-d '' -f 1 2>/dev
/null
< /proc
/"$pid"/cmdline
); then
152 command_basename
=$
(basename "$full_command_no_argument")
153 if grep -q "$pattern" <<< "$command_basename"; then
157 done <<< "$possible_pids"
163 # Check if we are a terminal
165 echo -e "\e[1;32mOK\e[0m"
171 function print_fail
()
173 # Check if we are a terminal
175 echo -e "\e[1;31mFAIL\e[0m"
181 function print_test_banner
()
187 function validate_kernel_version
()
189 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
190 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
193 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
196 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
202 # Generate a random string
203 # $1 = number of characters; defaults to 16
204 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
205 function randstring
()
207 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
208 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
212 # Helpers for get_possible_cpus.
213 function get_possible_cpus_count_from_sysfs_possible_mask
()
215 local max_possible_cpu_id
217 # The Awk script extracts the highest CPU id from the possible CPU
218 # mask. Assuming a numerical order, a field separator '-' and a record
219 # separator ','. The last value parsed is the highest id.
220 if [ -f /sys
/devices
/system
/cpu
/possible
]; then
221 max_possible_cpu_id
=$
(awk -F '-' 'BEGIN { RS = ","} { last = $NF } END { printf("%d\n", last) }' \
222 /sys
/devices
/system
/cpu
/possible
)
223 echo "$((max_possible_cpu_id+1))"
229 # This is a fallback if the possible CPU mask is not available. This will not
230 # take into account unplugged CPUs.
231 function get_max_cpus_count_from_sysfs_cpu_directories
()
233 local max_possible_cpu_id
=0
236 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
237 current_cpu_id
="${i#/sys/devices/system/cpu/cpu}"
238 if [ "$current_cpu_id" -gt "$max_possible_cpu_id" ]; then
239 max_possible_cpu_id
="$current_cpu_id"
243 echo "$((max_possible_cpu_id+1))"
246 # Return the number of possible CPUs.
247 function get_possible_cpus_count
()
249 local possible_cpus_count
250 possible_cpus_count
=$
(get_possible_cpus_count_from_sysfs_possible_mask
)
252 if [ "$possible_cpus_count" -eq "0" ]; then
253 local configured_cpus_count
254 configured_cpus_count
=$
(getconf _NPROCESSORS_CONF
)
255 possible_cpus_count
=$
(get_max_cpus_count_from_sysfs_cpu_directories
)
256 possible_cpus_count
=$
((configured_cpus_count
> possible_cpus_count \
257 ? configured_cpus_count \
258 : possible_cpus_count
))
261 echo "$possible_cpus_count"
264 # Return the list of exposed CPU.
266 # NOTE! Use it like so:
268 # IFS=" " read -r -a VARIABLE <<< "$(get_exposed_cpus_list)"
269 function get_exposed_cpus_list
()
273 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
274 list
+=("${i#/sys/devices/system/cpu/cpu}")
280 # Return the number of _configured_ CPUs.
281 function conf_proc_count
()
283 getconf _NPROCESSORS_CONF
284 if [ $?
-ne 0 ]; then
285 diag
"Failed to get the number of configured CPUs"
290 # Check if base lttng-modules are present.
291 # Bail out on failure
292 function validate_lttng_modules_present
()
294 # Check for loadable modules.
295 modprobe
-n lttng-tracer
2>/dev
/null
296 if [ $?
-eq 0 ]; then
300 # Check for builtin modules.
301 ls /proc
/lttng
> /dev
/null
2>&1
302 if [ $?
-eq 0 ]; then
306 LTTNG_BAIL_OUT
"LTTng modules not detected."
309 # Run the lttng binary.
311 # The first two arguments are stdout and stderr redirect paths, respectively.
312 # The rest of the arguments are forwarded to the lttng binary
313 function _run_lttng_cmd
315 local stdout_dest
="$1"
316 local stderr_dest
="$2"
319 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN $*"
320 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"
323 function enable_kernel_lttng_event
326 local expected_to_fail
="$2"
328 local event_name
="$4"
329 local channel_name
="$5"
331 if [ -z "$event_name" ]; then
332 # Enable all event if no event name specified
336 if [ -z "$channel_name" ]; then
337 # default channel if none specified
340 chan
="-c $channel_name"
343 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
345 if [[ $expected_to_fail -eq "1" ]]; then
348 if [ $withtap -eq "1" ]; then
349 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
352 if [ $withtap -eq "1" ]; then
353 ok
$ret "Enable kernel event $event_name for session $sess_name"
358 function enable_kernel_lttng_event_ok
()
360 enable_kernel_lttng_event
1 0 "$@"
363 function enable_kernel_lttng_event_fail
()
365 enable_kernel_lttng_event
1 1 "$@"
368 function enable_kernel_lttng_event_notap
()
370 enable_kernel_lttng_event
0 0 "$@"
374 function lttng_enable_kernel_event
376 enable_kernel_lttng_event_ok
"$@"
379 function lttng_enable_kernel_syscall
()
381 local expected_to_fail
=$1
383 local syscall_name
=$3
384 local channel_name
=$4
386 if [ -z $syscall_name ]; then
387 # Enable all event if no syscall name specified
391 if [ -z $channel_name ]; then
392 # default channel if none specified
395 chan
="-c $channel_name"
398 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
400 if [[ $expected_to_fail -eq "1" ]]; then
402 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
404 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
408 function lttng_enable_kernel_syscall_ok
()
410 lttng_enable_kernel_syscall
0 "$@"
413 function lttng_enable_kernel_syscall_fail
()
415 lttng_enable_kernel_syscall
1 "$@"
418 function lttng_disable_kernel_syscall
()
420 local expected_to_fail
=$1
422 local syscall_name
=$3
423 local channel_name
=$4
425 if [ -z $syscall_name ]; then
426 # Enable all event if no syscall name specified
430 if [ -z $channel_name ]; then
431 # default channel if none specified
434 chan
="-c $channel_name"
437 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
440 if [[ $expected_to_fail -eq "1" ]]; then
442 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
444 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
448 function lttng_disable_kernel_syscall_ok
()
450 lttng_disable_kernel_syscall
0 "$@"
453 function lttng_disable_kernel_syscall_fail
()
455 lttng_disable_kernel_syscall
1 "$@"
458 function lttng_enable_kernel_function_event
()
460 local expected_to_fail
="$1"
463 local event_name
="$4"
465 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
467 if [[ $expected_to_fail -eq "1" ]]; then
469 ok $?
"Enable kernel function event for session $sess_name failed as expected"
471 ok
$ret "Enable kernel function event for session $sess_name"
475 function lttng_enable_kernel_function_event_ok
()
477 lttng_enable_kernel_function_event
0 "$@"
480 function lttng_enable_kernel_userspace_probe_event
()
482 local expected_to_fail
="$1"
485 local event_name
="$4"
487 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
489 if [[ $expected_to_fail -eq "1" ]]; then
491 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
493 ok
$ret "Enable kernel userspace probe event for session $sess_name"
497 function lttng_enable_kernel_userspace_probe_event_fail
()
499 lttng_enable_kernel_userspace_probe_event
1 "$@"
502 function lttng_enable_kernel_userspace_probe_event_ok
()
504 lttng_enable_kernel_userspace_probe_event
0 "$@"
507 function disable_kernel_lttng_userspace_probe_event_ok
()
510 local event_name
="$2"
512 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
513 ok $?
"Disable kernel event $target for session $sess_name"
515 function lttng_enable_kernel_channel
()
518 local expected_to_fail
=$2
520 local channel_name
=$4
523 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
525 if [[ $expected_to_fail -eq "1" ]]; then
528 if [ $withtap -eq "1" ]; then
529 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
532 if [ $withtap -eq "1" ]; then
533 ok
$ret "Enable channel $channel_name for session $sess_name"
538 function lttng_enable_kernel_channel_ok
()
540 lttng_enable_kernel_channel
1 0 "$@"
543 function lttng_enable_kernel_channel_fail
()
545 lttng_enable_kernel_channel
1 1 "$@"
548 function lttng_enable_kernel_channel_notap
()
550 lttng_enable_kernel_channel
0 0 "$@"
553 function enable_kernel_lttng_channel_ok
()
555 lttng_enable_kernel_channel
1 0 "$@"
558 function lttng_disable_kernel_channel
()
560 local expected_to_fail
=$1
562 local channel_name
=$3
564 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
566 if [[ $expected_to_fail -eq "1" ]]; then
568 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
570 ok
$ret "Disable channel $channel_name for session $sess_name"
574 function lttng_disable_kernel_channel_ok
()
576 lttng_disable_kernel_channel
0 "$@"
579 function lttng_disable_kernel_channel_fail
()
581 lttng_disable_kernel_channel
1 "$@"
584 function start_lttng_relayd_opt
()
587 local process_mode
=$2
590 DIR
=$
(readlink
-f "$TESTDIR")
592 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
593 # shellcheck disable=SC2086
594 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
595 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
596 if [ $?
-eq 1 ]; then
597 if [ $withtap -eq "1" ]; then
598 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
602 if [ $withtap -eq "1" ]; then
603 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
607 pass
"Start lttng-relayd (opt: $opt)"
611 function start_lttng_relayd
()
613 start_lttng_relayd_opt
1 "-b" "$@"
616 function start_lttng_relayd_notap
()
618 start_lttng_relayd_opt
0 "-b" "$@"
621 function stop_lttng_relayd_opt
()
631 if [ -z "$signal" ]; then
636 # Multiply time by 2 to simplify integer arithmetic
637 if [ -n "$timeout_s" ]; then
638 dtimeleft_s
=$
((timeout_s
* 2))
642 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
643 if [ -z "$pids" ]; then
644 if [ "$is_cleanup" -eq 1 ]; then
646 elif [ "$withtap" -eq "1" ]; then
647 fail
"No relay daemon to kill"
649 LTTNG_BAIL_OUT
"No relay daemon to kill"
654 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
656 # shellcheck disable=SC2086
657 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
659 if [ "$withtap" -eq "1" ]; then
660 fail
"Kill relay daemon"
664 while [ -n "$out" ]; do
665 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
666 if [ -n "$dtimeleft_s" ]; then
667 if [ $dtimeleft_s -lt 0 ]; then
671 dtimeleft_s
=$
((dtimeleft_s
- 1))
675 if [ "$withtap" -eq "1" ]; then
676 if [ "$retval" -eq "0" ]; then
677 pass
"Wait after kill relay daemon"
679 fail
"Wait after kill relay daemon"
686 function stop_lttng_relayd
()
688 stop_lttng_relayd_opt
1 0 "$@"
691 function stop_lttng_relayd_notap
()
693 stop_lttng_relayd_opt
0 0 "$@"
696 function stop_lttng_relayd_cleanup
()
698 stop_lttng_relayd_opt
0 1 "$@"
701 #First arg: show tap output
702 #Second argument: load path for automatic loading
703 function start_lttng_sessiond_opt
()
708 # The rest of the arguments will be passed directly to lttng-sessiond.
714 local long_bit_value
=
715 long_bit_value
=$
(getconf LONG_BIT
)
717 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
718 # Env variable requested no session daemon
722 DIR
=$
(readlink
-f "$TESTDIR")
724 # Get long_bit value for 32/64 consumerd
725 case "$long_bit_value" in
727 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
730 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
737 # Check for env. variable. Allow the use of LD_PRELOAD etc.
738 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
739 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
741 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
743 if ! validate_kernel_version
; then
744 fail
"Start session daemon"
745 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
748 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
749 export LTTNG_SESSION_CONFIG_XSD_PATH
751 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
753 if [ -n "$load_path" ]; then
754 # shellcheck disable=SC2086
755 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
757 # shellcheck disable=SC2086
758 env
$env_vars --background "$consumerd" "$@"
760 #$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
762 if [ "$withtap" -eq "1" ]; then
763 ok
$status "Start session daemon"
768 function start_lttng_sessiond
()
770 start_lttng_sessiond_opt
1 "$@"
773 function start_lttng_sessiond_notap
()
775 start_lttng_sessiond_opt
0 "$@"
778 function stop_lttng_sessiond_opt
()
789 if [ -z "$signal" ]; then
793 # Multiply time by 2 to simplify integer arithmetic
794 if [ -n "$timeout_s" ]; then
795 dtimeleft_s
=$
((timeout_s
* 2))
798 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
799 # Env variable requested no session daemon
803 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
804 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
806 if [ -n "$runas_pids" ]; then
807 pids
="$pids $runas_pids"
810 if [ -z "$pids" ]; then
811 if [ "$is_cleanup" -eq 1 ]; then
813 elif [ "$withtap" -eq "1" ]; then
814 fail
"No session daemon to kill"
816 LTTNG_BAIL_OUT
"No session daemon to kill"
821 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
823 # shellcheck disable=SC2086
824 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
826 if [ "$withtap" -eq "1" ]; then
827 fail
"Kill sessions daemon"
831 while [ -n "$out" ]; do
832 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
833 if [ -n "$dtimeleft_s" ]; then
834 if [ $dtimeleft_s -lt 0 ]; then
838 dtimeleft_s
=$
((dtimeleft_s
- 1))
843 while [ -n "$out" ]; do
844 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
845 if [ -n "$dtimeleft_s" ]; then
846 if [ $dtimeleft_s -lt 0 ]; then
850 dtimeleft_s
=$
((dtimeleft_s
- 1))
855 if [ "$withtap" -eq "1" ]; then
856 if [ "$retval" -eq "0" ]; then
857 pass
"Wait after kill session daemon"
859 fail
"Wait after kill session daemon"
863 if [ "$signal" = "SIGKILL" ]; then
864 if [ "$(id -u)" -eq "0" ]; then
866 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
868 if [ -n "$modules" ]; then
869 diag
"Unloading all LTTng modules"
870 modprobe
--remove "$modules"
878 function stop_lttng_sessiond
()
880 stop_lttng_sessiond_opt
1 0 "$@"
883 function stop_lttng_sessiond_notap
()
885 stop_lttng_sessiond_opt
0 0 "$@"
888 function stop_lttng_sessiond_cleanup
()
890 stop_lttng_sessiond_opt
0 1 "$@"
893 function sigstop_lttng_sessiond_opt
()
899 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
900 # Env variable requested no session daemon
904 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
906 if [ "$withtap" -eq "1" ]; then
907 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
910 # shellcheck disable=SC2086
911 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
912 if [ "$withtap" -eq "1" ]; then
913 fail
"Sending SIGSTOP to session daemon"
917 while [ $out -ne 0 ]; do
918 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
920 # Wait until state becomes stopped for session
923 for sessiond_pid
in $pids; do
924 state
="$(ps -p "$sessiond_pid" -o state= )"
925 if [[ -n "$state" && "$state" != "T" ]]; then
931 if [ "$withtap" -eq "1" ]; then
932 pass
"Sending SIGSTOP to session daemon"
937 function sigstop_lttng_sessiond
()
939 sigstop_lttng_sessiond_opt
1 "$@"
942 function sigstop_lttng_sessiond_notap
()
944 sigstop_lttng_sessiond_opt
0 "$@"
947 function stop_lttng_consumerd_opt
()
957 if [ -z "$signal" ]; then
961 # Multiply time by 2 to simplify integer arithmetic
962 if [ -n "$timeout_s" ]; then
963 dtimeleft_s
=$
((timeout_s
* 2))
966 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
968 if [ -z "$pids" ]; then
969 if [ "$is_cleanup" -eq 1 ]; then
971 elif [ "$withtap" -eq "1" ]; then
972 fail
"No consumerd daemon to kill"
974 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
979 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
981 # shellcheck disable=SC2086
982 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
984 if [ "$withtap" -eq "1" ]; then
985 fail
"Kill consumer daemon"
989 while [ $out -ne 0 ]; do
990 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
992 # If consumerds are still present check their status.
993 # A zombie status qualifies the consumerd as *killed*
995 for consumer_pid
in $pids; do
996 state
="$(ps -p "$consumer_pid" -o state= )"
997 if [[ -n "$state" && "$state" != "Z" ]]; then
1001 if [ -n "$dtimeleft_s" ]; then
1002 if [ $dtimeleft_s -lt 0 ]; then
1006 dtimeleft_s
=$
((dtimeleft_s
- 1))
1010 if [ "$withtap" -eq "1" ]; then
1011 if [ "$retval" -eq "0" ]; then
1012 pass
"Wait after kill consumer daemon"
1014 fail
"Wait after kill consumer daemon"
1022 function stop_lttng_consumerd
()
1024 stop_lttng_consumerd_opt
1 0 "$@"
1027 function stop_lttng_consumerd_notap
()
1029 stop_lttng_consumerd_opt
0 0 "$@"
1032 function stop_lttng_consumerd_cleanup
()
1034 stop_lttng_consumerd_opt
0 1 "$@"
1037 function sigstop_lttng_consumerd_opt
()
1040 local signal
=SIGSTOP
1043 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1045 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1047 # shellcheck disable=SC2086
1048 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1051 if [ $retval -eq 1 ]; then
1052 if [ "$withtap" -eq "1" ]; then
1053 fail
"Sending SIGSTOP to consumer daemon"
1058 while [ $out -ne 0 ]; do
1059 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1061 # Wait until state becomes stopped for all
1064 for consumer_pid
in $pids; do
1065 state
="$(ps -p "$consumer_pid" -o state= )"
1066 if [[ -n "$state" && "$state" != "T" ]]; then
1072 if [ "$withtap" -eq "1" ]; then
1073 pass
"Sending SIGSTOP to consumer daemon"
1079 function sigstop_lttng_consumerd
()
1081 sigstop_lttng_consumerd_opt
1 "$@"
1084 function sigstop_lttng_consumerd_notap
()
1086 sigstop_lttng_consumerd_opt
0 "$@"
1089 function list_lttng_with_opts
()
1095 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1097 if [ $withtap -eq "1" ]; then
1098 ok
$ret "Lttng-tool list command with option $opts"
1102 function list_lttng_ok
()
1104 list_lttng_with_opts
1 "$@"
1107 function list_lttng_notap
()
1109 list_lttng_with_opts
0 "$@"
1112 function create_lttng_session_no_output
()
1117 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1118 ok $?
"Create session $sess_name in no-output mode"
1121 function create_lttng_session_uri
() {
1126 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1127 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1130 function create_lttng_session
()
1133 local expected_to_fail
=$2
1138 if [ -z "$trace_path" ]; then
1139 # Use lttng-sessiond default output.
1142 trace_path
="-o $trace_path"
1145 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1147 if [ $expected_to_fail -eq "1" ]; then
1150 if [ $withtap -eq "1" ]; then
1151 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1154 if [ $withtap -eq "1" ]; then
1155 ok
$ret "Create session $sess_name in $trace_path"
1161 function create_lttng_session_ok
()
1163 create_lttng_session
1 0 "$@"
1166 function create_lttng_session_fail
()
1168 create_lttng_session
1 1 "$@"
1171 function create_lttng_session_notap
()
1173 create_lttng_session
0 0 "$@"
1177 function enable_ust_lttng_channel
()
1180 local expected_to_fail
=$2
1182 local channel_name
=$4
1185 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1187 if [[ $expected_to_fail -eq "1" ]]; then
1190 if [ $withtap -eq "1" ]; then
1191 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1194 if [ $withtap -eq "1" ]; then
1195 ok
$ret "Enable channel $channel_name for session $sess_name"
1201 function enable_ust_lttng_channel_ok
()
1203 enable_ust_lttng_channel
1 0 "$@"
1206 function enable_ust_lttng_channel_fail
()
1208 enable_ust_lttng_channel
1 1 "$@"
1211 function enable_ust_lttng_channel_notap
()
1213 enable_ust_lttng_channel
0 0 "$@"
1216 function disable_ust_lttng_channel
()
1219 local channel_name
=$2
1221 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1222 ok $?
"Disable channel $channel_name for session $sess_name"
1225 function enable_lttng_mmap_overwrite_kernel_channel
()
1228 local channel_name
=$2
1230 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1231 ok $?
"Enable channel $channel_name for session $sess_name"
1234 function enable_lttng_mmap_discard_small_kernel_channel
()
1237 local channel_name
=$2
1239 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--discard --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1240 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1243 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1246 local channel_name
=$2
1248 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1249 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1252 function enable_lttng_mmap_overwrite_ust_channel
()
1255 local channel_name
=$2
1257 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1258 ok $?
"Enable channel $channel_name for session $sess_name"
1261 function enable_ust_lttng_event
()
1264 local expected_to_fail
=$2
1266 local event_name
="$4"
1267 local channel_name
=$5
1269 if [ -z $channel_name ]; then
1270 # default channel if none specified
1273 chan
="-c $channel_name"
1276 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1278 if [[ $expected_to_fail -eq "1" ]]; then
1281 if [[ $withtap -eq "1" ]]; then
1282 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1285 if [[ $withtap -eq "1" ]]; then
1286 ok
$ret "Enable ust event $event_name for session $sess_name"
1292 function enable_ust_lttng_event_ok
()
1294 enable_ust_lttng_event
1 0 "$@"
1297 function enable_ust_lttng_event_fail
()
1299 enable_ust_lttng_event
1 1 "$@"
1302 function enable_ust_lttng_event_notap
()
1304 enable_ust_lttng_event
0 0 "$@"
1307 function enable_jul_lttng_event
()
1313 if [ -z $channel_name ]; then
1314 # default channel if none specified
1317 chan
="-c $channel_name"
1320 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1321 ok $?
"Enable JUL event $event_name for session $sess_name"
1324 function enable_jul_lttng_event_loglevel
()
1327 local event_name
="$2"
1329 local channel_name
=$4
1331 if [ -z $channel_name ]; then
1332 # default channel if none specified
1335 chan
="-c $channel_name"
1338 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1339 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1342 function enable_log4j_lttng_event
()
1346 local channel_name
=$3
1350 # default channel if none specified
1351 if [ -n "$channel_name" ]; then
1352 chan_opt
=("-c" "$channel_name")
1355 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1356 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1357 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1360 function enable_log4j_lttng_event_filter
()
1366 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1367 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1368 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1371 function enable_log4j_lttng_event_filter_loglevel_only
()
1378 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1379 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1380 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1383 function enable_log4j_lttng_event_loglevel
()
1388 local channel_name
=$4
1391 # default channel if none specified
1392 if [ -n "$channel_name" ]; then
1393 chan_opt
=("-c" "$channel_name")
1396 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1397 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1398 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1401 function enable_log4j_lttng_event_loglevel_only
()
1406 local channel_name
=$4
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
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1417 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1420 function enable_python_lttng_event
()
1426 if [ -z $channel_name ]; then
1427 # default channel if none specified
1430 chan
="-c $channel_name"
1433 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1434 ok $?
"Enable Python event $event_name for session $sess_name"
1437 function enable_python_lttng_event_loglevel
()
1440 local event_name
="$2"
1442 local channel_name
=$4
1444 if [ -z $channel_name ]; then
1445 # default channel if none specified
1448 chan
="-c $channel_name"
1451 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1452 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1455 function enable_ust_lttng_event_filter
()
1457 local sess_name
="$1"
1458 local event_name
="$2"
1460 local channel_name
=$4
1462 if [ -z $channel_name ]; then
1463 # default channel if none specified
1466 chan
="-c $channel_name"
1469 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1470 ok $?
"Enable event $event_name with filtering for session $sess_name"
1473 function enable_ust_lttng_event_loglevel
()
1475 local sess_name
="$1"
1476 local event_name
="$2"
1479 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1480 ok $?
"Enable event $event_name with loglevel $loglevel"
1483 function enable_ust_lttng_event_loglevel_only
()
1485 local sess_name
="$1"
1486 local event_name
="$2"
1489 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1490 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1493 function disable_ust_lttng_event
()
1495 local sess_name
="$1"
1496 local event_name
="$2"
1497 local channel_name
="$3"
1499 if [ -z $channel_name ]; then
1500 # default channel if none specified
1503 chan
="-c $channel_name"
1506 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1507 ok $?
"Disable event $event_name for session $sess_name"
1510 function disable_jul_lttng_event
()
1512 local sess_name
="$1"
1513 local event_name
="$2"
1515 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1516 ok $?
"Disable JUL event $event_name for session $sess_name"
1519 function disable_log4j_lttng_event
()
1521 local sess_name
="$1"
1522 local event_name
="$2"
1524 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1525 disable-event
"$event_name" -s "$sess_name" --log4j
1526 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1529 function disable_python_lttng_event
()
1531 local sess_name
="$1"
1532 local event_name
="$2"
1534 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1535 ok $?
"Disable Python event $event_name for session $sess_name"
1538 function start_lttng_tracing_opt
()
1541 local expected_to_fail
=$2
1544 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1546 if [[ $expected_to_fail -eq "1" ]]; then
1549 if [ $withtap -eq "1" ]; then
1550 ok $?
"Start tracing for session $sess_name failed as expected"
1553 if [ $withtap -eq "1" ]; then
1554 ok
$ret "Start tracing for session $sess_name"
1559 function start_lttng_tracing_ok
()
1561 start_lttng_tracing_opt
1 0 "$@"
1564 function start_lttng_tracing_fail
()
1566 start_lttng_tracing_opt
1 1 "$@"
1569 function start_lttng_tracing_notap
()
1571 start_lttng_tracing_opt
0 1 "$@"
1574 function stop_lttng_tracing_opt
()
1577 local expected_to_fail
=$2
1580 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1582 if [[ $expected_to_fail -eq "1" ]]; then
1585 if [ $withtap -eq "1" ]; then
1586 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1589 if [ $withtap -eq "1" ]; then
1590 ok
$ret "Stop lttng tracing for session $sess_name"
1595 function stop_lttng_tracing_ok
()
1597 stop_lttng_tracing_opt
1 0 "$@"
1600 function stop_lttng_tracing_fail
()
1602 stop_lttng_tracing_opt
1 1 "$@"
1605 function stop_lttng_tracing_notap
()
1607 stop_lttng_tracing_opt
0 0 "$@"
1610 function destroy_lttng_session
()
1613 local expected_to_fail
=$2
1616 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1618 if [[ $expected_to_fail -eq "1" ]]; then
1621 if [ $withtap -eq "1" ]; then
1622 ok
$ret "Destroy session $sess_name failed as expected"
1625 if [ $withtap -eq "1" ]; then
1626 ok
$ret "Destroy session $sess_name"
1631 function destroy_lttng_session_ok
()
1633 destroy_lttng_session
1 0 "$@"
1637 function destroy_lttng_session_fail
()
1639 destroy_lttng_session
1 1 "$@"
1642 function destroy_lttng_session_notap
()
1644 destroy_lttng_session
0 0 "$@"
1647 function destroy_lttng_sessions
()
1649 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1650 ok $?
"Destroy all lttng sessions"
1653 function lttng_snapshot_add_output
()
1655 local expected_to_fail
=$1
1660 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1662 if [[ $expected_to_fail -eq 1 ]]; then
1664 ok $?
"Added snapshot output $trace_path failed as expected"
1666 ok
$ret "Added snapshot output $trace_path"
1670 function lttng_snapshot_add_output_ok
()
1672 lttng_snapshot_add_output
0 "$@"
1675 function lttng_snapshot_add_output_fail
()
1677 lttng_snapshot_add_output
1 "$@"
1680 function lttng_snapshot_del_output
()
1682 local expected_to_fail
=$1
1686 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1688 if [[ $expected_to_fail -eq "1" ]]; then
1690 ok $?
"Deleted snapshot output id $id failed as expected"
1692 ok
$ret "Deleted snapshot output id $id"
1696 function lttng_snapshot_del_output_ok
()
1698 lttng_snapshot_del_output
0 "$@"
1701 function lttng_snapshot_del_output_fail
()
1703 lttng_snapshot_del_output
1 "$@"
1706 function lttng_snapshot_record
()
1711 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s "$sess_name" "$trace_path" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1712 ok $?
"Snapshot recorded"
1715 function lttng_snapshot_list
()
1718 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1719 ok $?
"Snapshot list"
1722 function lttng_save
()
1727 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1728 ok $?
"Session saved"
1731 function lttng_load
()
1733 local expected_to_fail
=$1
1736 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1738 if [[ $expected_to_fail -eq "1" ]]; then
1740 ok $?
"Load command failed as expected with opts: $opts"
1742 ok
$ret "Load command with opts: $opts"
1746 function lttng_load_ok
()
1751 function lttng_load_fail
()
1756 function lttng_track
()
1758 local expected_to_fail
="$1"
1761 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1763 if [[ $expected_to_fail -eq "1" ]]; then
1765 ok $?
"Track command failed as expected with opts: $opts"
1767 ok
$ret "Track command with opts: $opts"
1771 function lttng_track_ok
()
1776 function lttng_track_fail
()
1781 function lttng_untrack
()
1783 local expected_to_fail
="$1"
1786 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1788 if [[ $expected_to_fail -eq "1" ]]; then
1790 ok $?
"Untrack command failed as expected with opts: $opts"
1792 ok
$ret "Untrack command with opts: $opts"
1796 function lttng_untrack_ok
()
1798 lttng_untrack
0 "$@"
1801 function lttng_untrack_fail
()
1803 lttng_untrack
1 "$@"
1806 function lttng_track_pid_ok
()
1809 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1810 ok $?
"Lttng track pid on the kernel domain"
1813 function lttng_untrack_kernel_all_ok
()
1815 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1816 ok $?
"Lttng untrack all pid on the kernel domain"
1819 function lttng_track_ust_ok
()
1821 lttng_track_ok
-u "$@"
1824 function lttng_track_ust_fail
()
1826 lttng_track_fail
-u "$@"
1829 function lttng_track_kernel_ok
()
1831 lttng_track_ok
-k "$@"
1834 function lttng_track_kernel_fail
()
1836 lttng_track_fail
-k "$@"
1839 function lttng_untrack_ust_ok
()
1841 lttng_untrack_ok
-u "$@"
1844 function lttng_untrack_ust_fail
()
1846 lttng_untrack_fail
-u "$@"
1849 function lttng_untrack_kernel_ok
()
1851 lttng_untrack_ok
-k "$@"
1854 function lttng_untrack_kernel_fail
()
1856 lttng_untrack_fail
-k "$@"
1859 function lttng_add_context_list
()
1861 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1863 ok
$ret "Context listing"
1866 function add_context_lttng
()
1868 local expected_to_fail
="$1"
1870 local session_name
="$3"
1871 local channel_name
="$4"
1874 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1876 if [[ $expected_to_fail -eq "1" ]]; then
1878 ok $?
"Add context command failed as expected for type: $type"
1880 ok
$ret "Add context command for type: $type"
1884 function add_context_ust_ok
()
1886 add_context_lttng
0 -u "$@"
1889 function add_context_ust_fail
()
1891 add_context_lttng
1 -u "$@"
1894 function add_context_kernel_ok
()
1896 add_context_lttng
0 -k "$@"
1899 function add_context_kernel_fail
()
1901 add_context_lttng
1 -k "$@"
1904 function wait_live_trace_ready
()
1907 local zero_client_match
=0
1909 diag
"Waiting for live trace at url: $url"
1910 while [ $zero_client_match -eq 0 ]; do
1911 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
1914 pass
"Waiting for live trace at url: $url"
1917 function wait_live_viewer_connect
()
1920 local one_client_match
=0
1922 diag
"Waiting for live viewers on url: $url"
1923 while [ $one_client_match -eq 0 ]; do
1924 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
1927 pass
"Waiting for live viewers on url: $url"
1930 function bail_out_if_no_babeltrace
()
1932 which "$BABELTRACE_BIN" >/dev
/null
1933 if [ $?
-ne 0 ]; then
1934 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
1938 function validate_metadata_event
()
1941 local nr_event_id
=$2
1944 local metadata_file
=$
(find $trace_path -name "metadata")
1945 local metadata_path
=$
(dirname $metadata_file)
1947 which $BABELTRACE_BIN >/dev
/null
1948 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1950 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1952 if [ "$count" -ne "$nr_event_id" ]; then
1953 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1954 diag
"$count matching event id found in metadata"
1956 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1961 function trace_matches
()
1967 which $BABELTRACE_BIN >/dev
/null
1968 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1970 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1972 if [ "$count" -ne "$nr_iter" ]; then
1974 diag
"$count matching events found in trace"
1980 function trace_match_only
()
1986 which $BABELTRACE_BIN >/dev
/null
1987 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1989 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1990 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1992 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1993 pass
"Trace match with $total event $event_name"
1996 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
2000 function validate_trace
2005 which $BABELTRACE_BIN >/dev
/null
2006 if [ $?
-ne 0 ]; then
2007 skip
0 "Babeltrace binary not found. Skipping trace validation"
2012 for i
in $event_name; do
2013 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2014 if [ "$traced" -ne 0 ]; then
2015 pass
"Validate trace for event $i, $traced events"
2017 fail
"Validate trace for event $i"
2018 diag
"Found $traced occurrences of $i"
2026 function validate_trace_count
2030 local expected_count
=$3
2032 which $BABELTRACE_BIN >/dev
/null
2033 if [ $?
-ne 0 ]; then
2034 skip
0 "Babeltrace binary not found. Skipping trace validation"
2040 for i
in $event_name; do
2041 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2042 if [ "$traced" -ne 0 ]; then
2043 pass
"Validate trace for event $i, $traced events"
2045 fail
"Validate trace for event $i"
2046 diag
"Found $traced occurrences of $i"
2048 cnt
=$
(($cnt + $traced))
2051 test $cnt -eq $expected_count
2052 ok $?
"Read a total of $cnt events, expected $expected_count"
2055 function validate_trace_count_range_incl_min_excl_max
2059 local expected_min
=$3
2060 local expected_max
=$4
2062 which $BABELTRACE_BIN >/dev
/null
2063 if [ $?
-ne 0 ]; then
2064 skip
0 "Babeltrace binary not found. Skipping trace validation"
2070 for i
in $event_name; do
2071 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2072 if [ "$traced" -ge $expected_min ]; then
2073 pass
"Validate trace for event $i, $traced events"
2075 fail
"Validate trace for event $i"
2076 diag
"Found $traced occurrences of $i"
2078 cnt
=$
(($cnt + $traced))
2081 test $cnt -lt $expected_max
2082 ok $?
"Read a total of $cnt events, expected between [$expected_min, $expected_max["
2085 function trace_first_line
2089 which $BABELTRACE_BIN >/dev
/null
2090 if [ $?
-ne 0 ]; then
2091 skip
0 "Babeltrace binary not found. Skipping trace validation"
2094 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
2097 function validate_trace_exp
()
2102 which $BABELTRACE_BIN >/dev
/null
2103 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
2105 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
2106 if [ "$traced" -ne 0 ]; then
2107 pass
"Validate trace for expression '${event_exp}', $traced events"
2109 fail
"Validate trace for expression '${event_exp}'"
2110 diag
"Found $traced occurrences of '${event_exp}'"
2116 function validate_trace_only_exp
()
2121 which $BABELTRACE_BIN >/dev
/null
2122 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2124 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
2125 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
2127 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
2128 pass
"Trace match with $total for expression '${event_exp}'"
2131 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
2137 function validate_trace_empty
()
2141 which $BABELTRACE_BIN >/dev
/null
2142 if [ $?
-ne 0 ]; then
2143 skip
0 "Babeltrace binary not found. Skipping trace validation"
2146 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
2148 if [ $ret -ne 0 ]; then
2149 fail
"Failed to parse trace"
2153 traced
=$
(echo -n "$events" |
wc -l)
2154 if [ "$traced" -eq 0 ]; then
2155 pass
"Validate empty trace"
2157 fail
"Validate empty trace"
2158 diag
"Found $traced events in trace"
2164 function validate_directory_empty
()
2166 local trace_path
="$1"
2168 # Do not double quote `$trace_path` below as we want wildcards to be
2170 files
="$(ls -A $trace_path)"
2172 if [ $ret -ne 0 ]; then
2173 fail
"Failed to list content of directory \"$trace_path\""
2177 nb_files
="$(echo -n "$files" | wc -l)"
2178 ok
$nb_files "Directory \"$trace_path\" is empty"
2181 function validate_trace_session_ust_empty
()
2183 validate_directory_empty
"$1"/ust
2186 function validate_trace_session_kernel_empty
()
2188 validate_trace_empty
"$1"/kernel
2191 function regenerate_metadata
()
2193 local expected_to_fail
=$1
2196 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2198 if [[ $expected_to_fail -eq "1" ]]; then
2200 ok $?
"Expected fail on regenerate metadata $sess_name"
2202 ok
$ret "Metadata regenerate $sess_name"
2206 function regenerate_metadata_ok
()
2208 regenerate_metadata
0 "$@"
2211 function regenerate_metadata_fail
()
2213 regenerate_metadata
1 "$@"
2216 function regenerate_statedump
()
2218 local expected_to_fail
=$1
2221 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2223 if [[ $expected_to_fail -eq "1" ]]; then
2225 ok $?
"Expected fail on regenerate statedump $sess_name"
2227 ok
$ret "Statedump regenerate $sess_name"
2231 function regenerate_statedump_ok
()
2233 regenerate_statedump
0 "$@"
2236 function regenerate_statedump_fail
()
2238 regenerate_statedump
1 "$@"
2241 function rotate_session
()
2243 local expected_to_fail
=$1
2246 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2248 if [[ $expected_to_fail -eq "1" ]]; then
2250 ok $?
"Expected fail on rotate session $sess_name"
2252 ok
$ret "Rotate session $sess_name"
2256 function rotate_session_ok
()
2258 rotate_session
0 "$@"
2261 function rotate_session_fail
()
2263 rotate_session
1 "$@"
2266 function destructive_tests_enabled
()
2268 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2275 function lttng_enable_rotation_timer
()
2277 local expected_to_fail
=$1
2281 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2283 if [[ $expected_to_fail -eq "1" ]]; then
2285 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2287 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2291 function lttng_enable_rotation_timer_ok
()
2293 lttng_enable_rotation_timer
0 $@
2296 function lttng_enable_rotation_timer_fail
()
2298 lttng_enable_rotation_timer
1 $@
2301 function lttng_enable_rotation_size
()
2303 local expected_to_fail
=$1
2307 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2309 if [[ $expected_to_fail -eq "1" ]]; then
2311 ok $?
"Expected fail on rotate session $sess_name"
2313 ok
$ret "Rotate session $sess_name"
2317 function lttng_enable_rotation_size_ok
()
2319 lttng_enable_rotation_size
0 $@
2322 function lttng_enable_rotation_size_fail
()
2324 lttng_enable_rotation_size
1 $@
2327 function lttng_clear_session
()
2329 local expected_to_fail
=$1
2332 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2334 if [[ $expected_to_fail -eq "1" ]]; then
2336 ok $?
"Expected fail on clear session $sess_name"
2338 ok
$ret "Clear session $sess_name"
2342 function lttng_clear_session_ok
()
2344 lttng_clear_session
0 $@
2347 function lttng_clear_session_fail
()
2349 lttng_clear_session
1 $@
2352 function lttng_clear_all
()
2354 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2355 ok $?
"Clear all lttng sessions"
2358 function lttng_add_trigger
()
2360 local expected_to_fail
="$1"
2361 local trigger_name
="$2"
2365 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2366 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2368 if [[ $expected_to_fail -eq "1" ]]; then
2370 ok $?
"Add trigger $trigger_name failed as expected"
2372 ok
$ret "Add trigger $trigger_name"
2376 function lttng_remove_trigger
()
2378 local expected_to_fail
="$1"
2379 local trigger_name
="$2"
2382 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2383 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2385 if [[ $expected_to_fail -eq "1" ]]; then
2387 ok $?
"Remove trigger $trigger_name failed as expected"
2389 ok
$ret "Remove trigger $trigger_name"
2393 function lttng_add_trigger_ok
()
2395 lttng_add_trigger
0 "$@"
2398 function lttng_add_trigger_fail
()
2400 lttng_add_trigger
1 "$@"
2403 function lttng_remove_trigger_ok
()
2405 lttng_remove_trigger
0 "$@"
2408 function list_triggers_matches_ok
()
2410 local tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2411 local tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2413 local test_name
="$1"
2414 local expected_stdout_file
="$2"
2416 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2418 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2419 ok $?
"${test_name}: exit code is 0"
2421 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2422 ok $?
"${test_name}: expected stdout"
2424 diff -u /dev
/null
"${tmp_stderr}"
2425 ok $?
"${test_name}: expected stderr"
2427 rm -f "${tmp_stdout}"
2428 rm -f "${tmp_stderr}"
2431 function list_triggers_matches_mi_ok
()
2434 local tmp_stdout_raw
2437 local test_name
="$1"
2438 local expected_stdout_file
="$2"
2440 tmp_stdout_raw
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2441 tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2442 tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2444 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2446 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2447 ok $?
"${test_name}: exit code is 0"
2449 # Pretty-fy xml before further test.
2450 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2452 $MI_VALIDATE "${tmp_stdout}"
2453 ok $?
"list-trigger mi is valid"
2455 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2456 ok $?
"${test_name}: expected stdout"
2458 diff -u /dev
/null
"${tmp_stderr}"
2459 ok $?
"${test_name}: expected stderr"
2461 rm -f "${tmp_stdout}"
2462 rm -f "${tmp_stdout_raw}"
2463 rm -f "${tmp_stderr}"
2466 function validate_path_pattern
()
2470 # Base path is only used in error case and is used to list the content
2479 if [ "$ret" -ne "0" ]; then
2480 diag
"Path pattern expected: $pattern"
2481 # List the tracepath for more info. We use find as a recursive
2483 diag
"The base path content:"
2484 find "$base_path" -print
2488 function validate_trace_path_ust_uid
()
2491 local session_name
=$2
2493 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2495 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2498 function validate_trace_path_ust_uid_network
()
2501 local session_name
=$2
2504 local hostname
=$HOSTNAME
2508 # If the session was given a network base path (e.g
2509 # 127.0.0.1/my/custom/path on creation, there is no session name
2510 # component to the path on the relayd side. Caller can simply not pass a
2511 # session name for this scenario.
2512 if [ -n "$session_name" ]; then
2513 session_name
="$session_name-$date_time_pattern"
2514 if [ -n "$base_path" ]; then
2515 fail
"Session name and base path are mutually exclusive"
2520 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2522 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2525 function validate_trace_path_ust_uid_snapshot_network
()
2528 local session_name
=$2
2529 local snapshot_name
=$3
2530 local snapshot_number
=$4
2532 local hostname
=$HOSTNAME
2537 # If the session/output was given a network base path (e.g
2538 # 127.0.0.1/my/custom/path on creation, there is no session name
2539 # component to the path on the relayd side. Caller can simply not pass a
2540 # session name for this scenario.
2541 if [ -n "$session_name" ]; then
2542 session_name
="$session_name-$date_time_pattern"
2543 if [ -n "$base_path" ]; then
2544 fail
"Session name and base path are mutually exclusive"
2549 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2551 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2554 function validate_trace_path_ust_uid_snapshot
()
2557 local session_name
=$2
2558 local snapshot_name
=$3
2559 local snapshot_number
=$4
2565 # If the session/output was given a network base path (e.g
2566 # 127.0.0.1/my/custom/path) on creation, there is no session name
2567 # component to the path on the relayd side. Caller can simply not pass a
2568 # session name for this scenario.
2569 if [ -n "$session_name" ]; then
2570 session_name
="$session_name-$date_time_pattern"
2571 if [ -n "$base_path" ]; then
2572 fail
"Session name and base path are mutually exclusive"
2577 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2579 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2582 function validate_trace_path_ust_pid
()
2585 local session_name
=$2
2591 # If the session was given a trace path on creation, there is no session
2592 # name component to the path. Caller can simply not pass a session name
2593 # for this scenario.
2594 if [ -n "$session_name" ]; then
2595 session_name
="$session_name-$date_time_pattern"
2598 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2600 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2603 function validate_trace_path_kernel
()
2606 local session_name
=$2
2609 # If the session was given a trace path on creation, there is no session
2610 # name component to the path. Caller can simply not pass a session name
2611 # for this scenario.
2612 if [ -n "$session_name" ]; then
2613 session_name
="$session_name-$date_time_pattern"
2616 pattern
="$trace_path/$session_name/kernel/metadata"
2618 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2621 function validate_trace_path_kernel_network
()
2624 local session_name
=$2
2625 local hostname
=$HOSTNAME
2626 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2628 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2631 function validate_trace_path_kernel_snapshot
()
2634 local session_name
=$2
2635 local snapshot_name
=$3
2636 local snapshot_number
=$4
2641 # If the session/output was given a network base path (e.g
2642 # 127.0.0.1/my/custom/path on creation, there is no session name
2643 # component to the path on the relayd side. Caller can simply not pass a
2644 # session name for this scenario.
2645 if [ -n "$session_name" ]; then
2646 session_name
="$session_name-$date_time_pattern"
2647 if [ -n "$base_path" ]; then
2648 fail
"Session name and base path are mutually exclusive"
2653 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2655 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2658 function validate_trace_path_kernel_snapshot_network
()
2661 local session_name
=$2
2662 local snapshot_name
=$3
2663 local snapshot_number
=$4
2665 local hostname
=$HOSTNAME
2669 # If the session/output was given a network base path (e.g
2670 # 127.0.0.1/my/custom/path on creation, there is no session name
2671 # component to the path on the relayd side. Caller can simply not pass a
2672 # session name for this scenario.
2673 if [ -n "$session_name" ]; then
2674 session_name
="$session_name-$date_time_pattern"
2675 if [ -n "$base_path" ]; then
2676 fail
"Session name and base path are mutually exclusive"
2681 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2683 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"