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"
420 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
422 if [ $?
-eq 1 ]; then
423 if [ $withtap -eq "1" ]; then
424 fail
"Kill sessions daemon"
428 while [ -n "$out" ]; do
429 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
433 while [ -n "$out" ]; do
434 out
=$
(pgrep
--full $CONSUMERD_BIN)
437 if [ $withtap -eq "1" ]; then
438 pass
"Kill session daemon"
443 function stop_lttng_sessiond
()
445 stop_lttng_sessiond_opt
1 "$@"
448 function stop_lttng_sessiond_notap
()
450 stop_lttng_sessiond_opt
0 "$@"
453 function stop_lttng_consumerd_opt
()
459 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
462 kill_opt
="$kill_opt -s $signal"
465 if [ $withtap -eq "1" ]; then
466 diag
"Killing lttng-consumerd (pid: $PID_CONSUMERD)"
468 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
472 if [ $?
-eq 1 ]; then
473 if [ $withtap -eq "1" ]; then
474 fail
"Kill consumer daemon"
479 while [ $out -ne 0 ]; do
480 pid
=$
(pgrep
--full $CONSUMERD_BIN)
482 # If consumerds are still present check their status.
483 # A zombie status qualifies the consumerd as *killed*
485 for consumer_pid
in $pid; do
486 state
=$
(ps
-p $consumer_pid -o state
= )
487 if [[ -n "$state" && "$state" != "Z" ]]; then
493 if [ $withtap -eq "1" ]; then
494 pass
"Kill consumer daemon"
500 function stop_lttng_consumerd
()
502 stop_lttng_consumerd_opt
1 "$@"
505 function stop_lttng_consumerd_notap
()
507 stop_lttng_consumerd_opt
0 "$@"
510 function list_lttng_with_opts
()
513 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
514 ok $?
"Lttng-tool list command with option $opts"
517 function create_lttng_session_no_output
()
521 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
522 ok $?
"Create session $sess_name in no-output mode"
525 function create_lttng_session
()
527 local expected_to_fail
=$1
532 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
534 if [[ $expected_to_fail -eq "1" ]]; then
536 ok $?
"Create session $sess_name in $trace_path failed as expected"
538 ok
$ret "Create session $sess_name in $trace_path"
542 function create_lttng_session_ok
()
544 create_lttng_session
0 "$@"
547 function create_lttng_session_fail
()
549 create_lttng_session
1 "$@"
553 function enable_ust_lttng_channel
()
555 local expected_to_fail
=$1
557 local channel_name
=$3
560 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
562 if [[ $expected_to_fail -eq "1" ]]; then
564 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
566 ok
$ret "Enable channel $channel_name for session $sess_name"
570 function enable_ust_lttng_channel_ok
()
572 enable_ust_lttng_channel
0 "$@"
575 function enable_ust_lttng_channel_fail
()
577 enable_ust_lttng_channel
1 "$@"
580 function disable_ust_lttng_channel
()
583 local channel_name
=$2
585 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
586 ok $?
"Disable channel $channel_name for session $sess_name"
589 function enable_lttng_mmap_overwrite_kernel_channel
()
592 local channel_name
=$2
594 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
595 ok $?
"Enable channel $channel_name for session $sess_name"
598 function enable_lttng_mmap_overwrite_ust_channel
()
601 local channel_name
=$2
603 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
604 ok $?
"Enable channel $channel_name for session $sess_name"
607 function enable_ust_lttng_event
()
609 local expected_to_fail
=$1
611 local event_name
="$3"
612 local channel_name
=$4
614 if [ -z $channel_name ]; then
615 # default channel if none specified
618 chan
="-c $channel_name"
621 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
623 if [[ $expected_to_fail -eq "1" ]]; then
625 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
627 ok
$ret "Enable ust event $event_name for session $sess_name"
631 function enable_ust_lttng_event_ok
()
633 enable_ust_lttng_event
0 "$@"
636 function enable_ust_lttng_event_fail
()
638 enable_ust_lttng_event
1 "$@"
641 function enable_jul_lttng_event
()
647 if [ -z $channel_name ]; then
648 # default channel if none specified
651 chan
="-c $channel_name"
654 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
655 ok $?
"Enable JUL event $event_name for session $sess_name"
658 function enable_jul_lttng_event_loglevel
()
661 local event_name
="$2"
663 local channel_name
=$4
665 if [ -z $channel_name ]; then
666 # default channel if none specified
669 chan
="-c $channel_name"
672 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
673 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
676 function enable_log4j_lttng_event
()
682 if [ -z $channel_name ]; then
683 # default channel if none specified
686 chan
="-c $channel_name"
689 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
690 ok $?
"Enable LOG4J event $event_name for session $sess_name"
693 function enable_log4j_lttng_event_loglevel
()
696 local event_name
="$2"
698 local channel_name
=$4
700 if [ -z $channel_name ]; then
701 # default channel if none specified
704 chan
="-c $channel_name"
707 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
708 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
711 function enable_python_lttng_event
()
717 if [ -z $channel_name ]; then
718 # default channel if none specified
721 chan
="-c $channel_name"
724 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
725 ok $?
"Enable Python event $event_name for session $sess_name"
728 function enable_python_lttng_event_loglevel
()
731 local event_name
="$2"
733 local channel_name
=$4
735 if [ -z $channel_name ]; then
736 # default channel if none specified
739 chan
="-c $channel_name"
742 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
743 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
746 function enable_ust_lttng_event_filter
()
749 local event_name
="$2"
752 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
753 ok $?
"Enable event $event_name with filtering for session $sess_name"
756 function enable_ust_lttng_event_loglevel
()
759 local event_name
="$2"
762 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
763 ok $?
"Enable event $event_name with loglevel $loglevel"
766 function enable_ust_lttng_event_loglevel_only
()
769 local event_name
="$2"
772 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
773 ok $?
"Enable event $event_name with loglevel-only $loglevel"
776 function disable_ust_lttng_event
()
779 local event_name
="$2"
780 local channel_name
="$3"
782 if [ -z $channel_name ]; then
783 # default channel if none specified
786 chan
="-c $channel_name"
789 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
790 ok $?
"Disable event $event_name for session $sess_name"
793 function disable_jul_lttng_event
()
796 local event_name
="$2"
798 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
799 ok $?
"Disable JUL event $event_name for session $sess_name"
802 function disable_log4j_lttng_event
()
805 local event_name
="$2"
807 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
808 ok $?
"Disable LOG4J event $event_name for session $sess_name"
811 function disable_python_lttng_event
()
814 local event_name
="$2"
816 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
817 ok $?
"Disable Python event $event_name for session $sess_name"
820 function start_lttng_tracing
()
822 local expected_to_fail
=$1
825 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
827 if [[ $expected_to_fail -eq "1" ]]; then
829 ok $?
"Start tracing for session $sess_name failed as expected"
831 ok
$ret "Start tracing for session $sess_name"
835 function start_lttng_tracing_ok
()
837 start_lttng_tracing
0 "$@"
840 function start_lttng_tracing_fail
()
842 start_lttng_tracing
1 "$@"
845 function stop_lttng_tracing
()
847 local expected_to_fail
=$1
850 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
852 if [[ $expected_to_fail -eq "1" ]]; then
854 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
856 ok
$ret "Stop lttng tracing for session $sess_name"
860 function stop_lttng_tracing_ok
()
862 stop_lttng_tracing
0 "$@"
865 function stop_lttng_tracing_fail
()
867 stop_lttng_tracing
1 "$@"
870 function destroy_lttng_session
()
872 local expected_to_fail
=$1
875 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
877 if [[ $expected_to_fail -eq "1" ]]; then
879 ok $?
"Destroy session $sess_name failed as expected"
881 ok
$ret "Destroy session $sess_name"
885 function destroy_lttng_session_ok
()
887 destroy_lttng_session
0 "$@"
891 function destroy_lttng_session_fail
()
893 destroy_lttng_session
1 "$@"
897 function destroy_lttng_sessions
()
899 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
900 ok $?
"Destroy all lttng sessions"
903 function lttng_snapshot_add_output
()
905 local expected_to_fail
=$1
909 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
911 if [[ $expected_to_fail -eq 1 ]]; then
913 ok $?
"Added snapshot output file://$trace_path failed as expected"
915 ok
$ret "Added snapshot output file://$trace_path"
919 function lttng_snapshot_add_output_ok
()
921 lttng_snapshot_add_output
0 "$@"
924 function lttng_snapshot_add_output_fail
()
926 lttng_snapshot_add_output
1 "$@"
929 function lttng_snapshot_del_output
()
931 local expected_to_fail
=$1
935 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
937 if [[ $expected_to_fail -eq "1" ]]; then
939 ok $?
"Deleted snapshot output id $id failed as expected"
941 ok
$ret "Deleted snapshot output id $id"
945 function lttng_snapshot_del_output_ok
()
947 lttng_snapshot_del_output
0 "$@"
950 function lttng_snapshot_del_output_fail
()
952 lttng_snapshot_del_output
1 "$@"
955 function lttng_snapshot_record
()
960 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
961 ok $?
"Snapshot recorded"
964 function lttng_snapshot_list
()
967 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
968 ok $?
"Snapshot list"
971 function lttng_save
()
976 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
977 ok $?
"Session saved"
980 function lttng_load
()
984 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
985 ok $?
"Load command with opts: $opts"
988 function lttng_track
()
990 local expected_to_fail
=$1
992 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
994 if [[ $expected_to_fail -eq "1" ]]; then
996 ok $?
"Track command failed as expected with opts: $opts"
998 ok
$ret "Track command with opts: $opts"
1002 function lttng_track_ok
()
1007 function lttng_track_fail
()
1012 function lttng_untrack
()
1014 local expected_to_fail
=$1
1016 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1018 if [[ $expected_to_fail -eq "1" ]]; then
1020 ok $?
"Untrack command failed as expected with opts: $opts"
1022 ok
$ret "Untrack command with opts: $opts"
1026 function lttng_untrack_ok
()
1028 lttng_untrack
0 "$@"
1031 function lttng_untrack_fail
()
1033 lttng_untrack
1 "$@"
1036 function add_context_lttng
()
1038 local expected_to_fail
="$1"
1040 local session_name
="$3"
1041 local channel_name
="$4"
1044 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1046 if [[ $expected_to_fail -eq "1" ]]; then
1048 ok $?
"Add context command failed as expected for type: $type"
1050 ok
$ret "Add context command for type: $type"
1054 function add_context_ust_ok
()
1056 add_context_lttng
0 -u "$@"
1059 function add_context_ust_fail
()
1061 add_context_lttng
1 -u "$@"
1064 function add_context_kernel_ok
()
1066 add_context_lttng
0 -k "$@"
1069 function add_context_kernel_fail
()
1071 add_context_lttng
1 -k "$@"
1074 function trace_matches
()
1080 which $BABELTRACE_BIN >/dev
/null
1081 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1083 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1085 if [ "$count" -ne "$nr_iter" ]; then
1087 diag
"$count events found in trace"
1093 function trace_match_only
()
1099 which $BABELTRACE_BIN >/dev
/null
1100 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1102 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1103 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1105 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1106 pass
"Trace match with $total event $event_name"
1109 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1113 function validate_trace
1118 which $BABELTRACE_BIN >/dev
/null
1119 if [ $?
-ne 0 ]; then
1120 skip
0 "Babeltrace binary not found. Skipping trace validation"
1125 for i
in $event_name; do
1126 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1127 if [ "$traced" -ne 0 ]; then
1128 pass
"Validate trace for event $i, $traced events"
1130 fail
"Validate trace for event $i"
1131 diag
"Found $traced occurences of $i"
1139 function validate_trace_exp
()
1144 which $BABELTRACE_BIN >/dev
/null
1145 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1147 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1148 if [ "$traced" -ne 0 ]; then
1149 pass
"Validate trace for expression '${event_exp}', $traced events"
1151 fail
"Validate trace for expression '${event_exp}'"
1152 diag
"Found $traced occurences of '${event_exp}'"
1158 function validate_trace_only_exp
()
1163 which $BABELTRACE_BIN >/dev
/null
1164 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1166 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1167 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1169 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1170 pass
"Trace match with $total for expression '${event_exp}"
1173 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1179 function validate_trace_empty
()
1183 which $BABELTRACE_BIN >/dev
/null
1184 if [ $?
-ne 0 ]; then
1185 skip
0 "Babeltrace binary not found. Skipping trace validation"
1188 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1189 if [ "$traced" -eq 0 ]; then
1190 pass
"Validate empty trace"
1192 fail
"Validate empty trace"
1193 diag
"Found $traced events in trace"