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 if [ -z "$trace_path" ]; then
904 # Use lttng-sessiond default output.
907 trace_path
="-o $trace_path"
910 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
"$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
912 if [ $expected_to_fail -eq "1" ]; then
915 if [ $withtap -eq "1" ]; then
916 ok
$ret "Create session $sess_name in $trace_path failed as expected"
919 if [ $withtap -eq "1" ]; then
920 ok
$ret "Create session $sess_name in $trace_path"
926 function create_lttng_session_ok
()
928 create_lttng_session
1 0 "$@"
931 function create_lttng_session_fail
()
933 create_lttng_session
1 1 "$@"
936 function create_lttng_session_notap
()
938 create_lttng_session
0 0 "$@"
942 function enable_ust_lttng_channel
()
945 local expected_to_fail
=$2
947 local channel_name
=$4
950 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
952 if [[ $expected_to_fail -eq "1" ]]; then
955 if [ $withtap -eq "1" ]; then
956 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
959 if [ $withtap -eq "1" ]; then
960 ok
$ret "Enable channel $channel_name for session $sess_name"
966 function enable_ust_lttng_channel_ok
()
968 enable_ust_lttng_channel
1 0 "$@"
971 function enable_ust_lttng_channel_fail
()
973 enable_ust_lttng_channel
1 1 "$@"
976 function enable_ust_lttng_channel_notap
()
978 enable_ust_lttng_channel
0 0 "$@"
981 function disable_ust_lttng_channel
()
984 local channel_name
=$2
986 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
987 ok $?
"Disable channel $channel_name for session $sess_name"
990 function enable_lttng_mmap_overwrite_kernel_channel
()
993 local channel_name
=$2
995 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
996 ok $?
"Enable channel $channel_name for session $sess_name"
999 function enable_lttng_mmap_discard_small_kernel_channel
()
1002 local channel_name
=$2
1004 $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
1005 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1008 function enable_lttng_mmap_overwrite_small_kernel_channel
()
1011 local channel_name
=$2
1013 $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
1014 ok $?
"Enable small discard channel $channel_name for session $sess_name"
1017 function enable_lttng_mmap_overwrite_ust_channel
()
1020 local channel_name
=$2
1022 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1023 ok $?
"Enable channel $channel_name for session $sess_name"
1026 function enable_ust_lttng_event
()
1029 local expected_to_fail
=$2
1031 local event_name
="$4"
1032 local channel_name
=$5
1034 if [ -z $channel_name ]; then
1035 # default channel if none specified
1038 chan
="-c $channel_name"
1041 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1043 if [[ $expected_to_fail -eq "1" ]]; then
1046 if [[ $withtap -eq "1" ]]; then
1047 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
1050 if [[ $withtap -eq "1" ]]; then
1051 ok
$ret "Enable ust event $event_name for session $sess_name"
1057 function enable_ust_lttng_event_ok
()
1059 enable_ust_lttng_event
1 0 "$@"
1062 function enable_ust_lttng_event_fail
()
1064 enable_ust_lttng_event
1 1 "$@"
1067 function enable_ust_lttng_event_notap
()
1069 enable_ust_lttng_event
0 0 "$@"
1072 function enable_jul_lttng_event
()
1078 if [ -z $channel_name ]; then
1079 # default channel if none specified
1082 chan
="-c $channel_name"
1085 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1086 ok $?
"Enable JUL event $event_name for session $sess_name"
1089 function enable_jul_lttng_event_loglevel
()
1092 local event_name
="$2"
1094 local channel_name
=$4
1096 if [ -z $channel_name ]; then
1097 # default channel if none specified
1100 chan
="-c $channel_name"
1103 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1104 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1107 function enable_log4j_lttng_event
()
1113 if [ -z $channel_name ]; then
1114 # default channel if none specified
1117 chan
="-c $channel_name"
1120 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1121 ok $?
"Enable LOG4J event $event_name for session $sess_name"
1124 function enable_log4j_lttng_event_loglevel
()
1127 local event_name
="$2"
1129 local channel_name
=$4
1131 if [ -z $channel_name ]; then
1132 # default channel if none specified
1135 chan
="-c $channel_name"
1138 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1139 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
1142 function enable_python_lttng_event
()
1148 if [ -z $channel_name ]; then
1149 # default channel if none specified
1152 chan
="-c $channel_name"
1155 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1156 ok $?
"Enable Python event $event_name for session $sess_name"
1159 function enable_python_lttng_event_loglevel
()
1162 local event_name
="$2"
1164 local channel_name
=$4
1166 if [ -z $channel_name ]; then
1167 # default channel if none specified
1170 chan
="-c $channel_name"
1173 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1174 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1177 function enable_ust_lttng_event_filter
()
1179 local sess_name
="$1"
1180 local event_name
="$2"
1183 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1184 ok $?
"Enable event $event_name with filtering for session $sess_name"
1187 function enable_ust_lttng_event_loglevel
()
1189 local sess_name
="$1"
1190 local event_name
="$2"
1193 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1194 ok $?
"Enable event $event_name with loglevel $loglevel"
1197 function enable_ust_lttng_event_loglevel_only
()
1199 local sess_name
="$1"
1200 local event_name
="$2"
1203 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1204 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1207 function disable_ust_lttng_event
()
1209 local sess_name
="$1"
1210 local event_name
="$2"
1211 local channel_name
="$3"
1213 if [ -z $channel_name ]; then
1214 # default channel if none specified
1217 chan
="-c $channel_name"
1220 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1221 ok $?
"Disable event $event_name for session $sess_name"
1224 function disable_jul_lttng_event
()
1226 local sess_name
="$1"
1227 local event_name
="$2"
1229 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1230 ok $?
"Disable JUL event $event_name for session $sess_name"
1233 function disable_log4j_lttng_event
()
1235 local sess_name
="$1"
1236 local event_name
="$2"
1238 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1239 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1242 function disable_python_lttng_event
()
1244 local sess_name
="$1"
1245 local event_name
="$2"
1247 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1248 ok $?
"Disable Python event $event_name for session $sess_name"
1251 function start_lttng_tracing_opt
()
1254 local expected_to_fail
=$2
1257 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1259 if [[ $expected_to_fail -eq "1" ]]; then
1262 if [ $withtap -eq "1" ]; then
1263 ok $?
"Start tracing for session $sess_name failed as expected"
1266 if [ $withtap -eq "1" ]; then
1267 ok
$ret "Start tracing for session $sess_name"
1272 function start_lttng_tracing_ok
()
1274 start_lttng_tracing_opt
1 0 "$@"
1277 function start_lttng_tracing_fail
()
1279 start_lttng_tracing_opt
1 1 "$@"
1282 function start_lttng_tracing_notap
()
1284 start_lttng_tracing_opt
0 1 "$@"
1287 function stop_lttng_tracing_opt
()
1290 local expected_to_fail
=$2
1293 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1295 if [[ $expected_to_fail -eq "1" ]]; then
1298 if [ $withtap -eq "1" ]; then
1299 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1302 if [ $withtap -eq "1" ]; then
1303 ok
$ret "Stop lttng tracing for session $sess_name"
1308 function stop_lttng_tracing_ok
()
1310 stop_lttng_tracing_opt
1 0 "$@"
1313 function stop_lttng_tracing_fail
()
1315 stop_lttng_tracing_opt
1 1 "$@"
1318 function stop_lttng_tracing_notap
()
1320 stop_lttng_tracing_opt
0 0 "$@"
1323 function destroy_lttng_session
()
1326 local expected_to_fail
=$2
1329 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1331 if [[ $expected_to_fail -eq "1" ]]; then
1334 if [ $withtap -eq "1" ]; then
1335 ok
$ret "Destroy session $sess_name failed as expected"
1338 if [ $withtap -eq "1" ]; then
1339 ok
$ret "Destroy session $sess_name"
1344 function destroy_lttng_session_ok
()
1346 destroy_lttng_session
1 0 "$@"
1350 function destroy_lttng_session_fail
()
1352 destroy_lttng_session
1 1 "$@"
1355 function destroy_lttng_session_notap
()
1357 destroy_lttng_session
0 0 "$@"
1360 function destroy_lttng_sessions
()
1362 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1363 ok $?
"Destroy all lttng sessions"
1366 function lttng_snapshot_add_output
()
1368 local expected_to_fail
=$1
1372 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1374 if [[ $expected_to_fail -eq 1 ]]; then
1376 ok $?
"Added snapshot output file://$trace_path failed as expected"
1378 ok
$ret "Added snapshot output file://$trace_path"
1382 function lttng_snapshot_add_output_ok
()
1384 lttng_snapshot_add_output
0 "$@"
1387 function lttng_snapshot_add_output_fail
()
1389 lttng_snapshot_add_output
1 "$@"
1392 function lttng_snapshot_del_output
()
1394 local expected_to_fail
=$1
1398 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1400 if [[ $expected_to_fail -eq "1" ]]; then
1402 ok $?
"Deleted snapshot output id $id failed as expected"
1404 ok
$ret "Deleted snapshot output id $id"
1408 function lttng_snapshot_del_output_ok
()
1410 lttng_snapshot_del_output
0 "$@"
1413 function lttng_snapshot_del_output_fail
()
1415 lttng_snapshot_del_output
1 "$@"
1418 function lttng_snapshot_record
()
1423 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1424 ok $?
"Snapshot recorded"
1427 function lttng_snapshot_list
()
1430 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1431 ok $?
"Snapshot list"
1434 function lttng_save
()
1439 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1440 ok $?
"Session saved"
1443 function lttng_load
()
1445 local expected_to_fail
=$1
1448 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1450 if [[ $expected_to_fail -eq "1" ]]; then
1452 ok $?
"Load command failed as expected with opts: $opts"
1454 ok
$ret "Load command with opts: $opts"
1458 function lttng_load_ok
()
1463 function lttng_load_fail
()
1468 function lttng_track
()
1470 local expected_to_fail
=$1
1472 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1474 if [[ $expected_to_fail -eq "1" ]]; then
1476 ok $?
"Track command failed as expected with opts: $opts"
1478 ok
$ret "Track command with opts: $opts"
1482 function lttng_track_ok
()
1487 function lttng_track_fail
()
1492 function lttng_untrack
()
1494 local expected_to_fail
=$1
1496 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1498 if [[ $expected_to_fail -eq "1" ]]; then
1500 ok $?
"Untrack command failed as expected with opts: $opts"
1502 ok
$ret "Untrack command with opts: $opts"
1506 function lttng_untrack_ok
()
1508 lttng_untrack
0 "$@"
1511 function lttng_untrack_fail
()
1513 lttng_untrack
1 "$@"
1516 function lttng_track_pid_ok
()
1519 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1520 ok $?
"Lttng track pid on the kernel domain"
1523 function lttng_untrack_kernel_all_ok
()
1525 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1526 ok $?
"Lttng untrack all pid on the kernel domain"
1529 function lttng_add_context_list
()
1531 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1533 ok
$ret "Context listing"
1536 function add_context_lttng
()
1538 local expected_to_fail
="$1"
1540 local session_name
="$3"
1541 local channel_name
="$4"
1544 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1546 if [[ $expected_to_fail -eq "1" ]]; then
1548 ok $?
"Add context command failed as expected for type: $type"
1550 ok
$ret "Add context command for type: $type"
1554 function add_context_ust_ok
()
1556 add_context_lttng
0 -u "$@"
1559 function add_context_ust_fail
()
1561 add_context_lttng
1 -u "$@"
1564 function add_context_kernel_ok
()
1566 add_context_lttng
0 -k "$@"
1569 function add_context_kernel_fail
()
1571 add_context_lttng
1 -k "$@"
1574 function validate_metadata_event
()
1577 local nr_event_id
=$2
1580 local metadata_file
=$
(find $trace_path |
grep metadata
)
1581 local metadata_path
=$
(dirname $metadata_file)
1583 which $BABELTRACE_BIN >/dev
/null
1584 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1586 local count
=$
($BABELTRACE_BIN --output-format=ctf-metadata
$metadata_path |
grep $event_name |
wc -l)
1588 if [ "$count" -ne "$nr_event_id" ]; then
1589 fail
"Metadata match with the metadata of $count event(s) named $event_name"
1590 diag
"$count matching event id found in metadata"
1592 pass
"Metadata match with the metadata of $count event(s) named $event_name"
1597 function trace_matches
()
1603 which $BABELTRACE_BIN >/dev
/null
1604 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1606 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1608 if [ "$count" -ne "$nr_iter" ]; then
1610 diag
"$count matching events found in trace"
1616 function trace_match_only
()
1622 which $BABELTRACE_BIN >/dev
/null
1623 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1625 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1626 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1628 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1629 pass
"Trace match with $total event $event_name"
1632 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1636 function validate_trace
1641 which $BABELTRACE_BIN >/dev
/null
1642 if [ $?
-ne 0 ]; then
1643 skip
0 "Babeltrace binary not found. Skipping trace validation"
1648 for i
in $event_name; do
1649 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1650 if [ "$traced" -ne 0 ]; then
1651 pass
"Validate trace for event $i, $traced events"
1653 fail
"Validate trace for event $i"
1654 diag
"Found $traced occurences of $i"
1662 function validate_trace_count
1666 local expected_count
=$3
1668 which $BABELTRACE_BIN >/dev
/null
1669 if [ $?
-ne 0 ]; then
1670 skip
0 "Babeltrace binary not found. Skipping trace validation"
1676 for i
in $event_name; do
1677 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1678 if [ "$traced" -ne 0 ]; then
1679 pass
"Validate trace for event $i, $traced events"
1681 fail
"Validate trace for event $i"
1682 diag
"Found $traced occurences of $i"
1684 cnt
=$
(($cnt + $traced))
1687 test $cnt -eq $expected_count
1688 ok $?
"Read a total of $cnt events, expected $expected_count"
1691 function trace_first_line
1695 which $BABELTRACE_BIN >/dev
/null
1696 if [ $?
-ne 0 ]; then
1697 skip
0 "Babeltrace binary not found. Skipping trace validation"
1700 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1703 function validate_trace_exp
()
1708 which $BABELTRACE_BIN >/dev
/null
1709 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1711 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
1712 if [ "$traced" -ne 0 ]; then
1713 pass
"Validate trace for expression '${event_exp}', $traced events"
1715 fail
"Validate trace for expression '${event_exp}'"
1716 diag
"Found $traced occurences of '${event_exp}'"
1722 function validate_trace_only_exp
()
1727 which $BABELTRACE_BIN >/dev
/null
1728 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1730 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
1731 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1733 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1734 pass
"Trace match with $total for expression '${event_exp}'"
1737 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1743 function validate_trace_empty
()
1747 which $BABELTRACE_BIN >/dev
/null
1748 if [ $?
-ne 0 ]; then
1749 skip
0 "Babeltrace binary not found. Skipping trace validation"
1752 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1754 if [ $ret -ne 0 ]; then
1755 fail
"Failed to parse trace"
1759 traced
=$
(echo -n "$events" |
wc -l)
1760 if [ "$traced" -eq 0 ]; then
1761 pass
"Validate empty trace"
1763 fail
"Validate empty trace"
1764 diag
"Found $traced events in trace"
1770 function regenerate_metadata
()
1772 local expected_to_fail
=$1
1775 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1777 if [[ $expected_to_fail -eq "1" ]]; then
1779 ok $?
"Expected fail on regenerate metadata $sess_name"
1781 ok
$ret "Metadata regenerate $sess_name"
1785 function regenerate_metadata_ok
()
1787 regenerate_metadata
0 "$@"
1790 function regenerate_metadata_fail
()
1792 regenerate_metadata
1 "$@"
1795 function regenerate_statedump
()
1797 local expected_to_fail
=$1
1800 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1802 if [[ $expected_to_fail -eq "1" ]]; then
1804 ok $?
"Expected fail on regenerate statedump $sess_name"
1806 ok
$ret "Statedump regenerate $sess_name"
1810 function regenerate_statedump_ok
()
1812 regenerate_statedump
0 "$@"
1815 function regenerate_statedump_fail
()
1817 regenerate_statedump
1 "$@"
1820 function rotate_session
()
1822 local expected_to_fail
=$1
1825 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1827 if [[ $expected_to_fail -eq "1" ]]; then
1829 ok $?
"Expected fail on rotate session $sess_name"
1831 ok
$ret "Rotate session $sess_name"
1835 function rotate_session_ok
()
1837 rotate_session
0 "$@"
1840 function rotate_session_fail
()
1842 rotate_session
1 "$@"
1845 function destructive_tests_enabled
()
1847 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
1854 function lttng_enable_rotation_timer
()
1856 local expected_to_fail
=$1
1860 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1862 if [[ $expected_to_fail -eq "1" ]]; then
1864 ok $?
"Expected fail when setting periodic rotation ($period) of session $sess_name"
1866 ok
$ret "Set periodic rotation ($period) of session $sess_name"
1870 function lttng_enable_rotation_timer_ok
()
1872 lttng_enable_rotation_timer
0 $@
1875 function lttng_enable_rotation_timer_fail
()
1877 lttng_enable_rotation_timer
1 $@
1880 function lttng_enable_rotation_size
()
1882 local expected_to_fail
=$1
1886 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1888 if [[ $expected_to_fail -eq "1" ]]; then
1890 ok $?
"Expected fail on rotate session $sess_name"
1892 ok
$ret "Rotate session $sess_name"
1896 function lttng_enable_rotation_size_ok
()
1898 lttng_enable_rotation_size
0 $@
1901 function lttng_enable_rotation_size_fail
()
1903 lttng_enable_rotation_size
1 $@