1 # Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
3 # SPDX-License-Identifier: LGPL-2.1-only
6 SESSIOND_BIN
="lttng-sessiond"
7 SESSIOND_MATCH
=".*lttng-sess.*"
8 RUNAS_BIN
="lttng-runas"
9 RUNAS_MATCH
=".*lttng-runas.*"
10 CONSUMERD_BIN
="lttng-consumerd"
11 CONSUMERD_MATCH
=".*lttng-consumerd.*"
12 RELAYD_BIN
="lttng-relayd"
13 RELAYD_MATCH
=".*lttng-relayd.*"
15 BABELTRACE_BIN
="babeltrace2"
17 ERROR_OUTPUT_DEST
=/dev
/null
18 MI_XSD_MAJOR_VERSION
=4
19 MI_XSD_MINOR_VERSION
=1
20 MI_XSD_PATH
="$TESTDIR/../src/common/mi-lttng-${MI_XSD_MAJOR_VERSION}.${MI_XSD_MINOR_VERSION}.xsd"
21 MI_VALIDATE
="$TESTDIR/utils/xml-utils/validate_xml ${MI_XSD_PATH}"
23 XML_PRETTY
="$TESTDIR/utils/xml-utils/pretty_xml"
24 XML_EXTRACT
="$TESTDIR/utils/xml-utils/extract_xml"
25 XML_NODE_CHECK
="${XML_EXTRACT} -e"
27 # To match 20201127-175802
28 date_time_pattern
="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]"
29 # The size of a long on this system
30 system_long_bit_size
=$
(getconf LONG_BIT
)
32 # Minimal kernel version supported for session daemon tests
33 KERNEL_MAJOR_VERSION
=2
34 KERNEL_MINOR_VERSION
=6
35 KERNEL_PATCHLEVEL_VERSION
=27
37 # We set the default UST register timeout and network and app socket timeout to
38 # "wait forever", so that basic tests don't have to worry about hitting
39 # timeouts on busy systems. Specialized tests should test those corner-cases.
40 export LTTNG_UST_REGISTER_TIMEOUT
=-1
41 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
42 export LTTNG_APP_SOCKET_TIMEOUT
=-1
44 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
45 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
46 # its own sessiond if none is running. It also ensures that 'lttng create'
47 # fails when no sessiond is running.
48 export LTTNG_SESSIOND_PATH
="/bin/true"
50 source $TESTDIR/utils
/tap
/tap.sh
52 if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then
53 LTTNG_TEST_TEARDOWN_TIMEOUT
=60
56 # Enable job monitor mode.
57 # Here we are mostly interested in the following from the monitor mode:
58 # All processes run in a separate process group.
59 # This allows us to ensure that all subprocesses from all background tasks are
60 # cleaned up correctly using signal to process group id.
63 kill_background_jobs
()
68 if [ -z "$pids" ]; then
75 # Use negative number to send the signal to the process group.
76 # This ensure that any subprocesses receive the signal.
77 # /dev/null is used since there is an acceptable race between
78 # the moments the pids are listed and the moment we send a
80 kill -SIGTERM -- "-$pid" 2>/dev
/null
86 # Try to kill daemons gracefully
87 stop_lttng_relayd_cleanup SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
88 stop_lttng_sessiond_cleanup SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
90 # If daemons are still present, forcibly kill them
91 stop_lttng_relayd_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
92 stop_lttng_sessiond_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
93 stop_lttng_consumerd_cleanup SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
98 function full_cleanup
()
104 function LTTNG_BAIL_OUT
()
110 function null_pipes
()
117 trap full_cleanup SIGINT SIGTERM
119 # perl prove closes its child pipes before giving it a chance to run its
120 # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
121 # to allow those trap handlers to proceed.
123 trap null_pipes SIGPIPE
125 # Check pgrep from env, default to pgrep if none
126 if [ -z "$PGREP" ]; then
130 # Due to the renaming of threads we need to use the full command (pgrep -f) to
131 # identify the pids for multiple lttng related processes. The problem with "pgrep
132 # -f" is that it ends up also looking at the arguments. We use a two stage
133 # lookup. The first one is using "pgrep -f" yielding potential candidate.
134 # The second on perform grep on the basename of the first field of the
135 # /proc/pid/cmdline of the previously identified pids. The first field
136 # correspond to the actual command.
137 function lttng_pgrep
()
141 local full_command_no_argument
142 local command_basename
144 possible_pids
=$
($PGREP -f "$pattern")
145 if [ -z "$possible_pids" ]; then
149 while IFS
= read -r pid
; do
150 # /proc/pid/cmdline is null separated.
151 if full_command_no_argument
=$
( (tr '\0' '\n' < /proc
/"$pid"/cmdline
) 2>/dev
/null |
head -n1); then
152 command_basename
=$
(basename "$full_command_no_argument")
153 if grep -q "$pattern" <<< "$command_basename"; then
157 done <<< "$possible_pids"
163 # Check if we are a terminal
165 echo -e "\e[1;32mOK\e[0m"
171 function print_fail
()
173 # Check if we are a terminal
175 echo -e "\e[1;31mFAIL\e[0m"
181 function print_test_banner
()
187 function validate_kernel_version
()
189 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
190 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
193 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
196 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
202 # Generate a random string
203 # $1 = number of characters; defaults to 16
204 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
205 function randstring
()
209 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
210 # /dev/urandom isn't guaranteed to generate valid multi-byte characters.
211 # Specifying the C locale eliminates the "Illegal byte sequence" error
212 # that 'tr' outputs in such cases.
213 LC_CTYPE
=C
tr -cd "$CHAR" < /dev
/urandom
2>/dev
/null |
head -c "$len" 2>/dev
/null
217 # Return a space-separated string of online CPU IDs, based on
218 # /sys/devices/system/cpu/online, or from 0 to nproc - 1 otherwise.
219 function get_online_cpus
()
223 if [ -f /sys
/devices
/system
/cpu
/online
]; then
224 range_re
='([0-9]+)-([0-9]+)'
225 while read -r range
; do
226 if [[ "${range}" =~
${range_re} ]] ; then
227 mapfile
-t -O "${#cpus[*]}" cpus <<< $(seq "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
231 done < <(tr ',' $
'\n' < /sys
/devices
/system
/cpu
/online
)
233 read -r -a cpus
<<< $
(seq 0 $
(( $
(conf_proc_count
) - 1 )) )
238 # Helpers for get_possible_cpus.
239 function get_possible_cpus_count_from_sysfs_possible_mask
()
241 local max_possible_cpu_id
243 # The Awk script extracts the highest CPU id from the possible CPU
244 # mask. Assuming a numerical order, a field separator '-' and a record
245 # separator ','. The last value parsed is the highest id.
246 if [ -f /sys
/devices
/system
/cpu
/possible
]; then
247 max_possible_cpu_id
=$
(awk -F '-' 'BEGIN { RS = ","} { last = $NF } END { printf("%d\n", last) }' \
248 /sys
/devices
/system
/cpu
/possible
)
249 echo "$((max_possible_cpu_id+1))"
255 # This is a fallback if the possible CPU mask is not available. This will not
256 # take into account unplugged CPUs.
257 function get_max_cpus_count_from_sysfs_cpu_directories
()
259 local max_possible_cpu_id
=0
262 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
263 current_cpu_id
="${i#/sys/devices/system/cpu/cpu}"
264 if [ "$current_cpu_id" -gt "$max_possible_cpu_id" ]; then
265 max_possible_cpu_id
="$current_cpu_id"
269 echo "$((max_possible_cpu_id+1))"
272 # Return the number of possible CPUs.
273 function get_possible_cpus_count
()
275 local possible_cpus_count
276 possible_cpus_count
=$
(get_possible_cpus_count_from_sysfs_possible_mask
)
278 if [ "$possible_cpus_count" -eq "0" ]; then
279 local configured_cpus_count
280 configured_cpus_count
=$
(getconf _NPROCESSORS_CONF
)
281 possible_cpus_count
=$
(get_max_cpus_count_from_sysfs_cpu_directories
)
282 possible_cpus_count
=$
((configured_cpus_count
> possible_cpus_count \
283 ? configured_cpus_count \
284 : possible_cpus_count
))
287 echo "$possible_cpus_count"
290 # Return the list of exposed CPU.
292 # NOTE! Use it like so:
294 # IFS=" " read -r -a VARIABLE <<< "$(get_exposed_cpus_list)"
295 function get_exposed_cpus_list
()
299 for i
in /sys
/devices
/system
/cpu
/cpu
[0-9]*; do
300 list
+=("${i#/sys/devices/system/cpu/cpu}")
306 # Return any available CPU found. Do not make assumption about the returned
307 # value, e.g. that it could be 0.
308 function get_any_available_cpu
()
310 for cpu
in $
(get_online_cpus
); do
316 # Return the number of _configured_ CPUs.
317 function conf_proc_count
()
319 getconf _NPROCESSORS_CONF
320 if [ $?
-ne 0 ]; then
321 diag
"Failed to get the number of configured CPUs"
327 # check_skip_kernel_test [NB_TESTS] [SKIP_MESSAGE]
328 # Return 0 if LTTNG_TOOLS_DISABLE_KERNEL_TESTS was set or the current user is not a root user
329 # If NB_TESTS is set, call skip() to skip number of tests.
330 # If NB_TESTS is empty, just output a reason with diag.
331 # An optional message can be added.
333 function check_skip_kernel_test
()
336 local skip_message
="$2"
338 # Check for skip test kernel flag
339 if [ "$LTTNG_TOOLS_DISABLE_KERNEL_TESTS" == "1" ]; then
340 if ! test -z "$num_tests"; then
341 skip
0 "LTTNG_TOOLS_DISABLE_KERNEL_TESTS was set.${skip_message+ }${skip_message}" "$num_tests"
343 diag
"LTTNG_TOOLS_DISABLE_KERNEL_TESTS was set.${skip_message+ }${skip_message}"
348 # Check if we are running as root
349 if [ "$(id -u)" != "0" ]; then
350 if ! test -z "$num_tests"; then
351 skip
0 "Root access is needed for kernel testing.${skip_message+ }${skip_message}" "$num_tests"
353 diag
"Root access is needed for kernel testing.${skip_message+ }${skip_message}"
361 # Check if base lttng-modules are present.
362 # Bail out on failure
363 function validate_lttng_modules_present
()
365 # Check for loadable modules.
366 modprobe
-n lttng-tracer
2>/dev
/null
367 if [ $?
-eq 0 ]; then
371 # Check for builtin modules.
372 ls /proc
/lttng
> /dev
/null
2>&1
373 if [ $?
-eq 0 ]; then
377 LTTNG_BAIL_OUT
"LTTng modules not detected."
380 # Run the lttng binary.
382 # The first two arguments are stdout and stderr redirect paths, respectively.
383 # The rest of the arguments are forwarded to the lttng binary
384 function _run_lttng_cmd
386 local stdout_dest
="$1"
387 local stderr_dest
="$2"
390 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN $*"
391 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"
394 function enable_kernel_lttng_event
397 local expected_to_fail
="$2"
399 local event_name
="$4"
400 local channel_name
="$5"
402 if [ -z "$event_name" ]; then
403 # Enable all event if no event name specified
407 if [ -z "$channel_name" ]; then
408 # default channel if none specified
411 chan
="-c $channel_name"
414 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
415 enable-event
"$event_name" $chan -s $sess_name -k
417 if [[ $expected_to_fail -eq "1" ]]; then
420 if [ $withtap -eq "1" ]; then
421 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
424 if [ $withtap -eq "1" ]; then
425 ok
$ret "Enable kernel event $event_name for session $sess_name"
430 function enable_kernel_lttng_event_ok
()
432 enable_kernel_lttng_event
1 0 "$@"
435 function enable_kernel_lttng_event_fail
()
437 enable_kernel_lttng_event
1 1 "$@"
440 function enable_kernel_lttng_event_notap
()
442 enable_kernel_lttng_event
0 0 "$@"
446 function lttng_enable_kernel_event
448 enable_kernel_lttng_event_ok
"$@"
451 function lttng_enable_kernel_syscall
()
453 local expected_to_fail
=$1
455 local syscall_name
=$3
456 local channel_name
=$4
458 if [ -z $syscall_name ]; then
459 # Enable all event if no syscall name specified
463 if [ -z $channel_name ]; then
464 # default channel if none specified
467 chan
="-c $channel_name"
470 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
471 enable-event
--syscall "$syscall_name" $chan -s $sess_name -k
473 if [[ $expected_to_fail -eq "1" ]]; then
475 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
477 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
481 function lttng_enable_kernel_syscall_ok
()
483 lttng_enable_kernel_syscall
0 "$@"
486 function lttng_enable_kernel_syscall_fail
()
488 lttng_enable_kernel_syscall
1 "$@"
491 function lttng_disable_kernel_syscall
()
493 local expected_to_fail
=$1
495 local syscall_name
=$3
496 local channel_name
=$4
498 if [ -z $syscall_name ]; then
499 # Enable all event if no syscall name specified
503 if [ -z $channel_name ]; then
504 # default channel if none specified
507 chan
="-c $channel_name"
510 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
511 disable-event
--syscall "$syscall_name" $chan -s $sess_name -k
514 if [[ $expected_to_fail -eq "1" ]]; then
516 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
518 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
522 function lttng_disable_kernel_syscall_ok
()
524 lttng_disable_kernel_syscall
0 "$@"
527 function lttng_disable_kernel_syscall_fail
()
529 lttng_disable_kernel_syscall
1 "$@"
532 function lttng_enable_kernel_function_event
()
534 local expected_to_fail
="$1"
537 local event_name
="$4"
539 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
541 if [[ $expected_to_fail -eq "1" ]]; then
543 ok $?
"Enable kernel function event for session $sess_name failed as expected"
545 ok
$ret "Enable kernel function event for session $sess_name"
549 function lttng_enable_kernel_function_event_ok
()
551 lttng_enable_kernel_function_event
0 "$@"
554 function lttng_enable_kernel_userspace_probe_event
()
556 local expected_to_fail
="$1"
559 local event_name
="$4"
561 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
563 if [[ $expected_to_fail -eq "1" ]]; then
565 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
567 ok
$ret "Enable kernel userspace probe event for session $sess_name"
571 function lttng_enable_kernel_userspace_probe_event_fail
()
573 lttng_enable_kernel_userspace_probe_event
1 "$@"
576 function lttng_enable_kernel_userspace_probe_event_ok
()
578 lttng_enable_kernel_userspace_probe_event
0 "$@"
581 function disable_kernel_lttng_userspace_probe_event_ok
()
584 local event_name
="$2"
586 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
587 ok $?
"Disable kernel event $target for session $sess_name"
589 function lttng_enable_kernel_channel
()
592 local expected_to_fail
=$2
594 local channel_name
=$4
597 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
598 enable-channel
-k $channel_name -s $sess_name $opts
600 if [[ $expected_to_fail -eq "1" ]]; then
603 if [ $withtap -eq "1" ]; then
604 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
607 if [ $withtap -eq "1" ]; then
608 ok
$ret "Enable channel $channel_name for session $sess_name"
613 function lttng_enable_kernel_channel_ok
()
615 lttng_enable_kernel_channel
1 0 "$@"
618 function lttng_enable_kernel_channel_fail
()
620 lttng_enable_kernel_channel
1 1 "$@"
623 function lttng_enable_kernel_channel_notap
()
625 lttng_enable_kernel_channel
0 0 "$@"
628 function enable_kernel_lttng_channel_ok
()
630 lttng_enable_kernel_channel
1 0 "$@"
633 function lttng_disable_kernel_channel
()
635 local expected_to_fail
=$1
637 local channel_name
=$3
639 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
640 disable-channel
-k $channel_name -s $sess_name
642 if [[ $expected_to_fail -eq "1" ]]; then
644 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
646 ok
$ret "Disable channel $channel_name for session $sess_name"
650 function lttng_disable_kernel_channel_ok
()
652 lttng_disable_kernel_channel
0 "$@"
655 function lttng_disable_kernel_channel_fail
()
657 lttng_disable_kernel_channel
1 "$@"
660 function start_lttng_relayd_opt
()
663 local process_mode
=$2
666 DIR
=$
(readlink
-f "$TESTDIR")
668 if [ -z $
(lttng_pgrep
"$RELAYD_MATCH") ]; then
669 # shellcheck disable=SC2086
670 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
671 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $process_mode $opt -vvv >>/tmp/relayd.log 2>&1 &
672 if [ $?
-eq 1 ]; then
673 if [ $withtap -eq "1" ]; then
674 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
678 if [ $withtap -eq "1" ]; then
679 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
683 pass
"Start lttng-relayd (opt: $opt)"
687 function start_lttng_relayd
()
689 start_lttng_relayd_opt
1 "-b" "$@"
692 function start_lttng_relayd_notap
()
694 start_lttng_relayd_opt
0 "-b" "$@"
697 function stop_lttng_relayd_opt
()
707 if [ -z "$signal" ]; then
712 # Multiply time by 2 to simplify integer arithmetic
713 # Multiply time by 5 to adjust for sleeping every 0.1s
714 if [ -n "$timeout_s" ]; then
715 dtimeleft_s
=$
((timeout_s
* 2 * 5))
719 pids
=$
(lttng_pgrep
"$RELAYD_MATCH")
720 if [ -z "$pids" ]; then
721 if [ "$is_cleanup" -eq 1 ]; then
723 elif [ "$withtap" -eq "1" ]; then
724 fail
"No relay daemon to kill"
726 LTTNG_BAIL_OUT
"No relay daemon to kill"
731 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
733 # shellcheck disable=SC2086
734 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
736 if [ "$withtap" -eq "1" ]; then
737 fail
"Kill relay daemon"
741 while [ -n "$out" ]; do
742 out
=$
(lttng_pgrep
"$RELAYD_MATCH")
743 if [ -n "$dtimeleft_s" ]; then
744 if [ $dtimeleft_s -lt 0 ]; then
748 dtimeleft_s
=$
((dtimeleft_s
- 1))
752 if [ "$withtap" -eq "1" ]; then
753 if [ "$retval" -eq "0" ]; then
754 pass
"Wait after kill relay daemon"
756 fail
"Wait after kill relay daemon"
763 function stop_lttng_relayd
()
765 stop_lttng_relayd_opt
1 0 "$@"
768 function stop_lttng_relayd_notap
()
770 stop_lttng_relayd_opt
0 0 "$@"
773 function stop_lttng_relayd_cleanup
()
775 stop_lttng_relayd_opt
0 1 "$@"
778 #First arg: show tap output
779 #Second argument: load path for automatic loading
780 function start_lttng_sessiond_opt
()
785 # The rest of the arguments will be passed directly to lttng-sessiond.
791 local long_bit_value
=
792 long_bit_value
=$
(getconf LONG_BIT
)
794 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
795 # Env variable requested no session daemon
799 DIR
=$
(readlink
-f "$TESTDIR")
801 # Get long_bit value for 32/64 consumerd
802 case "$long_bit_value" in
804 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
807 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
814 # Check for env. variable. Allow the use of LD_PRELOAD etc.
815 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
816 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
818 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
820 if ! validate_kernel_version
; then
821 fail
"Start session daemon"
822 LTTNG_BAIL_OUT
"*** Kernel too old for session daemon tests ***"
825 diag
"export LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/"
826 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/"}"
827 export LTTNG_SESSION_CONFIG_XSD_PATH
829 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
831 if [ -n "$load_path" ]; then
832 diag
"env $env_vars --load $load_path --background $consumerd $@"
833 # shellcheck disable=SC2086
834 env
$env_vars --load "$load_path" --background "$consumerd" "$@"
836 diag
"env $env_vars --background $consumerd $@"
837 # shellcheck disable=SC2086
838 env
$env_vars --background "$consumerd" "$@"
840 #$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
842 if [ "$withtap" -eq "1" ]; then
843 ok
$status "Start session daemon"
848 function start_lttng_sessiond
()
850 start_lttng_sessiond_opt
1 "$@"
853 function start_lttng_sessiond_notap
()
855 start_lttng_sessiond_opt
0 "$@"
858 function stop_lttng_sessiond_opt
()
869 if [ -z "$signal" ]; then
873 # Multiply time by 2 to simplify integer arithmetic
874 # Multiply time by 5 to adjust for sleeping every 0.1s
875 if [ -n "$timeout_s" ]; then
876 dtimeleft_s
=$
((timeout_s
* 2 * 5))
879 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
880 # Env variable requested no session daemon
884 runas_pids
=$
(lttng_pgrep
"$RUNAS_MATCH")
885 pids
=$
(lttng_pgrep
"$SESSIOND_MATCH")
887 if [ -n "$runas_pids" ]; then
888 pids
="$pids $runas_pids"
891 if [ -z "$pids" ]; then
892 if [ "$is_cleanup" -eq 1 ]; then
894 elif [ "$withtap" -eq "1" ]; then
895 fail
"No session daemon to kill"
897 LTTNG_BAIL_OUT
"No session daemon to kill"
902 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
904 # shellcheck disable=SC2086
905 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
907 if [ "$withtap" -eq "1" ]; then
908 fail
"Kill sessions daemon"
912 while [ -n "$out" ]; do
913 out
=$
(lttng_pgrep
"${SESSIOND_MATCH}")
914 if [ -n "$dtimeleft_s" ]; then
915 if [ $dtimeleft_s -lt 0 ]; then
919 dtimeleft_s
=$
((dtimeleft_s
- 1))
924 while [ -n "$out" ]; do
925 out
=$
(lttng_pgrep
"$CONSUMERD_MATCH")
926 if [ -n "$dtimeleft_s" ]; then
927 if [ $dtimeleft_s -lt 0 ]; then
931 dtimeleft_s
=$
((dtimeleft_s
- 1))
936 if [ "$withtap" -eq "1" ]; then
937 if [ "$retval" -eq "0" ]; then
938 pass
"Wait after kill session daemon"
940 fail
"Wait after kill session daemon"
944 if [ "$signal" = "SIGKILL" ]; then
945 if [ "$(id -u)" -eq "0" ]; then
947 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
949 if [ -n "$modules" ]; then
950 diag
"Unloading all LTTng modules"
951 modprobe
--remove "$modules"
959 function stop_lttng_sessiond
()
961 stop_lttng_sessiond_opt
1 0 "$@"
964 function stop_lttng_sessiond_notap
()
966 stop_lttng_sessiond_opt
0 0 "$@"
969 function stop_lttng_sessiond_cleanup
()
971 stop_lttng_sessiond_opt
0 1 "$@"
974 function sigstop_lttng_sessiond_opt
()
980 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
981 # Env variable requested no session daemon
985 pids
="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
987 if [ "$withtap" -eq "1" ]; then
988 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
991 # shellcheck disable=SC2086
992 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
993 if [ "$withtap" -eq "1" ]; then
994 fail
"Sending SIGSTOP to session daemon"
998 while [ $out -ne 0 ]; do
999 pids
="$(lttng_pgrep "$SESSIOND_MATCH")"
1001 # Wait until state becomes stopped for session
1004 for sessiond_pid
in $pids; do
1005 state
="$(ps -p "$sessiond_pid" -o state= )"
1006 if [[ -n "$state" && "$state" != "T" ]]; then
1012 if [ "$withtap" -eq "1" ]; then
1013 pass
"Sending SIGSTOP to session daemon"
1018 function sigstop_lttng_sessiond
()
1020 sigstop_lttng_sessiond_opt
1 "$@"
1023 function sigstop_lttng_sessiond_notap
()
1025 sigstop_lttng_sessiond_opt
0 "$@"
1028 function stop_lttng_consumerd_opt
()
1038 if [ -z "$signal" ]; then
1042 # Multiply time by 2 to simplify integer arithmetic
1043 # Multiply time by 5 to adjust for sleeping every 0.1s
1044 if [ -n "$timeout_s" ]; then
1045 dtimeleft_s
=$
((timeout_s
* 2 * 5))
1048 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1050 if [ -z "$pids" ]; then
1051 if [ "$is_cleanup" -eq 1 ]; then
1053 elif [ "$withtap" -eq "1" ]; then
1054 fail
"No consumerd daemon to kill"
1056 LTTNG_BAIL_OUT
"No consumerd daemon to kill"
1061 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1063 # shellcheck disable=SC2086
1064 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
1066 if [ "$withtap" -eq "1" ]; then
1067 fail
"Kill consumer daemon"
1071 while [ $out -ne 0 ]; do
1072 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1074 # If consumerds are still present check their status.
1075 # A zombie status qualifies the consumerd as *killed*
1077 for consumer_pid
in $pids; do
1078 state
="$(ps -p "$consumer_pid" -o state= )"
1079 if [[ -n "$state" && "$state" != "Z" ]]; then
1083 if [ -n "$dtimeleft_s" ]; then
1084 if [ $dtimeleft_s -lt 0 ]; then
1088 dtimeleft_s
=$
((dtimeleft_s
- 1))
1092 if [ "$withtap" -eq "1" ]; then
1093 if [ "$retval" -eq "0" ]; then
1094 pass
"Wait after kill consumer daemon"
1096 fail
"Wait after kill consumer daemon"
1104 function stop_lttng_consumerd
()
1106 stop_lttng_consumerd_opt
1 0 "$@"
1109 function stop_lttng_consumerd_notap
()
1111 stop_lttng_consumerd_opt
0 0 "$@"
1114 function stop_lttng_consumerd_cleanup
()
1116 stop_lttng_consumerd_opt
0 1 "$@"
1119 function sigstop_lttng_consumerd_opt
()
1122 local signal
=SIGSTOP
1125 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1127 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')"
1129 # shellcheck disable=SC2086
1130 kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1133 if [ $retval -eq 1 ]; then
1134 if [ "$withtap" -eq "1" ]; then
1135 fail
"Sending SIGSTOP to consumer daemon"
1140 while [ $out -ne 0 ]; do
1141 pids
="$(lttng_pgrep "$CONSUMERD_MATCH")"
1143 # Wait until state becomes stopped for all
1146 for consumer_pid
in $pids; do
1147 state
="$(ps -p "$consumer_pid" -o state= )"
1148 if [[ -n "$state" && "$state" != "T" ]]; then
1154 if [ "$withtap" -eq "1" ]; then
1155 pass
"Sending SIGSTOP to consumer daemon"
1161 function sigstop_lttng_consumerd
()
1163 sigstop_lttng_consumerd_opt
1 "$@"
1166 function sigstop_lttng_consumerd_notap
()
1168 sigstop_lttng_consumerd_opt
0 "$@"
1171 function list_lttng_with_opts
()
1177 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1180 if [ $withtap -eq "1" ]; then
1181 ok
$ret "Lttng-tool list command with option $opts"
1185 function list_lttng_ok
()
1187 list_lttng_with_opts
1 "$@"
1190 function list_lttng_notap
()
1192 list_lttng_with_opts
0 "$@"
1195 function create_lttng_session_no_output
()
1200 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1201 create
$sess_name --no-output $opts
1202 ok $?
"Create session $sess_name in no-output mode"
1205 function create_lttng_session_uri
() {
1210 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1211 create
$sess_name -U $uri $opts
1212 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
1215 function create_lttng_session
()
1218 local expected_to_fail
=$2
1223 if [ -z "$trace_path" ]; then
1224 # Use lttng-sessiond default output.
1227 trace_path
="-o $trace_path"
1230 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1231 create
"$sess_name" $trace_path $opt
1233 if [ $expected_to_fail -eq "1" ]; then
1236 if [ $withtap -eq "1" ]; then
1237 ok
$ret "Create session $sess_name in $trace_path failed as expected"
1240 if [ $withtap -eq "1" ]; then
1241 ok
$ret "Create session $sess_name in $trace_path"
1247 function create_lttng_session_ok
()
1249 create_lttng_session
1 0 "$@"
1252 function create_lttng_session_fail
()
1254 create_lttng_session
1 1 "$@"
1257 function create_lttng_session_notap
()
1259 create_lttng_session
0 0 "$@"
1263 function enable_ust_lttng_channel
()
1266 local expected_to_fail
=$2
1268 local channel_name
=$4
1271 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1272 enable-channel
-u $channel_name -s $sess_name $opts
1274 if [[ $expected_to_fail -eq "1" ]]; then
1277 if [ $withtap -eq "1" ]; then
1278 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
1281 if [ $withtap -eq "1" ]; then
1282 ok
$ret "Enable channel $channel_name for session $sess_name"
1288 function enable_ust_lttng_channel_ok
()
1290 enable_ust_lttng_channel
1 0 "$@"
1293 function enable_ust_lttng_channel_fail
()
1295 enable_ust_lttng_channel
1 1 "$@"
1298 function enable_ust_lttng_channel_notap
()
1300 enable_ust_lttng_channel
0 0 "$@"
1303 function disable_ust_lttng_channel
()
1306 local channel_name
=$2
1308 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1309 disable-channel
-u $channel_name -s $sess_name
1310 ok $?
"Disable channel $channel_name for session $sess_name"
1313 function enable_lttng_mmap_overwrite_kernel_channel
()
1316 local channel_name
=$2
1318 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1319 enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite
1320 ok $?
"Enable channel $channel_name for session $sess_name"
1323 function enable_lttng_mmap_discard_small_kernel_channel
()
1326 local channel_name
=$2
1328 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1329 enable-channel
-s $sess_name $channel_name -k --output mmap
--discard --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2
1330 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1333 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1336 local channel_name
=$2
1338 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1339 enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2
1340 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1343 function enable_lttng_mmap_overwrite_ust_channel
()
1346 local channel_name
=$2
1348 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1349 enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite
1350 ok $?
"Enable channel $channel_name for session $sess_name"
1353 function enable_ust_lttng_event
()
1356 local expected_to_fail
=$2
1358 local event_name
="$4"
1359 local channel_name
=$5
1361 if [ -z $channel_name ]; then
1362 # default channel if none specified
1365 chan
="-c $channel_name"
1368 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1369 enable-event
"$event_name" $chan -s "$sess_name" -u
1371 if [[ $expected_to_fail -eq "1" ]]; then
1374 if [[ $withtap -eq "1" ]]; then
1375 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1378 if [[ $withtap -eq "1" ]]; then
1379 ok
$ret "Enable ust event $event_name for session $sess_name"
1385 function enable_ust_lttng_event_ok
()
1387 enable_ust_lttng_event
1 0 "$@"
1390 function enable_ust_lttng_event_fail
()
1392 enable_ust_lttng_event
1 1 "$@"
1395 function enable_ust_lttng_event_notap
()
1397 enable_ust_lttng_event
0 0 "$@"
1400 function enable_jul_lttng_event
()
1406 if [ -z $channel_name ]; then
1407 # default channel if none specified
1410 chan
="-c $channel_name"
1413 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1414 enable-event
"$event_name" $chan -s $sess_name -j
1415 ok $?
"Enable JUL event $event_name for session $sess_name"
1418 function enable_jul_lttng_event_loglevel
()
1421 local event_name
="$2"
1423 local channel_name
=$4
1425 if [ -z $channel_name ]; then
1426 # default channel if none specified
1429 chan
="-c $channel_name"
1432 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1433 enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j
1434 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1437 function enable_log4j_lttng_event
()
1441 local channel_name
=$3
1445 # default channel if none specified
1446 if [ -n "$channel_name" ]; then
1447 chan_opt
=("-c" "$channel_name")
1450 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1451 enable-event
"$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1452 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name'"
1455 function enable_log4j_lttng_event_filter
()
1461 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1462 enable-event
"$event_name" -s "$sess_name" --log4j --filter "$filter"
1463 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' for session '$sess_name'"
1466 function enable_log4j_lttng_event_filter_loglevel_only
()
1473 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1474 enable-event
--loglevel-only "$loglevel" "$event_name" -s "$sess_name" -l --filter "$filter"
1475 ok $?
"Enable LOG4J event '$event_name' with filter '$filter' and loglevel-only '$loglevel' for session '$sess_name'"
1478 function enable_log4j_lttng_event_loglevel
()
1483 local channel_name
=$4
1486 # default channel if none specified
1487 if [ -n "$channel_name" ]; then
1488 chan_opt
=("-c" "$channel_name")
1491 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1492 enable-event
--loglevel "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1493 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel '$loglevel'"
1496 function enable_log4j_lttng_event_loglevel_only
()
1501 local channel_name
=$4
1505 # default channel if none specified
1506 if [ -n "$channel_name" ]; then
1507 chan_opt
=("-c" "$channel_name")
1510 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1511 enable-event
--loglevel-only "$loglevel" "$event_name" "${chan_opt[@]}" -s "$sess_name" --log4j
1512 ok $?
"Enable LOG4J event '$event_name' for session '$sess_name' with loglevel-only '$loglevel'"
1515 function enable_python_lttng_event
()
1521 if [ -z $channel_name ]; then
1522 # default channel if none specified
1525 chan
="-c $channel_name"
1528 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1529 enable-event
"$event_name" $chan -s $sess_name -p
1530 ok $?
"Enable Python event $event_name for session $sess_name"
1533 function enable_python_lttng_event_loglevel
()
1536 local event_name
="$2"
1538 local channel_name
=$4
1540 if [ -z $channel_name ]; then
1541 # default channel if none specified
1544 chan
="-c $channel_name"
1547 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1548 enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p
1549 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1552 function enable_ust_lttng_event_filter
()
1554 local sess_name
="$1"
1555 local event_name
="$2"
1557 local channel_name
=$4
1559 if [ -z $channel_name ]; then
1560 # default channel if none specified
1563 chan
="-c $channel_name"
1566 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1567 enable-event
$chan "$event_name" -s $sess_name -u --filter "$filter"
1568 ok $?
"Enable event $event_name with filtering for session $sess_name"
1571 function enable_ust_lttng_event_loglevel
()
1573 local sess_name
="$1"
1574 local event_name
="$2"
1576 local channel_name
="$4"
1578 if [ -n "${channel_name}" ] ; then
1579 chan
=('-c' "${channel_name}")
1582 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1583 enable-event
"${chan[@]}" "$event_name" -s "${sess_name}" -u --loglevel="${loglevel}"
1584 ok $?
"Enable event $event_name with loglevel $loglevel"
1587 function enable_ust_lttng_event_loglevel_only
()
1589 local sess_name
="$1"
1590 local event_name
="$2"
1592 local channel_name
="$4"
1594 if [ -n "${channel_name}" ] ; then
1595 chan
=('-c' "${channel_name}")
1598 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1599 enable-event
"${chan[@]}" "$event_name" -s "${sess_name}" -u --loglevel-only "${loglevel}"
1600 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1603 function disable_ust_lttng_event
()
1605 local sess_name
="$1"
1606 local event_name
="$2"
1607 local channel_name
="$3"
1609 if [ -z $channel_name ]; then
1610 # default channel if none specified
1613 chan
="-c $channel_name"
1616 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1617 disable-event
"$event_name" -s $sess_name $chan -u
1618 ok $?
"Disable event $event_name for session $sess_name"
1621 function disable_jul_lttng_event
()
1623 local sess_name
="$1"
1624 local event_name
="$2"
1626 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1627 ok $?
"Disable JUL event $event_name for session $sess_name"
1630 function disable_log4j_lttng_event
()
1632 local sess_name
="$1"
1633 local event_name
="$2"
1635 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1636 disable-event
"$event_name" -s "$sess_name" --log4j
1637 ok $?
"Disable LOG4J event '$event_name' for session '$sess_name'"
1640 function disable_python_lttng_event
()
1642 local sess_name
="$1"
1643 local event_name
="$2"
1645 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1646 disable-event
"$event_name" -s $sess_name -p
1647 ok $?
"Disable Python event $event_name for session $sess_name"
1650 function start_lttng_tracing_opt
()
1653 local expected_to_fail
=$2
1656 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1659 if [[ $expected_to_fail -eq "1" ]]; then
1662 if [ $withtap -eq "1" ]; then
1663 ok $?
"Start tracing for session $sess_name failed as expected"
1666 if [ $withtap -eq "1" ]; then
1667 ok
$ret "Start tracing for session $sess_name"
1672 function start_lttng_tracing_ok
()
1674 start_lttng_tracing_opt
1 0 "$@"
1677 function start_lttng_tracing_fail
()
1679 start_lttng_tracing_opt
1 1 "$@"
1682 function start_lttng_tracing_notap
()
1684 start_lttng_tracing_opt
0 1 "$@"
1687 function stop_lttng_tracing_opt
()
1690 local expected_to_fail
=$2
1693 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1696 if [[ $expected_to_fail -eq "1" ]]; then
1699 if [ $withtap -eq "1" ]; then
1700 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1703 if [ $withtap -eq "1" ]; then
1704 ok
$ret "Stop lttng tracing for session $sess_name"
1709 function stop_lttng_tracing_ok
()
1711 stop_lttng_tracing_opt
1 0 "$@"
1714 function stop_lttng_tracing_fail
()
1716 stop_lttng_tracing_opt
1 1 "$@"
1719 function stop_lttng_tracing_notap
()
1721 stop_lttng_tracing_opt
0 0 "$@"
1724 function destroy_lttng_session
()
1727 local expected_to_fail
=$2
1731 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1732 destroy
$sess_name $@
1734 if [[ $expected_to_fail -eq "1" ]]; then
1737 if [ $withtap -eq "1" ]; then
1738 ok
$ret "Destroy session $sess_name failed as expected"
1741 if [ $withtap -eq "1" ]; then
1742 ok
$ret "Destroy session $sess_name"
1747 function destroy_lttng_session_ok
()
1749 destroy_lttng_session
1 0 "$@"
1753 function destroy_lttng_session_fail
()
1755 destroy_lttng_session
1 1 "$@"
1758 function destroy_lttng_session_notap
()
1760 destroy_lttng_session
0 0 "$@"
1763 function destroy_lttng_sessions
()
1765 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1767 ok $?
"Destroy all lttng sessions"
1770 function lttng_snapshot_add_output
()
1772 local expected_to_fail
=$1
1777 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1778 snapshot add-output
-s $sess_name $trace_path $opts
1780 if [[ $expected_to_fail -eq 1 ]]; then
1782 ok $?
"Added snapshot output $trace_path failed as expected"
1784 ok
$ret "Added snapshot output $trace_path"
1788 function lttng_snapshot_add_output_ok
()
1790 lttng_snapshot_add_output
0 "$@"
1793 function lttng_snapshot_add_output_fail
()
1795 lttng_snapshot_add_output
1 "$@"
1798 function lttng_snapshot_del_output
()
1800 local expected_to_fail
=$1
1804 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1805 snapshot del-output
-s $sess_name $id
1807 if [[ $expected_to_fail -eq "1" ]]; then
1809 ok $?
"Deleted snapshot output id $id failed as expected"
1811 ok
$ret "Deleted snapshot output id $id"
1815 function lttng_snapshot_del_output_ok
()
1817 lttng_snapshot_del_output
0 "$@"
1820 function lttng_snapshot_del_output_fail
()
1822 lttng_snapshot_del_output
1 "$@"
1825 function lttng_snapshot_record
()
1830 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1831 snapshot record
-s "$sess_name" "$trace_path"
1832 ok $?
"Snapshot recorded"
1835 function lttng_snapshot_list
()
1838 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1839 snapshot list-output
-s $sess_name
1840 ok $?
"Snapshot list"
1843 function lttng_save
()
1848 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1849 save
$sess_name $opts
1850 ok $?
"Session saved"
1853 function lttng_load
()
1855 local expected_to_fail
=$1
1858 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1861 if [[ $expected_to_fail -eq "1" ]]; then
1863 ok $?
"Load command failed as expected with opts: $opts"
1865 ok
$ret "Load command with opts: $opts"
1869 function lttng_load_ok
()
1874 function lttng_load_fail
()
1879 function lttng_track
()
1881 local expected_to_fail
="$1"
1884 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1886 if [[ $expected_to_fail -eq "1" ]]; then
1888 ok $?
"Track command failed as expected with opts: $opts"
1890 ok
$ret "Track command with opts: $opts"
1894 function lttng_track_ok
()
1899 function lttng_track_fail
()
1904 function lttng_untrack
()
1906 local expected_to_fail
="$1"
1909 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1911 if [[ $expected_to_fail -eq "1" ]]; then
1913 ok $?
"Untrack command failed as expected with opts: $opts"
1915 ok
$ret "Untrack command with opts: $opts"
1919 function lttng_untrack_ok
()
1921 lttng_untrack
0 "$@"
1924 function lttng_untrack_fail
()
1926 lttng_untrack
1 "$@"
1929 function lttng_track_pid_ok
()
1932 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1933 ok $?
"Lttng track pid on the kernel domain"
1936 function lttng_untrack_kernel_all_ok
()
1938 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1939 ok $?
"Lttng untrack all pid on the kernel domain"
1942 function lttng_track_ust_ok
()
1944 lttng_track_ok
-u "$@"
1947 function lttng_track_ust_fail
()
1949 lttng_track_fail
-u "$@"
1952 function lttng_track_kernel_ok
()
1954 lttng_track_ok
-k "$@"
1957 function lttng_track_kernel_fail
()
1959 lttng_track_fail
-k "$@"
1962 function lttng_untrack_ust_ok
()
1964 lttng_untrack_ok
-u "$@"
1967 function lttng_untrack_ust_fail
()
1969 lttng_untrack_fail
-u "$@"
1972 function lttng_untrack_kernel_ok
()
1974 lttng_untrack_ok
-k "$@"
1977 function lttng_untrack_kernel_fail
()
1979 lttng_untrack_fail
-k "$@"
1982 function lttng_add_context_list
()
1984 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1987 ok
$ret "Context listing"
1990 function add_context_lttng
()
1992 local expected_to_fail
="$1"
1994 local session_name
="$3"
1995 local channel_name
="$4"
1998 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
1999 add-context
-s $session_name -c $channel_name -t $type $domain
2001 if [[ $expected_to_fail -eq "1" ]]; then
2003 ok $?
"Add context command failed as expected for type: $type"
2005 ok
$ret "Add context command for type: $type"
2009 function add_context_ust_ok
()
2011 add_context_lttng
0 -u "$@"
2014 function add_context_ust_fail
()
2016 add_context_lttng
1 -u "$@"
2019 function add_context_kernel_ok
()
2021 add_context_lttng
0 -k "$@"
2024 function add_context_kernel_fail
()
2026 add_context_lttng
1 -k "$@"
2029 function wait_live_trace_ready
()
2032 local zero_client_match
=0
2034 diag
"Waiting for live trace at url: $url"
2035 while [ $zero_client_match -eq 0 ]; do
2036 zero_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "0 client(s) connected" |
wc -l)
2039 pass
"Waiting for live trace at url: $url"
2042 function wait_live_viewer_connect
()
2045 local one_client_match
=0
2047 diag
"Waiting for live viewers on url: $url"
2048 while [ $one_client_match -eq 0 ]; do
2049 one_client_match
=$
($BABELTRACE_BIN -i lttng-live
$url |
grep "1 client(s) connected" |
wc -l)
2052 pass
"Waiting for live viewers on url: $url"
2055 function bail_out_if_no_babeltrace
()
2057 which "$BABELTRACE_BIN" >/dev
/null
2058 if [ $?
-ne 0 ]; then
2059 LTTNG_BAIL_OUT
"\"$BABELTRACE_BIN\" binary not found. Skipping tests"
2063 # Check that the trace metadata contains '$expected' event ids matching '$event_name'.
2064 function validate_metadata_event
()
2074 metadata_file
=$
(find "$trace_path" -name "metadata")
2075 metadata_path
=$
(dirname "$metadata_file")
2077 bail_out_if_no_babeltrace
2079 count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
"$metadata_path" |
grep -c "$event_name")
2081 test "$count" -eq "$expected"
2082 ok $?
"Found $count / $expected metadata event id matching '$event_name'"
2085 # Check that the trace contains '$expected' events matching '$event_name', other
2086 # events not matching '$event_name' can be present.
2087 function trace_matches
()
2096 bail_out_if_no_babeltrace
2098 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2099 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2101 test "$count" -eq "$expected"
2103 ok $?
"Found $count / $expected events matching '$event_name' out of $total events"
2106 # Check that the trace contains '$expected' events matching '$event_name' and no
2108 function trace_match_only
()
2117 bail_out_if_no_babeltrace
2119 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2120 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2122 test "$expected" -eq "$count" && test "$total" -eq "$expected"
2124 ok $?
"Found $count / $expected events matching '$event_name' amongst $total events"
2127 # Check that the trace contains at least 1 event matching each name in the
2128 # comma separated list '$event_names'.
2129 function validate_trace
()
2131 local event_names
=$1
2136 bail_out_if_no_babeltrace
2140 for event_name
in $event_names; do
2141 # trace_path is unquoted since callers make use of globbing
2142 count
=$
($BABELTRACE_BIN $trace_path |
grep -c "$event_name")
2144 ok $?
"Found $count events matching '$event_name'"
2149 # Check that the trace contains at least 1 event matching each name in the
2150 # comma separated list '$event_names' and a total of '$expected' events.
2151 function validate_trace_count
()
2153 local event_names
=$1
2160 bail_out_if_no_babeltrace
2164 for event_name
in $event_names; do
2165 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2167 ok $?
"Found '$count' events matching '$event_name'"
2168 total
=$
(( total
+ count
))
2171 test $total -eq "$expected"
2172 ok $?
"Found $total events, expected $expected events"
2175 # Check that the trace contains at least '$expected_min' event matching each
2176 # name in the comma separated list '$event_names' and a total at least
2177 # '$expected_min' and less than '$expected_max' events.
2178 function validate_trace_count_range_incl_min_excl_max
()
2180 local event_names
=$1
2182 local expected_min
=$3
2183 local expected_max
=$4
2188 bail_out_if_no_babeltrace
2192 for event_name
in $event_names; do
2193 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c "$event_name")
2194 test "$count" -ge "$expected_min"
2195 ok $?
"Found $count events matching '$event_name', expected at least $expected_min"
2196 total
=$
(( total
+ count
))
2199 test $total -ge "$expected_min" && test $total -lt "$expected_max"
2200 ok $?
"Found a total of $total events, expected at least $expected_min and less than $expected_max"
2203 function trace_first_line
()
2207 $BABELTRACE_BIN "$trace_path" |
head -n 1
2210 # Check that the trace contains at least 1 event matching the grep extended
2211 # regexp '$event_exp'.
2212 function validate_trace_exp
()
2219 bail_out_if_no_babeltrace
2221 # event_exp is unquoted since it contains multiple grep arguments
2222 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c --extended-regexp $event_exp)
2224 ok $?
"Found $count events matching expression '$event_exp'"
2227 # Check that the trace contains at least 1 event matching the grep extended
2228 # regexp '$event_exp' and zero event not matching it.
2229 function validate_trace_only_exp
()
2237 bail_out_if_no_babeltrace
2239 # event_exp is unquoted since it contains multiple grep arguments
2240 count
=$
($BABELTRACE_BIN "$trace_path" |
grep -c --extended-regexp $event_exp)
2241 total
=$
($BABELTRACE_BIN "$trace_path" |
wc -l)
2243 test "$count" -gt 0 && test "$total" -eq "$count"
2244 ok $?
"Found $count events matching expression '$event_exp' amongst $total events"
2247 # Check that the trace is valid and contains 0 event.
2248 function validate_trace_empty
()
2255 bail_out_if_no_babeltrace
2257 events
=$
($BABELTRACE_BIN "$trace_path")
2259 if [ $ret -ne 0 ]; then
2260 fail
"Failed to parse trace"
2264 count
=$
(echo -n "$events" |
wc -l)
2266 ok $?
"Validate trace is empty, found $count events"
2269 function validate_directory_empty
()
2271 local trace_path
="$1"
2277 # Do not double quote `$trace_path` below as we want wildcards to be
2279 files
="$(ls -A $trace_path)"
2281 if [ $ret -ne 0 ]; then
2282 fail
"Failed to list content of directory \"$trace_path\""
2286 nb_files
="$(echo -n "$files" | wc -l)"
2287 test "$nb_files" -eq 0
2288 ok $?
"Directory \"$trace_path\" is empty"
2291 function validate_trace_session_ust_empty
()
2293 validate_directory_empty
"$1"/ust
2296 function validate_trace_session_kernel_empty
()
2298 validate_trace_empty
"$1"/kernel
2301 function regenerate_metadata
()
2303 local expected_to_fail
=$1
2306 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2307 regenerate metadata
-s $sess_name
2309 if [[ $expected_to_fail -eq "1" ]]; then
2311 ok $?
"Expected fail on regenerate metadata $sess_name"
2313 ok
$ret "Metadata regenerate $sess_name"
2317 function regenerate_metadata_ok
()
2319 regenerate_metadata
0 "$@"
2322 function regenerate_metadata_fail
()
2324 regenerate_metadata
1 "$@"
2327 function regenerate_statedump
()
2329 local expected_to_fail
=$1
2332 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2333 regenerate statedump
-s $sess_name
2335 if [[ $expected_to_fail -eq "1" ]]; then
2337 ok $?
"Expected fail on regenerate statedump $sess_name"
2339 ok
$ret "Statedump regenerate $sess_name"
2343 function regenerate_statedump_ok
()
2345 regenerate_statedump
0 "$@"
2348 function regenerate_statedump_fail
()
2350 regenerate_statedump
1 "$@"
2353 function rotate_session
()
2355 local expected_to_fail
=$1
2358 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2361 if [[ $expected_to_fail -eq "1" ]]; then
2363 ok $?
"Expected fail on rotate session $sess_name"
2365 ok
$ret "Rotate session $sess_name"
2369 function rotate_session_ok
()
2371 rotate_session
0 "$@"
2374 function rotate_session_fail
()
2376 rotate_session
1 "$@"
2379 function destructive_tests_enabled
()
2381 if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then
2388 function lttng_enable_rotation_timer
()
2390 local expected_to_fail
=$1
2394 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2395 enable-rotation
-s $sess_name --timer $period
2397 if [[ $expected_to_fail -eq "1" ]]; then
2399 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
2401 ok
$ret "Set periodic rotation ($period) of session $sess_name"
2405 function lttng_enable_rotation_timer_ok
()
2407 lttng_enable_rotation_timer
0 $@
2410 function lttng_enable_rotation_timer_fail
()
2412 lttng_enable_rotation_timer
1 $@
2415 function lttng_enable_rotation_size
()
2417 local expected_to_fail
=$1
2421 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2422 enable-rotation
-s $sess_name --size $size
2424 if [[ $expected_to_fail -eq "1" ]]; then
2426 ok $?
"Expected to fail to set a periodic rotation of session $sess_name" "every " $size " bytes"
2428 ok
$ret "Set a scheduled rotation of session $sess_name" "every " $size " bytes"
2432 function lttng_enable_rotation_size_ok
()
2434 lttng_enable_rotation_size
0 $@
2437 function lttng_enable_rotation_size_fail
()
2439 lttng_enable_rotation_size
1 $@
2442 function lttng_clear_session
()
2444 local expected_to_fail
=$1
2447 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2450 if [[ $expected_to_fail -eq "1" ]]; then
2452 ok $?
"Expected fail on clear session $sess_name"
2454 ok
$ret "Clear session $sess_name"
2458 function lttng_clear_session_ok
()
2460 lttng_clear_session
0 $@
2463 function lttng_clear_session_fail
()
2465 lttng_clear_session
1 $@
2468 function lttng_clear_all
()
2470 _run_lttng_cmd
"$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \
2472 ok $?
"Clear all lttng sessions"
2475 function lttng_add_trigger
()
2477 local expected_to_fail
="$1"
2478 local trigger_name
="$2"
2482 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}"
2483 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-trigger
--name "$trigger_name" "${args[@]}" 1> /dev
/null
2> /dev
/null
2485 if [[ $expected_to_fail -eq "1" ]]; then
2487 ok $?
"Add trigger $trigger_name failed as expected"
2489 ok
$ret "Add trigger $trigger_name"
2493 function lttng_remove_trigger
()
2495 local expected_to_fail
="$1"
2496 local trigger_name
="$2"
2499 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*"
2500 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger
"$trigger_name" "$@" 1> /dev
/null
2> /dev
/null
2502 if [[ $expected_to_fail -eq "1" ]]; then
2504 ok $?
"Remove trigger $trigger_name failed as expected"
2506 ok
$ret "Remove trigger $trigger_name"
2510 function lttng_add_trigger_ok
()
2512 lttng_add_trigger
0 "$@"
2515 function lttng_add_trigger_fail
()
2517 lttng_add_trigger
1 "$@"
2520 function lttng_remove_trigger_ok
()
2522 lttng_remove_trigger
0 "$@"
2525 function list_triggers_matches_ok
()
2527 local tmp_stdout
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2528 local tmp_stderr
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2530 local test_name
="$1"
2531 local expected_stdout_file
="$2"
2533 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
2535 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers
> "${tmp_stdout}" 2> "${tmp_stderr}"
2536 ok $?
"${test_name}: exit code is 0"
2538 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2539 ok $?
"${test_name}: expected stdout"
2541 diff -u /dev
/null
"${tmp_stderr}"
2542 ok $?
"${test_name}: expected stderr"
2544 rm -f "${tmp_stdout}"
2545 rm -f "${tmp_stderr}"
2548 function list_triggers_matches_mi_ok
()
2551 local tmp_stdout_raw
2554 local test_name
="$1"
2555 local expected_stdout_file
="$2"
2557 tmp_stdout_raw
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2558 tmp_stdout
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
2559 tmp_stderr
=$
(mktemp
-t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
2561 diag
"$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi xml list-triggers"
2563 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" --mi=xml list-triggers
> "${tmp_stdout_raw}" 2> "${tmp_stderr}"
2564 ok $?
"${test_name}: exit code is 0"
2566 # Pretty-fy xml before further test.
2567 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
2569 $MI_VALIDATE "${tmp_stdout}"
2570 ok $?
"list-trigger mi is valid"
2572 diff -u "${expected_stdout_file}" "${tmp_stdout}"
2573 ok $?
"${test_name}: expected stdout"
2575 diff -u /dev
/null
"${tmp_stderr}"
2576 ok $?
"${test_name}: expected stderr"
2578 rm -f "${tmp_stdout}"
2579 rm -f "${tmp_stdout_raw}"
2580 rm -f "${tmp_stderr}"
2583 function validate_path_pattern
()
2587 # Base path is only used in error case and is used to list the content
2596 if [ "$ret" -ne "0" ]; then
2597 diag
"Path pattern expected: $pattern"
2598 # List the tracepath for more info. We use find as a recursive
2600 diag
"The base path content:"
2601 find "$base_path" -print
2605 function validate_trace_path_ust_uid
()
2608 local session_name
=$2
2610 local pattern
="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2612 validate_path_pattern
"UST per-uid trace path is valid" "$pattern" "$trace_path"
2615 function validate_trace_path_ust_uid_network
()
2618 local session_name
=$2
2621 local hostname
=$HOSTNAME
2625 # If the session was given a network base path (e.g
2626 # 127.0.0.1/my/custom/path on creation, there is no session name
2627 # component to the path on the relayd side. Caller can simply not pass a
2628 # session name for this scenario.
2629 if [ -n "$session_name" ]; then
2630 session_name
="$session_name-$date_time_pattern"
2631 if [ -n "$base_path" ]; then
2632 fail
"Session name and base path are mutually exclusive"
2637 pattern
="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2639 validate_path_pattern
"UST per-uid network trace path is valid" "$pattern" "$trace_path"
2642 function validate_trace_path_ust_uid_snapshot_network
()
2645 local session_name
=$2
2646 local snapshot_name
=$3
2647 local snapshot_number
=$4
2649 local hostname
=$HOSTNAME
2654 # If the session/output was given a network base path (e.g
2655 # 127.0.0.1/my/custom/path on creation, there is no session name
2656 # component to the path on the relayd side. Caller can simply not pass a
2657 # session name for this scenario.
2658 if [ -n "$session_name" ]; then
2659 session_name
="$session_name-$date_time_pattern"
2660 if [ -n "$base_path" ]; then
2661 fail
"Session name and base path are mutually exclusive"
2666 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2668 validate_path_pattern
"UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
2671 function validate_trace_path_ust_uid_snapshot
()
2674 local session_name
=$2
2675 local snapshot_name
=$3
2676 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/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
2696 validate_path_pattern
"UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
2699 function validate_trace_path_ust_pid
()
2702 local session_name
=$2
2708 # If the session was given a trace path on creation, there is no session
2709 # name component to the path. Caller can simply not pass a session name
2710 # for this scenario.
2711 if [ -n "$session_name" ]; then
2712 session_name
="$session_name-$date_time_pattern"
2715 pattern
="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
2717 validate_path_pattern
"UST per-pid trace path is valid" "$pattern" "$trace_path"
2720 function validate_trace_path_kernel
()
2723 local session_name
=$2
2726 # If the session was given a trace path on creation, there is no session
2727 # name component to the path. Caller can simply not pass a session name
2728 # for this scenario.
2729 if [ -n "$session_name" ]; then
2730 session_name
="$session_name-$date_time_pattern"
2733 pattern
="$trace_path/$session_name/kernel/metadata"
2735 validate_path_pattern
"Kernel trace path is valid" "$pattern" "$trace_path"
2738 function validate_trace_path_kernel_network
()
2741 local session_name
=$2
2742 local hostname
=$HOSTNAME
2743 local pattern
="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
2745 validate_path_pattern
"Kernel network trace path is valid" "$pattern" "$trace_path"
2748 function validate_trace_path_kernel_snapshot
()
2751 local session_name
=$2
2752 local snapshot_name
=$3
2753 local snapshot_number
=$4
2758 # If the session/output was given a network base path (e.g
2759 # 127.0.0.1/my/custom/path on creation, there is no session name
2760 # component to the path on the relayd side. Caller can simply not pass a
2761 # session name for this scenario.
2762 if [ -n "$session_name" ]; then
2763 session_name
="$session_name-$date_time_pattern"
2764 if [ -n "$base_path" ]; then
2765 fail
"Session name and base path are mutually exclusive"
2770 pattern
="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2772 validate_path_pattern
"Kernel snapshot trace path is valid" "$pattern" "$trace_path"
2775 function validate_trace_path_kernel_snapshot_network
()
2778 local session_name
=$2
2779 local snapshot_name
=$3
2780 local snapshot_number
=$4
2782 local hostname
=$HOSTNAME
2786 # If the session/output was given a network base path (e.g
2787 # 127.0.0.1/my/custom/path on creation, there is no session name
2788 # component to the path on the relayd side. Caller can simply not pass a
2789 # session name for this scenario.
2790 if [ -n "$session_name" ]; then
2791 session_name
="$session_name-$date_time_pattern"
2792 if [ -n "$base_path" ]; then
2793 fail
"Session name and base path are mutually exclusive"
2798 pattern
="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
2800 validate_path_pattern
"Kernel network snapshot trace path is valid" "$pattern" "$trace_path"