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 lttng_enable_kernel_event
95 if [ -z $event_name ]; then
96 # Enable all event if no event name specified
100 if [ -z $channel_name ]; then
101 # default channel if none specified
104 chan
="-c $channel_name"
107 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
108 ok $?
"Enable kernel event $event_name for session $sess_name"
111 function lttng_enable_kernel_syscall
()
113 local expected_to_fail
=$1
115 local syscall_name
=$3
116 local channel_name
=$4
118 if [ -z $syscall_name ]; then
119 # Enable all event if no syscall name specified
123 if [ -z $channel_name ]; then
124 # default channel if none specified
127 chan
="-c $channel_name"
130 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
132 if [[ $expected_to_fail -eq "1" ]]; then
134 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
136 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
140 function lttng_enable_kernel_syscall_ok
()
142 lttng_enable_kernel_syscall
0 "$@"
145 function lttng_enable_kernel_syscall_fail
()
147 lttng_enable_kernel_syscall
1 "$@"
150 function lttng_disable_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 disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
172 if [[ $expected_to_fail -eq "1" ]]; then
174 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
176 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
180 function lttng_disable_kernel_syscall_ok
()
182 lttng_disable_kernel_syscall
0 "$@"
185 function lttng_disable_kernel_syscall_fail
()
187 lttng_disable_kernel_syscall
1 "$@"
190 function lttng_enable_kernel_channel
()
192 local expected_to_fail
=$1
194 local channel_name
=$3
196 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
198 if [[ $expected_to_fail -eq "1" ]]; then
200 ok $?
"Expected failure on kernel channel creation $channel_name in $sess_name"
202 ok
$ret "Enable channel $channel_name for session $sess_name"
206 function lttng_enable_kernel_channel_ok
()
208 lttng_enable_kernel_channel
0 "$@"
211 function lttng_enable_kernel_channel_fail
()
213 lttng_enable_kernel_channel
1 "$@"
216 function lttng_disable_kernel_channel
()
218 local expected_to_fail
=$1
220 local channel_name
=$3
222 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
224 if [[ $expected_to_fail -eq "1" ]]; then
226 ok $?
"Expected failure on kernel channel creation $channel_name in $sess_name"
228 ok
$ret "disable channel $channel_name for session $sess_name"
232 function lttng_disable_kernel_channel_ok
()
234 lttng_disable_kernel_channel
0 "$@"
237 function lttng_disable_kernel_channel_fail
()
239 lttng_disable_kernel_channel
1 "$@"
242 function start_lttng_relayd
246 DIR
=$
(readlink
-f $TESTDIR)
248 if [ -z $
(pidof lt-
$RELAYD_BIN) ]; then
249 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
250 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
251 if [ $?
-eq 1 ]; then
252 fail
"Start lttng-relayd (opt: $opt)"
255 pass
"Start lttng-relayd (opt: $opt)"
258 pass
"Start lttng-relayd (opt: $opt)"
262 function stop_lttng_relayd_nocheck
264 PID_RELAYD
=`pidof lt-$RELAYD_BIN`
266 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
267 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
270 if [ $retval -eq 1 ]; then
272 while [ -n "$out" ]; do
273 out
=$
(pidof lt-
$RELAYD_BIN)
280 function stop_lttng_relayd
282 stop_lttng_relayd_nocheck
284 if [ $?
-eq 1 ]; then
285 fail
"Killed lttng-relayd (pid: $PID_RELAYD)"
288 pass
"Killed lttng-relayd (pid: $PID_RELAYD)"
293 #First argument: load path for automatic loading
294 function start_lttng_sessiond
()
298 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
299 # Env variable requested no session daemon
303 validate_kernel_version
304 if [ $?
-ne 0 ]; then
305 fail
"Start session daemon"
306 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
309 DIR
=$
(readlink
-f $TESTDIR)
310 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
311 export LTTNG_SESSION_CONFIG_XSD_PATH
313 if [ -z $
(pidof lt-
$SESSIOND_BIN) ]; then
316 $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"
318 $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"
320 #$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
322 ok
$status "Start session daemon"
326 function stop_lttng_sessiond
()
328 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
329 # Env variable requested no session daemon
333 PID_SESSIOND
=`pidof lt-$SESSIOND_BIN`
335 kill $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
337 if [ $?
-eq 1 ]; then
338 fail
"Kill sessions daemon"
342 while [ -n "$out" ]; do
343 out
=$
(pidof lt-
$SESSIOND_BIN)
347 while [ -n "$out" ]; do
348 out
=$
(pidof
$CONSUMERD_BIN)
351 pass
"Kill session daemon"
355 function list_lttng_with_opts
()
358 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
359 ok $?
"Lttng-tool list command with option $opts"
362 function create_lttng_session_no_output
()
366 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
367 ok $?
"Create session $sess_name in no-output mode"
370 function create_lttng_session
()
372 local expected_to_fail
=$1
376 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path > $OUTPUT_DEST
378 if [[ $expected_to_fail -eq "1" ]]; then
380 ok $?
"Expected fail on session creation $sess_name in $trace_path"
382 ok
$ret "Create session $sess_name in $trace_path"
386 function create_lttng_session_ok
()
388 create_lttng_session
0 "$@"
391 function create_lttng_session_fail
()
393 create_lttng_session
1 "$@"
397 function enable_ust_lttng_channel
()
401 local channel_name
=$3
403 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
405 if [[ $expect_fail -eq "1" ]]; then
407 ok $?
"Expected fail on ust channel creation $channel_name in $sess_name"
409 ok
$ret "Enable channel $channel_name for session $sess_name"
413 function enable_ust_lttng_channel_ok
()
415 enable_ust_lttng_channel
0 "$@"
418 function enable_ust_lttng_channel_fail
()
420 enable_ust_lttng_channel
1 "$@"
423 function disable_ust_lttng_channel
()
426 local channel_name
=$2
428 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
429 ok $?
"Disable channel $channel_name for session $sess_name"
432 function enable_lttng_mmap_overwrite_kernel_channel
()
435 local channel_name
=$2
437 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
438 ok $?
"Enable channel $channel_name for session $sess_name"
441 function enable_lttng_mmap_overwrite_ust_channel
()
444 local channel_name
=$2
446 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
447 ok $?
"Enable channel $channel_name for session $sess_name"
450 function enable_ust_lttng_event
()
452 local expected_to_fail
=$1
454 local event_name
="$3"
455 local channel_name
=$4
457 if [ -z $channel_name ]; then
458 # default channel if none specified
461 chan
="-c $channel_name"
464 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
466 if [[ $expected_to_fail -eq "1" ]]; then
468 ok $?
"Enable ust event $event_name for session $session_name on channel $channel_name failed as expected"
470 ok
$ret "Enable event $event_name for session $sess_name"
474 function enable_ust_lttng_event_ok
()
476 enable_ust_lttng_event
0 "$@"
479 function enable_ust_lttng_event_fail
()
481 enable_ust_lttng_event
1 "$@"
484 function enable_jul_lttng_event
()
490 if [ -z $channel_name ]; then
491 # default channel if none specified
494 chan
="-c $channel_name"
497 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
498 ok $?
"Enable JUL event $event_name for session $sess_name"
501 function enable_jul_lttng_event_loglevel
()
504 local event_name
="$2"
506 local channel_name
=$4
508 if [ -z $channel_name ]; then
509 # default channel if none specified
512 chan
="-c $channel_name"
515 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
516 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
519 function enable_log4j_lttng_event
()
525 if [ -z $channel_name ]; then
526 # default channel if none specified
529 chan
="-c $channel_name"
532 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
533 ok $?
"Enable LOG4J event $event_name for session $sess_name"
536 function enable_log4j_lttng_event_loglevel
()
539 local event_name
="$2"
541 local channel_name
=$4
543 if [ -z $channel_name ]; then
544 # default channel if none specified
547 chan
="-c $channel_name"
550 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
551 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
554 function enable_python_lttng_event
()
560 if [ -z $channel_name ]; then
561 # default channel if none specified
564 chan
="-c $channel_name"
567 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
568 ok $?
"Enable Python event $event_name for session $sess_name"
571 function enable_python_lttng_event_loglevel
()
574 local event_name
="$2"
576 local channel_name
=$4
578 if [ -z $channel_name ]; then
579 # default channel if none specified
582 chan
="-c $channel_name"
585 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
586 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
589 function enable_ust_lttng_event_filter
()
592 local event_name
="$2"
595 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
596 ok $?
"Enable event $event_name with filtering for session $sess_name"
599 function enable_ust_lttng_event_loglevel
()
602 local event_name
="$2"
605 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
606 ok $?
"Enable event $event_name with loglevel $loglevel"
609 function enable_ust_lttng_event_loglevel_only
()
612 local event_name
="$2"
615 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
616 ok $?
"Enable event $event_name with loglevel-only $loglevel"
619 function disable_ust_lttng_event
()
622 local event_name
="$2"
623 local channel_name
="$3"
625 if [ -z $channel_name ]; then
626 # default channel if none specified
629 chan
="-c $channel_name"
632 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
633 ok $?
"Disable event $event_name for session $sess_name"
636 function disable_jul_lttng_event
()
639 local event_name
="$2"
641 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
642 ok $?
"Disable JUL event $event_name for session $sess_name"
645 function disable_log4j_lttng_event
()
648 local event_name
="$2"
650 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
651 ok $?
"Disable LOG4J event $event_name for session $sess_name"
654 function disable_python_lttng_event
()
657 local event_name
="$2"
659 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
660 ok $?
"Disable Python event $event_name for session $sess_name"
663 function start_lttng_tracing
()
665 local expected_to_fail
=$1
668 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
670 if [[ $expected_to_fail -eq "1" ]]; then
672 ok $?
"Expected fail on start tracing for session: $sess_name"
674 ok
$ret "Start tracing for session $sess_name"
678 function start_lttng_tracing_ok
()
680 start_lttng_tracing
0 "$@"
683 function start_lttng_tracing_fail
()
685 start_lttng_tracing
1 "$@"
688 function stop_lttng_tracing
()
690 local expected_to_fail
=$1
693 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
695 if [[ $expected_to_fail -eq "1" ]]; then
697 ok $?
"Expected fail on stop tracing for session: $sess_name"
699 ok
$ret "Stop lttng tracing for session $sess_name"
703 function stop_lttng_tracing_ok
()
705 stop_lttng_tracing
0 "$@"
708 function stop_lttng_tracing_fail
()
710 stop_lttng_tracing
1 "$@"
713 function destroy_lttng_session
()
715 local expected_to_fail
=$1
718 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
720 if [[ $expected_to_fail -eq "1" ]]; then
722 ok $?
"Expected fail on session deletion $sess_name"
724 ok
$ret "Destroy session $sess_name"
728 function destroy_lttng_session_ok
()
730 destroy_lttng_session
0 "$@"
734 function destroy_lttng_session_fail
()
736 destroy_lttng_session
1 "$@"
740 function destroy_lttng_sessions
()
742 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
743 ok $?
"Destroy all lttng sessions"
746 function lttng_snapshot_add_output
()
748 local expected_to_fail
=$1
752 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
754 if [[ $expected_to_fail -eq 1 ]]; then
756 ok $?
"Failed to add a snapshot output file://$trace_path as expected"
758 ok
$ret "Added snapshot output file://$trace_path"
762 function lttng_snapshot_add_output_ok
()
764 lttng_snapshot_add_output
0 "$@"
767 function lttng_snapshot_add_output_fail
()
769 lttng_snapshot_add_output
1 "$@"
772 function lttng_snapshot_del_output
()
774 local expected_to_fail
=$1
778 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
780 if [[ $expected_to_fail -eq "1" ]]; then
782 ok $?
"Expect fail on deletion of snapshot output id $id"
784 ok
$ret "Deleted snapshot output id $id"
788 function lttng_snapshot_del_output_ok
()
790 lttng_snapshot_del_output
0 "$@"
793 function lttng_snapshot_del_output_fail
()
795 lttng_snapshot_del_output
1 "$@"
798 function lttng_snapshot_record
()
803 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
804 ok $?
"Snapshot recorded"
807 function lttng_snapshot_list
()
810 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
811 ok $?
"Snapshot list"
814 function lttng_save
()
819 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
820 ok $?
"Session successfully saved"
823 function lttng_load
()
827 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
828 ok $?
"Load command successful"
831 function lttng_track
()
833 local expected_to_fail
=$1
835 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
837 if [[ $expected_to_fail -eq "1" ]]; then
839 ok $?
"Track command failed as expected with opts: $opts"
841 ok
$ret "Track command success as expected with opts: $opts"
845 function lttng_track_ok
()
850 function lttng_track_fail
()
855 function lttng_untrack
()
857 local expected_to_fail
=$1
859 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
861 if [[ $expected_to_fail -eq "1" ]]; then
863 ok $?
"Untrack command failed as expected with opts: $opts"
865 ok
$ret "Untrack command success as expected with opts: $opts"
869 function lttng_untrack_ok
()
874 function lttng_untrack_fail
()
879 function trace_matches
()
885 which $BABELTRACE_BIN >/dev
/null
886 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
888 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
890 if [ "$count" -ne "$nr_iter" ]; then
892 diag
"$count events found in trace"
898 function trace_match_only
()
904 which $BABELTRACE_BIN >/dev
/null
905 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
907 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
908 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
910 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
911 pass
"Trace match with $total event $event_name"
914 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
918 function validate_trace
923 which $BABELTRACE_BIN >/dev
/null
924 if [ $?
-ne 0 ]; then
925 skip
0 "Babeltrace binary not found. Skipping trace validation"
930 for i
in $event_name; do
931 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
932 if [ "$traced" -ne 0 ]; then
933 pass
"Validate trace for event $i, $traced events"
935 fail
"Validate trace for event $i"
936 diag
"Found $traced occurences of $i"
944 function validate_trace_exp
()
949 which $BABELTRACE_BIN >/dev
/null
950 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
952 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
953 if [ "$traced" -ne 0 ]; then
954 pass
"Validate trace for expression '${event_exp}', $traced events"
956 fail
"Validate trace for expression '${event_exp}'"
957 diag
"Found $traced occurences of '${event_exp}'"
963 function validate_trace_only_exp
()
968 which $BABELTRACE_BIN >/dev
/null
969 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
971 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
972 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
974 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
975 pass
"Trace match with $total for expression '${event_exp}"
978 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
984 function validate_trace_empty
()
988 which $BABELTRACE_BIN >/dev
/null
989 if [ $?
-ne 0 ]; then
990 skip
0 "Babeltrace binary not found. Skipping trace validation"
993 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
994 if [ "$traced" -eq 0 ]; then
995 pass
"Validate empty trace"
997 fail
"Validate empty trace"
998 diag
"Found $traced events in trace"