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"
19 RUNAS_BIN
="lttng-runas"
20 CONSUMERD_BIN
="lttng-consumerd"
21 RELAYD_BIN
="lttng-relayd"
23 BABELTRACE_BIN
="babeltrace"
25 ERROR_OUTPUT_DEST
=/dev
/null
27 # Minimal kernel version supported for session daemon tests
28 KERNEL_MAJOR_VERSION
=2
29 KERNEL_MINOR_VERSION
=6
30 KERNEL_PATCHLEVEL_VERSION
=27
32 # We set the default UST register timeout to "wait forever", so that
33 # basic tests don't have to worry about hitting timeouts on busy
34 # systems. Specialized tests should test those corner-cases.
35 export LTTNG_UST_REGISTER_TIMEOUT
=-1
37 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
38 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
39 # its own sessiond if none is running. It also ensures that 'lttng create'
40 # fails when no sessiond is running.
41 export LTTNG_SESSIOND_PATH
="/bin/true"
43 source $TESTDIR/utils
/tap
/tap.sh
47 # Check if we are a terminal
49 echo -e "\e[1;32mOK\e[0m"
55 function print_fail
()
57 # Check if we are a terminal
59 echo -e "\e[1;31mFAIL\e[0m"
65 function print_test_banner
()
71 function validate_kernel_version
()
73 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
74 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
77 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
80 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
86 # Generate a random string
87 # $1 = number of characters; defaults to 16
88 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
91 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
92 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
96 # Return the number of _configured_ CPUs.
97 function conf_proc_count
()
99 getconf _NPROCESSORS_CONF
100 if [ $?
-ne 0 ]; then
101 diag
"Failed to get the number of configured CPUs"
106 function enable_kernel_lttng_event
108 local expected_to_fail
="$1"
110 local event_name
="$3"
111 local channel_name
="$4"
113 if [ -z "$event_name" ]; then
114 # Enable all event if no event name specified
118 if [ -z "$channel_name" ]; then
119 # default channel if none specified
122 chan
="-c $channel_name"
125 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
127 if [[ $expected_to_fail -eq "1" ]]; then
129 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
131 ok
$ret "Enable kernel event $event_name for session $sess_name"
135 function enable_kernel_lttng_event_ok
()
137 enable_kernel_lttng_event
0 "$@"
140 function enable_kernel_lttng_event_fail
()
142 enable_kernel_lttng_event
1 "$@"
146 function lttng_enable_kernel_event
148 enable_kernel_lttng_event_ok
"$@"
151 function lttng_enable_kernel_syscall
()
153 local expected_to_fail
=$1
155 local syscall_name
=$3
156 local channel_name
=$4
158 if [ -z $syscall_name ]; then
159 # Enable all event if no syscall name specified
163 if [ -z $channel_name ]; then
164 # default channel if none specified
167 chan
="-c $channel_name"
170 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
172 if [[ $expected_to_fail -eq "1" ]]; then
174 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
176 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
180 function lttng_enable_kernel_syscall_ok
()
182 lttng_enable_kernel_syscall
0 "$@"
185 function lttng_enable_kernel_syscall_fail
()
187 lttng_enable_kernel_syscall
1 "$@"
190 function lttng_disable_kernel_syscall
()
192 local expected_to_fail
=$1
194 local syscall_name
=$3
195 local channel_name
=$4
197 if [ -z $syscall_name ]; then
198 # Enable all event if no syscall name specified
202 if [ -z $channel_name ]; then
203 # default channel if none specified
206 chan
="-c $channel_name"
209 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
212 if [[ $expected_to_fail -eq "1" ]]; then
214 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
216 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
220 function lttng_disable_kernel_syscall_ok
()
222 lttng_disable_kernel_syscall
0 "$@"
225 function lttng_disable_kernel_syscall_fail
()
227 lttng_disable_kernel_syscall
1 "$@"
230 function lttng_enable_kernel_channel
()
232 local expected_to_fail
=$1
234 local channel_name
=$3
236 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
238 if [[ $expected_to_fail -eq "1" ]]; then
240 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
242 ok
$ret "Enable channel $channel_name for session $sess_name"
246 function lttng_enable_kernel_channel_ok
()
248 lttng_enable_kernel_channel
0 "$@"
251 function lttng_enable_kernel_channel_fail
()
253 lttng_enable_kernel_channel
1 "$@"
256 function lttng_disable_kernel_channel
()
258 local expected_to_fail
=$1
260 local channel_name
=$3
262 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
264 if [[ $expected_to_fail -eq "1" ]]; then
266 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
268 ok
$ret "Disable channel $channel_name for session $sess_name"
272 function lttng_disable_kernel_channel_ok
()
274 lttng_disable_kernel_channel
0 "$@"
277 function lttng_disable_kernel_channel_fail
()
279 lttng_disable_kernel_channel
1 "$@"
282 function start_lttng_relayd_opt
()
287 DIR
=$
(readlink
-f $TESTDIR)
289 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
290 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
291 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
292 if [ $?
-eq 1 ]; then
293 if [ $withtap -eq "1" ]; then
294 fail
"Start lttng-relayd (opt: $opt)"
298 if [ $withtap -eq "1" ]; then
299 pass
"Start lttng-relayd (opt: $opt)"
303 pass
"Start lttng-relayd (opt: $opt)"
307 function start_lttng_relayd
()
309 start_lttng_relayd_opt
1 "$@"
312 function start_lttng_relayd_notap
()
314 start_lttng_relayd_opt
0 "$@"
317 function stop_lttng_relayd_opt
()
321 PID_RELAYD
=`pgrep --full lt-$RELAYD_BIN`
323 if [ $withtap -eq "1" ]; then
324 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
326 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
329 if [ $?
-eq 1 ]; then
330 if [ $withtap -eq "1" ]; then
331 fail
"Kill relay daemon"
336 while [ -n "$out" ]; do
337 out
=$
(pgrep
--full lt-
$RELAYD_BIN)
340 if [ $withtap -eq "1" ]; then
341 pass
"Kill relay daemon"
347 function stop_lttng_relayd
()
349 stop_lttng_relayd_opt
1 "$@"
352 function stop_lttng_relayd_notap
()
354 stop_lttng_relayd_opt
0 "$@"
357 #First arg: show tap output
358 #Second argument: load path for automatic loading
359 function start_lttng_sessiond_opt
()
364 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
365 # Env variable requested no session daemon
369 validate_kernel_version
370 if [ $?
-ne 0 ]; then
371 fail
"Start session daemon"
372 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
375 DIR
=$
(readlink
-f $TESTDIR)
376 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
377 export LTTNG_SESSION_CONFIG_XSD_PATH
379 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
381 if [ -n "$load_path" ]; then
382 $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"
384 $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"
386 #$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
388 if [ $withtap -eq "1" ]; then
389 ok
$status "Start session daemon"
394 function start_lttng_sessiond
()
396 start_lttng_sessiond_opt
1 "$@"
399 function start_lttng_sessiond_notap
()
401 start_lttng_sessiond_opt
0 "$@"
404 function stop_lttng_sessiond_opt
()
410 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
411 # Env variable requested no session daemon
415 PID_SESSIOND
="$(pgrep --full lt-$SESSIOND_BIN) $(pgrep --full $RUNAS_BIN)"
418 kill_opt
="$kill_opt -s $signal"
420 if [ $withtap -eq "1" ]; then
421 diag
"Killing lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
423 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
425 if [ $?
-eq 1 ]; then
426 if [ $withtap -eq "1" ]; then
427 fail
"Kill sessions daemon"
431 while [ -n "$out" ]; do
432 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
436 while [ -n "$out" ]; do
437 out
=$
(pgrep
--full $CONSUMERD_BIN)
440 if [ $withtap -eq "1" ]; then
441 pass
"Kill session daemon"
446 function stop_lttng_sessiond
()
448 stop_lttng_sessiond_opt
1 "$@"
451 function stop_lttng_sessiond_notap
()
453 stop_lttng_sessiond_opt
0 "$@"
456 function sigstop_lttng_sessiond_opt
()
462 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
463 # Env variable requested no session daemon
467 PID_SESSIOND
="$(pgrep --full lt-$SESSIOND_BIN) $(pgrep --full $RUNAS_BIN)"
469 kill_opt
="$kill_opt -s $signal"
471 if [ $withtap -eq "1" ]; then
472 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
474 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
476 if [ $?
-eq 1 ]; then
477 if [ $withtap -eq "1" ]; then
478 fail
"Sending SIGSTOP to session daemon"
482 while [ $out -ne 0 ]; do
483 pid
=$
(pgrep
--full lt-
$SESSIOND_BIN)
485 # Wait until state becomes stopped for session
488 for sessiond_pid
in $pid; do
489 state
=$
(ps
-p $sessiond_pid -o state
= )
490 if [[ -n "$state" && "$state" != "T" ]]; then
496 if [ $withtap -eq "1" ]; then
497 pass
"Sending SIGSTOP to session daemon"
502 function sigstop_lttng_sessiond
()
504 sigstop_lttng_sessiond_opt
1 "$@"
507 function sigstop_lttng_sessiond_notap
()
509 sigstop_lttng_sessiond_opt
0 "$@"
512 function stop_lttng_consumerd_opt
()
518 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
521 kill_opt
="$kill_opt -s $signal"
524 if [ $withtap -eq "1" ]; then
525 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
527 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
531 if [ $?
-eq 1 ]; then
532 if [ $withtap -eq "1" ]; then
533 fail
"Kill consumer daemon"
538 while [ $out -ne 0 ]; do
539 pid
=$
(pgrep
--full $CONSUMERD_BIN)
541 # If consumerds are still present check their status.
542 # A zombie status qualifies the consumerd as *killed*
544 for consumer_pid
in $pid; do
545 state
=$
(ps
-p $consumer_pid -o state
= )
546 if [[ -n "$state" && "$state" != "Z" ]]; then
552 if [ $withtap -eq "1" ]; then
553 pass
"Kill consumer daemon"
559 function stop_lttng_consumerd
()
561 stop_lttng_consumerd_opt
1 "$@"
564 function stop_lttng_consumerd_notap
()
566 stop_lttng_consumerd_opt
0 "$@"
569 function sigstop_lttng_consumerd_opt
()
575 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
577 kill_opt
="$kill_opt -s $signal"
579 if [ $withtap -eq "1" ]; then
580 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
582 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
586 if [ $?
-eq 1 ]; then
587 if [ $withtap -eq "1" ]; then
588 fail
"Sending SIGSTOP to consumer daemon"
593 while [ $out -ne 0 ]; do
594 pid
=$
(pgrep
--full $CONSUMERD_BIN)
596 # Wait until state becomes stopped for all
599 for consumer_pid
in $pid; do
600 state
=$
(ps
-p $consumer_pid -o state
= )
601 if [[ -n "$state" && "$state" != "T" ]]; then
607 if [ $withtap -eq "1" ]; then
608 pass
"Sending SIGSTOP to consumer daemon"
614 function sigstop_lttng_consumerd
()
616 sigstop_lttng_consumerd_opt
1 "$@"
619 function sigstop_lttng_consumerd_notap
()
621 sigstop_lttng_consumerd_opt
0 "$@"
624 function list_lttng_with_opts
()
627 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
628 ok $?
"Lttng-tool list command with option $opts"
631 function create_lttng_session_no_output
()
635 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
636 ok $?
"Create session $sess_name in no-output mode"
639 function create_lttng_session
()
641 local expected_to_fail
=$1
646 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
648 if [[ $expected_to_fail -eq "1" ]]; then
650 ok $?
"Create session $sess_name in $trace_path failed as expected"
652 ok
$ret "Create session $sess_name in $trace_path"
656 function create_lttng_session_ok
()
658 create_lttng_session
0 "$@"
661 function create_lttng_session_fail
()
663 create_lttng_session
1 "$@"
667 function enable_ust_lttng_channel
()
669 local expected_to_fail
=$1
671 local channel_name
=$3
674 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
676 if [[ $expected_to_fail -eq "1" ]]; then
678 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
680 ok
$ret "Enable channel $channel_name for session $sess_name"
684 function enable_ust_lttng_channel_ok
()
686 enable_ust_lttng_channel
0 "$@"
689 function enable_ust_lttng_channel_fail
()
691 enable_ust_lttng_channel
1 "$@"
694 function disable_ust_lttng_channel
()
697 local channel_name
=$2
699 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
700 ok $?
"Disable channel $channel_name for session $sess_name"
703 function enable_lttng_mmap_overwrite_kernel_channel
()
706 local channel_name
=$2
708 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
709 ok $?
"Enable channel $channel_name for session $sess_name"
712 function enable_lttng_mmap_discard_small_kernel_channel
()
715 local channel_name
=$2
717 $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
718 ok $?
"Enable small discard channel $channel_name for session $sess_name"
721 function enable_lttng_mmap_overwrite_small_kernel_channel
()
724 local channel_name
=$2
726 $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
727 ok $?
"Enable small discard channel $channel_name for session $sess_name"
730 function enable_lttng_mmap_overwrite_ust_channel
()
733 local channel_name
=$2
735 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
736 ok $?
"Enable channel $channel_name for session $sess_name"
739 function enable_ust_lttng_event
()
741 local expected_to_fail
=$1
743 local event_name
="$3"
744 local channel_name
=$4
746 if [ -z $channel_name ]; then
747 # default channel if none specified
750 chan
="-c $channel_name"
753 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
755 if [[ $expected_to_fail -eq "1" ]]; then
757 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
759 ok
$ret "Enable ust event $event_name for session $sess_name"
763 function enable_ust_lttng_event_ok
()
765 enable_ust_lttng_event
0 "$@"
768 function enable_ust_lttng_event_fail
()
770 enable_ust_lttng_event
1 "$@"
773 function enable_jul_lttng_event
()
779 if [ -z $channel_name ]; then
780 # default channel if none specified
783 chan
="-c $channel_name"
786 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
787 ok $?
"Enable JUL event $event_name for session $sess_name"
790 function enable_jul_lttng_event_loglevel
()
793 local event_name
="$2"
795 local channel_name
=$4
797 if [ -z $channel_name ]; then
798 # default channel if none specified
801 chan
="-c $channel_name"
804 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
805 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
808 function enable_log4j_lttng_event
()
814 if [ -z $channel_name ]; then
815 # default channel if none specified
818 chan
="-c $channel_name"
821 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
822 ok $?
"Enable LOG4J event $event_name for session $sess_name"
825 function enable_log4j_lttng_event_loglevel
()
828 local event_name
="$2"
830 local channel_name
=$4
832 if [ -z $channel_name ]; then
833 # default channel if none specified
836 chan
="-c $channel_name"
839 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
840 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
843 function enable_python_lttng_event
()
849 if [ -z $channel_name ]; then
850 # default channel if none specified
853 chan
="-c $channel_name"
856 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
857 ok $?
"Enable Python event $event_name for session $sess_name"
860 function enable_python_lttng_event_loglevel
()
863 local event_name
="$2"
865 local channel_name
=$4
867 if [ -z $channel_name ]; then
868 # default channel if none specified
871 chan
="-c $channel_name"
874 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
875 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
878 function enable_ust_lttng_event_filter
()
881 local event_name
="$2"
884 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
885 ok $?
"Enable event $event_name with filtering for session $sess_name"
888 function enable_ust_lttng_event_loglevel
()
891 local event_name
="$2"
894 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
895 ok $?
"Enable event $event_name with loglevel $loglevel"
898 function enable_ust_lttng_event_loglevel_only
()
901 local event_name
="$2"
904 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
905 ok $?
"Enable event $event_name with loglevel-only $loglevel"
908 function disable_ust_lttng_event
()
911 local event_name
="$2"
912 local channel_name
="$3"
914 if [ -z $channel_name ]; then
915 # default channel if none specified
918 chan
="-c $channel_name"
921 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
922 ok $?
"Disable event $event_name for session $sess_name"
925 function disable_jul_lttng_event
()
928 local event_name
="$2"
930 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
931 ok $?
"Disable JUL event $event_name for session $sess_name"
934 function disable_log4j_lttng_event
()
937 local event_name
="$2"
939 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
940 ok $?
"Disable LOG4J event $event_name for session $sess_name"
943 function disable_python_lttng_event
()
946 local event_name
="$2"
948 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
949 ok $?
"Disable Python event $event_name for session $sess_name"
952 function start_lttng_tracing
()
954 local expected_to_fail
=$1
957 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
959 if [[ $expected_to_fail -eq "1" ]]; then
961 ok $?
"Start tracing for session $sess_name failed as expected"
963 ok
$ret "Start tracing for session $sess_name"
967 function start_lttng_tracing_ok
()
969 start_lttng_tracing
0 "$@"
972 function start_lttng_tracing_fail
()
974 start_lttng_tracing
1 "$@"
977 function stop_lttng_tracing
()
979 local expected_to_fail
=$1
982 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
984 if [[ $expected_to_fail -eq "1" ]]; then
986 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
988 ok
$ret "Stop lttng tracing for session $sess_name"
992 function stop_lttng_tracing_ok
()
994 stop_lttng_tracing
0 "$@"
997 function stop_lttng_tracing_fail
()
999 stop_lttng_tracing
1 "$@"
1002 function destroy_lttng_session
()
1004 local expected_to_fail
=$1
1007 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1009 if [[ $expected_to_fail -eq "1" ]]; then
1011 ok $?
"Destroy session $sess_name failed as expected"
1013 ok
$ret "Destroy session $sess_name"
1017 function destroy_lttng_session_ok
()
1019 destroy_lttng_session
0 "$@"
1023 function destroy_lttng_session_fail
()
1025 destroy_lttng_session
1 "$@"
1029 function destroy_lttng_sessions
()
1031 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1032 ok $?
"Destroy all lttng sessions"
1035 function lttng_snapshot_add_output
()
1037 local expected_to_fail
=$1
1041 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1043 if [[ $expected_to_fail -eq 1 ]]; then
1045 ok $?
"Added snapshot output file://$trace_path failed as expected"
1047 ok
$ret "Added snapshot output file://$trace_path"
1051 function lttng_snapshot_add_output_ok
()
1053 lttng_snapshot_add_output
0 "$@"
1056 function lttng_snapshot_add_output_fail
()
1058 lttng_snapshot_add_output
1 "$@"
1061 function lttng_snapshot_del_output
()
1063 local expected_to_fail
=$1
1067 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1069 if [[ $expected_to_fail -eq "1" ]]; then
1071 ok $?
"Deleted snapshot output id $id failed as expected"
1073 ok
$ret "Deleted snapshot output id $id"
1077 function lttng_snapshot_del_output_ok
()
1079 lttng_snapshot_del_output
0 "$@"
1082 function lttng_snapshot_del_output_fail
()
1084 lttng_snapshot_del_output
1 "$@"
1087 function lttng_snapshot_record
()
1092 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1093 ok $?
"Snapshot recorded"
1096 function lttng_snapshot_list
()
1099 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1100 ok $?
"Snapshot list"
1103 function lttng_save
()
1108 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1109 ok $?
"Session saved"
1112 function lttng_load
()
1116 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1117 ok $?
"Load command with opts: $opts"
1120 function lttng_track
()
1122 local expected_to_fail
=$1
1124 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1126 if [[ $expected_to_fail -eq "1" ]]; then
1128 ok $?
"Track command failed as expected with opts: $opts"
1130 ok
$ret "Track command with opts: $opts"
1134 function lttng_track_ok
()
1139 function lttng_track_fail
()
1144 function lttng_untrack
()
1146 local expected_to_fail
=$1
1148 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1150 if [[ $expected_to_fail -eq "1" ]]; then
1152 ok $?
"Untrack command failed as expected with opts: $opts"
1154 ok
$ret "Untrack command with opts: $opts"
1158 function lttng_untrack_ok
()
1160 lttng_untrack
0 "$@"
1163 function lttng_untrack_fail
()
1165 lttng_untrack
1 "$@"
1168 function add_context_lttng
()
1170 local expected_to_fail
="$1"
1172 local session_name
="$3"
1173 local channel_name
="$4"
1176 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1178 if [[ $expected_to_fail -eq "1" ]]; then
1180 ok $?
"Add context command failed as expected for type: $type"
1182 ok
$ret "Add context command for type: $type"
1186 function add_context_ust_ok
()
1188 add_context_lttng
0 -u "$@"
1191 function add_context_ust_fail
()
1193 add_context_lttng
1 -u "$@"
1196 function add_context_kernel_ok
()
1198 add_context_lttng
0 -k "$@"
1201 function add_context_kernel_fail
()
1203 add_context_lttng
1 -k "$@"
1206 function trace_matches
()
1212 which $BABELTRACE_BIN >/dev
/null
1213 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1215 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1217 if [ "$count" -ne "$nr_iter" ]; then
1219 diag
"$count events found in trace"
1225 function trace_match_only
()
1231 which $BABELTRACE_BIN >/dev
/null
1232 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1234 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1235 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1237 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1238 pass
"Trace match with $total event $event_name"
1241 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1245 function validate_trace
1250 which $BABELTRACE_BIN >/dev
/null
1251 if [ $?
-ne 0 ]; then
1252 skip
0 "Babeltrace binary not found. Skipping trace validation"
1257 for i
in $event_name; do
1258 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1259 if [ "$traced" -ne 0 ]; then
1260 pass
"Validate trace for event $i, $traced events"
1262 fail
"Validate trace for event $i"
1263 diag
"Found $traced occurences of $i"
1271 function trace_first_line
1275 which $BABELTRACE_BIN >/dev
/null
1276 if [ $?
-ne 0 ]; then
1277 skip
0 "Babeltrace binary not found. Skipping trace validation"
1280 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1283 function validate_trace_exp
()
1288 which $BABELTRACE_BIN >/dev
/null
1289 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1291 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1292 if [ "$traced" -ne 0 ]; then
1293 pass
"Validate trace for expression '${event_exp}', $traced events"
1295 fail
"Validate trace for expression '${event_exp}'"
1296 diag
"Found $traced occurences of '${event_exp}'"
1302 function validate_trace_only_exp
()
1307 which $BABELTRACE_BIN >/dev
/null
1308 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1310 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1311 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1313 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1314 pass
"Trace match with $total for expression '${event_exp}"
1317 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1323 function validate_trace_empty
()
1327 which $BABELTRACE_BIN >/dev
/null
1328 if [ $?
-ne 0 ]; then
1329 skip
0 "Babeltrace binary not found. Skipping trace validation"
1332 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1333 if [ "$traced" -eq 0 ]; then
1334 pass
"Validate empty trace"
1336 fail
"Validate empty trace"
1337 diag
"Found $traced events in trace"
1343 function metadata_regenerate
()
1345 local expected_to_fail
=$1
1348 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN metadata regenerate
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1350 if [[ $expected_to_fail -eq "1" ]]; then
1352 ok $?
"Expected fail on regenerate $sess_name"
1354 ok
$ret "Metadata regenerate $sess_name"
1358 function metadata_regenerate_ok
()
1360 metadata_regenerate
0 "$@"
1363 function metadata_regenerate_fail
()
1365 metadata_regenerate
1 "$@"
1368 function destructive_tests_enabled
()
1370 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then