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 any available CPU found. Do not make assumption about the returned
281 # value, e.g. that it could be 0.
282 function get_any_available_cpu
()
284 for cpu
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
285 echo "${cpu#/sys/devices/system/cpu/cpu}"
290 # Return the number of _configured_ CPUs.
291 function conf_proc_count
()
293 getconf _NPROCESSORS_CONF
294 if [ $?
-ne 0 ]; then
295 diag
"Failed to get the number of configured CPUs"
300 # Check if base lttng-modules are present.
301 # Bail out on failure
302 function validate_lttng_modules_present
()
304 # Check for loadable modules.
305 modprobe
-n lttng-tracer
2>/dev
/null
306 if [ $?
-eq 0 ]; then
310 # Check for builtin modules.
311 ls /proc
/lttng
> /dev
/null
2>&1
312 if [ $?
-eq 0 ]; then
316 LTTNG_BAIL_OUT
"LTTng modules not detected."
319 # Run the lttng binary.
321 # The first two arguments are stdout and stderr redirect paths, respectively.
322 # The rest of the arguments are forwarded to the lttng binary
323 function _run_lttng_cmd
325 local stdout_dest
="$1"
326 local stderr_dest
="$2"
329 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN $*"
330 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"
333 function enable_kernel_lttng_event
336 local expected_to_fail
="$2"
338 local event_name
="$4"
339 local channel_name
="$5"
341 if [ -z "$event_name" ]; then
342 # Enable all event if no event name specified
346 if [ -z "$channel_name" ]; then
347 # default channel if none specified
350 chan
="-c $channel_name"
353 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
355 if [[ $expected_to_fail -eq "1" ]]; then
358 if [ $withtap -eq "1" ]; then
359 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
362 if [ $withtap -eq "1" ]; then
363 ok
$ret "Enable kernel event $event_name for session $sess_name"
368 function enable_kernel_lttng_event_ok
()
370 enable_kernel_lttng_event
1 0 "$@"
373 function enable_kernel_lttng_event_fail
()
375 enable_kernel_lttng_event
1 1 "$@"
378 function enable_kernel_lttng_event_notap
()
380 enable_kernel_lttng_event
0 0 "$@"
384 function lttng_enable_kernel_event
386 enable_kernel_lttng_event_ok
"$@"
389 function lttng_enable_kernel_syscall
()
391 local expected_to_fail
=$1
393 local syscall_name
=$3
394 local channel_name
=$4
396 if [ -z $syscall_name ]; then
397 # Enable all event if no syscall name specified
401 if [ -z $channel_name ]; then
402 # default channel if none specified
405 chan
="-c $channel_name"
408 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
410 if [[ $expected_to_fail -eq "1" ]]; then
412 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
414 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
418 function lttng_enable_kernel_syscall_ok
()
420 lttng_enable_kernel_syscall
0 "$@"
423 function lttng_enable_kernel_syscall_fail
()
425 lttng_enable_kernel_syscall
1 "$@"
428 function lttng_disable_kernel_syscall
()
430 local expected_to_fail
=$1
432 local syscall_name
=$3
433 local channel_name
=$4
435 if [ -z $syscall_name ]; then
436 # Enable all event if no syscall name specified
440 if [ -z $channel_name ]; then
441 # default channel if none specified
444 chan
="-c $channel_name"
447 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
450 if [[ $expected_to_fail -eq "1" ]]; then
452 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
454 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
458 function lttng_disable_kernel_syscall_ok
()
460 lttng_disable_kernel_syscall
0 "$@"
463 function lttng_disable_kernel_syscall_fail
()
465 lttng_disable_kernel_syscall
1 "$@"
468 function lttng_enable_kernel_function_event
()
470 local expected_to_fail
="$1"
473 local event_name
="$4"
475 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
477 if [[ $expected_to_fail -eq "1" ]]; then
479 ok $?
"Enable kernel function event for session $sess_name failed as expected"
481 ok
$ret "Enable kernel function event for session $sess_name"
485 function lttng_enable_kernel_function_event_ok
()
487 lttng_enable_kernel_function_event
0 "$@"
490 function lttng_enable_kernel_userspace_probe_event
()
492 local expected_to_fail
="$1"
495 local event_name
="$4"
497 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
499 if [[ $expected_to_fail -eq "1" ]]; then
501 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
503 ok
$ret "Enable kernel userspace probe event for session $sess_name"
507 function lttng_enable_kernel_userspace_probe_event_fail
()
509 lttng_enable_kernel_userspace_probe_event
1 "$@"
512 function lttng_enable_kernel_userspace_probe_event_ok
()
514 lttng_enable_kernel_userspace_probe_event
0 "$@"
517 function disable_kernel_lttng_userspace_probe_event_ok
()
520 local event_name
="$2"
522 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
523 ok $?
"Disable kernel event $target for session $sess_name"
525 function lttng_enable_kernel_channel
()
528 local expected_to_fail
=$2
530 local channel_name
=$4
533 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
535 if [[ $expected_to_fail -eq "1" ]]; then
538 if [ $withtap -eq "1" ]; then
539 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
542 if [ $withtap -eq "1" ]; then
543 ok
$ret "Enable channel $channel_name for session $sess_name"
548 function lttng_enable_kernel_channel_ok
()
550 lttng_enable_kernel_channel
1 0 "$@"
553 function lttng_enable_kernel_channel_fail
()
555 lttng_enable_kernel_channel
1 1 "$@"
558 function lttng_enable_kernel_channel_notap
()
560 lttng_enable_kernel_channel
0 0 "$@"
563 function enable_kernel_lttng_channel_ok
()
565 lttng_enable_kernel_channel
1 0 "$@"
568 function lttng_disable_kernel_channel
()
570 local expected_to_fail
=$1
572 local channel_name
=$3
574 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
576 if [[ $expected_to_fail -eq "1" ]]; then
578 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
580 ok
$ret "Disable channel $channel_name for session $sess_name"
584 function lttng_disable_kernel_channel_ok
()
586 lttng_disable_kernel_channel
0 "$@"
589 function lttng_disable_kernel_channel_fail
()
591 lttng_disable_kernel_channel
1 "$@"
594 function start_lttng_relayd_opt
()
597 local process_mode
=$2
600 DIR
=$
(readlink
-f "$TESTDIR")
602 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
603 # shellcheck disable=SC2086
604 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
605 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
606 if [ $?
-eq 1 ]; then
607 if [ $withtap -eq "1" ]; then
608 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
612 if [ $withtap -eq "1" ]; then
613 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
617 pass
"Start lttng-relayd (opt: $opt)"
621 function start_lttng_relayd
()
623 start_lttng_relayd_opt
1 "-b" "$@"
626 function start_lttng_relayd_notap
()
628 start_lttng_relayd_opt
0 "-b" "$@"
631 function stop_lttng_relayd_opt
()
641 if [ -z "$signal" ]; then
646 # Multiply time by 2 to simplify integer arithmetic
647 if [ -n "$timeout_s" ]; then
648 dtimeleft_s
=$
((timeout_s
* 2))
652 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
653 if [ -z "$pids" ]; then
654 if [ "$is_cleanup" -eq 1 ]; then
656 elif [ "$withtap" -eq "1" ]; then
657 fail
"No relay daemon to kill"
659 LTTNG_BAIL_OUT
"No relay daemon to kill"
664 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
666 # shellcheck disable=SC2086
667 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
669 if [ "$withtap" -eq "1" ]; then
670 fail
"Kill relay daemon"
674 while [ -n "$out" ]; do
675 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
676 if [ -n "$dtimeleft_s" ]; then
677 if [ $dtimeleft_s -lt 0 ]; then
681 dtimeleft_s
=$
((dtimeleft_s
- 1))
685 if [ "$withtap" -eq "1" ]; then
686 if [ "$retval" -eq "0" ]; then
687 pass
"Wait after kill relay daemon"
689 fail
"Wait after kill relay daemon"
696 function stop_lttng_relayd
()
698 stop_lttng_relayd_opt
1 0 "$@"
701 function stop_lttng_relayd_notap
()
703 stop_lttng_relayd_opt
0 0 "$@"
706 function stop_lttng_relayd_cleanup
()
708 stop_lttng_relayd_opt
0 1 "$@"
711 #First arg: show tap output
712 #Second argument: load path for automatic loading
713 function start_lttng_sessiond_opt
()
718 # The rest of the arguments will be passed directly to lttng-sessiond.
724 local long_bit_value
=
725 long_bit_value
=$
(getconf LONG_BIT
)
727 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
728 # Env variable requested no session daemon
732 DIR
=$
(readlink
-f "$TESTDIR")
734 # Get long_bit value for 32/64 consumerd
735 case "$long_bit_value" in
737 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
740 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
747 # Check for env. variable. Allow the use of LD_PRELOAD etc.
748 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
749 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
751 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
753 if ! validate_kernel_version
; then
754 fail
"Start session daemon"
755 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
758 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
759 export LTTNG_SESSION_CONFIG_XSD_PATH
761 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
763 if [ -n "$load_path" ]; then
764 # shellcheck disable=SC2086
765 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
767 # shellcheck disable=SC2086
768 env
$env_vars --background "$consumerd" "$@"
770 #$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
772 if [ "$withtap" -eq "1" ]; then
773 ok
$status "Start session daemon"
778 function start_lttng_sessiond
()
780 start_lttng_sessiond_opt
1 "$@"
783 function start_lttng_sessiond_notap
()
785 start_lttng_sessiond_opt
0 "$@"
788 function stop_lttng_sessiond_opt
()
799 if [ -z "$signal" ]; then
803 # Multiply time by 2 to simplify integer arithmetic
804 if [ -n "$timeout_s" ]; then
805 dtimeleft_s
=$
((timeout_s
* 2))
808 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
809 # Env variable requested no session daemon
813 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
814 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
816 if [ -n "$runas_pids" ]; then
817 pids
="$pids $runas_pids"
820 if [ -z "$pids" ]; then
821 if [ "$is_cleanup" -eq 1 ]; then
823 elif [ "$withtap" -eq "1" ]; then
824 fail
"No session daemon to kill"
826 LTTNG_BAIL_OUT
"No session daemon to kill"
831 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
833 # shellcheck disable=SC2086
834 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
836 if [ "$withtap" -eq "1" ]; then
837 fail
"Kill sessions daemon"
841 while [ -n "$out" ]; do
842 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
843 if [ -n "$dtimeleft_s" ]; then
844 if [ $dtimeleft_s -lt 0 ]; then
848 dtimeleft_s
=$
((dtimeleft_s
- 1))
853 while [ -n "$out" ]; do
854 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
855 if [ -n "$dtimeleft_s" ]; then
856 if [ $dtimeleft_s -lt 0 ]; then
860 dtimeleft_s
=$
((dtimeleft_s
- 1))
865 if [ "$withtap" -eq "1" ]; then
866 if [ "$retval" -eq "0" ]; then
867 pass
"Wait after kill session daemon"
869 fail
"Wait after kill session daemon"
873 if [ "$signal" = "SIGKILL" ]; then
874 if [ "$(id -u)" -eq "0" ]; then
876 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
878 if [ -n "$modules" ]; then
879 diag
"Unloading all LTTng modules"
880 modprobe
--remove "$modules"
888 function stop_lttng_sessiond
()
890 stop_lttng_sessiond_opt
1 0 "$@"
893 function stop_lttng_sessiond_notap
()
895 stop_lttng_sessiond_opt
0 0 "$@"
898 function stop_lttng_sessiond_cleanup
()
900 stop_lttng_sessiond_opt
0 1 "$@"
903 function sigstop_lttng_sessiond_opt
()
909 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
910 # Env variable requested no session daemon
914 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
916 if [ "$withtap" -eq "1" ]; then
917 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
920 # shellcheck disable=SC2086
921 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
922 if [ "$withtap" -eq "1" ]; then
923 fail
"Sending SIGSTOP to session daemon"
927 while [ $out -ne 0 ]; do
928 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
930 # Wait until state becomes stopped for session
933 for sessiond_pid
in $pids; do
934 state
="$(ps -p "$sessiond_pid" -o state= )"
935 if [[ -n "$state" && "$state" != "T" ]]; then
941 if [ "$withtap" -eq "1" ]; then
942 pass
"Sending SIGSTOP to session daemon"
947 function sigstop_lttng_sessiond
()
949 sigstop_lttng_sessiond_opt
1 "$@"
952 function sigstop_lttng_sessiond_notap
()
954 sigstop_lttng_sessiond_opt
0 "$@"
957 function stop_lttng_consumerd_opt
()
967 if [ -z "$signal" ]; then
971 # Multiply time by 2 to simplify integer arithmetic
972 if [ -n "$timeout_s" ]; then
973 dtimeleft_s
=$
((timeout_s
* 2))
976 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
978 if [ -z "$pids" ]; then
979 if [ "$is_cleanup" -eq 1 ]; then
981 elif [ "$withtap" -eq "1" ]; then
982 fail
"No consumerd daemon to kill"
984 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
989 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
991 # shellcheck disable=SC2086
992 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
994 if [ "$withtap" -eq "1" ]; then
995 fail
"Kill consumer daemon"
999 while [ $out -ne 0 ]; do
1000 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1002 # If consumerds are still present check their status.
1003 # A zombie status qualifies the consumerd as *killed*
1005 for consumer_pid
in $pids; do
1006 state
="$(ps -p "$consumer_pid" -o state= )"
1007 if [[ -n "$state" && "$state" != "Z" ]]; then
1011 if [ -n "$dtimeleft_s" ]; then
1012 if [ $dtimeleft_s -lt 0 ]; then
1016 dtimeleft_s
=$
((dtimeleft_s
- 1))
1020 if [ "$withtap" -eq "1" ]; then
1021 if [ "$retval" -eq "0" ]; then
1022 pass
"Wait after kill consumer daemon"
1024 fail
"Wait after kill consumer daemon"
1032 function stop_lttng_consumerd
()
1034 stop_lttng_consumerd_opt
1 0 "$@"
1037 function stop_lttng_consumerd_notap
()
1039 stop_lttng_consumerd_opt
0 0 "$@"
1042 function stop_lttng_consumerd_cleanup
()
1044 stop_lttng_consumerd_opt
0 1 "$@"
1047 function sigstop_lttng_consumerd_opt
()
1050 local signal
=SIGSTOP
1053 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1055 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1057 # shellcheck disable=SC2086
1058 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1061 if [ $retval -eq 1 ]; then
1062 if [ "$withtap" -eq "1" ]; then
1063 fail
"Sending SIGSTOP to consumer daemon"
1068 while [ $out -ne 0 ]; do
1069 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1071 # Wait until state becomes stopped for all
1074 for consumer_pid
in $pids; do
1075 state
="$(ps -p "$consumer_pid" -o state= )"
1076 if [[ -n "$state" && "$state" != "T" ]]; then
1082 if [ "$withtap" -eq "1" ]; then
1083 pass
"Sending SIGSTOP to consumer daemon"
1089 function sigstop_lttng_consumerd
()
1091 sigstop_lttng_consumerd_opt
1 "$@"
1094 function sigstop_lttng_consumerd_notap
()
1096 sigstop_lttng_consumerd_opt
0 "$@"
1099 function list_lttng_with_opts
()
1105 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1107 if [ $withtap -eq "1" ]; then
1108 ok
$ret "Lttng-tool list command with option $opts"
1112 function list_lttng_ok
()
1114 list_lttng_with_opts
1 "$@"
1117 function list_lttng_notap
()
1119 list_lttng_with_opts
0 "$@"
1122 function create_lttng_session_no_output
()
1127 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1128 ok $?
"Create session $sess_name in no-output mode"
1131 function create_lttng_session_uri
() {
1136 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1137 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1140 function create_lttng_session
()
1143 local expected_to_fail
=$2
1148 if [ -z "$trace_path" ]; then
1149 # Use lttng-sessiond default output.
1152 trace_path
="-o $trace_path"
1155 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1157 if [ $expected_to_fail -eq "1" ]; then
1160 if [ $withtap -eq "1" ]; then
1161 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1164 if [ $withtap -eq "1" ]; then
1165 ok
$ret "Create session $sess_name in $trace_path"
1171 function create_lttng_session_ok
()
1173 create_lttng_session
1 0 "$@"
1176 function create_lttng_session_fail
()
1178 create_lttng_session
1 1 "$@"
1181 function create_lttng_session_notap
()
1183 create_lttng_session
0 0 "$@"
1187 function enable_ust_lttng_channel
()
1190 local expected_to_fail
=$2
1192 local channel_name
=$4
1195 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1197 if [[ $expected_to_fail -eq "1" ]]; then
1200 if [ $withtap -eq "1" ]; then
1201 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1204 if [ $withtap -eq "1" ]; then
1205 ok
$ret "Enable channel $channel_name for session $sess_name"
1211 function enable_ust_lttng_channel_ok
()
1213 enable_ust_lttng_channel
1 0 "$@"
1216 function enable_ust_lttng_channel_fail
()
1218 enable_ust_lttng_channel
1 1 "$@"
1221 function enable_ust_lttng_channel_notap
()
1223 enable_ust_lttng_channel
0 0 "$@"
1226 function disable_ust_lttng_channel
()
1229 local channel_name
=$2
1231 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1232 ok $?
"Disable channel $channel_name for session $sess_name"
1235 function enable_lttng_mmap_overwrite_kernel_channel
()
1238 local channel_name
=$2
1240 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1241 ok $?
"Enable channel $channel_name for session $sess_name"
1244 function enable_lttng_mmap_discard_small_kernel_channel
()
1247 local channel_name
=$2
1249 $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
1250 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1253 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1256 local channel_name
=$2
1258 $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
1259 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1262 function enable_lttng_mmap_overwrite_ust_channel
()
1265 local channel_name
=$2
1267 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1268 ok $?
"Enable channel $channel_name for session $sess_name"
1271 function enable_ust_lttng_event
()
1274 local expected_to_fail
=$2
1276 local event_name
="$4"
1277 local channel_name
=$5
1279 if [ -z $channel_name ]; then
1280 # default channel if none specified
1283 chan
="-c $channel_name"
1286 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1288 if [[ $expected_to_fail -eq "1" ]]; then
1291 if [[ $withtap -eq "1" ]]; then
1292 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1295 if [[ $withtap -eq "1" ]]; then
1296 ok
$ret "Enable ust event $event_name for session $sess_name"
1302 function enable_ust_lttng_event_ok
()
1304 enable_ust_lttng_event
1 0 "$@"
1307 function enable_ust_lttng_event_fail
()
1309 enable_ust_lttng_event
1 1 "$@"
1312 function enable_ust_lttng_event_notap
()
1314 enable_ust_lttng_event
0 0 "$@"
1317 function enable_jul_lttng_event
()
1323 if [ -z $channel_name ]; then
1324 # default channel if none specified
1327 chan
="-c $channel_name"
1330 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1331 ok $?
"Enable JUL event $event_name for session $sess_name"
1334 function enable_jul_lttng_event_loglevel
()
1337 local event_name
="$2"
1339 local channel_name
=$4
1341 if [ -z $channel_name ]; then
1342 # default channel if none specified
1345 chan
="-c $channel_name"
1348 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1349 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1352 function enable_log4j_lttng_event
()
1356 local channel_name
=$3
1360 # default channel if none specified
1361 if [ -n "$channel_name" ]; then
1362 chan_opt
=("-c" "$channel_name")
1365 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1366 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1367 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1370 function enable_log4j_lttng_event_filter
()
1376 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1377 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1378 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1381 function enable_log4j_lttng_event_filter_loglevel_only
()
1388 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1389 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1390 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1393 function enable_log4j_lttng_event_loglevel
()
1398 local channel_name
=$4
1401 # default channel if none specified
1402 if [ -n "$channel_name" ]; then
1403 chan_opt
=("-c" "$channel_name")
1406 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1407 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1408 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1411 function enable_log4j_lttng_event_loglevel_only
()
1416 local channel_name
=$4
1420 # default channel if none specified
1421 if [ -n "$channel_name" ]; then
1422 chan_opt
=("-c" "$channel_name")
1425 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1426 enable-event
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1427 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1430 function enable_python_lttng_event
()
1436 if [ -z $channel_name ]; then
1437 # default channel if none specified
1440 chan
="-c $channel_name"
1443 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1444 ok $?
"Enable Python event $event_name for session $sess_name"
1447 function enable_python_lttng_event_loglevel
()
1450 local event_name
="$2"
1452 local channel_name
=$4
1454 if [ -z $channel_name ]; then
1455 # default channel if none specified
1458 chan
="-c $channel_name"
1461 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1462 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1465 function enable_ust_lttng_event_filter
()
1467 local sess_name
="$1"
1468 local event_name
="$2"
1470 local channel_name
=$4
1472 if [ -z $channel_name ]; then
1473 # default channel if none specified
1476 chan
="-c $channel_name"
1479 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1480 ok $?
"Enable event $event_name with filtering for session $sess_name"
1483 function enable_ust_lttng_event_loglevel
()
1485 local sess_name
="$1"
1486 local event_name
="$2"
1488 local channel_name
="$4"
1490 if [ -n "${channel_name}" ] ; then
1491 chan
=('-c' "${channel_name}")
1494 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"${chan[@]}" "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1495 ok $?
"Enable event $event_name with loglevel $loglevel"
1498 function enable_ust_lttng_event_loglevel_only
()
1500 local sess_name
="$1"
1501 local event_name
="$2"
1503 local channel_name
="$4"
1505 if [ -n "${channel_name}" ] ; then
1506 chan
=('-c' "${channel_name}")
1509 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"${chan[@]}" "$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1510 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1513 function disable_ust_lttng_event
()
1515 local sess_name
="$1"
1516 local event_name
="$2"
1517 local channel_name
="$3"
1519 if [ -z $channel_name ]; then
1520 # default channel if none specified
1523 chan
="-c $channel_name"
1526 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1527 ok $?
"Disable event $event_name for session $sess_name"
1530 function disable_jul_lttng_event
()
1532 local sess_name
="$1"
1533 local event_name
="$2"
1535 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1536 ok $?
"Disable JUL event $event_name for session $sess_name"
1539 function disable_log4j_lttng_event
()
1541 local sess_name
="$1"
1542 local event_name
="$2"
1544 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1545 disable-event
"$event_name" -s "$sess_name" --log4j
1546 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1549 function disable_python_lttng_event
()
1551 local sess_name
="$1"
1552 local event_name
="$2"
1554 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1555 ok $?
"Disable Python event $event_name for session $sess_name"
1558 function start_lttng_tracing_opt
()
1561 local expected_to_fail
=$2
1564 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1566 if [[ $expected_to_fail -eq "1" ]]; then
1569 if [ $withtap -eq "1" ]; then
1570 ok $?
"Start tracing for session $sess_name failed as expected"
1573 if [ $withtap -eq "1" ]; then
1574 ok
$ret "Start tracing for session $sess_name"
1579 function start_lttng_tracing_ok
()
1581 start_lttng_tracing_opt
1 0 "$@"
1584 function start_lttng_tracing_fail
()
1586 start_lttng_tracing_opt
1 1 "$@"
1589 function start_lttng_tracing_notap
()
1591 start_lttng_tracing_opt
0 1 "$@"
1594 function stop_lttng_tracing_opt
()
1597 local expected_to_fail
=$2
1600 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1602 if [[ $expected_to_fail -eq "1" ]]; then
1605 if [ $withtap -eq "1" ]; then
1606 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1609 if [ $withtap -eq "1" ]; then
1610 ok
$ret "Stop lttng tracing for session $sess_name"
1615 function stop_lttng_tracing_ok
()
1617 stop_lttng_tracing_opt
1 0 "$@"
1620 function stop_lttng_tracing_fail
()
1622 stop_lttng_tracing_opt
1 1 "$@"
1625 function stop_lttng_tracing_notap
()
1627 stop_lttng_tracing_opt
0 0 "$@"
1630 function destroy_lttng_session
()
1633 local expected_to_fail
=$2
1636 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1638 if [[ $expected_to_fail -eq "1" ]]; then
1641 if [ $withtap -eq "1" ]; then
1642 ok
$ret "Destroy session $sess_name failed as expected"
1645 if [ $withtap -eq "1" ]; then
1646 ok
$ret "Destroy session $sess_name"
1651 function destroy_lttng_session_ok
()
1653 destroy_lttng_session
1 0 "$@"
1657 function destroy_lttng_session_fail
()
1659 destroy_lttng_session
1 1 "$@"
1662 function destroy_lttng_session_notap
()
1664 destroy_lttng_session
0 0 "$@"
1667 function destroy_lttng_sessions
()
1669 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1670 ok $?
"Destroy all lttng sessions"
1673 function lttng_snapshot_add_output
()
1675 local expected_to_fail
=$1
1680 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1682 if [[ $expected_to_fail -eq 1 ]]; then
1684 ok $?
"Added snapshot output $trace_path failed as expected"
1686 ok
$ret "Added snapshot output $trace_path"
1690 function lttng_snapshot_add_output_ok
()
1692 lttng_snapshot_add_output
0 "$@"
1695 function lttng_snapshot_add_output_fail
()
1697 lttng_snapshot_add_output
1 "$@"
1700 function lttng_snapshot_del_output
()
1702 local expected_to_fail
=$1
1706 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1708 if [[ $expected_to_fail -eq "1" ]]; then
1710 ok $?
"Deleted snapshot output id $id failed as expected"
1712 ok
$ret "Deleted snapshot output id $id"
1716 function lttng_snapshot_del_output_ok
()
1718 lttng_snapshot_del_output
0 "$@"
1721 function lttng_snapshot_del_output_fail
()
1723 lttng_snapshot_del_output
1 "$@"
1726 function lttng_snapshot_record
()
1731 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s "$sess_name" "$trace_path" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1732 ok $?
"Snapshot recorded"
1735 function lttng_snapshot_list
()
1738 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1739 ok $?
"Snapshot list"
1742 function lttng_save
()
1747 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1748 ok $?
"Session saved"
1751 function lttng_load
()
1753 local expected_to_fail
=$1
1756 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1758 if [[ $expected_to_fail -eq "1" ]]; then
1760 ok $?
"Load command failed as expected with opts: $opts"
1762 ok
$ret "Load command with opts: $opts"
1766 function lttng_load_ok
()
1771 function lttng_load_fail
()
1776 function lttng_track
()
1778 local expected_to_fail
="$1"
1781 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1783 if [[ $expected_to_fail -eq "1" ]]; then
1785 ok $?
"Track command failed as expected with opts: $opts"
1787 ok
$ret "Track command with opts: $opts"
1791 function lttng_track_ok
()
1796 function lttng_track_fail
()
1801 function lttng_untrack
()
1803 local expected_to_fail
="$1"
1806 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1808 if [[ $expected_to_fail -eq "1" ]]; then
1810 ok $?
"Untrack command failed as expected with opts: $opts"
1812 ok
$ret "Untrack command with opts: $opts"
1816 function lttng_untrack_ok
()
1818 lttng_untrack
0 "$@"
1821 function lttng_untrack_fail
()
1823 lttng_untrack
1 "$@"
1826 function lttng_track_pid_ok
()
1829 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1830 ok $?
"Lttng track pid on the kernel domain"
1833 function lttng_untrack_kernel_all_ok
()
1835 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1836 ok $?
"Lttng untrack all pid on the kernel domain"
1839 function lttng_track_ust_ok
()
1841 lttng_track_ok
-u "$@"
1844 function lttng_track_ust_fail
()
1846 lttng_track_fail
-u "$@"
1849 function lttng_track_kernel_ok
()
1851 lttng_track_ok
-k "$@"
1854 function lttng_track_kernel_fail
()
1856 lttng_track_fail
-k "$@"
1859 function lttng_untrack_ust_ok
()
1861 lttng_untrack_ok
-u "$@"
1864 function lttng_untrack_ust_fail
()
1866 lttng_untrack_fail
-u "$@"
1869 function lttng_untrack_kernel_ok
()
1871 lttng_untrack_ok
-k "$@"
1874 function lttng_untrack_kernel_fail
()
1876 lttng_untrack_fail
-k "$@"
1879 function lttng_add_context_list
()
1881 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1883 ok
$ret "Context listing"
1886 function add_context_lttng
()
1888 local expected_to_fail
="$1"
1890 local session_name
="$3"
1891 local channel_name
="$4"
1894 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1896 if [[ $expected_to_fail -eq "1" ]]; then
1898 ok $?
"Add context command failed as expected for type: $type"
1900 ok
$ret "Add context command for type: $type"
1904 function add_context_ust_ok
()
1906 add_context_lttng
0 -u "$@"
1909 function add_context_ust_fail
()
1911 add_context_lttng
1 -u "$@"
1914 function add_context_kernel_ok
()
1916 add_context_lttng
0 -k "$@"
1919 function add_context_kernel_fail
()
1921 add_context_lttng
1 -k "$@"
1924 function wait_live_trace_ready
()
1927 local zero_client_match
=0
1929 diag
"Waiting for live trace at url: $url"
1930 while [ $zero_client_match -eq 0 ]; do
1931 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
1934 pass
"Waiting for live trace at url: $url"
1937 function wait_live_viewer_connect
()
1940 local one_client_match
=0
1942 diag
"Waiting for live viewers on url: $url"
1943 while [ $one_client_match -eq 0 ]; do
1944 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
1947 pass
"Waiting for live viewers on url: $url"
1950 function bail_out_if_no_babeltrace
()
1952 which "$BABELTRACE_BIN" >/dev
/null
1953 if [ $?
-ne 0 ]; then
1954 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
1958 function validate_metadata_event
()
1961 local nr_event_id
=$2
1964 local metadata_file
=$
(find $trace_path -name "metadata")
1965 local metadata_path
=$
(dirname $metadata_file)
1967 which $BABELTRACE_BIN >/dev
/null
1968 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1970 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1972 if [ "$count" -ne "$nr_event_id" ]; then
1973 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1974 diag
"$count matching event id found in metadata"
1976 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1981 function trace_matches
()
1987 which $BABELTRACE_BIN >/dev
/null
1988 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1990 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1992 if [ "$count" -ne "$nr_iter" ]; then
1994 diag
"$count matching events found in trace"
2000 function trace_match_only
()
2006 which $BABELTRACE_BIN >/dev
/null
2007 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2009 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
2010 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
2012 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
2013 pass
"Trace match with $total event $event_name"
2016 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
2020 function validate_trace
2025 which $BABELTRACE_BIN >/dev
/null
2026 if [ $?
-ne 0 ]; then
2027 skip
0 "Babeltrace binary not found. Skipping trace validation"
2032 for i
in $event_name; do
2033 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2034 if [ "$traced" -ne 0 ]; then
2035 pass
"Validate trace for event $i, $traced events"
2037 fail
"Validate trace for event $i"
2038 diag
"Found $traced occurrences of $i"
2046 function validate_trace_count
2050 local expected_count
=$3
2052 which $BABELTRACE_BIN >/dev
/null
2053 if [ $?
-ne 0 ]; then
2054 skip
0 "Babeltrace binary not found. Skipping trace validation"
2060 for i
in $event_name; do
2061 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2062 if [ "$traced" -ne 0 ]; then
2063 pass
"Validate trace for event $i, $traced events"
2065 fail
"Validate trace for event $i"
2066 diag
"Found $traced occurrences of $i"
2068 cnt
=$
(($cnt + $traced))
2071 test $cnt -eq $expected_count
2072 ok $?
"Read a total of $cnt events, expected $expected_count"
2075 function validate_trace_count_range_incl_min_excl_max
2079 local expected_min
=$3
2080 local expected_max
=$4
2082 which $BABELTRACE_BIN >/dev
/null
2083 if [ $?
-ne 0 ]; then
2084 skip
0 "Babeltrace binary not found. Skipping trace validation"
2090 for i
in $event_name; do
2091 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2092 if [ "$traced" -ge $expected_min ]; then
2093 pass
"Validate trace for event $i, $traced events"
2095 fail
"Validate trace for event $i"
2096 diag
"Found $traced occurrences of $i"
2098 cnt
=$
(($cnt + $traced))
2101 test $cnt -lt $expected_max
2102 ok $?
"Read a total of $cnt events, expected between [$expected_min, $expected_max["
2105 function trace_first_line
2109 which $BABELTRACE_BIN >/dev
/null
2110 if [ $?
-ne 0 ]; then
2111 skip
0 "Babeltrace binary not found. Skipping trace validation"
2114 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
2117 function validate_trace_exp
()
2122 which $BABELTRACE_BIN >/dev
/null
2123 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
2125 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
2126 if [ "$traced" -ne 0 ]; then
2127 pass
"Validate trace for expression '${event_exp}', $traced events"
2129 fail
"Validate trace for expression '${event_exp}'"
2130 diag
"Found $traced occurrences of '${event_exp}'"
2136 function validate_trace_only_exp
()
2141 which $BABELTRACE_BIN >/dev
/null
2142 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2144 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
2145 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
2147 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
2148 pass
"Trace match with $total for expression '${event_exp}'"
2151 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
2157 function validate_trace_empty
()
2161 which $BABELTRACE_BIN >/dev
/null
2162 if [ $?
-ne 0 ]; then
2163 skip
0 "Babeltrace binary not found. Skipping trace validation"
2166 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
2168 if [ $ret -ne 0 ]; then
2169 fail
"Failed to parse trace"
2173 traced
=$
(echo -n "$events" |
wc -l)
2174 if [ "$traced" -eq 0 ]; then
2175 pass
"Validate empty trace"
2177 fail
"Validate empty trace"
2178 diag
"Found $traced events in trace"
2184 function validate_directory_empty
()
2186 local trace_path
="$1"
2188 # Do not double quote `$trace_path` below as we want wildcards to be
2190 files
="$(ls -A $trace_path)"
2192 if [ $ret -ne 0 ]; then
2193 fail
"Failed to list content of directory \"$trace_path\""
2197 nb_files
="$(echo -n "$files" | wc -l)"
2198 ok
$nb_files "Directory \"$trace_path\" is empty"
2201 function validate_trace_session_ust_empty
()
2203 validate_directory_empty
"$1"/ust
2206 function validate_trace_session_kernel_empty
()
2208 validate_trace_empty
"$1"/kernel
2211 function regenerate_metadata
()
2213 local expected_to_fail
=$1
2216 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2218 if [[ $expected_to_fail -eq "1" ]]; then
2220 ok $?
"Expected fail on regenerate metadata $sess_name"
2222 ok
$ret "Metadata regenerate $sess_name"
2226 function regenerate_metadata_ok
()
2228 regenerate_metadata
0 "$@"
2231 function regenerate_metadata_fail
()
2233 regenerate_metadata
1 "$@"
2236 function regenerate_statedump
()
2238 local expected_to_fail
=$1
2241 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2243 if [[ $expected_to_fail -eq "1" ]]; then
2245 ok $?
"Expected fail on regenerate statedump $sess_name"
2247 ok
$ret "Statedump regenerate $sess_name"
2251 function regenerate_statedump_ok
()
2253 regenerate_statedump
0 "$@"
2256 function regenerate_statedump_fail
()
2258 regenerate_statedump
1 "$@"
2261 function rotate_session
()
2263 local expected_to_fail
=$1
2266 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2268 if [[ $expected_to_fail -eq "1" ]]; then
2270 ok $?
"Expected fail on rotate session $sess_name"
2272 ok
$ret "Rotate session $sess_name"
2276 function rotate_session_ok
()
2278 rotate_session
0 "$@"
2281 function rotate_session_fail
()
2283 rotate_session
1 "$@"
2286 function destructive_tests_enabled
()
2288 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2295 function lttng_enable_rotation_timer
()
2297 local expected_to_fail
=$1
2301 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2303 if [[ $expected_to_fail -eq "1" ]]; then
2305 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2307 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2311 function lttng_enable_rotation_timer_ok
()
2313 lttng_enable_rotation_timer
0 $@
2316 function lttng_enable_rotation_timer_fail
()
2318 lttng_enable_rotation_timer
1 $@
2321 function lttng_enable_rotation_size
()
2323 local expected_to_fail
=$1
2327 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2329 if [[ $expected_to_fail -eq "1" ]]; then
2331 ok $?
"Expected fail on rotate session $sess_name"
2333 ok
$ret "Rotate session $sess_name"
2337 function lttng_enable_rotation_size_ok
()
2339 lttng_enable_rotation_size
0 $@
2342 function lttng_enable_rotation_size_fail
()
2344 lttng_enable_rotation_size
1 $@
2347 function lttng_clear_session
()
2349 local expected_to_fail
=$1
2352 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2354 if [[ $expected_to_fail -eq "1" ]]; then
2356 ok $?
"Expected fail on clear session $sess_name"
2358 ok
$ret "Clear session $sess_name"
2362 function lttng_clear_session_ok
()
2364 lttng_clear_session
0 $@
2367 function lttng_clear_session_fail
()
2369 lttng_clear_session
1 $@
2372 function lttng_clear_all
()
2374 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2375 ok $?
"Clear all lttng sessions"
2378 function lttng_add_trigger
()
2380 local expected_to_fail
="$1"
2381 local trigger_name
="$2"
2385 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2386 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2388 if [[ $expected_to_fail -eq "1" ]]; then
2390 ok $?
"Add trigger $trigger_name failed as expected"
2392 ok
$ret "Add trigger $trigger_name"
2396 function lttng_remove_trigger
()
2398 local expected_to_fail
="$1"
2399 local trigger_name
="$2"
2402 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2403 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2405 if [[ $expected_to_fail -eq "1" ]]; then
2407 ok $?
"Remove trigger $trigger_name failed as expected"
2409 ok
$ret "Remove trigger $trigger_name"
2413 function lttng_add_trigger_ok
()
2415 lttng_add_trigger
0 "$@"
2418 function lttng_add_trigger_fail
()
2420 lttng_add_trigger
1 "$@"
2423 function lttng_remove_trigger_ok
()
2425 lttng_remove_trigger
0 "$@"
2428 function list_triggers_matches_ok
()
2430 local tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2431 local tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2433 local test_name
="$1"
2434 local expected_stdout_file
="$2"
2436 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2438 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2439 ok $?
"${test_name}: exit code is 0"
2441 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2442 ok $?
"${test_name}: expected stdout"
2444 diff -u /dev
/null
"${tmp_stderr}"
2445 ok $?
"${test_name}: expected stderr"
2447 rm -f "${tmp_stdout}"
2448 rm -f "${tmp_stderr}"
2451 function list_triggers_matches_mi_ok
()
2454 local tmp_stdout_raw
2457 local test_name
="$1"
2458 local expected_stdout_file
="$2"
2460 tmp_stdout_raw
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2461 tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2462 tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2464 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2466 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2467 ok $?
"${test_name}: exit code is 0"
2469 # Pretty-fy xml before further test.
2470 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2472 $MI_VALIDATE "${tmp_stdout}"
2473 ok $?
"list-trigger mi is valid"
2475 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2476 ok $?
"${test_name}: expected stdout"
2478 diff -u /dev
/null
"${tmp_stderr}"
2479 ok $?
"${test_name}: expected stderr"
2481 rm -f "${tmp_stdout}"
2482 rm -f "${tmp_stdout_raw}"
2483 rm -f "${tmp_stderr}"
2486 function validate_path_pattern
()
2490 # Base path is only used in error case and is used to list the content
2499 if [ "$ret" -ne "0" ]; then
2500 diag
"Path pattern expected: $pattern"
2501 # List the tracepath for more info. We use find as a recursive
2503 diag
"The base path content:"
2504 find "$base_path" -print
2508 function validate_trace_path_ust_uid
()
2511 local session_name
=$2
2513 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2515 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2518 function validate_trace_path_ust_uid_network
()
2521 local session_name
=$2
2524 local hostname
=$HOSTNAME
2528 # If the session was given a network base path (e.g
2529 # 127.0.0.1/my/custom/path on creation, there is no session name
2530 # component to the path on the relayd side. Caller can simply not pass a
2531 # session name for this scenario.
2532 if [ -n "$session_name" ]; then
2533 session_name
="$session_name-$date_time_pattern"
2534 if [ -n "$base_path" ]; then
2535 fail
"Session name and base path are mutually exclusive"
2540 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2542 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2545 function validate_trace_path_ust_uid_snapshot_network
()
2548 local session_name
=$2
2549 local snapshot_name
=$3
2550 local snapshot_number
=$4
2552 local hostname
=$HOSTNAME
2557 # If the session/output was given a network base path (e.g
2558 # 127.0.0.1/my/custom/path on creation, there is no session name
2559 # component to the path on the relayd side. Caller can simply not pass a
2560 # session name for this scenario.
2561 if [ -n "$session_name" ]; then
2562 session_name
="$session_name-$date_time_pattern"
2563 if [ -n "$base_path" ]; then
2564 fail
"Session name and base path are mutually exclusive"
2569 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2571 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2574 function validate_trace_path_ust_uid_snapshot
()
2577 local session_name
=$2
2578 local snapshot_name
=$3
2579 local snapshot_number
=$4
2585 # If the session/output was given a network base path (e.g
2586 # 127.0.0.1/my/custom/path) on creation, there is no session name
2587 # component to the path on the relayd side. Caller can simply not pass a
2588 # session name for this scenario.
2589 if [ -n "$session_name" ]; then
2590 session_name
="$session_name-$date_time_pattern"
2591 if [ -n "$base_path" ]; then
2592 fail
"Session name and base path are mutually exclusive"
2597 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2599 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2602 function validate_trace_path_ust_pid
()
2605 local session_name
=$2
2611 # If the session was given a trace path on creation, there is no session
2612 # name component to the path. Caller can simply not pass a session name
2613 # for this scenario.
2614 if [ -n "$session_name" ]; then
2615 session_name
="$session_name-$date_time_pattern"
2618 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2620 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2623 function validate_trace_path_kernel
()
2626 local session_name
=$2
2629 # If the session was given a trace path on creation, there is no session
2630 # name component to the path. Caller can simply not pass a session name
2631 # for this scenario.
2632 if [ -n "$session_name" ]; then
2633 session_name
="$session_name-$date_time_pattern"
2636 pattern
="$trace_path/$session_name/kernel/metadata"
2638 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2641 function validate_trace_path_kernel_network
()
2644 local session_name
=$2
2645 local hostname
=$HOSTNAME
2646 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2648 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2651 function validate_trace_path_kernel_snapshot
()
2654 local session_name
=$2
2655 local snapshot_name
=$3
2656 local snapshot_number
=$4
2661 # If the session/output was given a network base path (e.g
2662 # 127.0.0.1/my/custom/path on creation, there is no session name
2663 # component to the path on the relayd side. Caller can simply not pass a
2664 # session name for this scenario.
2665 if [ -n "$session_name" ]; then
2666 session_name
="$session_name-$date_time_pattern"
2667 if [ -n "$base_path" ]; then
2668 fail
"Session name and base path are mutually exclusive"
2673 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2675 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2678 function validate_trace_path_kernel_snapshot_network
()
2681 local session_name
=$2
2682 local snapshot_name
=$3
2683 local snapshot_number
=$4
2685 local hostname
=$HOSTNAME
2689 # If the session/output was given a network base path (e.g
2690 # 127.0.0.1/my/custom/path on creation, there is no session name
2691 # component to the path on the relayd side. Caller can simply not pass a
2692 # session name for this scenario.
2693 if [ -n "$session_name" ]; then
2694 session_name
="$session_name-$date_time_pattern"
2695 if [ -n "$base_path" ]; then
2696 fail
"Session name and base path are mutually exclusive"
2701 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2703 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"