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 fail 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 $?
"Expected failure on kernel channel creation $channel_name in $sess_name"
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 $?
"Expected failure on kernel channel creation $channel_name in $sess_name"
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 $
(pidof 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
=`pidof 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
=$
(pidof 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 $
(pidof 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
()
391 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
392 # Env variable requested no session daemon
396 PID_SESSIOND
=`pidof lt-$SESSIOND_BIN`
398 kill $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
400 if [ $?
-eq 1 ]; then
401 if [ $withtap -eq "1" ]; then
402 fail
"Kill sessions daemon"
406 while [ -n "$out" ]; do
407 out
=$
(pidof lt-
$SESSIOND_BIN)
411 while [ -n "$out" ]; do
412 out
=$
(pidof
$CONSUMERD_BIN)
415 if [ $withtap -eq "1" ]; then
416 pass
"Kill session daemon"
421 function stop_lttng_sessiond
()
423 stop_lttng_sessiond_opt
1 "$@"
426 function stop_lttng_sessiond_notap
()
428 stop_lttng_sessiond_opt
0 "$@"
431 function list_lttng_with_opts
()
434 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
435 ok $?
"Lttng-tool list command with option $opts"
438 function create_lttng_session_no_output
()
442 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
443 ok $?
"Create session $sess_name in no-output mode"
446 function create_lttng_session
()
448 local expected_to_fail
=$1
452 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path > $OUTPUT_DEST
454 if [[ $expected_to_fail -eq "1" ]]; then
456 ok $?
"Expected fail on session creation $sess_name in $trace_path"
458 ok
$ret "Create session $sess_name in $trace_path"
462 function create_lttng_session_ok
()
464 create_lttng_session
0 "$@"
467 function create_lttng_session_fail
()
469 create_lttng_session
1 "$@"
473 function enable_ust_lttng_channel
()
477 local channel_name
=$3
479 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
481 if [[ $expect_fail -eq "1" ]]; then
483 ok $?
"Expected fail on ust channel creation $channel_name in $sess_name"
485 ok
$ret "Enable channel $channel_name for session $sess_name"
489 function enable_ust_lttng_channel_ok
()
491 enable_ust_lttng_channel
0 "$@"
494 function enable_ust_lttng_channel_fail
()
496 enable_ust_lttng_channel
1 "$@"
499 function disable_ust_lttng_channel
()
502 local channel_name
=$2
504 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
505 ok $?
"Disable channel $channel_name for session $sess_name"
508 function enable_lttng_mmap_overwrite_kernel_channel
()
511 local channel_name
=$2
513 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
514 ok $?
"Enable channel $channel_name for session $sess_name"
517 function enable_lttng_mmap_overwrite_ust_channel
()
520 local channel_name
=$2
522 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
523 ok $?
"Enable channel $channel_name for session $sess_name"
526 function enable_ust_lttng_event
()
528 local expected_to_fail
=$1
530 local event_name
="$3"
531 local channel_name
=$4
533 if [ -z $channel_name ]; then
534 # default channel if none specified
537 chan
="-c $channel_name"
540 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
542 if [[ $expected_to_fail -eq "1" ]]; then
544 ok $?
"Enable ust event $event_name for session $session_name on channel $channel_name failed as expected"
546 ok
$ret "Enable event $event_name for session $sess_name"
550 function enable_ust_lttng_event_ok
()
552 enable_ust_lttng_event
0 "$@"
555 function enable_ust_lttng_event_fail
()
557 enable_ust_lttng_event
1 "$@"
560 function enable_jul_lttng_event
()
566 if [ -z $channel_name ]; then
567 # default channel if none specified
570 chan
="-c $channel_name"
573 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
574 ok $?
"Enable JUL event $event_name for session $sess_name"
577 function enable_jul_lttng_event_loglevel
()
580 local event_name
="$2"
582 local channel_name
=$4
584 if [ -z $channel_name ]; then
585 # default channel if none specified
588 chan
="-c $channel_name"
591 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
592 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
595 function enable_log4j_lttng_event
()
601 if [ -z $channel_name ]; then
602 # default channel if none specified
605 chan
="-c $channel_name"
608 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
609 ok $?
"Enable LOG4J event $event_name for session $sess_name"
612 function enable_log4j_lttng_event_loglevel
()
615 local event_name
="$2"
617 local channel_name
=$4
619 if [ -z $channel_name ]; then
620 # default channel if none specified
623 chan
="-c $channel_name"
626 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
627 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
630 function enable_python_lttng_event
()
636 if [ -z $channel_name ]; then
637 # default channel if none specified
640 chan
="-c $channel_name"
643 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
644 ok $?
"Enable Python event $event_name for session $sess_name"
647 function enable_python_lttng_event_loglevel
()
650 local event_name
="$2"
652 local channel_name
=$4
654 if [ -z $channel_name ]; then
655 # default channel if none specified
658 chan
="-c $channel_name"
661 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
662 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
665 function enable_ust_lttng_event_filter
()
668 local event_name
="$2"
671 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
672 ok $?
"Enable event $event_name with filtering for session $sess_name"
675 function enable_ust_lttng_event_loglevel
()
678 local event_name
="$2"
681 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
682 ok $?
"Enable event $event_name with loglevel $loglevel"
685 function enable_ust_lttng_event_loglevel_only
()
688 local event_name
="$2"
691 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
692 ok $?
"Enable event $event_name with loglevel-only $loglevel"
695 function disable_ust_lttng_event
()
698 local event_name
="$2"
699 local channel_name
="$3"
701 if [ -z $channel_name ]; then
702 # default channel if none specified
705 chan
="-c $channel_name"
708 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
709 ok $?
"Disable event $event_name for session $sess_name"
712 function disable_jul_lttng_event
()
715 local event_name
="$2"
717 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
718 ok $?
"Disable JUL event $event_name for session $sess_name"
721 function disable_log4j_lttng_event
()
724 local event_name
="$2"
726 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
727 ok $?
"Disable LOG4J event $event_name for session $sess_name"
730 function disable_python_lttng_event
()
733 local event_name
="$2"
735 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
736 ok $?
"Disable Python event $event_name for session $sess_name"
739 function start_lttng_tracing
()
741 local expected_to_fail
=$1
744 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
746 if [[ $expected_to_fail -eq "1" ]]; then
748 ok $?
"Expected fail on start tracing for session: $sess_name"
750 ok
$ret "Start tracing for session $sess_name"
754 function start_lttng_tracing_ok
()
756 start_lttng_tracing
0 "$@"
759 function start_lttng_tracing_fail
()
761 start_lttng_tracing
1 "$@"
764 function stop_lttng_tracing
()
766 local expected_to_fail
=$1
769 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
771 if [[ $expected_to_fail -eq "1" ]]; then
773 ok $?
"Expected fail on stop tracing for session: $sess_name"
775 ok
$ret "Stop lttng tracing for session $sess_name"
779 function stop_lttng_tracing_ok
()
781 stop_lttng_tracing
0 "$@"
784 function stop_lttng_tracing_fail
()
786 stop_lttng_tracing
1 "$@"
789 function destroy_lttng_session
()
791 local expected_to_fail
=$1
794 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
796 if [[ $expected_to_fail -eq "1" ]]; then
798 ok $?
"Expected fail on session deletion $sess_name"
800 ok
$ret "Destroy session $sess_name"
804 function destroy_lttng_session_ok
()
806 destroy_lttng_session
0 "$@"
810 function destroy_lttng_session_fail
()
812 destroy_lttng_session
1 "$@"
816 function destroy_lttng_sessions
()
818 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
819 ok $?
"Destroy all lttng sessions"
822 function lttng_snapshot_add_output
()
824 local expected_to_fail
=$1
828 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
830 if [[ $expected_to_fail -eq 1 ]]; then
832 ok $?
"Failed to add a snapshot output file://$trace_path as expected"
834 ok
$ret "Added snapshot output file://$trace_path"
838 function lttng_snapshot_add_output_ok
()
840 lttng_snapshot_add_output
0 "$@"
843 function lttng_snapshot_add_output_fail
()
845 lttng_snapshot_add_output
1 "$@"
848 function lttng_snapshot_del_output
()
850 local expected_to_fail
=$1
854 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
856 if [[ $expected_to_fail -eq "1" ]]; then
858 ok $?
"Expect fail on deletion of snapshot output id $id"
860 ok
$ret "Deleted snapshot output id $id"
864 function lttng_snapshot_del_output_ok
()
866 lttng_snapshot_del_output
0 "$@"
869 function lttng_snapshot_del_output_fail
()
871 lttng_snapshot_del_output
1 "$@"
874 function lttng_snapshot_record
()
879 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
880 ok $?
"Snapshot recorded"
883 function lttng_snapshot_list
()
886 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
887 ok $?
"Snapshot list"
890 function lttng_save
()
895 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
896 ok $?
"Session successfully saved"
899 function lttng_load
()
903 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
904 ok $?
"Load command successful"
907 function lttng_track
()
909 local expected_to_fail
=$1
911 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
913 if [[ $expected_to_fail -eq "1" ]]; then
915 ok $?
"Track command failed as expected with opts: $opts"
917 ok
$ret "Track command success as expected with opts: $opts"
921 function lttng_track_ok
()
926 function lttng_track_fail
()
931 function lttng_untrack
()
933 local expected_to_fail
=$1
935 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
937 if [[ $expected_to_fail -eq "1" ]]; then
939 ok $?
"Untrack command failed as expected with opts: $opts"
941 ok
$ret "Untrack command success as expected with opts: $opts"
945 function lttng_untrack_ok
()
950 function lttng_untrack_fail
()
955 function trace_matches
()
961 which $BABELTRACE_BIN >/dev
/null
962 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
964 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
966 if [ "$count" -ne "$nr_iter" ]; then
968 diag
"$count events found in trace"
974 function trace_match_only
()
980 which $BABELTRACE_BIN >/dev
/null
981 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
983 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
984 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
986 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
987 pass
"Trace match with $total event $event_name"
990 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
994 function validate_trace
999 which $BABELTRACE_BIN >/dev
/null
1000 if [ $?
-ne 0 ]; then
1001 skip
0 "Babeltrace binary not found. Skipping trace validation"
1006 for i
in $event_name; do
1007 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1008 if [ "$traced" -ne 0 ]; then
1009 pass
"Validate trace for event $i, $traced events"
1011 fail
"Validate trace for event $i"
1012 diag
"Found $traced occurences of $i"
1020 function validate_trace_exp
()
1025 which $BABELTRACE_BIN >/dev
/null
1026 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1028 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1029 if [ "$traced" -ne 0 ]; then
1030 pass
"Validate trace for expression '${event_exp}', $traced events"
1032 fail
"Validate trace for expression '${event_exp}'"
1033 diag
"Found $traced occurences of '${event_exp}'"
1039 function validate_trace_only_exp
()
1044 which $BABELTRACE_BIN >/dev
/null
1045 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1047 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1048 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1050 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1051 pass
"Trace match with $total for expression '${event_exp}"
1054 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1060 function validate_trace_empty
()
1064 which $BABELTRACE_BIN >/dev
/null
1065 if [ $?
-ne 0 ]; then
1066 skip
0 "Babeltrace binary not found. Skipping trace validation"
1069 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1070 if [ "$traced" -eq 0 ]; then
1071 pass
"Validate empty trace"
1073 fail
"Validate empty trace"
1074 diag
"Found $traced events in trace"