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 CONSUMERD_BIN
="lttng-consumerd"
20 RELAYD_BIN
="lttng-relayd"
22 BABELTRACE_BIN
="babeltrace"
24 ERROR_OUTPUT_DEST
=/dev
/null
26 # Minimal kernel version supported for session daemon tests
27 KERNEL_MAJOR_VERSION
=2
28 KERNEL_MINOR_VERSION
=6
29 KERNEL_PATCHLEVEL_VERSION
=27
31 # We set the default UST register timeout to "wait forever", so that
32 # basic tests don't have to worry about hitting timeouts on busy
33 # systems. Specialized tests should test those corner-cases.
34 export LTTNG_UST_REGISTER_TIMEOUT
=-1
36 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
37 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
38 # its own sessiond if none is running. It also ensures that 'lttng create'
39 # fails when no sessiond is running.
40 export LTTNG_SESSIOND_PATH
="/bin/true"
42 source $TESTDIR/utils
/tap
/tap.sh
46 # Check if we are a terminal
48 echo -e "\e[1;32mOK\e[0m"
54 function print_fail
()
56 # Check if we are a terminal
58 echo -e "\e[1;31mFAIL\e[0m"
64 function print_test_banner
()
70 function validate_kernel_version
()
72 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
73 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
76 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
79 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
85 # Generate a random string
86 # $1 = number of characters; defaults to 16
87 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
90 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
91 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
95 # Return the number of _configured_ CPUs.
96 function conf_proc_count
()
98 getconf _NPROCESSORS_CONF
100 diag
"Failed to get the number of configured CPUs"
105 function enable_kernel_lttng_event
107 local expected_to_fail
="$1"
109 local event_name
="$3"
110 local channel_name
="$4"
112 if [ -z "$event_name" ]; then
113 # Enable all event if no event name specified
117 if [ -z "$channel_name" ]; then
118 # default channel if none specified
121 chan
="-c $channel_name"
124 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
126 if [[ $expected_to_fail -eq "1" ]]; then
128 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
130 ok
$ret "Enable kernel event $event_name for session $sess_name"
134 function enable_kernel_lttng_event_ok
()
136 enable_kernel_lttng_event
0 "$@"
139 function enable_kernel_lttng_event_fail
()
141 enable_kernel_lttng_event
1 "$@"
145 function lttng_enable_kernel_event
147 enable_kernel_lttng_event_ok
"$@"
150 function lttng_enable_kernel_syscall
()
152 local expected_to_fail
=$1
154 local syscall_name
=$3
155 local channel_name
=$4
157 if [ -z $syscall_name ]; then
158 # Enable all event if no syscall name specified
162 if [ -z $channel_name ]; then
163 # default channel if none specified
166 chan
="-c $channel_name"
169 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
171 if [[ $expected_to_fail -eq "1" ]]; then
173 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
175 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
179 function lttng_enable_kernel_syscall_ok
()
181 lttng_enable_kernel_syscall
0 "$@"
184 function lttng_enable_kernel_syscall_fail
()
186 lttng_enable_kernel_syscall
1 "$@"
189 function lttng_disable_kernel_syscall
()
191 local expected_to_fail
=$1
193 local syscall_name
=$3
194 local channel_name
=$4
196 if [ -z $syscall_name ]; then
197 # Enable all event if no syscall name specified
201 if [ -z $channel_name ]; then
202 # default channel if none specified
205 chan
="-c $channel_name"
208 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
211 if [[ $expected_to_fail -eq "1" ]]; then
213 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
215 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
219 function lttng_disable_kernel_syscall_ok
()
221 lttng_disable_kernel_syscall
0 "$@"
224 function lttng_disable_kernel_syscall_fail
()
226 lttng_disable_kernel_syscall
1 "$@"
229 function lttng_enable_kernel_channel
()
231 local expected_to_fail
=$1
233 local channel_name
=$3
235 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
237 if [[ $expected_to_fail -eq "1" ]]; then
239 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
241 ok
$ret "Enable channel $channel_name for session $sess_name"
245 function lttng_enable_kernel_channel_ok
()
247 lttng_enable_kernel_channel
0 "$@"
250 function lttng_enable_kernel_channel_fail
()
252 lttng_enable_kernel_channel
1 "$@"
255 function lttng_disable_kernel_channel
()
257 local expected_to_fail
=$1
259 local channel_name
=$3
261 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
263 if [[ $expected_to_fail -eq "1" ]]; then
265 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
267 ok
$ret "Disable channel $channel_name for session $sess_name"
271 function lttng_disable_kernel_channel_ok
()
273 lttng_disable_kernel_channel
0 "$@"
276 function lttng_disable_kernel_channel_fail
()
278 lttng_disable_kernel_channel
1 "$@"
281 function start_lttng_relayd_opt
()
286 DIR
=$
(readlink
-f $TESTDIR)
288 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
289 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
290 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
291 if [ $?
-eq 1 ]; then
292 if [ $withtap -eq "1" ]; then
293 fail
"Start lttng-relayd (opt: $opt)"
297 if [ $withtap -eq "1" ]; then
298 pass
"Start lttng-relayd (opt: $opt)"
302 pass
"Start lttng-relayd (opt: $opt)"
306 function start_lttng_relayd
()
308 start_lttng_relayd_opt
1 "$@"
311 function start_lttng_relayd_notap
()
313 start_lttng_relayd_opt
0 "$@"
316 function stop_lttng_relayd_opt
()
320 PID_RELAYD
=`pgrep --full lt-$RELAYD_BIN`
322 if [ $withtap -eq "1" ]; then
323 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
325 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
328 if [ $?
-eq 1 ]; then
329 if [ $withtap -eq "1" ]; then
330 fail
"Kill relay daemon"
335 while [ -n "$out" ]; do
336 out
=$
(pgrep
--full lt-
$RELAYD_BIN)
339 if [ $withtap -eq "1" ]; then
340 pass
"Kill relay daemon"
346 function stop_lttng_relayd
()
348 stop_lttng_relayd_opt
1 "$@"
351 function stop_lttng_relayd_notap
()
353 stop_lttng_relayd_opt
0 "$@"
356 #First arg: show tap output
357 #Second argument: load path for automatic loading
358 function start_lttng_sessiond_opt
()
363 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
364 # Env variable requested no session daemon
368 validate_kernel_version
369 if [ $?
-ne 0 ]; then
370 fail
"Start session daemon"
371 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
374 DIR
=$
(readlink
-f $TESTDIR)
375 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
376 export LTTNG_SESSION_CONFIG_XSD_PATH
378 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
380 if [ -n "$load_path" ]; then
381 $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"
383 $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"
385 #$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
387 if [ $withtap -eq "1" ]; then
388 ok
$status "Start session daemon"
393 function start_lttng_sessiond
()
395 start_lttng_sessiond_opt
1 "$@"
398 function start_lttng_sessiond_notap
()
400 start_lttng_sessiond_opt
0 "$@"
403 function stop_lttng_sessiond_opt
()
409 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
410 # Env variable requested no session daemon
414 PID_SESSIOND
=`pgrep --full lt-$SESSIOND_BIN`
417 kill_opt
="$kill_opt -s $signal"
419 if [ $withtap -eq "1" ]; then
420 diag
"Killing lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
422 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
424 if [ $?
-eq 1 ]; then
425 if [ $withtap -eq "1" ]; then
426 fail
"Kill sessions daemon"
430 while [ -n "$out" ]; do
431 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
435 while [ -n "$out" ]; do
436 out
=$
(pgrep
--full $CONSUMERD_BIN)
439 if [ $withtap -eq "1" ]; then
440 pass
"Kill session daemon"
445 function stop_lttng_sessiond
()
447 stop_lttng_sessiond_opt
1 "$@"
450 function stop_lttng_sessiond_notap
()
452 stop_lttng_sessiond_opt
0 "$@"
455 function sigstop_lttng_sessiond_opt
()
461 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
462 # Env variable requested no session daemon
466 PID_SESSIOND
=`pgrep --full lt-$SESSIOND_BIN`
468 kill_opt
="$kill_opt -s $signal"
470 if [ $withtap -eq "1" ]; then
471 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
473 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
475 if [ $?
-eq 1 ]; then
476 if [ $withtap -eq "1" ]; then
477 fail
"Sending SIGSTOP to session daemon"
481 while [ $out -ne 0 ]; do
482 pid
=$
(pgrep
--full lt-
$SESSIOND_BIN)
484 # Wait until state becomes stopped for session
487 for sessiond_pid
in $pid; do
488 state
=$
(ps
-p $sessiond_pid -o state
= )
489 if [[ -n "$state" && "$state" != "T" ]]; then
495 if [ $withtap -eq "1" ]; then
496 pass
"Sending SIGSTOP to session daemon"
501 function sigstop_lttng_sessiond
()
503 sigstop_lttng_sessiond_opt
1 "$@"
506 function sigstop_lttng_sessiond_notap
()
508 sigstop_lttng_sessiond_opt
0 "$@"
511 function stop_lttng_consumerd_opt
()
517 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
520 kill_opt
="$kill_opt -s $signal"
523 if [ $withtap -eq "1" ]; then
524 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
526 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
530 if [ $?
-eq 1 ]; then
531 if [ $withtap -eq "1" ]; then
532 fail
"Kill consumer daemon"
537 while [ $out -ne 0 ]; do
538 pid
=$
(pgrep
--full $CONSUMERD_BIN)
540 # If consumerds are still present check their status.
541 # A zombie status qualifies the consumerd as *killed*
543 for consumer_pid
in $pid; do
544 state
=$
(ps
-p $consumer_pid -o state
= )
545 if [[ -n "$state" && "$state" != "Z" ]]; then
551 if [ $withtap -eq "1" ]; then
552 pass
"Kill consumer daemon"
558 function stop_lttng_consumerd
()
560 stop_lttng_consumerd_opt
1 "$@"
563 function stop_lttng_consumerd_notap
()
565 stop_lttng_consumerd_opt
0 "$@"
568 function sigstop_lttng_consumerd_opt
()
574 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
576 kill_opt
="$kill_opt -s $signal"
578 if [ $withtap -eq "1" ]; then
579 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
581 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
585 if [ $?
-eq 1 ]; then
586 if [ $withtap -eq "1" ]; then
587 fail
"Sending SIGSTOP to consumer daemon"
592 while [ $out -ne 0 ]; do
593 pid
=$
(pgrep
--full $CONSUMERD_BIN)
595 # Wait until state becomes stopped for all
598 for consumer_pid
in $pid; do
599 state
=$
(ps
-p $consumer_pid -o state
= )
600 if [[ -n "$state" && "$state" != "T" ]]; then
606 if [ $withtap -eq "1" ]; then
607 pass
"Sending SIGSTOP to consumer daemon"
613 function sigstop_lttng_consumerd
()
615 sigstop_lttng_consumerd_opt
1 "$@"
618 function sigstop_lttng_consumerd_notap
()
620 sigstop_lttng_consumerd_opt
0 "$@"
623 function list_lttng_with_opts
()
626 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
627 ok $?
"Lttng-tool list command with option $opts"
630 function create_lttng_session_no_output
()
634 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
635 ok $?
"Create session $sess_name in no-output mode"
638 function create_lttng_session
()
640 local expected_to_fail
=$1
645 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
647 if [[ $expected_to_fail -eq "1" ]]; then
649 ok $?
"Create session $sess_name in $trace_path failed as expected"
651 ok
$ret "Create session $sess_name in $trace_path"
655 function create_lttng_session_ok
()
657 create_lttng_session
0 "$@"
660 function create_lttng_session_fail
()
662 create_lttng_session
1 "$@"
666 function enable_ust_lttng_channel
()
668 local expected_to_fail
=$1
670 local channel_name
=$3
673 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
675 if [[ $expected_to_fail -eq "1" ]]; then
677 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
679 ok
$ret "Enable channel $channel_name for session $sess_name"
683 function enable_ust_lttng_channel_ok
()
685 enable_ust_lttng_channel
0 "$@"
688 function enable_ust_lttng_channel_fail
()
690 enable_ust_lttng_channel
1 "$@"
693 function disable_ust_lttng_channel
()
696 local channel_name
=$2
698 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
699 ok $?
"Disable channel $channel_name for session $sess_name"
702 function enable_lttng_mmap_overwrite_kernel_channel
()
705 local channel_name
=$2
707 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
708 ok $?
"Enable channel $channel_name for session $sess_name"
711 function enable_lttng_mmap_overwrite_ust_channel
()
714 local channel_name
=$2
716 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
717 ok $?
"Enable channel $channel_name for session $sess_name"
720 function enable_ust_lttng_event
()
722 local expected_to_fail
=$1
724 local event_name
="$3"
725 local channel_name
=$4
727 if [ -z $channel_name ]; then
728 # default channel if none specified
731 chan
="-c $channel_name"
734 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
736 if [[ $expected_to_fail -eq "1" ]]; then
738 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
740 ok
$ret "Enable ust event $event_name for session $sess_name"
744 function enable_ust_lttng_event_ok
()
746 enable_ust_lttng_event
0 "$@"
749 function enable_ust_lttng_event_fail
()
751 enable_ust_lttng_event
1 "$@"
754 function enable_jul_lttng_event
()
760 if [ -z $channel_name ]; then
761 # default channel if none specified
764 chan
="-c $channel_name"
767 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
768 ok $?
"Enable JUL event $event_name for session $sess_name"
771 function enable_jul_lttng_event_loglevel
()
774 local event_name
="$2"
776 local channel_name
=$4
778 if [ -z $channel_name ]; then
779 # default channel if none specified
782 chan
="-c $channel_name"
785 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
786 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
789 function enable_log4j_lttng_event
()
795 if [ -z $channel_name ]; then
796 # default channel if none specified
799 chan
="-c $channel_name"
802 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
803 ok $?
"Enable LOG4J event $event_name for session $sess_name"
806 function enable_log4j_lttng_event_loglevel
()
809 local event_name
="$2"
811 local channel_name
=$4
813 if [ -z $channel_name ]; then
814 # default channel if none specified
817 chan
="-c $channel_name"
820 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
821 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
824 function enable_python_lttng_event
()
830 if [ -z $channel_name ]; then
831 # default channel if none specified
834 chan
="-c $channel_name"
837 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
838 ok $?
"Enable Python event $event_name for session $sess_name"
841 function enable_python_lttng_event_loglevel
()
844 local event_name
="$2"
846 local channel_name
=$4
848 if [ -z $channel_name ]; then
849 # default channel if none specified
852 chan
="-c $channel_name"
855 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
856 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
859 function enable_ust_lttng_event_filter
()
862 local event_name
="$2"
865 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
866 ok $?
"Enable event $event_name with filtering for session $sess_name"
869 function enable_ust_lttng_event_loglevel
()
872 local event_name
="$2"
875 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
876 ok $?
"Enable event $event_name with loglevel $loglevel"
879 function enable_ust_lttng_event_loglevel_only
()
882 local event_name
="$2"
885 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
886 ok $?
"Enable event $event_name with loglevel-only $loglevel"
889 function disable_ust_lttng_event
()
892 local event_name
="$2"
893 local channel_name
="$3"
895 if [ -z $channel_name ]; then
896 # default channel if none specified
899 chan
="-c $channel_name"
902 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
903 ok $?
"Disable event $event_name for session $sess_name"
906 function disable_jul_lttng_event
()
909 local event_name
="$2"
911 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
912 ok $?
"Disable JUL event $event_name for session $sess_name"
915 function disable_log4j_lttng_event
()
918 local event_name
="$2"
920 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
921 ok $?
"Disable LOG4J event $event_name for session $sess_name"
924 function disable_python_lttng_event
()
927 local event_name
="$2"
929 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
930 ok $?
"Disable Python event $event_name for session $sess_name"
933 function start_lttng_tracing
()
935 local expected_to_fail
=$1
938 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
940 if [[ $expected_to_fail -eq "1" ]]; then
942 ok $?
"Start tracing for session $sess_name failed as expected"
944 ok
$ret "Start tracing for session $sess_name"
948 function start_lttng_tracing_ok
()
950 start_lttng_tracing
0 "$@"
953 function start_lttng_tracing_fail
()
955 start_lttng_tracing
1 "$@"
958 function stop_lttng_tracing
()
960 local expected_to_fail
=$1
963 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
965 if [[ $expected_to_fail -eq "1" ]]; then
967 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
969 ok
$ret "Stop lttng tracing for session $sess_name"
973 function stop_lttng_tracing_ok
()
975 stop_lttng_tracing
0 "$@"
978 function stop_lttng_tracing_fail
()
980 stop_lttng_tracing
1 "$@"
983 function destroy_lttng_session
()
985 local expected_to_fail
=$1
988 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
990 if [[ $expected_to_fail -eq "1" ]]; then
992 ok $?
"Destroy session $sess_name failed as expected"
994 ok
$ret "Destroy session $sess_name"
998 function destroy_lttng_session_ok
()
1000 destroy_lttng_session
0 "$@"
1004 function destroy_lttng_session_fail
()
1006 destroy_lttng_session
1 "$@"
1010 function destroy_lttng_sessions
()
1012 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1013 ok $?
"Destroy all lttng sessions"
1016 function lttng_snapshot_add_output
()
1018 local expected_to_fail
=$1
1022 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1024 if [[ $expected_to_fail -eq 1 ]]; then
1026 ok $?
"Added snapshot output file://$trace_path failed as expected"
1028 ok
$ret "Added snapshot output file://$trace_path"
1032 function lttng_snapshot_add_output_ok
()
1034 lttng_snapshot_add_output
0 "$@"
1037 function lttng_snapshot_add_output_fail
()
1039 lttng_snapshot_add_output
1 "$@"
1042 function lttng_snapshot_del_output
()
1044 local expected_to_fail
=$1
1048 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1050 if [[ $expected_to_fail -eq "1" ]]; then
1052 ok $?
"Deleted snapshot output id $id failed as expected"
1054 ok
$ret "Deleted snapshot output id $id"
1058 function lttng_snapshot_del_output_ok
()
1060 lttng_snapshot_del_output
0 "$@"
1063 function lttng_snapshot_del_output_fail
()
1065 lttng_snapshot_del_output
1 "$@"
1068 function lttng_snapshot_record
()
1073 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1074 ok $?
"Snapshot recorded"
1077 function lttng_snapshot_list
()
1080 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1081 ok $?
"Snapshot list"
1084 function lttng_save
()
1089 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1090 ok $?
"Session saved"
1093 function lttng_load
()
1097 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1098 ok $?
"Load command with opts: $opts"
1101 function lttng_track
()
1103 local expected_to_fail
=$1
1105 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1107 if [[ $expected_to_fail -eq "1" ]]; then
1109 ok $?
"Track command failed as expected with opts: $opts"
1111 ok
$ret "Track command with opts: $opts"
1115 function lttng_track_ok
()
1120 function lttng_track_fail
()
1125 function lttng_untrack
()
1127 local expected_to_fail
=$1
1129 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1131 if [[ $expected_to_fail -eq "1" ]]; then
1133 ok $?
"Untrack command failed as expected with opts: $opts"
1135 ok
$ret "Untrack command with opts: $opts"
1139 function lttng_untrack_ok
()
1141 lttng_untrack
0 "$@"
1144 function lttng_untrack_fail
()
1146 lttng_untrack
1 "$@"
1149 function add_context_lttng
()
1151 local expected_to_fail
="$1"
1153 local session_name
="$3"
1154 local channel_name
="$4"
1157 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1159 if [[ $expected_to_fail -eq "1" ]]; then
1161 ok $?
"Add context command failed as expected for type: $type"
1163 ok
$ret "Add context command for type: $type"
1167 function add_context_ust_ok
()
1169 add_context_lttng
0 -u "$@"
1172 function add_context_ust_fail
()
1174 add_context_lttng
1 -u "$@"
1177 function add_context_kernel_ok
()
1179 add_context_lttng
0 -k "$@"
1182 function add_context_kernel_fail
()
1184 add_context_lttng
1 -k "$@"
1187 function trace_matches
()
1193 which $BABELTRACE_BIN >/dev
/null
1194 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1196 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1198 if [ "$count" -ne "$nr_iter" ]; then
1200 diag
"$count events found in trace"
1206 function trace_match_only
()
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)
1216 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1218 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1219 pass
"Trace match with $total event $event_name"
1222 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1226 function validate_trace
1231 which $BABELTRACE_BIN >/dev
/null
1232 if [ $?
-ne 0 ]; then
1233 skip
0 "Babeltrace binary not found. Skipping trace validation"
1238 for i
in $event_name; do
1239 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1240 if [ "$traced" -ne 0 ]; then
1241 pass
"Validate trace for event $i, $traced events"
1243 fail
"Validate trace for event $i"
1244 diag
"Found $traced occurences of $i"
1252 function validate_trace_exp
()
1257 which $BABELTRACE_BIN >/dev
/null
1258 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1260 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1261 if [ "$traced" -ne 0 ]; then
1262 pass
"Validate trace for expression '${event_exp}', $traced events"
1264 fail
"Validate trace for expression '${event_exp}'"
1265 diag
"Found $traced occurences of '${event_exp}'"
1271 function validate_trace_only_exp
()
1276 which $BABELTRACE_BIN >/dev
/null
1277 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1279 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1280 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1282 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1283 pass
"Trace match with $total for expression '${event_exp}"
1286 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1292 function validate_trace_empty
()
1296 which $BABELTRACE_BIN >/dev
/null
1297 if [ $?
-ne 0 ]; then
1298 skip
0 "Babeltrace binary not found. Skipping trace validation"
1301 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1302 if [ "$traced" -eq 0 ]; then
1303 pass
"Validate empty trace"
1305 fail
"Validate empty trace"
1306 diag
"Found $traced events in trace"