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 # Return a space-separated string of online CPU IDs, based on
213 # /sys/devices/system/cpu/online, or from 0 to nproc - 1 otherwise.
214 function get_online_cpus
()
218 if [ -f /sys
/devices
/system
/cpu
/online
]; then
219 range_re
='([0-9]+)-([0-9]+)'
220 while read -r range
; do
221 if [[ "${range}" =~
${range_re} ]] ; then
222 mapfile
-t -O "${#cpus[*]}" cpus <<< $(seq "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
226 done < <(tr ',' $
'\n' < /sys
/devices
/system
/cpu
/online
)
228 read -r -a cpus
<<< $
(seq 0 $
(( $
(conf_proc_count
) - 1 )) )
233 # Helpers for get_possible_cpus.
234 function get_possible_cpus_count_from_sysfs_possible_mask
()
236 local max_possible_cpu_id
238 # The Awk script extracts the highest CPU id from the possible CPU
239 # mask. Assuming a numerical order, a field separator '-' and a record
240 # separator ','. The last value parsed is the highest id.
241 if [ -f /sys
/devices
/system
/cpu
/possible
]; then
242 max_possible_cpu_id
=$
(awk -F '-' 'BEGIN { RS = ","} { last = $NF } END { printf("%d\n", last) }' \
243 /sys
/devices
/system
/cpu
/possible
)
244 echo "$((max_possible_cpu_id+1))"
250 # This is a fallback if the possible CPU mask is not available. This will not
251 # take into account unplugged CPUs.
252 function get_max_cpus_count_from_sysfs_cpu_directories
()
254 local max_possible_cpu_id
=0
257 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
258 current_cpu_id
="${i#/sys/devices/system/cpu/cpu}"
259 if [ "$current_cpu_id" -gt "$max_possible_cpu_id" ]; then
260 max_possible_cpu_id
="$current_cpu_id"
264 echo "$((max_possible_cpu_id+1))"
267 # Return the number of possible CPUs.
268 function get_possible_cpus_count
()
270 local possible_cpus_count
271 possible_cpus_count
=$
(get_possible_cpus_count_from_sysfs_possible_mask
)
273 if [ "$possible_cpus_count" -eq "0" ]; then
274 local configured_cpus_count
275 configured_cpus_count
=$
(getconf _NPROCESSORS_CONF
)
276 possible_cpus_count
=$
(get_max_cpus_count_from_sysfs_cpu_directories
)
277 possible_cpus_count
=$
((configured_cpus_count
> possible_cpus_count \
278 ? configured_cpus_count \
279 : possible_cpus_count
))
282 echo "$possible_cpus_count"
285 # Return the list of exposed CPU.
287 # NOTE! Use it like so:
289 # IFS=" " read -r -a VARIABLE <<< "$(get_exposed_cpus_list)"
290 function get_exposed_cpus_list
()
294 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
295 list
+=("${i#/sys/devices/system/cpu/cpu}")
301 # Return any available CPU found. Do not make assumption about the returned
302 # value, e.g. that it could be 0.
303 function get_any_available_cpu
()
305 for cpu
in $
(get_online_cpus
); do
311 # Return the number of _configured_ CPUs.
312 function conf_proc_count
()
314 getconf _NPROCESSORS_CONF
315 if [ $?
-ne 0 ]; then
316 diag
"Failed to get the number of configured CPUs"
321 # Check if base lttng-modules are present.
322 # Bail out on failure
323 function validate_lttng_modules_present
()
325 # Check for loadable modules.
326 modprobe
-n lttng-tracer
2>/dev
/null
327 if [ $?
-eq 0 ]; then
331 # Check for builtin modules.
332 ls /proc
/lttng
> /dev
/null
2>&1
333 if [ $?
-eq 0 ]; then
337 LTTNG_BAIL_OUT
"LTTng modules not detected."
340 # Run the lttng binary.
342 # The first two arguments are stdout and stderr redirect paths, respectively.
343 # The rest of the arguments are forwarded to the lttng binary
344 function _run_lttng_cmd
346 local stdout_dest
="$1"
347 local stderr_dest
="$2"
350 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN $*"
351 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"
354 function enable_kernel_lttng_event
357 local expected_to_fail
="$2"
359 local event_name
="$4"
360 local channel_name
="$5"
362 if [ -z "$event_name" ]; then
363 # Enable all event if no event name specified
367 if [ -z "$channel_name" ]; then
368 # default channel if none specified
371 chan
="-c $channel_name"
374 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
376 if [[ $expected_to_fail -eq "1" ]]; then
379 if [ $withtap -eq "1" ]; then
380 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
383 if [ $withtap -eq "1" ]; then
384 ok
$ret "Enable kernel event $event_name for session $sess_name"
389 function enable_kernel_lttng_event_ok
()
391 enable_kernel_lttng_event
1 0 "$@"
394 function enable_kernel_lttng_event_fail
()
396 enable_kernel_lttng_event
1 1 "$@"
399 function enable_kernel_lttng_event_notap
()
401 enable_kernel_lttng_event
0 0 "$@"
405 function lttng_enable_kernel_event
407 enable_kernel_lttng_event_ok
"$@"
410 function lttng_enable_kernel_syscall
()
412 local expected_to_fail
=$1
414 local syscall_name
=$3
415 local channel_name
=$4
417 if [ -z $syscall_name ]; then
418 # Enable all event if no syscall name specified
422 if [ -z $channel_name ]; then
423 # default channel if none specified
426 chan
="-c $channel_name"
429 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
431 if [[ $expected_to_fail -eq "1" ]]; then
433 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
435 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
439 function lttng_enable_kernel_syscall_ok
()
441 lttng_enable_kernel_syscall
0 "$@"
444 function lttng_enable_kernel_syscall_fail
()
446 lttng_enable_kernel_syscall
1 "$@"
449 function lttng_disable_kernel_syscall
()
451 local expected_to_fail
=$1
453 local syscall_name
=$3
454 local channel_name
=$4
456 if [ -z $syscall_name ]; then
457 # Enable all event if no syscall name specified
461 if [ -z $channel_name ]; then
462 # default channel if none specified
465 chan
="-c $channel_name"
468 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
471 if [[ $expected_to_fail -eq "1" ]]; then
473 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
475 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
479 function lttng_disable_kernel_syscall_ok
()
481 lttng_disable_kernel_syscall
0 "$@"
484 function lttng_disable_kernel_syscall_fail
()
486 lttng_disable_kernel_syscall
1 "$@"
489 function lttng_enable_kernel_function_event
()
491 local expected_to_fail
="$1"
494 local event_name
="$4"
496 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
498 if [[ $expected_to_fail -eq "1" ]]; then
500 ok $?
"Enable kernel function event for session $sess_name failed as expected"
502 ok
$ret "Enable kernel function event for session $sess_name"
506 function lttng_enable_kernel_function_event_ok
()
508 lttng_enable_kernel_function_event
0 "$@"
511 function lttng_enable_kernel_userspace_probe_event
()
513 local expected_to_fail
="$1"
516 local event_name
="$4"
518 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
520 if [[ $expected_to_fail -eq "1" ]]; then
522 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
524 ok
$ret "Enable kernel userspace probe event for session $sess_name"
528 function lttng_enable_kernel_userspace_probe_event_fail
()
530 lttng_enable_kernel_userspace_probe_event
1 "$@"
533 function lttng_enable_kernel_userspace_probe_event_ok
()
535 lttng_enable_kernel_userspace_probe_event
0 "$@"
538 function disable_kernel_lttng_userspace_probe_event_ok
()
541 local event_name
="$2"
543 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
544 ok $?
"Disable kernel event $target for session $sess_name"
546 function lttng_enable_kernel_channel
()
549 local expected_to_fail
=$2
551 local channel_name
=$4
554 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
556 if [[ $expected_to_fail -eq "1" ]]; then
559 if [ $withtap -eq "1" ]; then
560 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
563 if [ $withtap -eq "1" ]; then
564 ok
$ret "Enable channel $channel_name for session $sess_name"
569 function lttng_enable_kernel_channel_ok
()
571 lttng_enable_kernel_channel
1 0 "$@"
574 function lttng_enable_kernel_channel_fail
()
576 lttng_enable_kernel_channel
1 1 "$@"
579 function lttng_enable_kernel_channel_notap
()
581 lttng_enable_kernel_channel
0 0 "$@"
584 function enable_kernel_lttng_channel_ok
()
586 lttng_enable_kernel_channel
1 0 "$@"
589 function lttng_disable_kernel_channel
()
591 local expected_to_fail
=$1
593 local channel_name
=$3
595 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
597 if [[ $expected_to_fail -eq "1" ]]; then
599 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
601 ok
$ret "Disable channel $channel_name for session $sess_name"
605 function lttng_disable_kernel_channel_ok
()
607 lttng_disable_kernel_channel
0 "$@"
610 function lttng_disable_kernel_channel_fail
()
612 lttng_disable_kernel_channel
1 "$@"
615 function start_lttng_relayd_opt
()
618 local process_mode
=$2
621 DIR
=$
(readlink
-f "$TESTDIR")
623 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
624 # shellcheck disable=SC2086
625 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
626 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
627 if [ $?
-eq 1 ]; then
628 if [ $withtap -eq "1" ]; then
629 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
633 if [ $withtap -eq "1" ]; then
634 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
638 pass
"Start lttng-relayd (opt: $opt)"
642 function start_lttng_relayd
()
644 start_lttng_relayd_opt
1 "-b" "$@"
647 function start_lttng_relayd_notap
()
649 start_lttng_relayd_opt
0 "-b" "$@"
652 function stop_lttng_relayd_opt
()
662 if [ -z "$signal" ]; then
667 # Multiply time by 2 to simplify integer arithmetic
668 if [ -n "$timeout_s" ]; then
669 dtimeleft_s
=$
((timeout_s
* 2))
673 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
674 if [ -z "$pids" ]; then
675 if [ "$is_cleanup" -eq 1 ]; then
677 elif [ "$withtap" -eq "1" ]; then
678 fail
"No relay daemon to kill"
680 LTTNG_BAIL_OUT
"No relay daemon to kill"
685 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
687 # shellcheck disable=SC2086
688 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
690 if [ "$withtap" -eq "1" ]; then
691 fail
"Kill relay daemon"
695 while [ -n "$out" ]; do
696 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
697 if [ -n "$dtimeleft_s" ]; then
698 if [ $dtimeleft_s -lt 0 ]; then
702 dtimeleft_s
=$
((dtimeleft_s
- 1))
706 if [ "$withtap" -eq "1" ]; then
707 if [ "$retval" -eq "0" ]; then
708 pass
"Wait after kill relay daemon"
710 fail
"Wait after kill relay daemon"
717 function stop_lttng_relayd
()
719 stop_lttng_relayd_opt
1 0 "$@"
722 function stop_lttng_relayd_notap
()
724 stop_lttng_relayd_opt
0 0 "$@"
727 function stop_lttng_relayd_cleanup
()
729 stop_lttng_relayd_opt
0 1 "$@"
732 #First arg: show tap output
733 #Second argument: load path for automatic loading
734 function start_lttng_sessiond_opt
()
739 # The rest of the arguments will be passed directly to lttng-sessiond.
745 local long_bit_value
=
746 long_bit_value
=$
(getconf LONG_BIT
)
748 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
749 # Env variable requested no session daemon
753 DIR
=$
(readlink
-f "$TESTDIR")
755 # Get long_bit value for 32/64 consumerd
756 case "$long_bit_value" in
758 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
761 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
768 # Check for env. variable. Allow the use of LD_PRELOAD etc.
769 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
770 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
772 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
774 if ! validate_kernel_version
; then
775 fail
"Start session daemon"
776 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
779 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
780 export LTTNG_SESSION_CONFIG_XSD_PATH
782 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
784 if [ -n "$load_path" ]; then
785 # shellcheck disable=SC2086
786 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
788 # shellcheck disable=SC2086
789 env
$env_vars --background "$consumerd" "$@"
791 #$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
793 if [ "$withtap" -eq "1" ]; then
794 ok
$status "Start session daemon"
799 function start_lttng_sessiond
()
801 start_lttng_sessiond_opt
1 "$@"
804 function start_lttng_sessiond_notap
()
806 start_lttng_sessiond_opt
0 "$@"
809 function stop_lttng_sessiond_opt
()
820 if [ -z "$signal" ]; then
824 # Multiply time by 2 to simplify integer arithmetic
825 if [ -n "$timeout_s" ]; then
826 dtimeleft_s
=$
((timeout_s
* 2))
829 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
830 # Env variable requested no session daemon
834 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
835 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
837 if [ -n "$runas_pids" ]; then
838 pids
="$pids $runas_pids"
841 if [ -z "$pids" ]; then
842 if [ "$is_cleanup" -eq 1 ]; then
844 elif [ "$withtap" -eq "1" ]; then
845 fail
"No session daemon to kill"
847 LTTNG_BAIL_OUT
"No session daemon to kill"
852 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
854 # shellcheck disable=SC2086
855 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
857 if [ "$withtap" -eq "1" ]; then
858 fail
"Kill sessions daemon"
862 while [ -n "$out" ]; do
863 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
864 if [ -n "$dtimeleft_s" ]; then
865 if [ $dtimeleft_s -lt 0 ]; then
869 dtimeleft_s
=$
((dtimeleft_s
- 1))
874 while [ -n "$out" ]; do
875 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
876 if [ -n "$dtimeleft_s" ]; then
877 if [ $dtimeleft_s -lt 0 ]; then
881 dtimeleft_s
=$
((dtimeleft_s
- 1))
886 if [ "$withtap" -eq "1" ]; then
887 if [ "$retval" -eq "0" ]; then
888 pass
"Wait after kill session daemon"
890 fail
"Wait after kill session daemon"
894 if [ "$signal" = "SIGKILL" ]; then
895 if [ "$(id -u)" -eq "0" ]; then
897 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
899 if [ -n "$modules" ]; then
900 diag
"Unloading all LTTng modules"
901 modprobe
--remove "$modules"
909 function stop_lttng_sessiond
()
911 stop_lttng_sessiond_opt
1 0 "$@"
914 function stop_lttng_sessiond_notap
()
916 stop_lttng_sessiond_opt
0 0 "$@"
919 function stop_lttng_sessiond_cleanup
()
921 stop_lttng_sessiond_opt
0 1 "$@"
924 function sigstop_lttng_sessiond_opt
()
930 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
931 # Env variable requested no session daemon
935 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
937 if [ "$withtap" -eq "1" ]; then
938 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
941 # shellcheck disable=SC2086
942 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
943 if [ "$withtap" -eq "1" ]; then
944 fail
"Sending SIGSTOP to session daemon"
948 while [ $out -ne 0 ]; do
949 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
951 # Wait until state becomes stopped for session
954 for sessiond_pid
in $pids; do
955 state
="$(ps -p "$sessiond_pid" -o state= )"
956 if [[ -n "$state" && "$state" != "T" ]]; then
962 if [ "$withtap" -eq "1" ]; then
963 pass
"Sending SIGSTOP to session daemon"
968 function sigstop_lttng_sessiond
()
970 sigstop_lttng_sessiond_opt
1 "$@"
973 function sigstop_lttng_sessiond_notap
()
975 sigstop_lttng_sessiond_opt
0 "$@"
978 function stop_lttng_consumerd_opt
()
988 if [ -z "$signal" ]; then
992 # Multiply time by 2 to simplify integer arithmetic
993 if [ -n "$timeout_s" ]; then
994 dtimeleft_s
=$
((timeout_s
* 2))
997 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
999 if [ -z "$pids" ]; then
1000 if [ "$is_cleanup" -eq 1 ]; then
1002 elif [ "$withtap" -eq "1" ]; then
1003 fail
"No consumerd daemon to kill"
1005 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
1010 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1012 # shellcheck disable=SC2086
1013 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
1015 if [ "$withtap" -eq "1" ]; then
1016 fail
"Kill consumer daemon"
1020 while [ $out -ne 0 ]; do
1021 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1023 # If consumerds are still present check their status.
1024 # A zombie status qualifies the consumerd as *killed*
1026 for consumer_pid
in $pids; do
1027 state
="$(ps -p "$consumer_pid" -o state= )"
1028 if [[ -n "$state" && "$state" != "Z" ]]; then
1032 if [ -n "$dtimeleft_s" ]; then
1033 if [ $dtimeleft_s -lt 0 ]; then
1037 dtimeleft_s
=$
((dtimeleft_s
- 1))
1041 if [ "$withtap" -eq "1" ]; then
1042 if [ "$retval" -eq "0" ]; then
1043 pass
"Wait after kill consumer daemon"
1045 fail
"Wait after kill consumer daemon"
1053 function stop_lttng_consumerd
()
1055 stop_lttng_consumerd_opt
1 0 "$@"
1058 function stop_lttng_consumerd_notap
()
1060 stop_lttng_consumerd_opt
0 0 "$@"
1063 function stop_lttng_consumerd_cleanup
()
1065 stop_lttng_consumerd_opt
0 1 "$@"
1068 function sigstop_lttng_consumerd_opt
()
1071 local signal
=SIGSTOP
1074 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1076 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1078 # shellcheck disable=SC2086
1079 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1082 if [ $retval -eq 1 ]; then
1083 if [ "$withtap" -eq "1" ]; then
1084 fail
"Sending SIGSTOP to consumer daemon"
1089 while [ $out -ne 0 ]; do
1090 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1092 # Wait until state becomes stopped for all
1095 for consumer_pid
in $pids; do
1096 state
="$(ps -p "$consumer_pid" -o state= )"
1097 if [[ -n "$state" && "$state" != "T" ]]; then
1103 if [ "$withtap" -eq "1" ]; then
1104 pass
"Sending SIGSTOP to consumer daemon"
1110 function sigstop_lttng_consumerd
()
1112 sigstop_lttng_consumerd_opt
1 "$@"
1115 function sigstop_lttng_consumerd_notap
()
1117 sigstop_lttng_consumerd_opt
0 "$@"
1120 function list_lttng_with_opts
()
1126 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1128 if [ $withtap -eq "1" ]; then
1129 ok
$ret "Lttng-tool list command with option $opts"
1133 function list_lttng_ok
()
1135 list_lttng_with_opts
1 "$@"
1138 function list_lttng_notap
()
1140 list_lttng_with_opts
0 "$@"
1143 function create_lttng_session_no_output
()
1148 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1149 ok $?
"Create session $sess_name in no-output mode"
1152 function create_lttng_session_uri
() {
1157 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1158 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1161 function create_lttng_session
()
1164 local expected_to_fail
=$2
1169 if [ -z "$trace_path" ]; then
1170 # Use lttng-sessiond default output.
1173 trace_path
="-o $trace_path"
1176 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1178 if [ $expected_to_fail -eq "1" ]; then
1181 if [ $withtap -eq "1" ]; then
1182 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1185 if [ $withtap -eq "1" ]; then
1186 ok
$ret "Create session $sess_name in $trace_path"
1192 function create_lttng_session_ok
()
1194 create_lttng_session
1 0 "$@"
1197 function create_lttng_session_fail
()
1199 create_lttng_session
1 1 "$@"
1202 function create_lttng_session_notap
()
1204 create_lttng_session
0 0 "$@"
1208 function enable_ust_lttng_channel
()
1211 local expected_to_fail
=$2
1213 local channel_name
=$4
1216 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1218 if [[ $expected_to_fail -eq "1" ]]; then
1221 if [ $withtap -eq "1" ]; then
1222 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1225 if [ $withtap -eq "1" ]; then
1226 ok
$ret "Enable channel $channel_name for session $sess_name"
1232 function enable_ust_lttng_channel_ok
()
1234 enable_ust_lttng_channel
1 0 "$@"
1237 function enable_ust_lttng_channel_fail
()
1239 enable_ust_lttng_channel
1 1 "$@"
1242 function enable_ust_lttng_channel_notap
()
1244 enable_ust_lttng_channel
0 0 "$@"
1247 function disable_ust_lttng_channel
()
1250 local channel_name
=$2
1252 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1253 ok $?
"Disable channel $channel_name for session $sess_name"
1256 function enable_lttng_mmap_overwrite_kernel_channel
()
1259 local channel_name
=$2
1261 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1262 ok $?
"Enable channel $channel_name for session $sess_name"
1265 function enable_lttng_mmap_discard_small_kernel_channel
()
1268 local channel_name
=$2
1270 $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
1271 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1274 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1277 local channel_name
=$2
1279 $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
1280 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1283 function enable_lttng_mmap_overwrite_ust_channel
()
1286 local channel_name
=$2
1288 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1289 ok $?
"Enable channel $channel_name for session $sess_name"
1292 function enable_ust_lttng_event
()
1295 local expected_to_fail
=$2
1297 local event_name
="$4"
1298 local channel_name
=$5
1300 if [ -z $channel_name ]; then
1301 # default channel if none specified
1304 chan
="-c $channel_name"
1307 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1309 if [[ $expected_to_fail -eq "1" ]]; then
1312 if [[ $withtap -eq "1" ]]; then
1313 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1316 if [[ $withtap -eq "1" ]]; then
1317 ok
$ret "Enable ust event $event_name for session $sess_name"
1323 function enable_ust_lttng_event_ok
()
1325 enable_ust_lttng_event
1 0 "$@"
1328 function enable_ust_lttng_event_fail
()
1330 enable_ust_lttng_event
1 1 "$@"
1333 function enable_ust_lttng_event_notap
()
1335 enable_ust_lttng_event
0 0 "$@"
1338 function enable_jul_lttng_event
()
1344 if [ -z $channel_name ]; then
1345 # default channel if none specified
1348 chan
="-c $channel_name"
1351 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1352 ok $?
"Enable JUL event $event_name for session $sess_name"
1355 function enable_jul_lttng_event_loglevel
()
1358 local event_name
="$2"
1360 local channel_name
=$4
1362 if [ -z $channel_name ]; then
1363 # default channel if none specified
1366 chan
="-c $channel_name"
1369 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1370 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1373 function enable_log4j_lttng_event
()
1377 local channel_name
=$3
1381 # default channel if none specified
1382 if [ -n "$channel_name" ]; then
1383 chan_opt
=("-c" "$channel_name")
1386 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1387 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1388 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1391 function enable_log4j_lttng_event_filter
()
1397 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1398 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1399 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1402 function enable_log4j_lttng_event_filter_loglevel_only
()
1409 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1410 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1411 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1414 function enable_log4j_lttng_event_loglevel
()
1419 local channel_name
=$4
1422 # default channel if none specified
1423 if [ -n "$channel_name" ]; then
1424 chan_opt
=("-c" "$channel_name")
1427 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1428 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1429 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1432 function enable_log4j_lttng_event_loglevel_only
()
1437 local channel_name
=$4
1441 # default channel if none specified
1442 if [ -n "$channel_name" ]; then
1443 chan_opt
=("-c" "$channel_name")
1446 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1447 enable-event
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1448 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1451 function enable_python_lttng_event
()
1457 if [ -z $channel_name ]; then
1458 # default channel if none specified
1461 chan
="-c $channel_name"
1464 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1465 ok $?
"Enable Python event $event_name for session $sess_name"
1468 function enable_python_lttng_event_loglevel
()
1471 local event_name
="$2"
1473 local channel_name
=$4
1475 if [ -z $channel_name ]; then
1476 # default channel if none specified
1479 chan
="-c $channel_name"
1482 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1483 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1486 function enable_ust_lttng_event_filter
()
1488 local sess_name
="$1"
1489 local event_name
="$2"
1491 local channel_name
=$4
1493 if [ -z $channel_name ]; then
1494 # default channel if none specified
1497 chan
="-c $channel_name"
1500 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1501 ok $?
"Enable event $event_name with filtering for session $sess_name"
1504 function enable_ust_lttng_event_loglevel
()
1506 local sess_name
="$1"
1507 local event_name
="$2"
1509 local channel_name
="$4"
1511 if [ -n "${channel_name}" ] ; then
1512 chan
=('-c' "${channel_name}")
1515 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"${chan[@]}" "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1516 ok $?
"Enable event $event_name with loglevel $loglevel"
1519 function enable_ust_lttng_event_loglevel_only
()
1521 local sess_name
="$1"
1522 local event_name
="$2"
1524 local channel_name
="$4"
1526 if [ -n "${channel_name}" ] ; then
1527 chan
=('-c' "${channel_name}")
1530 $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
1531 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1534 function disable_ust_lttng_event
()
1536 local sess_name
="$1"
1537 local event_name
="$2"
1538 local channel_name
="$3"
1540 if [ -z $channel_name ]; then
1541 # default channel if none specified
1544 chan
="-c $channel_name"
1547 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1548 ok $?
"Disable event $event_name for session $sess_name"
1551 function disable_jul_lttng_event
()
1553 local sess_name
="$1"
1554 local event_name
="$2"
1556 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1557 ok $?
"Disable JUL event $event_name for session $sess_name"
1560 function disable_log4j_lttng_event
()
1562 local sess_name
="$1"
1563 local event_name
="$2"
1565 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1566 disable-event
"$event_name" -s "$sess_name" --log4j
1567 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1570 function disable_python_lttng_event
()
1572 local sess_name
="$1"
1573 local event_name
="$2"
1575 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1576 ok $?
"Disable Python event $event_name for session $sess_name"
1579 function start_lttng_tracing_opt
()
1582 local expected_to_fail
=$2
1585 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1587 if [[ $expected_to_fail -eq "1" ]]; then
1590 if [ $withtap -eq "1" ]; then
1591 ok $?
"Start tracing for session $sess_name failed as expected"
1594 if [ $withtap -eq "1" ]; then
1595 ok
$ret "Start tracing for session $sess_name"
1600 function start_lttng_tracing_ok
()
1602 start_lttng_tracing_opt
1 0 "$@"
1605 function start_lttng_tracing_fail
()
1607 start_lttng_tracing_opt
1 1 "$@"
1610 function start_lttng_tracing_notap
()
1612 start_lttng_tracing_opt
0 1 "$@"
1615 function stop_lttng_tracing_opt
()
1618 local expected_to_fail
=$2
1621 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1623 if [[ $expected_to_fail -eq "1" ]]; then
1626 if [ $withtap -eq "1" ]; then
1627 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1630 if [ $withtap -eq "1" ]; then
1631 ok
$ret "Stop lttng tracing for session $sess_name"
1636 function stop_lttng_tracing_ok
()
1638 stop_lttng_tracing_opt
1 0 "$@"
1641 function stop_lttng_tracing_fail
()
1643 stop_lttng_tracing_opt
1 1 "$@"
1646 function stop_lttng_tracing_notap
()
1648 stop_lttng_tracing_opt
0 0 "$@"
1651 function destroy_lttng_session
()
1654 local expected_to_fail
=$2
1657 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1659 if [[ $expected_to_fail -eq "1" ]]; then
1662 if [ $withtap -eq "1" ]; then
1663 ok
$ret "Destroy session $sess_name failed as expected"
1666 if [ $withtap -eq "1" ]; then
1667 ok
$ret "Destroy session $sess_name"
1672 function destroy_lttng_session_ok
()
1674 destroy_lttng_session
1 0 "$@"
1678 function destroy_lttng_session_fail
()
1680 destroy_lttng_session
1 1 "$@"
1683 function destroy_lttng_session_notap
()
1685 destroy_lttng_session
0 0 "$@"
1688 function destroy_lttng_sessions
()
1690 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1691 ok $?
"Destroy all lttng sessions"
1694 function lttng_snapshot_add_output
()
1696 local expected_to_fail
=$1
1701 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1703 if [[ $expected_to_fail -eq 1 ]]; then
1705 ok $?
"Added snapshot output $trace_path failed as expected"
1707 ok
$ret "Added snapshot output $trace_path"
1711 function lttng_snapshot_add_output_ok
()
1713 lttng_snapshot_add_output
0 "$@"
1716 function lttng_snapshot_add_output_fail
()
1718 lttng_snapshot_add_output
1 "$@"
1721 function lttng_snapshot_del_output
()
1723 local expected_to_fail
=$1
1727 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1729 if [[ $expected_to_fail -eq "1" ]]; then
1731 ok $?
"Deleted snapshot output id $id failed as expected"
1733 ok
$ret "Deleted snapshot output id $id"
1737 function lttng_snapshot_del_output_ok
()
1739 lttng_snapshot_del_output
0 "$@"
1742 function lttng_snapshot_del_output_fail
()
1744 lttng_snapshot_del_output
1 "$@"
1747 function lttng_snapshot_record
()
1752 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s "$sess_name" "$trace_path" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1753 ok $?
"Snapshot recorded"
1756 function lttng_snapshot_list
()
1759 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1760 ok $?
"Snapshot list"
1763 function lttng_save
()
1768 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1769 ok $?
"Session saved"
1772 function lttng_load
()
1774 local expected_to_fail
=$1
1777 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1779 if [[ $expected_to_fail -eq "1" ]]; then
1781 ok $?
"Load command failed as expected with opts: $opts"
1783 ok
$ret "Load command with opts: $opts"
1787 function lttng_load_ok
()
1792 function lttng_load_fail
()
1797 function lttng_track
()
1799 local expected_to_fail
="$1"
1802 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1804 if [[ $expected_to_fail -eq "1" ]]; then
1806 ok $?
"Track command failed as expected with opts: $opts"
1808 ok
$ret "Track command with opts: $opts"
1812 function lttng_track_ok
()
1817 function lttng_track_fail
()
1822 function lttng_untrack
()
1824 local expected_to_fail
="$1"
1827 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1829 if [[ $expected_to_fail -eq "1" ]]; then
1831 ok $?
"Untrack command failed as expected with opts: $opts"
1833 ok
$ret "Untrack command with opts: $opts"
1837 function lttng_untrack_ok
()
1839 lttng_untrack
0 "$@"
1842 function lttng_untrack_fail
()
1844 lttng_untrack
1 "$@"
1847 function lttng_track_pid_ok
()
1850 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1851 ok $?
"Lttng track pid on the kernel domain"
1854 function lttng_untrack_kernel_all_ok
()
1856 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1857 ok $?
"Lttng untrack all pid on the kernel domain"
1860 function lttng_track_ust_ok
()
1862 lttng_track_ok
-u "$@"
1865 function lttng_track_ust_fail
()
1867 lttng_track_fail
-u "$@"
1870 function lttng_track_kernel_ok
()
1872 lttng_track_ok
-k "$@"
1875 function lttng_track_kernel_fail
()
1877 lttng_track_fail
-k "$@"
1880 function lttng_untrack_ust_ok
()
1882 lttng_untrack_ok
-u "$@"
1885 function lttng_untrack_ust_fail
()
1887 lttng_untrack_fail
-u "$@"
1890 function lttng_untrack_kernel_ok
()
1892 lttng_untrack_ok
-k "$@"
1895 function lttng_untrack_kernel_fail
()
1897 lttng_untrack_fail
-k "$@"
1900 function lttng_add_context_list
()
1902 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1904 ok
$ret "Context listing"
1907 function add_context_lttng
()
1909 local expected_to_fail
="$1"
1911 local session_name
="$3"
1912 local channel_name
="$4"
1915 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1917 if [[ $expected_to_fail -eq "1" ]]; then
1919 ok $?
"Add context command failed as expected for type: $type"
1921 ok
$ret "Add context command for type: $type"
1925 function add_context_ust_ok
()
1927 add_context_lttng
0 -u "$@"
1930 function add_context_ust_fail
()
1932 add_context_lttng
1 -u "$@"
1935 function add_context_kernel_ok
()
1937 add_context_lttng
0 -k "$@"
1940 function add_context_kernel_fail
()
1942 add_context_lttng
1 -k "$@"
1945 function wait_live_trace_ready
()
1948 local zero_client_match
=0
1950 diag
"Waiting for live trace at url: $url"
1951 while [ $zero_client_match -eq 0 ]; do
1952 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
1955 pass
"Waiting for live trace at url: $url"
1958 function wait_live_viewer_connect
()
1961 local one_client_match
=0
1963 diag
"Waiting for live viewers on url: $url"
1964 while [ $one_client_match -eq 0 ]; do
1965 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
1968 pass
"Waiting for live viewers on url: $url"
1971 function bail_out_if_no_babeltrace
()
1973 which "$BABELTRACE_BIN" >/dev
/null
1974 if [ $?
-ne 0 ]; then
1975 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
1979 function validate_metadata_event
()
1982 local nr_event_id
=$2
1985 local metadata_file
=$
(find $trace_path -name "metadata")
1986 local metadata_path
=$
(dirname $metadata_file)
1988 which $BABELTRACE_BIN >/dev
/null
1989 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1991 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1993 if [ "$count" -ne "$nr_event_id" ]; then
1994 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1995 diag
"$count matching event id found in metadata"
1997 pass
"Metadata match with the metadata of $count event(s) named $event_name"
2002 function trace_matches
()
2008 which $BABELTRACE_BIN >/dev
/null
2009 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2011 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
2013 if [ "$count" -ne "$nr_iter" ]; then
2015 diag
"$count matching events found in trace"
2021 function trace_match_only
()
2027 which $BABELTRACE_BIN >/dev
/null
2028 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2030 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
2031 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
2033 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
2034 pass
"Trace match with $total event $event_name"
2037 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
2041 function validate_trace
2046 which $BABELTRACE_BIN >/dev
/null
2047 if [ $?
-ne 0 ]; then
2048 skip
0 "Babeltrace binary not found. Skipping trace validation"
2053 for i
in $event_name; do
2054 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2055 if [ "$traced" -ne 0 ]; then
2056 pass
"Validate trace for event $i, $traced events"
2058 fail
"Validate trace for event $i"
2059 diag
"Found $traced occurrences of $i"
2067 function validate_trace_count
2071 local expected_count
=$3
2073 which $BABELTRACE_BIN >/dev
/null
2074 if [ $?
-ne 0 ]; then
2075 skip
0 "Babeltrace binary not found. Skipping trace validation"
2081 for i
in $event_name; do
2082 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2083 if [ "$traced" -ne 0 ]; then
2084 pass
"Validate trace for event $i, $traced events"
2086 fail
"Validate trace for event $i"
2087 diag
"Found $traced occurrences of $i"
2089 cnt
=$
(($cnt + $traced))
2092 test $cnt -eq $expected_count
2093 ok $?
"Read a total of $cnt events, expected $expected_count"
2096 function validate_trace_count_range_incl_min_excl_max
2100 local expected_min
=$3
2101 local expected_max
=$4
2103 which $BABELTRACE_BIN >/dev
/null
2104 if [ $?
-ne 0 ]; then
2105 skip
0 "Babeltrace binary not found. Skipping trace validation"
2111 for i
in $event_name; do
2112 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
2113 if [ "$traced" -ge $expected_min ]; then
2114 pass
"Validate trace for event $i, $traced events"
2116 fail
"Validate trace for event $i"
2117 diag
"Found $traced occurrences of $i"
2119 cnt
=$
(($cnt + $traced))
2122 test $cnt -lt $expected_max
2123 ok $?
"Read a total of $cnt events, expected between [$expected_min, $expected_max["
2126 function trace_first_line
2130 which $BABELTRACE_BIN >/dev
/null
2131 if [ $?
-ne 0 ]; then
2132 skip
0 "Babeltrace binary not found. Skipping trace validation"
2135 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
2138 function validate_trace_exp
()
2143 which $BABELTRACE_BIN >/dev
/null
2144 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
2146 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
2147 if [ "$traced" -ne 0 ]; then
2148 pass
"Validate trace for expression '${event_exp}', $traced events"
2150 fail
"Validate trace for expression '${event_exp}'"
2151 diag
"Found $traced occurrences of '${event_exp}'"
2157 function validate_trace_only_exp
()
2162 which $BABELTRACE_BIN >/dev
/null
2163 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
2165 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
2166 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
2168 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
2169 pass
"Trace match with $total for expression '${event_exp}'"
2172 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
2178 function validate_trace_empty
()
2182 which $BABELTRACE_BIN >/dev
/null
2183 if [ $?
-ne 0 ]; then
2184 skip
0 "Babeltrace binary not found. Skipping trace validation"
2187 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
2189 if [ $ret -ne 0 ]; then
2190 fail
"Failed to parse trace"
2194 traced
=$
(echo -n "$events" |
wc -l)
2195 if [ "$traced" -eq 0 ]; then
2196 pass
"Validate empty trace"
2198 fail
"Validate empty trace"
2199 diag
"Found $traced events in trace"
2205 function validate_directory_empty
()
2207 local trace_path
="$1"
2209 # Do not double quote `$trace_path` below as we want wildcards to be
2211 files
="$(ls -A $trace_path)"
2213 if [ $ret -ne 0 ]; then
2214 fail
"Failed to list content of directory \"$trace_path\""
2218 nb_files
="$(echo -n "$files" | wc -l)"
2219 ok
$nb_files "Directory \"$trace_path\" is empty"
2222 function validate_trace_session_ust_empty
()
2224 validate_directory_empty
"$1"/ust
2227 function validate_trace_session_kernel_empty
()
2229 validate_trace_empty
"$1"/kernel
2232 function regenerate_metadata
()
2234 local expected_to_fail
=$1
2237 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2239 if [[ $expected_to_fail -eq "1" ]]; then
2241 ok $?
"Expected fail on regenerate metadata $sess_name"
2243 ok
$ret "Metadata regenerate $sess_name"
2247 function regenerate_metadata_ok
()
2249 regenerate_metadata
0 "$@"
2252 function regenerate_metadata_fail
()
2254 regenerate_metadata
1 "$@"
2257 function regenerate_statedump
()
2259 local expected_to_fail
=$1
2262 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2264 if [[ $expected_to_fail -eq "1" ]]; then
2266 ok $?
"Expected fail on regenerate statedump $sess_name"
2268 ok
$ret "Statedump regenerate $sess_name"
2272 function regenerate_statedump_ok
()
2274 regenerate_statedump
0 "$@"
2277 function regenerate_statedump_fail
()
2279 regenerate_statedump
1 "$@"
2282 function rotate_session
()
2284 local expected_to_fail
=$1
2287 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2289 if [[ $expected_to_fail -eq "1" ]]; then
2291 ok $?
"Expected fail on rotate session $sess_name"
2293 ok
$ret "Rotate session $sess_name"
2297 function rotate_session_ok
()
2299 rotate_session
0 "$@"
2302 function rotate_session_fail
()
2304 rotate_session
1 "$@"
2307 function destructive_tests_enabled
()
2309 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2316 function lttng_enable_rotation_timer
()
2318 local expected_to_fail
=$1
2322 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2324 if [[ $expected_to_fail -eq "1" ]]; then
2326 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2328 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2332 function lttng_enable_rotation_timer_ok
()
2334 lttng_enable_rotation_timer
0 $@
2337 function lttng_enable_rotation_timer_fail
()
2339 lttng_enable_rotation_timer
1 $@
2342 function lttng_enable_rotation_size
()
2344 local expected_to_fail
=$1
2348 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2350 if [[ $expected_to_fail -eq "1" ]]; then
2352 ok $?
"Expected fail on rotate session $sess_name"
2354 ok
$ret "Rotate session $sess_name"
2358 function lttng_enable_rotation_size_ok
()
2360 lttng_enable_rotation_size
0 $@
2363 function lttng_enable_rotation_size_fail
()
2365 lttng_enable_rotation_size
1 $@
2368 function lttng_clear_session
()
2370 local expected_to_fail
=$1
2373 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2375 if [[ $expected_to_fail -eq "1" ]]; then
2377 ok $?
"Expected fail on clear session $sess_name"
2379 ok
$ret "Clear session $sess_name"
2383 function lttng_clear_session_ok
()
2385 lttng_clear_session
0 $@
2388 function lttng_clear_session_fail
()
2390 lttng_clear_session
1 $@
2393 function lttng_clear_all
()
2395 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2396 ok $?
"Clear all lttng sessions"
2399 function lttng_add_trigger
()
2401 local expected_to_fail
="$1"
2402 local trigger_name
="$2"
2406 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2407 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2409 if [[ $expected_to_fail -eq "1" ]]; then
2411 ok $?
"Add trigger $trigger_name failed as expected"
2413 ok
$ret "Add trigger $trigger_name"
2417 function lttng_remove_trigger
()
2419 local expected_to_fail
="$1"
2420 local trigger_name
="$2"
2423 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2424 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2426 if [[ $expected_to_fail -eq "1" ]]; then
2428 ok $?
"Remove trigger $trigger_name failed as expected"
2430 ok
$ret "Remove trigger $trigger_name"
2434 function lttng_add_trigger_ok
()
2436 lttng_add_trigger
0 "$@"
2439 function lttng_add_trigger_fail
()
2441 lttng_add_trigger
1 "$@"
2444 function lttng_remove_trigger_ok
()
2446 lttng_remove_trigger
0 "$@"
2449 function list_triggers_matches_ok
()
2451 local tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2452 local tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2454 local test_name
="$1"
2455 local expected_stdout_file
="$2"
2457 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2459 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2460 ok $?
"${test_name}: exit code is 0"
2462 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2463 ok $?
"${test_name}: expected stdout"
2465 diff -u /dev
/null
"${tmp_stderr}"
2466 ok $?
"${test_name}: expected stderr"
2468 rm -f "${tmp_stdout}"
2469 rm -f "${tmp_stderr}"
2472 function list_triggers_matches_mi_ok
()
2475 local tmp_stdout_raw
2478 local test_name
="$1"
2479 local expected_stdout_file
="$2"
2481 tmp_stdout_raw
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2482 tmp_stdout
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2483 tmp_stderr
=$
(mktemp
--tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2485 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2487 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2488 ok $?
"${test_name}: exit code is 0"
2490 # Pretty-fy xml before further test.
2491 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2493 $MI_VALIDATE "${tmp_stdout}"
2494 ok $?
"list-trigger mi is valid"
2496 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2497 ok $?
"${test_name}: expected stdout"
2499 diff -u /dev
/null
"${tmp_stderr}"
2500 ok $?
"${test_name}: expected stderr"
2502 rm -f "${tmp_stdout}"
2503 rm -f "${tmp_stdout_raw}"
2504 rm -f "${tmp_stderr}"
2507 function validate_path_pattern
()
2511 # Base path is only used in error case and is used to list the content
2520 if [ "$ret" -ne "0" ]; then
2521 diag
"Path pattern expected: $pattern"
2522 # List the tracepath for more info. We use find as a recursive
2524 diag
"The base path content:"
2525 find "$base_path" -print
2529 function validate_trace_path_ust_uid
()
2532 local session_name
=$2
2534 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2536 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2539 function validate_trace_path_ust_uid_network
()
2542 local session_name
=$2
2545 local hostname
=$HOSTNAME
2549 # If the session was given a network base path (e.g
2550 # 127.0.0.1/my/custom/path on creation, there is no session name
2551 # component to the path on the relayd side. Caller can simply not pass a
2552 # session name for this scenario.
2553 if [ -n "$session_name" ]; then
2554 session_name
="$session_name-$date_time_pattern"
2555 if [ -n "$base_path" ]; then
2556 fail
"Session name and base path are mutually exclusive"
2561 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2563 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2566 function validate_trace_path_ust_uid_snapshot_network
()
2569 local session_name
=$2
2570 local snapshot_name
=$3
2571 local snapshot_number
=$4
2573 local hostname
=$HOSTNAME
2578 # If the session/output was given a network base path (e.g
2579 # 127.0.0.1/my/custom/path on creation, there is no session name
2580 # component to the path on the relayd side. Caller can simply not pass a
2581 # session name for this scenario.
2582 if [ -n "$session_name" ]; then
2583 session_name
="$session_name-$date_time_pattern"
2584 if [ -n "$base_path" ]; then
2585 fail
"Session name and base path are mutually exclusive"
2590 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2592 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2595 function validate_trace_path_ust_uid_snapshot
()
2598 local session_name
=$2
2599 local snapshot_name
=$3
2600 local snapshot_number
=$4
2606 # If the session/output was given a network base path (e.g
2607 # 127.0.0.1/my/custom/path) on creation, there is no session name
2608 # component to the path on the relayd side. Caller can simply not pass a
2609 # session name for this scenario.
2610 if [ -n "$session_name" ]; then
2611 session_name
="$session_name-$date_time_pattern"
2612 if [ -n "$base_path" ]; then
2613 fail
"Session name and base path are mutually exclusive"
2618 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2620 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2623 function validate_trace_path_ust_pid
()
2626 local session_name
=$2
2632 # If the session was given a trace path on creation, there is no session
2633 # name component to the path. Caller can simply not pass a session name
2634 # for this scenario.
2635 if [ -n "$session_name" ]; then
2636 session_name
="$session_name-$date_time_pattern"
2639 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2641 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2644 function validate_trace_path_kernel
()
2647 local session_name
=$2
2650 # If the session was given a trace path on creation, there is no session
2651 # name component to the path. Caller can simply not pass a session name
2652 # for this scenario.
2653 if [ -n "$session_name" ]; then
2654 session_name
="$session_name-$date_time_pattern"
2657 pattern
="$trace_path/$session_name/kernel/metadata"
2659 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2662 function validate_trace_path_kernel_network
()
2665 local session_name
=$2
2666 local hostname
=$HOSTNAME
2667 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2669 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2672 function validate_trace_path_kernel_snapshot
()
2675 local session_name
=$2
2676 local snapshot_name
=$3
2677 local snapshot_number
=$4
2682 # If the session/output was given a network base path (e.g
2683 # 127.0.0.1/my/custom/path on creation, there is no session name
2684 # component to the path on the relayd side. Caller can simply not pass a
2685 # session name for this scenario.
2686 if [ -n "$session_name" ]; then
2687 session_name
="$session_name-$date_time_pattern"
2688 if [ -n "$base_path" ]; then
2689 fail
"Session name and base path are mutually exclusive"
2694 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2696 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2699 function validate_trace_path_kernel_snapshot_network
()
2702 local session_name
=$2
2703 local snapshot_name
=$3
2704 local snapshot_number
=$4
2706 local hostname
=$HOSTNAME
2710 # If the session/output was given a network base path (e.g
2711 # 127.0.0.1/my/custom/path on creation, there is no session name
2712 # component to the path on the relayd side. Caller can simply not pass a
2713 # session name for this scenario.
2714 if [ -n "$session_name" ]; then
2715 session_name
="$session_name-$date_time_pattern"
2716 if [ -n "$base_path" ]; then
2717 fail
"Session name and base path are mutually exclusive"
2722 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2724 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"