3 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 SESSIOND_BIN
="lttng-sessiond"
20 RUNAS_BIN
="lttng-runas"
21 CONSUMERD_BIN
="lttng-consumerd"
22 RELAYD_BIN
="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 to "wait forever", so that
35 # basic tests don't have to worry about hitting timeouts on busy
36 # systems. Specialized tests should test those corner-cases.
37 export LTTNG_UST_REGISTER_TIMEOUT
=-1
39 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
40 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
41 # its own sessiond if none is running. It also ensures that 'lttng create'
42 # fails when no sessiond is running.
43 export LTTNG_SESSIOND_PATH
="/bin/true"
45 source $TESTDIR/utils
/tap
/tap.sh
47 function full_cleanup
()
49 if [ -n "${SESSIOND_PIDS}" ] ||
[ -n "${RELAYD_PIDS}" ]; then
50 kill -9 ${SESSIOND_PIDS} ${RELAYD_PIDS} > /dev
/null
2>&1
53 # Disable trap for SIGTERM since the following kill to the
54 # pidgroup will be SIGTERM. Otherwise it loops.
55 # The '-' before the pid number ($$) indicates 'kill' to signal the
56 # whole process group.
57 trap - SIGTERM
&& kill -- -$$
61 trap full_cleanup SIGINT SIGTERM
65 # Check if we are a terminal
67 echo -e "\e[1;32mOK\e[0m"
73 function print_fail
()
75 # Check if we are a terminal
77 echo -e "\e[1;31mFAIL\e[0m"
83 function print_test_banner
()
89 function validate_kernel_version
()
91 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
92 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
95 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
98 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
104 # Generate a random string
105 # $1 = number of characters; defaults to 16
106 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
107 function randstring
()
109 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
110 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
114 # Return the number of _configured_ CPUs.
115 function conf_proc_count
()
117 getconf _NPROCESSORS_CONF
118 if [ $?
-ne 0 ]; then
119 diag
"Failed to get the number of configured CPUs"
124 function enable_kernel_lttng_event
126 local expected_to_fail
="$1"
128 local event_name
="$3"
129 local channel_name
="$4"
131 if [ -z "$event_name" ]; then
132 # Enable all event if no event name specified
136 if [ -z "$channel_name" ]; then
137 # default channel if none specified
140 chan
="-c $channel_name"
143 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
145 if [[ $expected_to_fail -eq "1" ]]; then
147 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
149 ok
$ret "Enable kernel event $event_name for session $sess_name"
153 function enable_kernel_lttng_event_ok
()
155 enable_kernel_lttng_event
0 "$@"
158 function enable_kernel_lttng_event_fail
()
160 enable_kernel_lttng_event
1 "$@"
164 function lttng_enable_kernel_event
166 enable_kernel_lttng_event_ok
"$@"
169 function lttng_enable_kernel_syscall
()
171 local expected_to_fail
=$1
173 local syscall_name
=$3
174 local channel_name
=$4
176 if [ -z $syscall_name ]; then
177 # Enable all event if no syscall name specified
181 if [ -z $channel_name ]; then
182 # default channel if none specified
185 chan
="-c $channel_name"
188 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
190 if [[ $expected_to_fail -eq "1" ]]; then
192 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
194 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
198 function lttng_enable_kernel_syscall_ok
()
200 lttng_enable_kernel_syscall
0 "$@"
203 function lttng_enable_kernel_syscall_fail
()
205 lttng_enable_kernel_syscall
1 "$@"
208 function lttng_disable_kernel_syscall
()
210 local expected_to_fail
=$1
212 local syscall_name
=$3
213 local channel_name
=$4
215 if [ -z $syscall_name ]; then
216 # Enable all event if no syscall name specified
220 if [ -z $channel_name ]; then
221 # default channel if none specified
224 chan
="-c $channel_name"
227 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
230 if [[ $expected_to_fail -eq "1" ]]; then
232 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
234 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
238 function lttng_disable_kernel_syscall_ok
()
240 lttng_disable_kernel_syscall
0 "$@"
243 function lttng_disable_kernel_syscall_fail
()
245 lttng_disable_kernel_syscall
1 "$@"
248 function lttng_enable_kernel_channel
()
250 local expected_to_fail
=$1
252 local channel_name
=$3
254 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
256 if [[ $expected_to_fail -eq "1" ]]; then
258 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
260 ok
$ret "Enable channel $channel_name for session $sess_name"
264 function lttng_enable_kernel_channel_ok
()
266 lttng_enable_kernel_channel
0 "$@"
269 function lttng_enable_kernel_channel_fail
()
271 lttng_enable_kernel_channel
1 "$@"
274 function lttng_disable_kernel_channel
()
276 local expected_to_fail
=$1
278 local channel_name
=$3
280 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
282 if [[ $expected_to_fail -eq "1" ]]; then
284 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
286 ok
$ret "Disable channel $channel_name for session $sess_name"
290 function lttng_disable_kernel_channel_ok
()
292 lttng_disable_kernel_channel
0 "$@"
295 function lttng_disable_kernel_channel_fail
()
297 lttng_disable_kernel_channel
1 "$@"
300 function start_lttng_relayd_opt
()
305 DIR
=$
(readlink
-f $TESTDIR)
307 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
308 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
309 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
310 if [ $?
-eq 1 ]; then
311 if [ $withtap -eq "1" ]; then
312 fail
"Start lttng-relayd (opt: $opt)"
316 if [ $withtap -eq "1" ]; then
317 pass
"Start lttng-relayd (opt: $opt)"
321 pass
"Start lttng-relayd (opt: $opt)"
324 RELAYD_PIDS
=$
(pgrep
--full lt-
$RELAYD_BIN)
327 function start_lttng_relayd
()
329 start_lttng_relayd_opt
1 "$@"
332 function start_lttng_relayd_notap
()
334 start_lttng_relayd_opt
0 "$@"
337 function stop_lttng_relayd_opt
()
341 if [ $withtap -eq "1" ]; then
342 diag
"Killing lttng-relayd (pid: $RELAYD_PIDS)"
344 kill $RELAYD_PIDS 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
347 if [ $?
-eq 1 ]; then
348 if [ $withtap -eq "1" ]; then
349 fail
"Kill relay daemon"
354 while [ -n "$out" ]; do
355 out
=$
(pgrep
--full lt-
$RELAYD_BIN)
358 if [ $withtap -eq "1" ]; then
359 pass
"Kill relay daemon"
366 function stop_lttng_relayd
()
368 stop_lttng_relayd_opt
1 "$@"
371 function stop_lttng_relayd_notap
()
373 stop_lttng_relayd_opt
0 "$@"
376 #First arg: show tap output
377 #Second argument: load path for automatic loading
378 function start_lttng_sessiond_opt
()
383 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
384 # Env variable requested no session daemon
388 validate_kernel_version
389 if [ $?
-ne 0 ]; then
390 fail
"Start session daemon"
391 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
394 DIR
=$
(readlink
-f $TESTDIR)
395 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
396 export LTTNG_SESSION_CONFIG_XSD_PATH
398 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
400 if [ -n "$load_path" ]; then
401 $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --load "$load_path" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
403 $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"
405 #$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
407 if [ $withtap -eq "1" ]; then
408 ok
$status "Start session daemon"
411 SESSIOND_PIDS
=$
(pgrep
--full lt-
$SESSIOND_BIN)
414 function start_lttng_sessiond
()
416 start_lttng_sessiond_opt
1 "$@"
419 function start_lttng_sessiond_notap
()
421 start_lttng_sessiond_opt
0 "$@"
424 function stop_lttng_sessiond_opt
()
430 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
431 # Env variable requested no session daemon
435 local pids
="${SESSIOND_PIDS} $(pgrep --full $RUNAS_BIN)"
438 kill_opt
="$kill_opt -s $signal"
440 if [ $withtap -eq "1" ]; then
441 diag
"Killing lt-$SESSIOND_BIN pids: $(echo $pids | tr '\n' ' ')"
443 kill $kill_opt $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
445 if [ $?
-eq 1 ]; then
446 if [ $withtap -eq "1" ]; then
447 fail
"Kill sessions daemon"
451 while [ -n "$out" ]; do
452 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
456 while [ -n "$out" ]; do
457 out
=$
(pgrep
--full $CONSUMERD_BIN)
462 if [ $withtap -eq "1" ]; then
463 pass
"Kill session daemon"
468 function stop_lttng_sessiond
()
470 stop_lttng_sessiond_opt
1 "$@"
473 function stop_lttng_sessiond_notap
()
475 stop_lttng_sessiond_opt
0 "$@"
478 function sigstop_lttng_sessiond_opt
()
484 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
485 # Env variable requested no session daemon
489 PID_SESSIOND
="$(pgrep --full lt-$SESSIOND_BIN) $(pgrep --full $RUNAS_BIN)"
491 kill_opt
="$kill_opt -s $signal"
493 if [ $withtap -eq "1" ]; then
494 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
496 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
498 if [ $?
-eq 1 ]; then
499 if [ $withtap -eq "1" ]; then
500 fail
"Sending SIGSTOP to session daemon"
504 while [ $out -ne 0 ]; do
505 pid
=$
(pgrep
--full lt-
$SESSIOND_BIN)
507 # Wait until state becomes stopped for session
510 for sessiond_pid
in $pid; do
511 state
=$
(ps
-p $sessiond_pid -o state
= )
512 if [[ -n "$state" && "$state" != "T" ]]; then
518 if [ $withtap -eq "1" ]; then
519 pass
"Sending SIGSTOP to session daemon"
524 function sigstop_lttng_sessiond
()
526 sigstop_lttng_sessiond_opt
1 "$@"
529 function sigstop_lttng_sessiond_notap
()
531 sigstop_lttng_sessiond_opt
0 "$@"
534 function stop_lttng_consumerd_opt
()
540 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
543 kill_opt
="$kill_opt -s $signal"
546 if [ $withtap -eq "1" ]; then
547 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
549 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
553 if [ $?
-eq 1 ]; then
554 if [ $withtap -eq "1" ]; then
555 fail
"Kill consumer daemon"
560 while [ $out -ne 0 ]; do
561 pid
=$
(pgrep
--full $CONSUMERD_BIN)
563 # If consumerds are still present check their status.
564 # A zombie status qualifies the consumerd as *killed*
566 for consumer_pid
in $pid; do
567 state
=$
(ps
-p $consumer_pid -o state
= )
568 if [[ -n "$state" && "$state" != "Z" ]]; then
574 if [ $withtap -eq "1" ]; then
575 pass
"Kill consumer daemon"
581 function stop_lttng_consumerd
()
583 stop_lttng_consumerd_opt
1 "$@"
586 function stop_lttng_consumerd_notap
()
588 stop_lttng_consumerd_opt
0 "$@"
591 function sigstop_lttng_consumerd_opt
()
597 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
599 kill_opt
="$kill_opt -s $signal"
601 if [ $withtap -eq "1" ]; then
602 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
604 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
608 if [ $?
-eq 1 ]; then
609 if [ $withtap -eq "1" ]; then
610 fail
"Sending SIGSTOP to consumer daemon"
615 while [ $out -ne 0 ]; do
616 pid
=$
(pgrep
--full $CONSUMERD_BIN)
618 # Wait until state becomes stopped for all
621 for consumer_pid
in $pid; do
622 state
=$
(ps
-p $consumer_pid -o state
= )
623 if [[ -n "$state" && "$state" != "T" ]]; then
629 if [ $withtap -eq "1" ]; then
630 pass
"Sending SIGSTOP to consumer daemon"
636 function sigstop_lttng_consumerd
()
638 sigstop_lttng_consumerd_opt
1 "$@"
641 function sigstop_lttng_consumerd_notap
()
643 sigstop_lttng_consumerd_opt
0 "$@"
646 function list_lttng_with_opts
()
649 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
650 ok $?
"Lttng-tool list command with option $opts"
653 function create_lttng_session_no_output
()
657 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
658 ok $?
"Create session $sess_name in no-output mode"
661 function create_lttng_session
()
663 local expected_to_fail
=$1
668 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
670 if [[ $expected_to_fail -eq "1" ]]; then
672 ok $?
"Create session $sess_name in $trace_path failed as expected"
674 ok
$ret "Create session $sess_name in $trace_path"
678 function create_lttng_session_ok
()
680 create_lttng_session
0 "$@"
683 function create_lttng_session_fail
()
685 create_lttng_session
1 "$@"
689 function enable_ust_lttng_channel
()
691 local expected_to_fail
=$1
693 local channel_name
=$3
696 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
698 if [[ $expected_to_fail -eq "1" ]]; then
700 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
702 ok
$ret "Enable channel $channel_name for session $sess_name"
706 function enable_ust_lttng_channel_ok
()
708 enable_ust_lttng_channel
0 "$@"
711 function enable_ust_lttng_channel_fail
()
713 enable_ust_lttng_channel
1 "$@"
716 function disable_ust_lttng_channel
()
719 local channel_name
=$2
721 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
722 ok $?
"Disable channel $channel_name for session $sess_name"
725 function enable_lttng_mmap_overwrite_kernel_channel
()
728 local channel_name
=$2
730 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
731 ok $?
"Enable channel $channel_name for session $sess_name"
734 function enable_lttng_mmap_overwrite_ust_channel
()
737 local channel_name
=$2
739 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
740 ok $?
"Enable channel $channel_name for session $sess_name"
743 function enable_ust_lttng_event
()
745 local expected_to_fail
=$1
747 local event_name
="$3"
748 local channel_name
=$4
750 if [ -z $channel_name ]; then
751 # default channel if none specified
754 chan
="-c $channel_name"
757 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
759 if [[ $expected_to_fail -eq "1" ]]; then
761 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
763 ok
$ret "Enable ust event $event_name for session $sess_name"
767 function enable_ust_lttng_event_ok
()
769 enable_ust_lttng_event
0 "$@"
772 function enable_ust_lttng_event_fail
()
774 enable_ust_lttng_event
1 "$@"
777 function enable_jul_lttng_event
()
783 if [ -z $channel_name ]; then
784 # default channel if none specified
787 chan
="-c $channel_name"
790 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
791 ok $?
"Enable JUL event $event_name for session $sess_name"
794 function enable_jul_lttng_event_loglevel
()
797 local event_name
="$2"
799 local channel_name
=$4
801 if [ -z $channel_name ]; then
802 # default channel if none specified
805 chan
="-c $channel_name"
808 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
809 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
812 function enable_log4j_lttng_event
()
818 if [ -z $channel_name ]; then
819 # default channel if none specified
822 chan
="-c $channel_name"
825 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
826 ok $?
"Enable LOG4J event $event_name for session $sess_name"
829 function enable_log4j_lttng_event_loglevel
()
832 local event_name
="$2"
834 local channel_name
=$4
836 if [ -z $channel_name ]; then
837 # default channel if none specified
840 chan
="-c $channel_name"
843 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
844 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
847 function enable_python_lttng_event
()
853 if [ -z $channel_name ]; then
854 # default channel if none specified
857 chan
="-c $channel_name"
860 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
861 ok $?
"Enable Python event $event_name for session $sess_name"
864 function enable_python_lttng_event_loglevel
()
867 local event_name
="$2"
869 local channel_name
=$4
871 if [ -z $channel_name ]; then
872 # default channel if none specified
875 chan
="-c $channel_name"
878 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
879 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
882 function enable_ust_lttng_event_filter
()
885 local event_name
="$2"
888 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
889 ok $?
"Enable event $event_name with filtering for session $sess_name"
892 function enable_ust_lttng_event_loglevel
()
895 local event_name
="$2"
898 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
899 ok $?
"Enable event $event_name with loglevel $loglevel"
902 function enable_ust_lttng_event_loglevel_only
()
905 local event_name
="$2"
908 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
909 ok $?
"Enable event $event_name with loglevel-only $loglevel"
912 function disable_ust_lttng_event
()
915 local event_name
="$2"
916 local channel_name
="$3"
918 if [ -z $channel_name ]; then
919 # default channel if none specified
922 chan
="-c $channel_name"
925 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
926 ok $?
"Disable event $event_name for session $sess_name"
929 function disable_jul_lttng_event
()
932 local event_name
="$2"
934 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
935 ok $?
"Disable JUL event $event_name for session $sess_name"
938 function disable_log4j_lttng_event
()
941 local event_name
="$2"
943 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
944 ok $?
"Disable LOG4J event $event_name for session $sess_name"
947 function disable_python_lttng_event
()
950 local event_name
="$2"
952 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
953 ok $?
"Disable Python event $event_name for session $sess_name"
956 function start_lttng_tracing
()
958 local expected_to_fail
=$1
961 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
963 if [[ $expected_to_fail -eq "1" ]]; then
965 ok $?
"Start tracing for session $sess_name failed as expected"
967 ok
$ret "Start tracing for session $sess_name"
971 function start_lttng_tracing_ok
()
973 start_lttng_tracing
0 "$@"
976 function start_lttng_tracing_fail
()
978 start_lttng_tracing
1 "$@"
981 function stop_lttng_tracing
()
983 local expected_to_fail
=$1
986 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
988 if [[ $expected_to_fail -eq "1" ]]; then
990 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
992 ok
$ret "Stop lttng tracing for session $sess_name"
996 function stop_lttng_tracing_ok
()
998 stop_lttng_tracing
0 "$@"
1001 function stop_lttng_tracing_fail
()
1003 stop_lttng_tracing
1 "$@"
1006 function destroy_lttng_session
()
1008 local expected_to_fail
=$1
1011 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1013 if [[ $expected_to_fail -eq "1" ]]; then
1015 ok $?
"Destroy session $sess_name failed as expected"
1017 ok
$ret "Destroy session $sess_name"
1021 function destroy_lttng_session_ok
()
1023 destroy_lttng_session
0 "$@"
1027 function destroy_lttng_session_fail
()
1029 destroy_lttng_session
1 "$@"
1033 function destroy_lttng_sessions
()
1035 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1036 ok $?
"Destroy all lttng sessions"
1039 function lttng_snapshot_add_output
()
1041 local expected_to_fail
=$1
1045 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1047 if [[ $expected_to_fail -eq 1 ]]; then
1049 ok $?
"Added snapshot output file://$trace_path failed as expected"
1051 ok
$ret "Added snapshot output file://$trace_path"
1055 function lttng_snapshot_add_output_ok
()
1057 lttng_snapshot_add_output
0 "$@"
1060 function lttng_snapshot_add_output_fail
()
1062 lttng_snapshot_add_output
1 "$@"
1065 function lttng_snapshot_del_output
()
1067 local expected_to_fail
=$1
1071 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1073 if [[ $expected_to_fail -eq "1" ]]; then
1075 ok $?
"Deleted snapshot output id $id failed as expected"
1077 ok
$ret "Deleted snapshot output id $id"
1081 function lttng_snapshot_del_output_ok
()
1083 lttng_snapshot_del_output
0 "$@"
1086 function lttng_snapshot_del_output_fail
()
1088 lttng_snapshot_del_output
1 "$@"
1091 function lttng_snapshot_record
()
1096 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1097 ok $?
"Snapshot recorded"
1100 function lttng_snapshot_list
()
1103 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1104 ok $?
"Snapshot list"
1107 function lttng_save
()
1112 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1113 ok $?
"Session saved"
1116 function lttng_load
()
1120 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1121 ok $?
"Load command with opts: $opts"
1124 function lttng_track
()
1126 local expected_to_fail
=$1
1128 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1130 if [[ $expected_to_fail -eq "1" ]]; then
1132 ok $?
"Track command failed as expected with opts: $opts"
1134 ok
$ret "Track command with opts: $opts"
1138 function lttng_track_ok
()
1143 function lttng_track_fail
()
1148 function lttng_untrack
()
1150 local expected_to_fail
=$1
1152 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1154 if [[ $expected_to_fail -eq "1" ]]; then
1156 ok $?
"Untrack command failed as expected with opts: $opts"
1158 ok
$ret "Untrack command with opts: $opts"
1162 function lttng_untrack_ok
()
1164 lttng_untrack
0 "$@"
1167 function lttng_untrack_fail
()
1169 lttng_untrack
1 "$@"
1172 function add_context_lttng
()
1174 local expected_to_fail
="$1"
1176 local session_name
="$3"
1177 local channel_name
="$4"
1180 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1182 if [[ $expected_to_fail -eq "1" ]]; then
1184 ok $?
"Add context command failed as expected for type: $type"
1186 ok
$ret "Add context command for type: $type"
1190 function add_context_ust_ok
()
1192 add_context_lttng
0 -u "$@"
1195 function add_context_ust_fail
()
1197 add_context_lttng
1 -u "$@"
1200 function add_context_kernel_ok
()
1202 add_context_lttng
0 -k "$@"
1205 function add_context_kernel_fail
()
1207 add_context_lttng
1 -k "$@"
1210 function trace_matches
()
1216 which $BABELTRACE_BIN >/dev
/null
1217 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1219 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1221 if [ "$count" -ne "$nr_iter" ]; then
1223 diag
"$count events found in trace"
1229 function trace_match_only
()
1235 which $BABELTRACE_BIN >/dev
/null
1236 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1238 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1239 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1241 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1242 pass
"Trace match with $total event $event_name"
1245 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1249 function validate_trace
1254 which $BABELTRACE_BIN >/dev
/null
1255 if [ $?
-ne 0 ]; then
1256 skip
0 "Babeltrace binary not found. Skipping trace validation"
1261 for i
in $event_name; do
1262 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1263 if [ "$traced" -ne 0 ]; then
1264 pass
"Validate trace for event $i, $traced events"
1266 fail
"Validate trace for event $i"
1267 diag
"Found $traced occurences of $i"
1275 function validate_trace_exp
()
1280 which $BABELTRACE_BIN >/dev
/null
1281 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1283 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1284 if [ "$traced" -ne 0 ]; then
1285 pass
"Validate trace for expression '${event_exp}', $traced events"
1287 fail
"Validate trace for expression '${event_exp}'"
1288 diag
"Found $traced occurences of '${event_exp}'"
1294 function validate_trace_only_exp
()
1299 which $BABELTRACE_BIN >/dev
/null
1300 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1302 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1303 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1305 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1306 pass
"Trace match with $total for expression '${event_exp}"
1309 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1315 function validate_trace_empty
()
1319 which $BABELTRACE_BIN >/dev
/null
1320 if [ $?
-ne 0 ]; then
1321 skip
0 "Babeltrace binary not found. Skipping trace validation"
1324 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1325 if [ "$traced" -eq 0 ]; then
1326 pass
"Validate empty trace"
1328 fail
"Validate empty trace"
1329 diag
"Found $traced events in trace"
1335 function metadata_regenerate
()
1337 local expected_to_fail
=$1
1340 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN metadata regenerate
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1342 if [[ $expected_to_fail -eq "1" ]]; then
1344 ok $?
"Expected fail on regenerate $sess_name"
1346 ok
$ret "Metadata regenerate $sess_name"
1350 function metadata_regenerate_ok
()
1352 metadata_regenerate
0 "$@"
1355 function metadata_regenerate_fail
()
1357 metadata_regenerate
1 "$@"
1360 function destructive_tests_enabled
()
1362 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then