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 source $TESTDIR/utils
/tap
/tap.sh
40 # Check if we are a terminal
42 echo -e "\e[1;32mOK\e[0m"
48 function print_fail
()
50 # Check if we are a terminal
52 echo -e "\e[1;31mFAIL\e[0m"
58 function print_test_banner
()
64 function validate_kernel_version
()
66 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
67 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
70 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
73 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
79 # Generate a random string
80 # $1 = number of characters; defaults to 16
81 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
84 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
85 cat /dev
/urandom |
tr -cd "$CHAR" |
head -c ${1:-16}
89 function enable_kernel_lttng_event
91 local expected_to_fail
="$1"
94 local channel_name
="$4"
96 if [ -z "$event_name" ]; then
97 # Enable all event if no event name specified
101 if [ -z "$channel_name" ]; then
102 # default channel if none specified
105 chan
="-c $channel_name"
108 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
110 if [[ $expected_to_fail -eq "1" ]]; then
112 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
114 ok
$ret "Enable kernel event $event_name for session $sess_name"
118 function enable_kernel_lttng_event_ok
()
120 enable_kernel_lttng_event
0 "$@"
123 function enable_kernel_lttng_event_fail
()
125 enable_kernel_lttng_event
1 "$@"
129 function lttng_enable_kernel_event
131 enable_kernel_lttng_event_ok
"$@"
134 function lttng_enable_kernel_syscall
()
136 local expected_to_fail
=$1
138 local syscall_name
=$3
139 local channel_name
=$4
141 if [ -z $syscall_name ]; then
142 # Enable all event if no syscall name specified
146 if [ -z $channel_name ]; then
147 # default channel if none specified
150 chan
="-c $channel_name"
153 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
155 if [[ $expected_to_fail -eq "1" ]]; then
157 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
159 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
163 function lttng_enable_kernel_syscall_ok
()
165 lttng_enable_kernel_syscall
0 "$@"
168 function lttng_enable_kernel_syscall_fail
()
170 lttng_enable_kernel_syscall
1 "$@"
173 function lttng_disable_kernel_syscall
()
175 local expected_to_fail
=$1
177 local syscall_name
=$3
178 local channel_name
=$4
180 if [ -z $syscall_name ]; then
181 # Enable all event if no syscall name specified
185 if [ -z $channel_name ]; then
186 # default channel if none specified
189 chan
="-c $channel_name"
192 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
195 if [[ $expected_to_fail -eq "1" ]]; then
197 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
199 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
203 function lttng_disable_kernel_syscall_ok
()
205 lttng_disable_kernel_syscall
0 "$@"
208 function lttng_disable_kernel_syscall_fail
()
210 lttng_disable_kernel_syscall
1 "$@"
213 function lttng_enable_kernel_channel
()
215 local expected_to_fail
=$1
217 local channel_name
=$3
219 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
221 if [[ $expected_to_fail -eq "1" ]]; then
223 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
225 ok
$ret "Enable channel $channel_name for session $sess_name"
229 function lttng_enable_kernel_channel_ok
()
231 lttng_enable_kernel_channel
0 "$@"
234 function lttng_enable_kernel_channel_fail
()
236 lttng_enable_kernel_channel
1 "$@"
239 function lttng_disable_kernel_channel
()
241 local expected_to_fail
=$1
243 local channel_name
=$3
245 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
247 if [[ $expected_to_fail -eq "1" ]]; then
249 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
251 ok
$ret "Disable channel $channel_name for session $sess_name"
255 function lttng_disable_kernel_channel_ok
()
257 lttng_disable_kernel_channel
0 "$@"
260 function lttng_disable_kernel_channel_fail
()
262 lttng_disable_kernel_channel
1 "$@"
265 function start_lttng_relayd_opt
()
270 DIR
=$
(readlink
-f $TESTDIR)
272 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
273 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
274 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
275 if [ $?
-eq 1 ]; then
276 if [ $withtap -eq "1" ]; then
277 fail
"Start lttng-relayd (opt: $opt)"
281 if [ $withtap -eq "1" ]; then
282 pass
"Start lttng-relayd (opt: $opt)"
286 pass
"Start lttng-relayd (opt: $opt)"
290 function start_lttng_relayd
()
292 start_lttng_relayd_opt
1 "$@"
295 function start_lttng_relayd_notap
()
297 start_lttng_relayd_opt
0 "$@"
300 function stop_lttng_relayd_opt
()
304 PID_RELAYD
=`pgrep --full lt-$RELAYD_BIN`
306 if [ $withtap -eq "1" ]; then
307 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
309 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
312 if [ $?
-eq 1 ]; then
313 if [ $withtap -eq "1" ]; then
314 fail
"Kill relay daemon"
319 while [ -n "$out" ]; do
320 out
=$
(pgrep
--full lt-
$RELAYD_BIN)
323 if [ $withtap -eq "1" ]; then
324 pass
"Kill relay daemon"
330 function stop_lttng_relayd
()
332 stop_lttng_relayd_opt
1 "$@"
335 function stop_lttng_relayd_notap
()
337 stop_lttng_relayd_opt
0 "$@"
340 #First arg: show tap output
341 #Second argument: load path for automatic loading
342 function start_lttng_sessiond_opt
()
347 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
348 # Env variable requested no session daemon
352 validate_kernel_version
353 if [ $?
-ne 0 ]; then
354 fail
"Start session daemon"
355 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
358 DIR
=$
(readlink
-f $TESTDIR)
359 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
360 export LTTNG_SESSION_CONFIG_XSD_PATH
362 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
364 if [ -n "$load_path" ]; then
365 $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --load "$1" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
367 $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"
369 #$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
371 if [ $withtap -eq "1" ]; then
372 ok
$status "Start session daemon"
377 function start_lttng_sessiond
()
379 start_lttng_sessiond_opt
1 "$@"
382 function start_lttng_sessiond_notap
()
384 start_lttng_sessiond_opt
0 "$@"
387 function stop_lttng_sessiond_opt
()
393 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
394 # Env variable requested no session daemon
398 PID_SESSIOND
=`pgrep --full lt-$SESSIOND_BIN`
401 kill_opt
="$kill_opt -s $signal"
404 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
406 if [ $?
-eq 1 ]; then
407 if [ $withtap -eq "1" ]; then
408 fail
"Kill sessions daemon"
412 while [ -n "$out" ]; do
413 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
417 while [ -n "$out" ]; do
418 out
=$
(pgrep
--full $CONSUMERD_BIN)
421 if [ $withtap -eq "1" ]; then
422 pass
"Kill session daemon"
427 function stop_lttng_sessiond
()
429 stop_lttng_sessiond_opt
1 "$@"
432 function stop_lttng_sessiond_notap
()
434 stop_lttng_sessiond_opt
0 "$@"
437 function stop_lttng_consumerd_opt
()
443 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
446 kill_opt
="$kill_opt -s $signal"
449 if [ $withtap -eq "1" ]; then
450 diag
"Killing lttng-consumerd (pid: $PID_CONSUMERD)"
452 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
456 if [ $?
-eq 1 ]; then
457 if [ $withtap -eq "1" ]; then
458 fail
"Kill consumer daemon"
463 while [ $out -ne 0 ]; do
464 pid
=$
(pgrep
--full $CONSUMERD_BIN)
466 # If consumerds are still present check their status.
467 # A zombie status qualifies the consumerd as *killed*
469 for consumer_pid
in $pid; do
470 state
=$
(ps
-p $consumer_pid -o state
= )
471 if [[ -n "$state" && "$state" != "Z" ]]; then
477 if [ $withtap -eq "1" ]; then
478 pass
"Kill consumer daemon"
484 function stop_lttng_consumerd
()
486 stop_lttng_consumerd_opt
1 "$@"
489 function stop_lttng_consumerd_notap
()
491 stop_lttng_consumerd_opt
0 "$@"
494 function list_lttng_with_opts
()
497 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
498 ok $?
"Lttng-tool list command with option $opts"
501 function create_lttng_session_no_output
()
505 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
506 ok $?
"Create session $sess_name in no-output mode"
509 function create_lttng_session
()
511 local expected_to_fail
=$1
516 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
518 if [[ $expected_to_fail -eq "1" ]]; then
520 ok $?
"Create session $sess_name in $trace_path failed as expected"
522 ok
$ret "Create session $sess_name in $trace_path"
526 function create_lttng_session_ok
()
528 create_lttng_session
0 "$@"
531 function create_lttng_session_fail
()
533 create_lttng_session
1 "$@"
537 function enable_ust_lttng_channel
()
539 local expected_to_fail
=$1
541 local channel_name
=$3
544 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
546 if [[ $expected_to_fail -eq "1" ]]; then
548 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
550 ok
$ret "Enable channel $channel_name for session $sess_name"
554 function enable_ust_lttng_channel_ok
()
556 enable_ust_lttng_channel
0 "$@"
559 function enable_ust_lttng_channel_fail
()
561 enable_ust_lttng_channel
1 "$@"
564 function disable_ust_lttng_channel
()
567 local channel_name
=$2
569 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
570 ok $?
"Disable channel $channel_name for session $sess_name"
573 function enable_lttng_mmap_overwrite_kernel_channel
()
576 local channel_name
=$2
578 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
579 ok $?
"Enable channel $channel_name for session $sess_name"
582 function enable_lttng_mmap_overwrite_ust_channel
()
585 local channel_name
=$2
587 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
588 ok $?
"Enable channel $channel_name for session $sess_name"
591 function enable_ust_lttng_event
()
593 local expected_to_fail
=$1
595 local event_name
="$3"
596 local channel_name
=$4
598 if [ -z $channel_name ]; then
599 # default channel if none specified
602 chan
="-c $channel_name"
605 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
607 if [[ $expected_to_fail -eq "1" ]]; then
609 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
611 ok
$ret "Enable ust event $event_name for session $sess_name"
615 function enable_ust_lttng_event_ok
()
617 enable_ust_lttng_event
0 "$@"
620 function enable_ust_lttng_event_fail
()
622 enable_ust_lttng_event
1 "$@"
625 function enable_jul_lttng_event
()
631 if [ -z $channel_name ]; then
632 # default channel if none specified
635 chan
="-c $channel_name"
638 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
639 ok $?
"Enable JUL event $event_name for session $sess_name"
642 function enable_jul_lttng_event_loglevel
()
645 local event_name
="$2"
647 local channel_name
=$4
649 if [ -z $channel_name ]; then
650 # default channel if none specified
653 chan
="-c $channel_name"
656 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
657 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
660 function enable_log4j_lttng_event
()
666 if [ -z $channel_name ]; then
667 # default channel if none specified
670 chan
="-c $channel_name"
673 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
674 ok $?
"Enable LOG4J event $event_name for session $sess_name"
677 function enable_log4j_lttng_event_loglevel
()
680 local event_name
="$2"
682 local channel_name
=$4
684 if [ -z $channel_name ]; then
685 # default channel if none specified
688 chan
="-c $channel_name"
691 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
692 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
695 function enable_python_lttng_event
()
701 if [ -z $channel_name ]; then
702 # default channel if none specified
705 chan
="-c $channel_name"
708 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
709 ok $?
"Enable Python event $event_name for session $sess_name"
712 function enable_python_lttng_event_loglevel
()
715 local event_name
="$2"
717 local channel_name
=$4
719 if [ -z $channel_name ]; then
720 # default channel if none specified
723 chan
="-c $channel_name"
726 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
727 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
730 function enable_ust_lttng_event_filter
()
733 local event_name
="$2"
736 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
737 ok $?
"Enable event $event_name with filtering for session $sess_name"
740 function enable_ust_lttng_event_loglevel
()
743 local event_name
="$2"
746 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
747 ok $?
"Enable event $event_name with loglevel $loglevel"
750 function enable_ust_lttng_event_loglevel_only
()
753 local event_name
="$2"
756 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
757 ok $?
"Enable event $event_name with loglevel-only $loglevel"
760 function disable_ust_lttng_event
()
763 local event_name
="$2"
764 local channel_name
="$3"
766 if [ -z $channel_name ]; then
767 # default channel if none specified
770 chan
="-c $channel_name"
773 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
774 ok $?
"Disable event $event_name for session $sess_name"
777 function disable_jul_lttng_event
()
780 local event_name
="$2"
782 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
783 ok $?
"Disable JUL event $event_name for session $sess_name"
786 function disable_log4j_lttng_event
()
789 local event_name
="$2"
791 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
792 ok $?
"Disable LOG4J event $event_name for session $sess_name"
795 function disable_python_lttng_event
()
798 local event_name
="$2"
800 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
801 ok $?
"Disable Python event $event_name for session $sess_name"
804 function start_lttng_tracing
()
806 local expected_to_fail
=$1
809 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
811 if [[ $expected_to_fail -eq "1" ]]; then
813 ok $?
"Start tracing for session $sess_name failed as expected"
815 ok
$ret "Start tracing for session $sess_name"
819 function start_lttng_tracing_ok
()
821 start_lttng_tracing
0 "$@"
824 function start_lttng_tracing_fail
()
826 start_lttng_tracing
1 "$@"
829 function stop_lttng_tracing
()
831 local expected_to_fail
=$1
834 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
836 if [[ $expected_to_fail -eq "1" ]]; then
838 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
840 ok
$ret "Stop lttng tracing for session $sess_name"
844 function stop_lttng_tracing_ok
()
846 stop_lttng_tracing
0 "$@"
849 function stop_lttng_tracing_fail
()
851 stop_lttng_tracing
1 "$@"
854 function destroy_lttng_session
()
856 local expected_to_fail
=$1
859 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
861 if [[ $expected_to_fail -eq "1" ]]; then
863 ok $?
"Destroy session $sess_name failed as expected"
865 ok
$ret "Destroy session $sess_name"
869 function destroy_lttng_session_ok
()
871 destroy_lttng_session
0 "$@"
875 function destroy_lttng_session_fail
()
877 destroy_lttng_session
1 "$@"
881 function destroy_lttng_sessions
()
883 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
884 ok $?
"Destroy all lttng sessions"
887 function lttng_snapshot_add_output
()
889 local expected_to_fail
=$1
893 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
895 if [[ $expected_to_fail -eq 1 ]]; then
897 ok $?
"Added snapshot output file://$trace_path failed as expected"
899 ok
$ret "Added snapshot output file://$trace_path"
903 function lttng_snapshot_add_output_ok
()
905 lttng_snapshot_add_output
0 "$@"
908 function lttng_snapshot_add_output_fail
()
910 lttng_snapshot_add_output
1 "$@"
913 function lttng_snapshot_del_output
()
915 local expected_to_fail
=$1
919 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
921 if [[ $expected_to_fail -eq "1" ]]; then
923 ok $?
"Deleted snapshot output id $id failed as expected"
925 ok
$ret "Deleted snapshot output id $id"
929 function lttng_snapshot_del_output_ok
()
931 lttng_snapshot_del_output
0 "$@"
934 function lttng_snapshot_del_output_fail
()
936 lttng_snapshot_del_output
1 "$@"
939 function lttng_snapshot_record
()
944 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
945 ok $?
"Snapshot recorded"
948 function lttng_snapshot_list
()
951 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
952 ok $?
"Snapshot list"
955 function lttng_save
()
960 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
961 ok $?
"Session saved"
964 function lttng_load
()
968 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
969 ok $?
"Load command with opts: $opts"
972 function lttng_track
()
974 local expected_to_fail
=$1
976 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
978 if [[ $expected_to_fail -eq "1" ]]; then
980 ok $?
"Track command failed as expected with opts: $opts"
982 ok
$ret "Track command with opts: $opts"
986 function lttng_track_ok
()
991 function lttng_track_fail
()
996 function lttng_untrack
()
998 local expected_to_fail
=$1
1000 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1002 if [[ $expected_to_fail -eq "1" ]]; then
1004 ok $?
"Untrack command failed as expected with opts: $opts"
1006 ok
$ret "Untrack command with opts: $opts"
1010 function lttng_untrack_ok
()
1012 lttng_untrack
0 "$@"
1015 function lttng_untrack_fail
()
1017 lttng_untrack
1 "$@"
1020 function add_context_lttng
()
1022 local expected_to_fail
="$1"
1024 local session_name
="$3"
1025 local channel_name
="$4"
1028 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1030 if [[ $expected_to_fail -eq "1" ]]; then
1032 ok $?
"Add context command failed as expected for type: $type"
1034 ok
$ret "Add context command for type: $type"
1038 function add_context_ust_ok
()
1040 add_context_lttng
0 -u "$@"
1043 function add_context_ust_fail
()
1045 add_context_lttng
1 -u "$@"
1048 function add_context_kernel_ok
()
1050 add_context_lttng
0 -k "$@"
1053 function add_context_kernel_fail
()
1055 add_context_lttng
1 -k "$@"
1058 function trace_matches
()
1064 which $BABELTRACE_BIN >/dev
/null
1065 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1067 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1069 if [ "$count" -ne "$nr_iter" ]; then
1071 diag
"$count events found in trace"
1077 function trace_match_only
()
1083 which $BABELTRACE_BIN >/dev
/null
1084 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1086 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1087 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1089 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1090 pass
"Trace match with $total event $event_name"
1093 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1097 function validate_trace
1102 which $BABELTRACE_BIN >/dev
/null
1103 if [ $?
-ne 0 ]; then
1104 skip
0 "Babeltrace binary not found. Skipping trace validation"
1109 for i
in $event_name; do
1110 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1111 if [ "$traced" -ne 0 ]; then
1112 pass
"Validate trace for event $i, $traced events"
1114 fail
"Validate trace for event $i"
1115 diag
"Found $traced occurences of $i"
1123 function validate_trace_exp
()
1128 which $BABELTRACE_BIN >/dev
/null
1129 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1131 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1132 if [ "$traced" -ne 0 ]; then
1133 pass
"Validate trace for expression '${event_exp}', $traced events"
1135 fail
"Validate trace for expression '${event_exp}'"
1136 diag
"Found $traced occurences of '${event_exp}'"
1142 function validate_trace_only_exp
()
1147 which $BABELTRACE_BIN >/dev
/null
1148 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1150 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1151 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1153 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1154 pass
"Trace match with $total for expression '${event_exp}"
1157 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1163 function validate_trace_empty
()
1167 which $BABELTRACE_BIN >/dev
/null
1168 if [ $?
-ne 0 ]; then
1169 skip
0 "Babeltrace binary not found. Skipping trace validation"
1172 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1173 if [ "$traced" -eq 0 ]; then
1174 pass
"Validate empty trace"
1176 fail
"Validate empty trace"
1177 diag
"Found $traced events in trace"