1 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
3 # This library is free software; you can redistribute it and/or modify it under
4 # the terms of the GNU Lesser General Public License as published by the Free
5 # Software Foundation; version 2.1 of the License.
7 # This library is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 # You should have received a copy of the GNU Lesser General Public License
13 # along with this library; if not, write to the Free Software Foundation, Inc.,
14 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 SESSIOND_BIN
="lttng-sessiond"
17 SESSIOND_MATCH
=".*lttng-sess.*"
18 RUNAS_BIN
="lttng-runas"
19 RUNAS_MATCH
=".*lttng-runas.*"
20 CONSUMERD_BIN
="lttng-consumerd"
21 CONSUMERD_MATCH
=".*lttng-consumerd.*"
22 RELAYD_BIN
="lttng-relayd"
23 RELAYD_MATCH
=".*lttng-relayd.*"
25 BABELTRACE_BIN
="babeltrace"
27 ERROR_OUTPUT_DEST
=/dev
/null
29 # Minimal kernel version supported for session daemon tests
30 KERNEL_MAJOR_VERSION
=2
31 KERNEL_MINOR_VERSION
=6
32 KERNEL_PATCHLEVEL_VERSION
=27
34 # We set the default UST register timeout and network and app socket timeout to
35 # "wait forever", so that basic tests don't have to worry about hitting
36 # timeouts on busy systems. Specialized tests should test those corner-cases.
37 export LTTNG_UST_REGISTER_TIMEOUT
=-1
38 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
39 export LTTNG_APP_SOCKET_TIMEOUT
=-1
41 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
42 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
43 # its own sessiond if none is running. It also ensures that 'lttng create'
44 # fails when no sessiond is running.
45 export LTTNG_SESSIOND_PATH
="/bin/true"
47 source $TESTDIR/utils
/tap
/tap.sh
49 if [ -z $LTTNG_TEST_TEARDOWN_TIMEOUT ]; then
50 LTTNG_TEST_TEARDOWN_TIMEOUT
=60
53 function full_cleanup
()
55 # Try to kill daemons gracefully
56 stop_lttng_relayd_notap SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
57 stop_lttng_sessiond_notap SIGTERM
$LTTNG_TEST_TEARDOWN_TIMEOUT
59 # If daemons are still present, forcibly kill them
60 stop_lttng_relayd_notap SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
61 stop_lttng_sessiond_notap SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
62 stop_lttng_consumerd_notap SIGKILL
$LTTNG_TEST_TEARDOWN_TIMEOUT
64 # Disable trap for SIGTERM since the following kill to the
65 # pidgroup will be SIGTERM. Otherwise it loops.
66 # The '-' before the pid number ($$) indicates 'kill' to signal the
67 # whole process group.
68 trap - SIGTERM
&& kill -- -$$
72 function null_pipes
()
79 trap full_cleanup SIGINT SIGTERM
81 # perl prove closes its child pipes before giving it a chance to run its
82 # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
83 # to allow those trap handlers to proceed.
85 trap null_pipes SIGPIPE
89 # Check if we are a terminal
91 echo -e "\e[1;32mOK\e[0m"
97 function print_fail
()
99 # Check if we are a terminal
101 echo -e "\e[1;31mFAIL\e[0m"
107 function print_test_banner
()
113 function validate_kernel_version
()
115 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
116 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
119 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
122 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
128 # Generate a random string
129 # $1 = number of characters; defaults to 16
130 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
131 function randstring
()
133 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
134 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
138 # Return the number of _configured_ CPUs.
139 function conf_proc_count
()
141 getconf _NPROCESSORS_CONF
142 if [ $?
-ne 0 ]; then
143 diag
"Failed to get the number of configured CPUs"
148 # Check if base lttng-modules are present.
149 # Bail out on failure
150 function validate_lttng_modules_present
()
152 modprobe
-n lttng-tracer
2>/dev
/null
153 if [ $?
-ne 0 ]; then
154 BAIL_OUT
"LTTng modules not detected."
158 function enable_kernel_lttng_event
161 local expected_to_fail
="$2"
163 local event_name
="$4"
164 local channel_name
="$5"
166 if [ -z "$event_name" ]; then
167 # Enable all event if no event name specified
171 if [ -z "$channel_name" ]; then
172 # default channel if none specified
175 chan
="-c $channel_name"
178 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
180 if [[ $expected_to_fail -eq "1" ]]; then
183 if [ $withtap -eq "1" ]; then
184 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
187 if [ $withtap -eq "1" ]; then
188 ok
$ret "Enable kernel event $event_name for session $sess_name"
193 function enable_kernel_lttng_event_ok
()
195 enable_kernel_lttng_event
1 0 "$@"
198 function enable_kernel_lttng_event_fail
()
200 enable_kernel_lttng_event
1 1 "$@"
203 function enable_kernel_lttng_event_notap
()
205 enable_kernel_lttng_event
0 0 "$@"
209 function lttng_enable_kernel_event
211 enable_kernel_lttng_event_ok
"$@"
214 function lttng_enable_kernel_syscall
()
216 local expected_to_fail
=$1
218 local syscall_name
=$3
219 local channel_name
=$4
221 if [ -z $syscall_name ]; then
222 # Enable all event if no syscall name specified
226 if [ -z $channel_name ]; then
227 # default channel if none specified
230 chan
="-c $channel_name"
233 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
235 if [[ $expected_to_fail -eq "1" ]]; then
237 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
239 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
243 function lttng_enable_kernel_syscall_ok
()
245 lttng_enable_kernel_syscall
0 "$@"
248 function lttng_enable_kernel_syscall_fail
()
250 lttng_enable_kernel_syscall
1 "$@"
253 function lttng_disable_kernel_syscall
()
255 local expected_to_fail
=$1
257 local syscall_name
=$3
258 local channel_name
=$4
260 if [ -z $syscall_name ]; then
261 # Enable all event if no syscall name specified
265 if [ -z $channel_name ]; then
266 # default channel if none specified
269 chan
="-c $channel_name"
272 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
275 if [[ $expected_to_fail -eq "1" ]]; then
277 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
279 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
283 function lttng_disable_kernel_syscall_ok
()
285 lttng_disable_kernel_syscall
0 "$@"
288 function lttng_disable_kernel_syscall_fail
()
290 lttng_disable_kernel_syscall
1 "$@"
293 function lttng_enable_kernel_userspace_probe_event
()
295 local expected_to_fail
="$1"
298 local event_name
="$4"
300 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event
--kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
302 if [[ $expected_to_fail -eq "1" ]]; then
304 ok $?
"Enable kernel userspace probe event for session $sess_name failed as expected"
306 ok
$ret "Enable kernel userspace probe event for session $sess_name"
310 function lttng_enable_kernel_userspace_probe_event_fail
()
312 lttng_enable_kernel_userspace_probe_event
1 "$@"
315 function lttng_enable_kernel_userspace_probe_event_ok
()
317 lttng_enable_kernel_userspace_probe_event
0 "$@"
320 function disable_kernel_lttng_userspace_probe_event_ok
()
323 local event_name
="$2"
325 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event
--kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
326 ok $?
"Disable kernel event $target for session $sess_name"
328 function lttng_enable_kernel_channel
()
331 local expected_to_fail
=$2
333 local channel_name
=$4
336 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
338 if [[ $expected_to_fail -eq "1" ]]; then
341 if [ $withtap -eq "1" ]; then
342 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
345 if [ $withtap -eq "1" ]; then
346 ok
$ret "Enable channel $channel_name for session $sess_name"
351 function lttng_enable_kernel_channel_ok
()
353 lttng_enable_kernel_channel
1 0 "$@"
356 function lttng_enable_kernel_channel_fail
()
358 lttng_enable_kernel_channel
1 1 "$@"
361 function lttng_enable_kernel_channel_notap
()
363 lttng_enable_kernel_channel
0 0 "$@"
366 function enable_kernel_lttng_channel_ok
()
368 lttng_enable_kernel_channel
1 0 "$@"
371 function lttng_disable_kernel_channel
()
373 local expected_to_fail
=$1
375 local channel_name
=$3
377 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
379 if [[ $expected_to_fail -eq "1" ]]; then
381 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
383 ok
$ret "Disable channel $channel_name for session $sess_name"
387 function lttng_disable_kernel_channel_ok
()
389 lttng_disable_kernel_channel
0 "$@"
392 function lttng_disable_kernel_channel_fail
()
394 lttng_disable_kernel_channel
1 "$@"
397 function start_lttng_relayd_opt
()
402 DIR
=$
(readlink
-f "$TESTDIR")
404 if [ -z "$(pgrep "$RELAYD_MATCH")" ]; then
405 # shellcheck disable=SC2086
406 "$DIR/../src/bin/lttng-relayd/$RELAYD_BIN" -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
407 #"$DIR/../src/bin/lttng-relayd/$RELAYD_BIN" $opt -vvv >>/tmp/relayd.log 2>&1 &
408 if [ $?
-eq 1 ]; then
409 if [ "$withtap" -eq "1" ]; then
410 fail
"Start lttng-relayd (opt: $opt)"
414 if [ "$withtap" -eq "1" ]; then
415 pass
"Start lttng-relayd (opt: $opt)"
419 pass
"Start lttng-relayd (opt: $opt)"
423 function start_lttng_relayd
()
425 start_lttng_relayd_opt
1 "$@"
428 function start_lttng_relayd_notap
()
430 start_lttng_relayd_opt
0 "$@"
433 function stop_lttng_relayd_opt
()
438 if [ -z "$signal" ]; then
445 # Multiply time by 2 to simplify integer arithmetic
446 if [ -n "$timeout_s" ]; then
447 dtimeleft_s
=$
((timeout_s
* 2))
453 pids
=$
(pgrep
"$RELAYD_MATCH")
454 if [ -z "$pids" ]; then
455 if [ "$withtap" -eq "1" ]; then
456 pass
"No relay daemon to kill"
461 diag
"Killing (signal $signal) lttng-relayd (pid: $pids)"
463 # shellcheck disable=SC2086
464 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
466 if [ "$withtap" -eq "1" ]; then
467 fail
"Kill relay daemon"
471 while [ -n "$out" ]; do
472 out
=$
(pgrep
"$RELAYD_MATCH")
473 if [ -n "$dtimeleft_s" ]; then
474 if [ $dtimeleft_s -lt 0 ]; then
478 dtimeleft_s
=$
((dtimeleft_s
- 1))
482 if [ "$withtap" -eq "1" ]; then
483 if [ "$retval" -eq "0" ]; then
484 pass
"Wait after kill relay daemon"
486 fail
"Wait after kill relay daemon"
493 function stop_lttng_relayd
()
495 stop_lttng_relayd_opt
1 "$@"
498 function stop_lttng_relayd_notap
()
500 stop_lttng_relayd_opt
0 "$@"
503 #First arg: show tap output
504 #Second argument: load path for automatic loading
505 function start_lttng_sessiond_opt
()
513 local long_bit_value
=
514 long_bit_value
=$
(getconf LONG_BIT
)
516 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
517 # Env variable requested no session daemon
521 DIR
=$
(readlink
-f "$TESTDIR")
523 # Get long_bit value for 32/64 consumerd
524 case "$long_bit_value" in
526 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
529 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
536 # Check for env. variable. Allow the use of LD_PRELOAD etc.
537 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
538 env_vars
="${LTTNG_SESSIOND_ENV_VARS} "
540 env_vars
="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
542 if ! validate_kernel_version
; then
543 fail
"Start session daemon"
544 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
547 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
548 export LTTNG_SESSION_CONFIG_XSD_PATH
550 if [ -z "$(pgrep "${SESSIOND_MATCH}")" ]; then
552 if [ -n "$load_path" ]; then
553 # shellcheck disable=SC2086
554 env
$env_vars --load "$load_path" --background "$consumerd"
556 # shellcheck disable=SC2086
557 env
$env_vars --background "$consumerd"
559 #$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
561 if [ "$withtap" -eq "1" ]; then
562 ok
$status "Start session daemon"
567 function start_lttng_sessiond
()
569 start_lttng_sessiond_opt
1 "$@"
572 function start_lttng_sessiond_notap
()
574 start_lttng_sessiond_opt
0 "$@"
577 function stop_lttng_sessiond_opt
()
582 if [ -z "$signal" ]; then
589 # Multiply time by 2 to simplify integer arithmetic
590 if [ -n "$timeout_s" ]; then
591 dtimeleft_s
=$
((timeout_s
* 2))
594 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
595 # Env variable requested no session daemon
602 runas_pids
=$
(pgrep
"$RUNAS_MATCH")
605 pids
=$
(pgrep
"$SESSIOND_MATCH")
607 if [ -n "$runas_pids" ]; then
608 pids
="$pids $runas_pids"
611 if [ -z "$pids" ]; then
612 if [ "$withtap" -eq "1" ]; then
613 pass
"No session daemon to kill"
618 diag
"Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
620 # shellcheck disable=SC2086
621 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
623 if [ "$withtap" -eq "1" ]; then
624 fail
"Kill sessions daemon"
628 while [ -n "$out" ]; do
629 out
=$
(pgrep
"${SESSIOND_MATCH}")
630 if [ -n "$dtimeleft_s" ]; then
631 if [ $dtimeleft_s -lt 0 ]; then
635 dtimeleft_s
=$
((dtimeleft_s
- 1))
640 while [ -n "$out" ]; do
641 out
=$
(pgrep
"$CONSUMERD_MATCH")
642 if [ -n "$dtimeleft_s" ]; then
643 if [ $dtimeleft_s -lt 0 ]; then
647 dtimeleft_s
=$
((dtimeleft_s
- 1))
652 if [ "$withtap" -eq "1" ]; then
653 if [ "$retval" -eq "0" ]; then
654 pass
"Wait after kill session daemon"
656 fail
"Wait after kill session daemon"
660 if [ "$signal" = "SIGKILL" ]; then
661 if [ "$(id -u)" -eq "0" ]; then
663 modules
="$(lsmod | grep ^lttng | awk '{print $1}')"
665 if [ -n "$modules" ]; then
666 diag
"Unloading all LTTng modules"
667 modprobe
-r "$modules"
675 function stop_lttng_sessiond
()
677 stop_lttng_sessiond_opt
1 "$@"
680 function stop_lttng_sessiond_notap
()
682 stop_lttng_sessiond_opt
0 "$@"
685 function sigstop_lttng_sessiond_opt
()
690 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
691 # Env variable requested no session daemon
695 PID_SESSIOND
="$(pgrep "${SESSIOND_MATCH}") $(pgrep "$RUNAS_MATCH")"
697 if [ "$withtap" -eq "1" ]; then
698 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$PID_SESSIOND" | tr '\n' ' ')"
701 # shellcheck disable=SC2086
702 if ! kill -s $signal $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
703 if [ "$withtap" -eq "1" ]; then
704 fail
"Sending SIGSTOP to session daemon"
708 while [ $out -ne 0 ]; do
709 pid
="$(pgrep "$SESSIOND_MATCH")"
711 # Wait until state becomes stopped for session
714 for sessiond_pid
in $pid; do
715 state
="$(ps -p "$sessiond_pid" -o state= )"
716 if [[ -n "$state" && "$state" != "T" ]]; then
722 if [ "$withtap" -eq "1" ]; then
723 pass
"Sending SIGSTOP to session daemon"
728 function sigstop_lttng_sessiond
()
730 sigstop_lttng_sessiond_opt
1 "$@"
733 function sigstop_lttng_sessiond_notap
()
735 sigstop_lttng_sessiond_opt
0 "$@"
738 function stop_lttng_consumerd_opt
()
743 if [ -z "$signal" ]; then
750 # Multiply time by 2 to simplify integer arithmetic
751 if [ -n "$timeout_s" ]; then
752 dtimeleft_s
=$
((timeout_s
* 2))
757 PID_CONSUMERD
="$(pgrep "$CONSUMERD_MATCH")"
759 if [ -z "$PID_CONSUMERD" ]; then
760 if [ "$withtap" -eq "1" ]; then
761 pass
"No consumer daemon to kill"
766 diag
"Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
768 # shellcheck disable=SC2086
769 if ! kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
771 if [ "$withtap" -eq "1" ]; then
772 fail
"Kill consumer daemon"
776 while [ $out -ne 0 ]; do
777 pid
="$(pgrep "$CONSUMERD_MATCH")"
779 # If consumerds are still present check their status.
780 # A zombie status qualifies the consumerd as *killed*
782 for consumer_pid
in $pid; do
783 state
="$(ps -p "$consumer_pid" -o state= )"
784 if [[ -n "$state" && "$state" != "Z" ]]; then
788 if [ -n "$dtimeleft_s" ]; then
789 if [ $dtimeleft_s -lt 0 ]; then
793 dtimeleft_s
=$
((dtimeleft_s
- 1))
797 if [ "$withtap" -eq "1" ]; then
798 if [ "$retval" -eq "0" ]; then
799 pass
"Wait after kill consumer daemon"
801 fail
"Wait after kill consumer daemon"
809 function stop_lttng_consumerd
()
811 stop_lttng_consumerd_opt
1 "$@"
814 function stop_lttng_consumerd_notap
()
816 stop_lttng_consumerd_opt
0 "$@"
819 function sigstop_lttng_consumerd_opt
()
824 PID_CONSUMERD
="$(pgrep "$CONSUMERD_MATCH")"
826 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
828 # shellcheck disable=SC2086
829 kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
832 if [ $retval -eq 1 ]; then
833 if [ "$withtap" -eq "1" ]; then
834 fail
"Sending SIGSTOP to consumer daemon"
839 while [ $out -ne 0 ]; do
840 pid
="$(pgrep "$CONSUMERD_MATCH")"
842 # Wait until state becomes stopped for all
845 for consumer_pid
in $pid; do
846 state
="$(ps -p "$consumer_pid" -o state= )"
847 if [[ -n "$state" && "$state" != "T" ]]; then
853 if [ "$withtap" -eq "1" ]; then
854 pass
"Sending SIGSTOP to consumer daemon"
860 function sigstop_lttng_consumerd
()
862 sigstop_lttng_consumerd_opt
1 "$@"
865 function sigstop_lttng_consumerd_notap
()
867 sigstop_lttng_consumerd_opt
0 "$@"
870 function list_lttng_with_opts
()
873 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
874 ok $?
"Lttng-tool list command with option $opts"
877 function create_lttng_session_no_output
()
882 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
883 ok $?
"Create session $sess_name in no-output mode"
886 function create_lttng_session_uri
() {
891 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
892 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
895 function create_lttng_session
()
898 local expected_to_fail
=$2
903 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
905 if [ $expected_to_fail -eq "1" ]; then
908 if [ $withtap -eq "1" ]; then
909 ok
$ret "Create session $sess_name in $trace_path failed as expected"
912 if [ $withtap -eq "1" ]; then
913 ok
$ret "Create session $sess_name in $trace_path"
919 function create_lttng_session_ok
()
921 create_lttng_session
1 0 "$@"
924 function create_lttng_session_fail
()
926 create_lttng_session
1 1 "$@"
929 function create_lttng_session_notap
()
931 create_lttng_session
0 0 "$@"
935 function enable_ust_lttng_channel
()
938 local expected_to_fail
=$2
940 local channel_name
=$4
943 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
945 if [[ $expected_to_fail -eq "1" ]]; then
948 if [ $withtap -eq "1" ]; then
949 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
952 if [ $withtap -eq "1" ]; then
953 ok
$ret "Enable channel $channel_name for session $sess_name"
959 function enable_ust_lttng_channel_ok
()
961 enable_ust_lttng_channel
1 0 "$@"
964 function enable_ust_lttng_channel_fail
()
966 enable_ust_lttng_channel
1 1 "$@"
969 function enable_ust_lttng_channel_notap
()
971 enable_ust_lttng_channel
0 0 "$@"
974 function disable_ust_lttng_channel
()
977 local channel_name
=$2
979 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
980 ok $?
"Disable channel $channel_name for session $sess_name"
983 function enable_lttng_mmap_overwrite_kernel_channel
()
986 local channel_name
=$2
988 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
989 ok $?
"Enable channel $channel_name for session $sess_name"
992 function enable_lttng_mmap_discard_small_kernel_channel
()
995 local channel_name
=$2
997 $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
998 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1001 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1004 local channel_name
=$2
1006 $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
1007 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1010 function enable_lttng_mmap_overwrite_ust_channel
()
1013 local channel_name
=$2
1015 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1016 ok $?
"Enable channel $channel_name for session $sess_name"
1019 function enable_ust_lttng_event
()
1022 local expected_to_fail
=$2
1024 local event_name
="$4"
1025 local channel_name
=$5
1027 if [ -z $channel_name ]; then
1028 # default channel if none specified
1031 chan
="-c $channel_name"
1034 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1036 if [[ $expected_to_fail -eq "1" ]]; then
1039 if [[ $withtap -eq "1" ]]; then
1040 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1043 if [[ $withtap -eq "1" ]]; then
1044 ok
$ret "Enable ust event $event_name for session $sess_name"
1050 function enable_ust_lttng_event_ok
()
1052 enable_ust_lttng_event
1 0 "$@"
1055 function enable_ust_lttng_event_fail
()
1057 enable_ust_lttng_event
1 1 "$@"
1060 function enable_ust_lttng_event_notap
()
1062 enable_ust_lttng_event
0 0 "$@"
1065 function enable_jul_lttng_event
()
1071 if [ -z $channel_name ]; then
1072 # default channel if none specified
1075 chan
="-c $channel_name"
1078 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1079 ok $?
"Enable JUL event $event_name for session $sess_name"
1082 function enable_jul_lttng_event_loglevel
()
1085 local event_name
="$2"
1087 local channel_name
=$4
1089 if [ -z $channel_name ]; then
1090 # default channel if none specified
1093 chan
="-c $channel_name"
1096 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1097 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1100 function enable_log4j_lttng_event
()
1106 if [ -z $channel_name ]; then
1107 # default channel if none specified
1110 chan
="-c $channel_name"
1113 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1114 ok $?
"Enable LOG4J event $event_name for session $sess_name"
1117 function enable_log4j_lttng_event_loglevel
()
1120 local event_name
="$2"
1122 local channel_name
=$4
1124 if [ -z $channel_name ]; then
1125 # default channel if none specified
1128 chan
="-c $channel_name"
1131 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1132 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
1135 function enable_python_lttng_event
()
1141 if [ -z $channel_name ]; then
1142 # default channel if none specified
1145 chan
="-c $channel_name"
1148 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1149 ok $?
"Enable Python event $event_name for session $sess_name"
1152 function enable_python_lttng_event_loglevel
()
1155 local event_name
="$2"
1157 local channel_name
=$4
1159 if [ -z $channel_name ]; then
1160 # default channel if none specified
1163 chan
="-c $channel_name"
1166 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1167 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1170 function enable_ust_lttng_event_filter
()
1172 local sess_name
="$1"
1173 local event_name
="$2"
1176 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1177 ok $?
"Enable event $event_name with filtering for session $sess_name"
1180 function enable_ust_lttng_event_loglevel
()
1182 local sess_name
="$1"
1183 local event_name
="$2"
1186 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1187 ok $?
"Enable event $event_name with loglevel $loglevel"
1190 function enable_ust_lttng_event_loglevel_only
()
1192 local sess_name
="$1"
1193 local event_name
="$2"
1196 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1197 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1200 function disable_ust_lttng_event
()
1202 local sess_name
="$1"
1203 local event_name
="$2"
1204 local channel_name
="$3"
1206 if [ -z $channel_name ]; then
1207 # default channel if none specified
1210 chan
="-c $channel_name"
1213 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1214 ok $?
"Disable event $event_name for session $sess_name"
1217 function disable_jul_lttng_event
()
1219 local sess_name
="$1"
1220 local event_name
="$2"
1222 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1223 ok $?
"Disable JUL event $event_name for session $sess_name"
1226 function disable_log4j_lttng_event
()
1228 local sess_name
="$1"
1229 local event_name
="$2"
1231 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1232 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1235 function disable_python_lttng_event
()
1237 local sess_name
="$1"
1238 local event_name
="$2"
1240 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1241 ok $?
"Disable Python event $event_name for session $sess_name"
1244 function start_lttng_tracing_opt
()
1247 local expected_to_fail
=$2
1250 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1252 if [[ $expected_to_fail -eq "1" ]]; then
1255 if [ $withtap -eq "1" ]; then
1256 ok $?
"Start tracing for session $sess_name failed as expected"
1259 if [ $withtap -eq "1" ]; then
1260 ok
$ret "Start tracing for session $sess_name"
1265 function start_lttng_tracing_ok
()
1267 start_lttng_tracing_opt
1 0 "$@"
1270 function start_lttng_tracing_fail
()
1272 start_lttng_tracing_opt
1 1 "$@"
1275 function start_lttng_tracing_notap
()
1277 start_lttng_tracing_opt
0 1 "$@"
1280 function stop_lttng_tracing_opt
()
1283 local expected_to_fail
=$2
1286 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1288 if [[ $expected_to_fail -eq "1" ]]; then
1291 if [ $withtap -eq "1" ]; then
1292 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1295 if [ $withtap -eq "1" ]; then
1296 ok
$ret "Stop lttng tracing for session $sess_name"
1301 function stop_lttng_tracing_ok
()
1303 stop_lttng_tracing_opt
1 0 "$@"
1306 function stop_lttng_tracing_fail
()
1308 stop_lttng_tracing_opt
1 1 "$@"
1311 function stop_lttng_tracing_notap
()
1313 stop_lttng_tracing_opt
0 0 "$@"
1316 function destroy_lttng_session
()
1319 local expected_to_fail
=$2
1322 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1324 if [[ $expected_to_fail -eq "1" ]]; then
1327 if [ $withtap -eq "1" ]; then
1328 ok
$ret "Destroy session $sess_name failed as expected"
1331 if [ $withtap -eq "1" ]; then
1332 ok
$ret "Destroy session $sess_name"
1337 function destroy_lttng_session_ok
()
1339 destroy_lttng_session
1 0 "$@"
1343 function destroy_lttng_session_fail
()
1345 destroy_lttng_session
1 1 "$@"
1348 function destroy_lttng_session_notap
()
1350 destroy_lttng_session
0 0 "$@"
1353 function destroy_lttng_sessions
()
1355 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1356 ok $?
"Destroy all lttng sessions"
1359 function lttng_snapshot_add_output
()
1361 local expected_to_fail
=$1
1365 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1367 if [[ $expected_to_fail -eq 1 ]]; then
1369 ok $?
"Added snapshot output file://$trace_path failed as expected"
1371 ok
$ret "Added snapshot output file://$trace_path"
1375 function lttng_snapshot_add_output_ok
()
1377 lttng_snapshot_add_output
0 "$@"
1380 function lttng_snapshot_add_output_fail
()
1382 lttng_snapshot_add_output
1 "$@"
1385 function lttng_snapshot_del_output
()
1387 local expected_to_fail
=$1
1391 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1393 if [[ $expected_to_fail -eq "1" ]]; then
1395 ok $?
"Deleted snapshot output id $id failed as expected"
1397 ok
$ret "Deleted snapshot output id $id"
1401 function lttng_snapshot_del_output_ok
()
1403 lttng_snapshot_del_output
0 "$@"
1406 function lttng_snapshot_del_output_fail
()
1408 lttng_snapshot_del_output
1 "$@"
1411 function lttng_snapshot_record
()
1416 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1417 ok $?
"Snapshot recorded"
1420 function lttng_snapshot_list
()
1423 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1424 ok $?
"Snapshot list"
1427 function lttng_save
()
1432 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1433 ok $?
"Session saved"
1436 function lttng_load
()
1438 local expected_to_fail
=$1
1441 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1443 if [[ $expected_to_fail -eq "1" ]]; then
1445 ok $?
"Load command failed as expected with opts: $opts"
1447 ok
$ret "Load command with opts: $opts"
1451 function lttng_load_ok
()
1456 function lttng_load_fail
()
1461 function lttng_track
()
1463 local expected_to_fail
=$1
1465 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1467 if [[ $expected_to_fail -eq "1" ]]; then
1469 ok $?
"Track command failed as expected with opts: $opts"
1471 ok
$ret "Track command with opts: $opts"
1475 function lttng_track_ok
()
1480 function lttng_track_fail
()
1485 function lttng_untrack
()
1487 local expected_to_fail
=$1
1489 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1491 if [[ $expected_to_fail -eq "1" ]]; then
1493 ok $?
"Untrack command failed as expected with opts: $opts"
1495 ok
$ret "Untrack command with opts: $opts"
1499 function lttng_untrack_ok
()
1501 lttng_untrack
0 "$@"
1504 function lttng_untrack_fail
()
1506 lttng_untrack
1 "$@"
1509 function lttng_track_pid_ok
()
1512 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1513 ok $?
"Lttng track pid on the kernel domain"
1516 function lttng_untrack_kernel_all_ok
()
1518 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1519 ok $?
"Lttng untrack all pid on the kernel domain"
1522 function lttng_add_context_list
()
1524 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1526 ok
$ret "Context listing"
1529 function add_context_lttng
()
1531 local expected_to_fail
="$1"
1533 local session_name
="$3"
1534 local channel_name
="$4"
1537 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1539 if [[ $expected_to_fail -eq "1" ]]; then
1541 ok $?
"Add context command failed as expected for type: $type"
1543 ok
$ret "Add context command for type: $type"
1547 function add_context_ust_ok
()
1549 add_context_lttng
0 -u "$@"
1552 function add_context_ust_fail
()
1554 add_context_lttng
1 -u "$@"
1557 function add_context_kernel_ok
()
1559 add_context_lttng
0 -k "$@"
1562 function add_context_kernel_fail
()
1564 add_context_lttng
1 -k "$@"
1567 function validate_metadata_event
()
1570 local nr_event_id
=$2
1573 local metadata_file
=$
(find $trace_path |
grep metadata
)
1574 local metadata_path
=$
(dirname $metadata_file)
1576 which $BABELTRACE_BIN >/dev
/null
1577 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1579 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1581 if [ "$count" -ne "$nr_event_id" ]; then
1582 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1583 diag
"$count matching event id found in metadata"
1585 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1590 function trace_matches
()
1596 which $BABELTRACE_BIN >/dev
/null
1597 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1599 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1601 if [ "$count" -ne "$nr_iter" ]; then
1603 diag
"$count matching events found in trace"
1609 function trace_match_only
()
1615 which $BABELTRACE_BIN >/dev
/null
1616 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1618 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1619 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1621 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1622 pass
"Trace match with $total event $event_name"
1625 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1629 function validate_trace
1634 which $BABELTRACE_BIN >/dev
/null
1635 if [ $?
-ne 0 ]; then
1636 skip
0 "Babeltrace binary not found. Skipping trace validation"
1641 for i
in $event_name; do
1642 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1643 if [ "$traced" -ne 0 ]; then
1644 pass
"Validate trace for event $i, $traced events"
1646 fail
"Validate trace for event $i"
1647 diag
"Found $traced occurences of $i"
1655 function validate_trace_count
1659 local expected_count
=$3
1661 which $BABELTRACE_BIN >/dev
/null
1662 if [ $?
-ne 0 ]; then
1663 skip
0 "Babeltrace binary not found. Skipping trace validation"
1669 for i
in $event_name; do
1670 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1671 if [ "$traced" -ne 0 ]; then
1672 pass
"Validate trace for event $i, $traced events"
1674 fail
"Validate trace for event $i"
1675 diag
"Found $traced occurences of $i"
1677 cnt
=$
(($cnt + $traced))
1680 test $cnt -eq $expected_count
1681 ok $?
"Read a total of $cnt events, expected $expected_count"
1684 function trace_first_line
1688 which $BABELTRACE_BIN >/dev
/null
1689 if [ $?
-ne 0 ]; then
1690 skip
0 "Babeltrace binary not found. Skipping trace validation"
1693 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1696 function validate_trace_exp
()
1701 which $BABELTRACE_BIN >/dev
/null
1702 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1704 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
1705 if [ "$traced" -ne 0 ]; then
1706 pass
"Validate trace for expression '${event_exp}', $traced events"
1708 fail
"Validate trace for expression '${event_exp}'"
1709 diag
"Found $traced occurences of '${event_exp}'"
1715 function validate_trace_only_exp
()
1720 which $BABELTRACE_BIN >/dev
/null
1721 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1723 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
1724 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1726 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1727 pass
"Trace match with $total for expression '${event_exp}'"
1730 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1736 function validate_trace_empty
()
1740 which $BABELTRACE_BIN >/dev
/null
1741 if [ $?
-ne 0 ]; then
1742 skip
0 "Babeltrace binary not found. Skipping trace validation"
1745 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1747 if [ $ret -ne 0 ]; then
1748 fail
"Failed to parse trace"
1752 traced
=$
(echo -n "$events" |
wc -l)
1753 if [ "$traced" -eq 0 ]; then
1754 pass
"Validate empty trace"
1756 fail
"Validate empty trace"
1757 diag
"Found $traced events in trace"
1763 function regenerate_metadata
()
1765 local expected_to_fail
=$1
1768 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1770 if [[ $expected_to_fail -eq "1" ]]; then
1772 ok $?
"Expected fail on regenerate metadata $sess_name"
1774 ok
$ret "Metadata regenerate $sess_name"
1778 function regenerate_metadata_ok
()
1780 regenerate_metadata
0 "$@"
1783 function regenerate_metadata_fail
()
1785 regenerate_metadata
1 "$@"
1788 function regenerate_statedump
()
1790 local expected_to_fail
=$1
1793 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1795 if [[ $expected_to_fail -eq "1" ]]; then
1797 ok $?
"Expected fail on regenerate statedump $sess_name"
1799 ok
$ret "Metadata regenerate $sess_name"
1803 function regenerate_statedump_ok
()
1805 regenerate_statedump
0 "$@"
1808 function regenerate_statedump_fail
()
1810 regenerate_statedump
1 "$@"
1813 function rotate_session
()
1815 local expected_to_fail
=$1
1818 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1820 if [[ $expected_to_fail -eq "1" ]]; then
1822 ok $?
"Expected fail on rotate session $sess_name"
1824 ok
$ret "Rotate session $sess_name"
1828 function rotate_session_ok
()
1830 rotate_session
0 "$@"
1833 function rotate_session_fail
()
1835 rotate_session
1 "$@"
1838 function destructive_tests_enabled
()
1840 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
1847 function lttng_enable_rotation_timer
()
1849 local expected_to_fail
=$1
1853 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1855 if [[ $expected_to_fail -eq "1" ]]; then
1857 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
1859 ok
$ret "Set periodic rotation ($period) of session $sess_name"
1863 function lttng_enable_rotation_timer_ok
()
1865 lttng_enable_rotation_timer
0 $@
1868 function lttng_enable_rotation_timer_fail
()
1870 lttng_enable_rotation_timer
1 $@
1873 function lttng_enable_rotation_size
()
1875 local expected_to_fail
=$1
1879 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1881 if [[ $expected_to_fail -eq "1" ]]; then
1883 ok $?
"Expected fail on rotate session $sess_name"
1885 ok
$ret "Rotate session $sess_name"
1889 function lttng_enable_rotation_size_ok
()
1891 lttng_enable_rotation_size
0 $@
1894 function lttng_enable_rotation_size_fail
()
1896 lttng_enable_rotation_size
1 $@