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 and network and app socket timeout to
33 # "wait forever", so that basic tests don't have to worry about hitting
34 # timeouts on busy systems. Specialized tests should test those corner-cases.
35 export LTTNG_UST_REGISTER_TIMEOUT
=-1
36 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
37 export LTTNG_APP_SOCKET_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
49 # Check if we are a terminal
51 echo -e "\e[1;32mOK\e[0m"
57 function print_fail
()
59 # Check if we are a terminal
61 echo -e "\e[1;31mFAIL\e[0m"
67 function print_test_banner
()
73 function validate_kernel_version
()
75 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
76 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
79 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
82 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
88 # Generate a random string
89 # $1 = number of characters; defaults to 16
90 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
93 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
94 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
98 # Return the number of _configured_ CPUs.
99 function conf_proc_count
()
101 getconf _NPROCESSORS_CONF
102 if [ $?
-ne 0 ]; then
103 diag
"Failed to get the number of configured CPUs"
108 function enable_kernel_lttng_event
110 local expected_to_fail
="$1"
112 local event_name
="$3"
113 local channel_name
="$4"
115 if [ -z "$event_name" ]; then
116 # Enable all event if no event name specified
120 if [ -z "$channel_name" ]; then
121 # default channel if none specified
124 chan
="-c $channel_name"
127 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
129 if [[ $expected_to_fail -eq "1" ]]; then
131 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
133 ok
$ret "Enable kernel event $event_name for session $sess_name"
137 function enable_kernel_lttng_event_ok
()
139 enable_kernel_lttng_event
0 "$@"
142 function enable_kernel_lttng_event_fail
()
144 enable_kernel_lttng_event
1 "$@"
148 function lttng_enable_kernel_event
150 enable_kernel_lttng_event_ok
"$@"
153 function lttng_enable_kernel_syscall
()
155 local expected_to_fail
=$1
157 local syscall_name
=$3
158 local channel_name
=$4
160 if [ -z $syscall_name ]; then
161 # Enable all event if no syscall name specified
165 if [ -z $channel_name ]; then
166 # default channel if none specified
169 chan
="-c $channel_name"
172 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
174 if [[ $expected_to_fail -eq "1" ]]; then
176 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
178 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
182 function lttng_enable_kernel_syscall_ok
()
184 lttng_enable_kernel_syscall
0 "$@"
187 function lttng_enable_kernel_syscall_fail
()
189 lttng_enable_kernel_syscall
1 "$@"
192 function lttng_disable_kernel_syscall
()
194 local expected_to_fail
=$1
196 local syscall_name
=$3
197 local channel_name
=$4
199 if [ -z $syscall_name ]; then
200 # Enable all event if no syscall name specified
204 if [ -z $channel_name ]; then
205 # default channel if none specified
208 chan
="-c $channel_name"
211 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
214 if [[ $expected_to_fail -eq "1" ]]; then
216 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
218 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
222 function lttng_disable_kernel_syscall_ok
()
224 lttng_disable_kernel_syscall
0 "$@"
227 function lttng_disable_kernel_syscall_fail
()
229 lttng_disable_kernel_syscall
1 "$@"
232 function lttng_enable_kernel_channel
()
234 local expected_to_fail
=$1
236 local channel_name
=$3
238 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
240 if [[ $expected_to_fail -eq "1" ]]; then
242 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
244 ok
$ret "Enable channel $channel_name for session $sess_name"
248 function lttng_enable_kernel_channel_ok
()
250 lttng_enable_kernel_channel
0 "$@"
253 function lttng_enable_kernel_channel_fail
()
255 lttng_enable_kernel_channel
1 "$@"
258 function lttng_disable_kernel_channel
()
260 local expected_to_fail
=$1
262 local channel_name
=$3
264 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
266 if [[ $expected_to_fail -eq "1" ]]; then
268 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
270 ok
$ret "Disable channel $channel_name for session $sess_name"
274 function lttng_disable_kernel_channel_ok
()
276 lttng_disable_kernel_channel
0 "$@"
279 function lttng_disable_kernel_channel_fail
()
281 lttng_disable_kernel_channel
1 "$@"
284 function start_lttng_relayd_opt
()
289 DIR
=$
(readlink
-f $TESTDIR)
291 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
292 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
293 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
294 if [ $?
-eq 1 ]; then
295 if [ $withtap -eq "1" ]; then
296 fail
"Start lttng-relayd (opt: $opt)"
300 if [ $withtap -eq "1" ]; then
301 pass
"Start lttng-relayd (opt: $opt)"
305 pass
"Start lttng-relayd (opt: $opt)"
309 function start_lttng_relayd
()
311 start_lttng_relayd_opt
1 "$@"
314 function start_lttng_relayd_notap
()
316 start_lttng_relayd_opt
0 "$@"
319 function stop_lttng_relayd_opt
()
323 PID_RELAYD
=`pgrep --full lt-$RELAYD_BIN`
325 if [ $withtap -eq "1" ]; then
326 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
328 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
331 if [ $?
-eq 1 ]; then
332 if [ $withtap -eq "1" ]; then
333 fail
"Kill relay daemon"
338 while [ -n "$out" ]; do
339 out
=$
(pgrep
--full lt-
$RELAYD_BIN)
342 if [ $withtap -eq "1" ]; then
343 pass
"Kill relay daemon"
349 function stop_lttng_relayd
()
351 stop_lttng_relayd_opt
1 "$@"
354 function stop_lttng_relayd_notap
()
356 stop_lttng_relayd_opt
0 "$@"
359 #First arg: show tap output
360 #Second argument: load path for automatic loading
361 function start_lttng_sessiond_opt
()
366 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
367 # Env variable requested no session daemon
371 validate_kernel_version
372 if [ $?
-ne 0 ]; then
373 fail
"Start session daemon"
374 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
377 DIR
=$
(readlink
-f $TESTDIR)
378 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
379 export LTTNG_SESSION_CONFIG_XSD_PATH
381 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
383 if [ -n "$load_path" ]; then
384 $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"
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"
388 #$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
390 if [ $withtap -eq "1" ]; then
391 ok
$status "Start session daemon"
396 function start_lttng_sessiond
()
398 start_lttng_sessiond_opt
1 "$@"
401 function start_lttng_sessiond_notap
()
403 start_lttng_sessiond_opt
0 "$@"
406 function stop_lttng_sessiond_opt
()
412 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
413 # Env variable requested no session daemon
417 PID_SESSIOND
="$(pgrep --full lt-$SESSIOND_BIN) $(pgrep --full $RUNAS_BIN)"
420 kill_opt
="$kill_opt -s $signal"
422 if [ $withtap -eq "1" ]; then
423 diag
"Killing lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
425 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
427 if [ $?
-eq 1 ]; then
428 if [ $withtap -eq "1" ]; then
429 fail
"Kill sessions daemon"
433 while [ -n "$out" ]; do
434 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
438 while [ -n "$out" ]; do
439 out
=$
(pgrep
--full $CONSUMERD_BIN)
442 if [ $withtap -eq "1" ]; then
443 pass
"Kill session daemon"
448 function stop_lttng_sessiond
()
450 stop_lttng_sessiond_opt
1 "$@"
453 function stop_lttng_sessiond_notap
()
455 stop_lttng_sessiond_opt
0 "$@"
458 function sigstop_lttng_sessiond_opt
()
464 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
465 # Env variable requested no session daemon
469 PID_SESSIOND
="$(pgrep --full lt-$SESSIOND_BIN) $(pgrep --full $RUNAS_BIN)"
471 kill_opt
="$kill_opt -s $signal"
473 if [ $withtap -eq "1" ]; then
474 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
476 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
478 if [ $?
-eq 1 ]; then
479 if [ $withtap -eq "1" ]; then
480 fail
"Sending SIGSTOP to session daemon"
484 while [ $out -ne 0 ]; do
485 pid
=$
(pgrep
--full lt-
$SESSIOND_BIN)
487 # Wait until state becomes stopped for session
490 for sessiond_pid
in $pid; do
491 state
=$
(ps
-p $sessiond_pid -o state
= )
492 if [[ -n "$state" && "$state" != "T" ]]; then
498 if [ $withtap -eq "1" ]; then
499 pass
"Sending SIGSTOP to session daemon"
504 function sigstop_lttng_sessiond
()
506 sigstop_lttng_sessiond_opt
1 "$@"
509 function sigstop_lttng_sessiond_notap
()
511 sigstop_lttng_sessiond_opt
0 "$@"
514 function stop_lttng_consumerd_opt
()
520 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
523 kill_opt
="$kill_opt -s $signal"
526 if [ $withtap -eq "1" ]; then
527 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
529 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
533 if [ $?
-eq 1 ]; then
534 if [ $withtap -eq "1" ]; then
535 fail
"Kill consumer daemon"
540 while [ $out -ne 0 ]; do
541 pid
=$
(pgrep
--full $CONSUMERD_BIN)
543 # If consumerds are still present check their status.
544 # A zombie status qualifies the consumerd as *killed*
546 for consumer_pid
in $pid; do
547 state
=$
(ps
-p $consumer_pid -o state
= )
548 if [[ -n "$state" && "$state" != "Z" ]]; then
554 if [ $withtap -eq "1" ]; then
555 pass
"Kill consumer daemon"
561 function stop_lttng_consumerd
()
563 stop_lttng_consumerd_opt
1 "$@"
566 function stop_lttng_consumerd_notap
()
568 stop_lttng_consumerd_opt
0 "$@"
571 function sigstop_lttng_consumerd_opt
()
577 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
579 kill_opt
="$kill_opt -s $signal"
581 if [ $withtap -eq "1" ]; then
582 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
584 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
588 if [ $?
-eq 1 ]; then
589 if [ $withtap -eq "1" ]; then
590 fail
"Sending SIGSTOP to consumer daemon"
595 while [ $out -ne 0 ]; do
596 pid
=$
(pgrep
--full $CONSUMERD_BIN)
598 # Wait until state becomes stopped for all
601 for consumer_pid
in $pid; do
602 state
=$
(ps
-p $consumer_pid -o state
= )
603 if [[ -n "$state" && "$state" != "T" ]]; then
609 if [ $withtap -eq "1" ]; then
610 pass
"Sending SIGSTOP to consumer daemon"
616 function sigstop_lttng_consumerd
()
618 sigstop_lttng_consumerd_opt
1 "$@"
621 function sigstop_lttng_consumerd_notap
()
623 sigstop_lttng_consumerd_opt
0 "$@"
626 function list_lttng_with_opts
()
629 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
630 ok $?
"Lttng-tool list command with option $opts"
633 function create_lttng_session_no_output
()
637 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
638 ok $?
"Create session $sess_name in no-output mode"
641 function create_lttng_session
()
643 local expected_to_fail
=$1
648 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
650 if [[ $expected_to_fail -eq "1" ]]; then
652 ok $?
"Create session $sess_name in $trace_path failed as expected"
654 ok
$ret "Create session $sess_name in $trace_path"
658 function create_lttng_session_ok
()
660 create_lttng_session
0 "$@"
663 function create_lttng_session_fail
()
665 create_lttng_session
1 "$@"
669 function enable_ust_lttng_channel
()
671 local expected_to_fail
=$1
673 local channel_name
=$3
676 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
678 if [[ $expected_to_fail -eq "1" ]]; then
680 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
682 ok
$ret "Enable channel $channel_name for session $sess_name"
686 function enable_ust_lttng_channel_ok
()
688 enable_ust_lttng_channel
0 "$@"
691 function enable_ust_lttng_channel_fail
()
693 enable_ust_lttng_channel
1 "$@"
696 function disable_ust_lttng_channel
()
699 local channel_name
=$2
701 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
702 ok $?
"Disable channel $channel_name for session $sess_name"
705 function enable_lttng_mmap_overwrite_kernel_channel
()
708 local channel_name
=$2
710 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
711 ok $?
"Enable channel $channel_name for session $sess_name"
714 function enable_lttng_mmap_overwrite_ust_channel
()
717 local channel_name
=$2
719 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
720 ok $?
"Enable channel $channel_name for session $sess_name"
723 function enable_ust_lttng_event
()
725 local expected_to_fail
=$1
727 local event_name
="$3"
728 local channel_name
=$4
730 if [ -z $channel_name ]; then
731 # default channel if none specified
734 chan
="-c $channel_name"
737 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
739 if [[ $expected_to_fail -eq "1" ]]; then
741 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
743 ok
$ret "Enable ust event $event_name for session $sess_name"
747 function enable_ust_lttng_event_ok
()
749 enable_ust_lttng_event
0 "$@"
752 function enable_ust_lttng_event_fail
()
754 enable_ust_lttng_event
1 "$@"
757 function enable_jul_lttng_event
()
763 if [ -z $channel_name ]; then
764 # default channel if none specified
767 chan
="-c $channel_name"
770 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
771 ok $?
"Enable JUL event $event_name for session $sess_name"
774 function enable_jul_lttng_event_loglevel
()
777 local event_name
="$2"
779 local channel_name
=$4
781 if [ -z $channel_name ]; then
782 # default channel if none specified
785 chan
="-c $channel_name"
788 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
789 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
792 function enable_log4j_lttng_event
()
798 if [ -z $channel_name ]; then
799 # default channel if none specified
802 chan
="-c $channel_name"
805 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
806 ok $?
"Enable LOG4J event $event_name for session $sess_name"
809 function enable_log4j_lttng_event_loglevel
()
812 local event_name
="$2"
814 local channel_name
=$4
816 if [ -z $channel_name ]; then
817 # default channel if none specified
820 chan
="-c $channel_name"
823 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
824 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
827 function enable_python_lttng_event
()
833 if [ -z $channel_name ]; then
834 # default channel if none specified
837 chan
="-c $channel_name"
840 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
841 ok $?
"Enable Python event $event_name for session $sess_name"
844 function enable_python_lttng_event_loglevel
()
847 local event_name
="$2"
849 local channel_name
=$4
851 if [ -z $channel_name ]; then
852 # default channel if none specified
855 chan
="-c $channel_name"
858 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
859 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
862 function enable_ust_lttng_event_filter
()
865 local event_name
="$2"
868 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
869 ok $?
"Enable event $event_name with filtering for session $sess_name"
872 function enable_ust_lttng_event_loglevel
()
875 local event_name
="$2"
878 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
879 ok $?
"Enable event $event_name with loglevel $loglevel"
882 function enable_ust_lttng_event_loglevel_only
()
885 local event_name
="$2"
888 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
889 ok $?
"Enable event $event_name with loglevel-only $loglevel"
892 function disable_ust_lttng_event
()
895 local event_name
="$2"
896 local channel_name
="$3"
898 if [ -z $channel_name ]; then
899 # default channel if none specified
902 chan
="-c $channel_name"
905 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
906 ok $?
"Disable event $event_name for session $sess_name"
909 function disable_jul_lttng_event
()
912 local event_name
="$2"
914 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
915 ok $?
"Disable JUL event $event_name for session $sess_name"
918 function disable_log4j_lttng_event
()
921 local event_name
="$2"
923 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
924 ok $?
"Disable LOG4J event $event_name for session $sess_name"
927 function disable_python_lttng_event
()
930 local event_name
="$2"
932 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
933 ok $?
"Disable Python event $event_name for session $sess_name"
936 function start_lttng_tracing
()
938 local expected_to_fail
=$1
941 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
943 if [[ $expected_to_fail -eq "1" ]]; then
945 ok $?
"Start tracing for session $sess_name failed as expected"
947 ok
$ret "Start tracing for session $sess_name"
951 function start_lttng_tracing_ok
()
953 start_lttng_tracing
0 "$@"
956 function start_lttng_tracing_fail
()
958 start_lttng_tracing
1 "$@"
961 function stop_lttng_tracing
()
963 local expected_to_fail
=$1
966 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
968 if [[ $expected_to_fail -eq "1" ]]; then
970 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
972 ok
$ret "Stop lttng tracing for session $sess_name"
976 function stop_lttng_tracing_ok
()
978 stop_lttng_tracing
0 "$@"
981 function stop_lttng_tracing_fail
()
983 stop_lttng_tracing
1 "$@"
986 function destroy_lttng_session
()
988 local expected_to_fail
=$1
991 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
993 if [[ $expected_to_fail -eq "1" ]]; then
995 ok $?
"Destroy session $sess_name failed as expected"
997 ok
$ret "Destroy session $sess_name"
1001 function destroy_lttng_session_ok
()
1003 destroy_lttng_session
0 "$@"
1007 function destroy_lttng_session_fail
()
1009 destroy_lttng_session
1 "$@"
1013 function destroy_lttng_sessions
()
1015 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1016 ok $?
"Destroy all lttng sessions"
1019 function lttng_snapshot_add_output
()
1021 local expected_to_fail
=$1
1025 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1027 if [[ $expected_to_fail -eq 1 ]]; then
1029 ok $?
"Added snapshot output file://$trace_path failed as expected"
1031 ok
$ret "Added snapshot output file://$trace_path"
1035 function lttng_snapshot_add_output_ok
()
1037 lttng_snapshot_add_output
0 "$@"
1040 function lttng_snapshot_add_output_fail
()
1042 lttng_snapshot_add_output
1 "$@"
1045 function lttng_snapshot_del_output
()
1047 local expected_to_fail
=$1
1051 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1053 if [[ $expected_to_fail -eq "1" ]]; then
1055 ok $?
"Deleted snapshot output id $id failed as expected"
1057 ok
$ret "Deleted snapshot output id $id"
1061 function lttng_snapshot_del_output_ok
()
1063 lttng_snapshot_del_output
0 "$@"
1066 function lttng_snapshot_del_output_fail
()
1068 lttng_snapshot_del_output
1 "$@"
1071 function lttng_snapshot_record
()
1076 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1077 ok $?
"Snapshot recorded"
1080 function lttng_snapshot_list
()
1083 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1084 ok $?
"Snapshot list"
1087 function lttng_save
()
1092 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1093 ok $?
"Session saved"
1096 function lttng_load
()
1100 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1101 ok $?
"Load command with opts: $opts"
1104 function lttng_track
()
1106 local expected_to_fail
=$1
1108 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1110 if [[ $expected_to_fail -eq "1" ]]; then
1112 ok $?
"Track command failed as expected with opts: $opts"
1114 ok
$ret "Track command with opts: $opts"
1118 function lttng_track_ok
()
1123 function lttng_track_fail
()
1128 function lttng_untrack
()
1130 local expected_to_fail
=$1
1132 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1134 if [[ $expected_to_fail -eq "1" ]]; then
1136 ok $?
"Untrack command failed as expected with opts: $opts"
1138 ok
$ret "Untrack command with opts: $opts"
1142 function lttng_untrack_ok
()
1144 lttng_untrack
0 "$@"
1147 function lttng_untrack_fail
()
1149 lttng_untrack
1 "$@"
1152 function add_context_lttng
()
1154 local expected_to_fail
="$1"
1156 local session_name
="$3"
1157 local channel_name
="$4"
1160 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1162 if [[ $expected_to_fail -eq "1" ]]; then
1164 ok $?
"Add context command failed as expected for type: $type"
1166 ok
$ret "Add context command for type: $type"
1170 function add_context_ust_ok
()
1172 add_context_lttng
0 -u "$@"
1175 function add_context_ust_fail
()
1177 add_context_lttng
1 -u "$@"
1180 function add_context_kernel_ok
()
1182 add_context_lttng
0 -k "$@"
1185 function add_context_kernel_fail
()
1187 add_context_lttng
1 -k "$@"
1190 function trace_matches
()
1196 which $BABELTRACE_BIN >/dev
/null
1197 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1199 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1201 if [ "$count" -ne "$nr_iter" ]; then
1203 diag
"$count matching events found in trace"
1209 function trace_match_only
()
1215 which $BABELTRACE_BIN >/dev
/null
1216 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1218 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1219 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1221 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1222 pass
"Trace match with $total event $event_name"
1225 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1229 function validate_trace
1234 which $BABELTRACE_BIN >/dev
/null
1235 if [ $?
-ne 0 ]; then
1236 skip
0 "Babeltrace binary not found. Skipping trace validation"
1241 for i
in $event_name; do
1242 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1243 if [ "$traced" -ne 0 ]; then
1244 pass
"Validate trace for event $i, $traced events"
1246 fail
"Validate trace for event $i"
1247 diag
"Found $traced occurences of $i"
1255 function validate_trace_exp
()
1260 which $BABELTRACE_BIN >/dev
/null
1261 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1263 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1264 if [ "$traced" -ne 0 ]; then
1265 pass
"Validate trace for expression '${event_exp}', $traced events"
1267 fail
"Validate trace for expression '${event_exp}'"
1268 diag
"Found $traced occurences of '${event_exp}'"
1274 function validate_trace_only_exp
()
1279 which $BABELTRACE_BIN >/dev
/null
1280 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1282 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1283 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1285 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1286 pass
"Trace match with $total for expression '${event_exp}"
1289 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1295 function validate_trace_empty
()
1299 which $BABELTRACE_BIN >/dev
/null
1300 if [ $?
-ne 0 ]; then
1301 skip
0 "Babeltrace binary not found. Skipping trace validation"
1304 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1305 if [ "$traced" -eq 0 ]; then
1306 pass
"Validate empty trace"
1308 fail
"Validate empty trace"
1309 diag
"Found $traced events in trace"