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 # Return the number of _configured_ CPUs.
90 function conf_proc_count
()
92 getconf _NPROCESSORS_CONF
94 diag
"Failed to get the number of configured CPUs"
99 function enable_kernel_lttng_event
101 local expected_to_fail
="$1"
103 local event_name
="$3"
104 local channel_name
="$4"
106 if [ -z "$event_name" ]; then
107 # Enable all event if no event name specified
111 if [ -z "$channel_name" ]; then
112 # default channel if none specified
115 chan
="-c $channel_name"
118 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
120 if [[ $expected_to_fail -eq "1" ]]; then
122 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
124 ok
$ret "Enable kernel event $event_name for session $sess_name"
128 function enable_kernel_lttng_event_ok
()
130 enable_kernel_lttng_event
0 "$@"
133 function enable_kernel_lttng_event_fail
()
135 enable_kernel_lttng_event
1 "$@"
139 function lttng_enable_kernel_event
141 enable_kernel_lttng_event_ok
"$@"
144 function lttng_enable_kernel_syscall
()
146 local expected_to_fail
=$1
148 local syscall_name
=$3
149 local channel_name
=$4
151 if [ -z $syscall_name ]; then
152 # Enable all event if no syscall name specified
156 if [ -z $channel_name ]; then
157 # default channel if none specified
160 chan
="-c $channel_name"
163 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
165 if [[ $expected_to_fail -eq "1" ]]; then
167 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
169 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
173 function lttng_enable_kernel_syscall_ok
()
175 lttng_enable_kernel_syscall
0 "$@"
178 function lttng_enable_kernel_syscall_fail
()
180 lttng_enable_kernel_syscall
1 "$@"
183 function lttng_disable_kernel_syscall
()
185 local expected_to_fail
=$1
187 local syscall_name
=$3
188 local channel_name
=$4
190 if [ -z $syscall_name ]; then
191 # Enable all event if no syscall name specified
195 if [ -z $channel_name ]; then
196 # default channel if none specified
199 chan
="-c $channel_name"
202 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
205 if [[ $expected_to_fail -eq "1" ]]; then
207 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
209 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
213 function lttng_disable_kernel_syscall_ok
()
215 lttng_disable_kernel_syscall
0 "$@"
218 function lttng_disable_kernel_syscall_fail
()
220 lttng_disable_kernel_syscall
1 "$@"
223 function lttng_enable_kernel_channel
()
225 local expected_to_fail
=$1
227 local channel_name
=$3
229 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
231 if [[ $expected_to_fail -eq "1" ]]; then
233 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
235 ok
$ret "Enable channel $channel_name for session $sess_name"
239 function lttng_enable_kernel_channel_ok
()
241 lttng_enable_kernel_channel
0 "$@"
244 function lttng_enable_kernel_channel_fail
()
246 lttng_enable_kernel_channel
1 "$@"
249 function lttng_disable_kernel_channel
()
251 local expected_to_fail
=$1
253 local channel_name
=$3
255 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
257 if [[ $expected_to_fail -eq "1" ]]; then
259 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
261 ok
$ret "Disable channel $channel_name for session $sess_name"
265 function lttng_disable_kernel_channel_ok
()
267 lttng_disable_kernel_channel
0 "$@"
270 function lttng_disable_kernel_channel_fail
()
272 lttng_disable_kernel_channel
1 "$@"
275 function start_lttng_relayd_opt
()
280 DIR
=$
(readlink
-f $TESTDIR)
282 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
283 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
284 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
285 if [ $?
-eq 1 ]; then
286 if [ $withtap -eq "1" ]; then
287 fail
"Start lttng-relayd (opt: $opt)"
291 if [ $withtap -eq "1" ]; then
292 pass
"Start lttng-relayd (opt: $opt)"
296 pass
"Start lttng-relayd (opt: $opt)"
300 function start_lttng_relayd
()
302 start_lttng_relayd_opt
1 "$@"
305 function start_lttng_relayd_notap
()
307 start_lttng_relayd_opt
0 "$@"
310 function stop_lttng_relayd_opt
()
314 PID_RELAYD
=`pgrep --full lt-$RELAYD_BIN`
316 if [ $withtap -eq "1" ]; then
317 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
319 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
322 if [ $?
-eq 1 ]; then
323 if [ $withtap -eq "1" ]; then
324 fail
"Kill relay daemon"
329 while [ -n "$out" ]; do
330 out
=$
(pgrep
--full lt-
$RELAYD_BIN)
333 if [ $withtap -eq "1" ]; then
334 pass
"Kill relay daemon"
340 function stop_lttng_relayd
()
342 stop_lttng_relayd_opt
1 "$@"
345 function stop_lttng_relayd_notap
()
347 stop_lttng_relayd_opt
0 "$@"
350 #First arg: show tap output
351 #Second argument: load path for automatic loading
352 function start_lttng_sessiond_opt
()
357 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
358 # Env variable requested no session daemon
362 validate_kernel_version
363 if [ $?
-ne 0 ]; then
364 fail
"Start session daemon"
365 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
368 DIR
=$
(readlink
-f $TESTDIR)
369 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
370 export LTTNG_SESSION_CONFIG_XSD_PATH
372 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
374 if [ -n "$load_path" ]; then
375 $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"
377 $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"
379 #$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
381 if [ $withtap -eq "1" ]; then
382 ok
$status "Start session daemon"
387 function start_lttng_sessiond
()
389 start_lttng_sessiond_opt
1 "$@"
392 function start_lttng_sessiond_notap
()
394 start_lttng_sessiond_opt
0 "$@"
397 function stop_lttng_sessiond_opt
()
403 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
404 # Env variable requested no session daemon
408 PID_SESSIOND
=`pgrep --full lt-$SESSIOND_BIN`
411 kill_opt
="$kill_opt -s $signal"
414 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
416 if [ $?
-eq 1 ]; then
417 if [ $withtap -eq "1" ]; then
418 fail
"Kill sessions daemon"
422 while [ -n "$out" ]; do
423 out
=$
(pgrep
--full lt-
$SESSIOND_BIN)
427 while [ -n "$out" ]; do
428 out
=$
(pgrep
--full $CONSUMERD_BIN)
431 if [ $withtap -eq "1" ]; then
432 pass
"Kill session daemon"
437 function stop_lttng_sessiond
()
439 stop_lttng_sessiond_opt
1 "$@"
442 function stop_lttng_sessiond_notap
()
444 stop_lttng_sessiond_opt
0 "$@"
447 function stop_lttng_consumerd_opt
()
453 PID_CONSUMERD
=`pgrep --full $CONSUMERD_BIN`
456 kill_opt
="$kill_opt -s $signal"
459 if [ $withtap -eq "1" ]; then
460 diag
"Killing lttng-consumerd (pid: $PID_CONSUMERD)"
462 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
466 if [ $?
-eq 1 ]; then
467 if [ $withtap -eq "1" ]; then
468 fail
"Kill consumer daemon"
473 while [ $out -ne 0 ]; do
474 pid
=$
(pgrep
--full $CONSUMERD_BIN)
476 # If consumerds are still present check their status.
477 # A zombie status qualifies the consumerd as *killed*
479 for consumer_pid
in $pid; do
480 state
=$
(ps
-p $consumer_pid -o state
= )
481 if [[ -n "$state" && "$state" != "Z" ]]; then
487 if [ $withtap -eq "1" ]; then
488 pass
"Kill consumer daemon"
494 function stop_lttng_consumerd
()
496 stop_lttng_consumerd_opt
1 "$@"
499 function stop_lttng_consumerd_notap
()
501 stop_lttng_consumerd_opt
0 "$@"
504 function list_lttng_with_opts
()
507 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
508 ok $?
"Lttng-tool list command with option $opts"
511 function create_lttng_session_no_output
()
515 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
516 ok $?
"Create session $sess_name in no-output mode"
519 function create_lttng_session
()
521 local expected_to_fail
=$1
526 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
528 if [[ $expected_to_fail -eq "1" ]]; then
530 ok $?
"Create session $sess_name in $trace_path failed as expected"
532 ok
$ret "Create session $sess_name in $trace_path"
536 function create_lttng_session_ok
()
538 create_lttng_session
0 "$@"
541 function create_lttng_session_fail
()
543 create_lttng_session
1 "$@"
547 function enable_ust_lttng_channel
()
549 local expected_to_fail
=$1
551 local channel_name
=$3
554 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
556 if [[ $expected_to_fail -eq "1" ]]; then
558 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
560 ok
$ret "Enable channel $channel_name for session $sess_name"
564 function enable_ust_lttng_channel_ok
()
566 enable_ust_lttng_channel
0 "$@"
569 function enable_ust_lttng_channel_fail
()
571 enable_ust_lttng_channel
1 "$@"
574 function disable_ust_lttng_channel
()
577 local channel_name
=$2
579 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
580 ok $?
"Disable channel $channel_name for session $sess_name"
583 function enable_lttng_mmap_overwrite_kernel_channel
()
586 local channel_name
=$2
588 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
589 ok $?
"Enable channel $channel_name for session $sess_name"
592 function enable_lttng_mmap_overwrite_ust_channel
()
595 local channel_name
=$2
597 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
598 ok $?
"Enable channel $channel_name for session $sess_name"
601 function enable_ust_lttng_event
()
603 local expected_to_fail
=$1
605 local event_name
="$3"
606 local channel_name
=$4
608 if [ -z $channel_name ]; then
609 # default channel if none specified
612 chan
="-c $channel_name"
615 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
617 if [[ $expected_to_fail -eq "1" ]]; then
619 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
621 ok
$ret "Enable ust event $event_name for session $sess_name"
625 function enable_ust_lttng_event_ok
()
627 enable_ust_lttng_event
0 "$@"
630 function enable_ust_lttng_event_fail
()
632 enable_ust_lttng_event
1 "$@"
635 function enable_jul_lttng_event
()
641 if [ -z $channel_name ]; then
642 # default channel if none specified
645 chan
="-c $channel_name"
648 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
649 ok $?
"Enable JUL event $event_name for session $sess_name"
652 function enable_jul_lttng_event_loglevel
()
655 local event_name
="$2"
657 local channel_name
=$4
659 if [ -z $channel_name ]; then
660 # default channel if none specified
663 chan
="-c $channel_name"
666 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
667 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
670 function enable_log4j_lttng_event
()
676 if [ -z $channel_name ]; then
677 # default channel if none specified
680 chan
="-c $channel_name"
683 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
684 ok $?
"Enable LOG4J event $event_name for session $sess_name"
687 function enable_log4j_lttng_event_loglevel
()
690 local event_name
="$2"
692 local channel_name
=$4
694 if [ -z $channel_name ]; then
695 # default channel if none specified
698 chan
="-c $channel_name"
701 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
702 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
705 function enable_python_lttng_event
()
711 if [ -z $channel_name ]; then
712 # default channel if none specified
715 chan
="-c $channel_name"
718 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
719 ok $?
"Enable Python event $event_name for session $sess_name"
722 function enable_python_lttng_event_loglevel
()
725 local event_name
="$2"
727 local channel_name
=$4
729 if [ -z $channel_name ]; then
730 # default channel if none specified
733 chan
="-c $channel_name"
736 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
737 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
740 function enable_ust_lttng_event_filter
()
743 local event_name
="$2"
746 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
747 ok $?
"Enable event $event_name with filtering for session $sess_name"
750 function enable_ust_lttng_event_loglevel
()
753 local event_name
="$2"
756 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
757 ok $?
"Enable event $event_name with loglevel $loglevel"
760 function enable_ust_lttng_event_loglevel_only
()
763 local event_name
="$2"
766 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
767 ok $?
"Enable event $event_name with loglevel-only $loglevel"
770 function disable_ust_lttng_event
()
773 local event_name
="$2"
774 local channel_name
="$3"
776 if [ -z $channel_name ]; then
777 # default channel if none specified
780 chan
="-c $channel_name"
783 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
784 ok $?
"Disable event $event_name for session $sess_name"
787 function disable_jul_lttng_event
()
790 local event_name
="$2"
792 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
793 ok $?
"Disable JUL event $event_name for session $sess_name"
796 function disable_log4j_lttng_event
()
799 local event_name
="$2"
801 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
802 ok $?
"Disable LOG4J event $event_name for session $sess_name"
805 function disable_python_lttng_event
()
808 local event_name
="$2"
810 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
811 ok $?
"Disable Python event $event_name for session $sess_name"
814 function start_lttng_tracing
()
816 local expected_to_fail
=$1
819 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
821 if [[ $expected_to_fail -eq "1" ]]; then
823 ok $?
"Start tracing for session $sess_name failed as expected"
825 ok
$ret "Start tracing for session $sess_name"
829 function start_lttng_tracing_ok
()
831 start_lttng_tracing
0 "$@"
834 function start_lttng_tracing_fail
()
836 start_lttng_tracing
1 "$@"
839 function stop_lttng_tracing
()
841 local expected_to_fail
=$1
844 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
846 if [[ $expected_to_fail -eq "1" ]]; then
848 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
850 ok
$ret "Stop lttng tracing for session $sess_name"
854 function stop_lttng_tracing_ok
()
856 stop_lttng_tracing
0 "$@"
859 function stop_lttng_tracing_fail
()
861 stop_lttng_tracing
1 "$@"
864 function destroy_lttng_session
()
866 local expected_to_fail
=$1
869 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
871 if [[ $expected_to_fail -eq "1" ]]; then
873 ok $?
"Destroy session $sess_name failed as expected"
875 ok
$ret "Destroy session $sess_name"
879 function destroy_lttng_session_ok
()
881 destroy_lttng_session
0 "$@"
885 function destroy_lttng_session_fail
()
887 destroy_lttng_session
1 "$@"
891 function destroy_lttng_sessions
()
893 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
894 ok $?
"Destroy all lttng sessions"
897 function lttng_snapshot_add_output
()
899 local expected_to_fail
=$1
903 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
905 if [[ $expected_to_fail -eq 1 ]]; then
907 ok $?
"Added snapshot output file://$trace_path failed as expected"
909 ok
$ret "Added snapshot output file://$trace_path"
913 function lttng_snapshot_add_output_ok
()
915 lttng_snapshot_add_output
0 "$@"
918 function lttng_snapshot_add_output_fail
()
920 lttng_snapshot_add_output
1 "$@"
923 function lttng_snapshot_del_output
()
925 local expected_to_fail
=$1
929 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
931 if [[ $expected_to_fail -eq "1" ]]; then
933 ok $?
"Deleted snapshot output id $id failed as expected"
935 ok
$ret "Deleted snapshot output id $id"
939 function lttng_snapshot_del_output_ok
()
941 lttng_snapshot_del_output
0 "$@"
944 function lttng_snapshot_del_output_fail
()
946 lttng_snapshot_del_output
1 "$@"
949 function lttng_snapshot_record
()
954 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
955 ok $?
"Snapshot recorded"
958 function lttng_snapshot_list
()
961 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
962 ok $?
"Snapshot list"
965 function lttng_save
()
970 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
971 ok $?
"Session saved"
974 function lttng_load
()
978 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
979 ok $?
"Load command with opts: $opts"
982 function lttng_track
()
984 local expected_to_fail
=$1
986 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
988 if [[ $expected_to_fail -eq "1" ]]; then
990 ok $?
"Track command failed as expected with opts: $opts"
992 ok
$ret "Track command with opts: $opts"
996 function lttng_track_ok
()
1001 function lttng_track_fail
()
1006 function lttng_untrack
()
1008 local expected_to_fail
=$1
1010 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1012 if [[ $expected_to_fail -eq "1" ]]; then
1014 ok $?
"Untrack command failed as expected with opts: $opts"
1016 ok
$ret "Untrack command with opts: $opts"
1020 function lttng_untrack_ok
()
1022 lttng_untrack
0 "$@"
1025 function lttng_untrack_fail
()
1027 lttng_untrack
1 "$@"
1030 function add_context_lttng
()
1032 local expected_to_fail
="$1"
1034 local session_name
="$3"
1035 local channel_name
="$4"
1038 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1040 if [[ $expected_to_fail -eq "1" ]]; then
1042 ok $?
"Add context command failed as expected for type: $type"
1044 ok
$ret "Add context command for type: $type"
1048 function add_context_ust_ok
()
1050 add_context_lttng
0 -u "$@"
1053 function add_context_ust_fail
()
1055 add_context_lttng
1 -u "$@"
1058 function add_context_kernel_ok
()
1060 add_context_lttng
0 -k "$@"
1063 function add_context_kernel_fail
()
1065 add_context_lttng
1 -k "$@"
1068 function trace_matches
()
1074 which $BABELTRACE_BIN >/dev
/null
1075 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1077 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1079 if [ "$count" -ne "$nr_iter" ]; then
1081 diag
"$count events found in trace"
1087 function trace_match_only
()
1093 which $BABELTRACE_BIN >/dev
/null
1094 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1096 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1097 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1099 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1100 pass
"Trace match with $total event $event_name"
1103 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1107 function validate_trace
1112 which $BABELTRACE_BIN >/dev
/null
1113 if [ $?
-ne 0 ]; then
1114 skip
0 "Babeltrace binary not found. Skipping trace validation"
1119 for i
in $event_name; do
1120 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1121 if [ "$traced" -ne 0 ]; then
1122 pass
"Validate trace for event $i, $traced events"
1124 fail
"Validate trace for event $i"
1125 diag
"Found $traced occurences of $i"
1133 function validate_trace_exp
()
1138 which $BABELTRACE_BIN >/dev
/null
1139 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1141 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1142 if [ "$traced" -ne 0 ]; then
1143 pass
"Validate trace for expression '${event_exp}', $traced events"
1145 fail
"Validate trace for expression '${event_exp}'"
1146 diag
"Found $traced occurences of '${event_exp}'"
1152 function validate_trace_only_exp
()
1157 which $BABELTRACE_BIN >/dev
/null
1158 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1160 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1161 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1163 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1164 pass
"Trace match with $total for expression '${event_exp}"
1167 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1173 function validate_trace_empty
()
1177 which $BABELTRACE_BIN >/dev
/null
1178 if [ $?
-ne 0 ]; then
1179 skip
0 "Babeltrace binary not found. Skipping trace validation"
1182 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1183 if [ "$traced" -eq 0 ]; then
1184 pass
"Validate empty trace"
1186 fail
"Validate empty trace"
1187 diag
"Found $traced events in trace"