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 lttng_enable_kernel_event
109 local channel_name
=$3
111 if [ -z $event_name ]; then
112 # Enable all event if no event name specified
116 if [ -z $channel_name ]; then
117 # default channel if none specified
120 chan
="-c $channel_name"
123 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
124 ok $?
"Enable kernel event $event_name for session $sess_name"
127 function lttng_enable_kernel_syscall
()
129 local expected_to_fail
=$1
131 local syscall_name
=$3
132 local channel_name
=$4
134 if [ -z $syscall_name ]; then
135 # Enable all event if no syscall name specified
139 if [ -z $channel_name ]; then
140 # default channel if none specified
143 chan
="-c $channel_name"
146 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
148 if [[ $expected_to_fail -eq "1" ]]; then
150 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
152 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
156 function lttng_enable_kernel_syscall_ok
()
158 lttng_enable_kernel_syscall
0 ${*}
161 function lttng_enable_kernel_syscall_fail
()
163 lttng_enable_kernel_syscall
1 ${*}
166 function lttng_disable_kernel_syscall
()
168 local expected_to_fail
=$1
170 local syscall_name
=$3
171 local channel_name
=$4
173 if [ -z $syscall_name ]; then
174 # Enable all event if no syscall name specified
178 if [ -z $channel_name ]; then
179 # default channel if none specified
182 chan
="-c $channel_name"
185 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
188 if [[ $expected_to_fail -eq "1" ]]; then
190 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
192 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
196 function lttng_disable_kernel_syscall_ok
()
198 lttng_disable_kernel_syscall
0 ${*}
201 function lttng_disable_kernel_syscall_fail
()
203 lttng_disable_kernel_syscall
1 ${*}
206 function lttng_enable_kernel_channel
()
208 local expected_to_fail
=$1
210 local channel_name
=$3
212 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
214 if [[ $expected_to_fail -eq "1" ]]; then
216 ok $?
"Expected failure on kernel channel creation $channel_name in $sess_name"
218 ok
$ret "Enable channel $channel_name for session $sess_name"
222 function lttng_enable_kernel_channel_ok
()
224 lttng_enable_kernel_channel
0 ${*}
227 function lttng_enable_kernel_channel_fail
()
229 lttng_enable_kernel_channel
1 ${*}
232 function lttng_disable_kernel_channel
()
234 local expected_to_fail
=$1
236 local channel_name
=$3
238 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
240 if [[ $expected_to_fail -eq "1" ]]; then
242 ok $?
"Expected failure on kernel channel creation $channel_name in $sess_name"
244 ok
$ret "disable channel $channel_name for session $sess_name"
248 function lttng_disable_kernel_channel_ok
()
250 lttng_disable_kernel_channel
0 ${*}
253 function lttng_disable_kernel_channel_fail
()
255 lttng_disable_kernel_channel
1 ${*}
258 function start_lttng_relayd_opt
()
263 DIR
=$
(readlink
-f $TESTDIR)
265 if [ -z $
(pidof lt-
$RELAYD_BIN) ]; then
266 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
267 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
268 if [ $?
-eq 1 ]; then
269 if [ $withtap -eq "1" ]; then
270 fail
"Start lttng-relayd (opt: $opt)"
274 if [ $withtap -eq "1" ]; then
275 pass
"Start lttng-relayd (opt: $opt)"
279 pass
"Start lttng-relayd (opt: $opt)"
283 function start_lttng_relayd
()
285 start_lttng_relayd_opt
1 "$@"
288 function start_lttng_relayd_notap
()
290 start_lttng_relayd_opt
0 "$@"
293 function stop_lttng_relayd_opt
()
297 PID_RELAYD
=`pidof lt-$RELAYD_BIN`
299 if [ $withtap -eq "1" ]; then
300 diag
"Killing lttng-relayd (pid: $PID_RELAYD)"
302 kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
305 if [ $?
-eq 1 ]; then
306 if [ $withtap -eq "1" ]; then
307 fail
"Kill relay daemon"
312 while [ -n "$out" ]; do
313 out
=$
(pidof lt-
$RELAYD_BIN)
316 if [ $withtap -eq "1" ]; then
317 pass
"Kill relay daemon"
323 function stop_lttng_relayd
()
325 stop_lttng_relayd_opt
1 "$@"
328 function stop_lttng_relayd_notap
()
330 stop_lttng_relayd_opt
0 "$@"
333 #First arg: show tap output
334 #Second argument: load path for automatic loading
335 function start_lttng_sessiond_opt
()
340 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
341 # Env variable requested no session daemon
345 validate_kernel_version
346 if [ $?
-ne 0 ]; then
347 fail
"Start session daemon"
348 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
351 DIR
=$
(readlink
-f $TESTDIR)
352 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
353 export LTTNG_SESSION_CONFIG_XSD_PATH
355 if [ -z $
(pidof lt-
$SESSIOND_BIN) ]; then
357 if [ -n "$load_path" ]; then
358 $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"
360 $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"
362 #$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
364 if [ $withtap -eq "1" ]; then
365 ok
$status "Start session daemon"
370 function start_lttng_sessiond
()
372 start_lttng_sessiond_opt
1 "$@"
375 function start_lttng_sessiond_notap
()
377 start_lttng_sessiond_opt
0 "$@"
380 function stop_lttng_sessiond_opt
()
384 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
385 # Env variable requested no session daemon
389 PID_SESSIOND
=`pidof lt-$SESSIOND_BIN`
391 kill $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
393 if [ $?
-eq 1 ]; then
394 if [ $withtap -eq "1" ]; then
395 fail
"Kill sessions daemon"
399 while [ -n "$out" ]; do
400 out
=$
(pidof lt-
$SESSIOND_BIN)
404 while [ -n "$out" ]; do
405 out
=$
(pidof
$CONSUMERD_BIN)
408 if [ $withtap -eq "1" ]; then
409 pass
"Kill session daemon"
414 function stop_lttng_sessiond
()
416 stop_lttng_sessiond_opt
1 "$@"
419 function stop_lttng_sessiond_notap
()
421 stop_lttng_sessiond_opt
0 "$@"
424 function list_lttng_with_opts
()
427 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
428 ok $?
"Lttng-tool list command with option $opts"
431 function create_lttng_session_no_output
()
435 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
436 ok $?
"Create session $sess_name in no-output mode"
439 function create_lttng_session
()
443 local expected_to_fail
=$3
445 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path > $OUTPUT_DEST
447 if [[ $expected_to_fail ]]; then
449 ok $?
"Expected fail on session creation $sess_name in $trace_path"
451 ok
$ret "Create session $sess_name in $trace_path"
455 function enable_ust_lttng_channel
()
458 local channel_name
=$2
461 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
463 if [[ $expect_fail ]]; then
465 ok $?
"Expected fail on ust channel creation $channel_name in $sess_name"
467 ok
$ret "Enable channel $channel_name for session $sess_name"
471 function disable_ust_lttng_channel
()
474 local channel_name
=$2
476 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
477 ok $?
"Disable channel $channel_name for session $sess_name"
480 function enable_lttng_mmap_overwrite_kernel_channel
()
483 local channel_name
=$2
485 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
486 ok $?
"Enable channel $channel_name for session $sess_name"
489 function enable_lttng_mmap_overwrite_ust_channel
()
492 local channel_name
=$2
494 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
495 ok $?
"Enable channel $channel_name for session $sess_name"
498 function enable_ust_lttng_event
()
501 local event_name
="$2"
502 local channel_name
=$3
503 local expected_to_fail
=$4
505 if [ -z $channel_name ]; then
506 # default channel if none specified
509 chan
="-c $channel_name"
512 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
514 if [[ $expected_to_fail ]]; then
516 ok $?
"Enable ust event $event_name for session $session_name on channel $channel_name failed as expected"
518 ok
$ret "Enable event $event_name for session $sess_name"
522 function enable_jul_lttng_event
()
528 if [ -z $channel_name ]; then
529 # default channel if none specified
532 chan
="-c $channel_name"
535 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
536 ok $?
"Enable JUL event $event_name for session $sess_name"
539 function enable_jul_lttng_event_loglevel
()
542 local event_name
="$2"
544 local channel_name
=$4
546 if [ -z $channel_name ]; then
547 # default channel if none specified
550 chan
="-c $channel_name"
553 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
554 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
557 function enable_log4j_lttng_event
()
563 if [ -z $channel_name ]; then
564 # default channel if none specified
567 chan
="-c $channel_name"
570 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
571 ok $?
"Enable LOG4J event $event_name for session $sess_name"
574 function enable_log4j_lttng_event_loglevel
()
577 local event_name
="$2"
579 local channel_name
=$4
581 if [ -z $channel_name ]; then
582 # default channel if none specified
585 chan
="-c $channel_name"
588 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
589 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
592 function enable_ust_lttng_event_filter
()
595 local event_name
="$2"
598 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
599 ok $?
"Enable event $event_name with filtering for session $sess_name"
602 function enable_ust_lttng_event_loglevel
()
605 local event_name
="$2"
608 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
609 ok $?
"Enable event $event_name with loglevel $loglevel"
612 function enable_ust_lttng_event_loglevel_only
()
615 local event_name
="$2"
618 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
619 ok $?
"Enable event $event_name with loglevel-only $loglevel"
622 function disable_ust_lttng_event
()
625 local event_name
="$2"
626 local channel_name
="$3"
628 if [ -z $channel_name ]; then
629 # default channel if none specified
632 chan
="-c $channel_name"
635 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
636 ok $?
"Disable event $event_name for session $sess_name"
639 function disable_jul_lttng_event
()
642 local event_name
="$2"
644 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
645 ok $?
"Disable JUL event $event_name for session $sess_name"
648 function disable_log4j_lttng_event
()
651 local event_name
="$2"
653 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
654 ok $?
"Disable LOG4J event $event_name for session $sess_name"
657 function start_lttng_tracing
()
660 local expected_to_fail
=$2
662 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
664 if [[ $expected_to_fail ]]; then
666 ok $?
"Expected fail on start tracing for session: $sess_name"
668 ok
$ret "Start tracing for session $sess_name"
672 function stop_lttng_tracing
()
675 local expected_to_fail
=$2
677 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
679 if [[ $expected_to_fail ]]; then
681 ok $?
"Expected fail on stop tracing for session: $sess_name"
683 ok
$ret "Stop lttng tracing for session $sess_name"
687 function destroy_lttng_session
()
690 local expected_to_fail
=$2
692 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
694 if [[ $expected_to_fail ]]; then
696 ok $?
"Expected fail on session deletion $sess_name"
698 ok
$ret "Destroy session $sess_name"
702 function destroy_lttng_sessions
()
704 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
705 ok $?
"Destroy all lttng sessions"
708 function lttng_snapshot_add_output
()
712 local expected_to_fail
=$3
714 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
716 if [[ $expected_to_fail ]]; then
718 ok $?
"Failed to add a snapshot output file://$trace_path as expected"
720 ok
$ret "Added snapshot output file://$trace_path"
724 function lttng_snapshot_del_output
()
728 local expected_to_fail
=$3
730 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
732 if [[ $expected_to_fail ]]; then
734 ok $?
"Expect fail on deletion of snapshot output id $id"
736 ok
$ret "Deleted snapshot output id $id"
740 function lttng_snapshot_record
()
745 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
746 ok $?
"Snapshot recorded"
749 function lttng_snapshot_list
()
752 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
753 ok $?
"Snapshot list"
756 function lttng_save
()
761 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
762 ok $?
"Session successfully saved"
765 function lttng_load
()
769 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
770 ok $?
"Load command successful"
773 function trace_matches
()
779 which $BABELTRACE_BIN >/dev
/null
780 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
782 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
784 if [ "$count" -ne "$nr_iter" ]; then
786 diag
"$count matching events found in trace"
792 function trace_match_only
()
798 which $BABELTRACE_BIN >/dev
/null
799 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
801 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
802 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
804 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
805 pass
"Trace match with $total event $event_name"
808 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
812 function validate_trace
817 which $BABELTRACE_BIN >/dev
/null
818 if [ $?
-ne 0 ]; then
819 skip
0 "Babeltrace binary not found. Skipping trace validation"
824 for i
in $event_name; do
825 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
826 if [ "$traced" -ne 0 ]; then
827 pass
"Validate trace for event $i, $traced events"
829 fail
"Validate trace for event $i"
830 diag
"Found $traced occurences of $i"
838 function validate_trace_exp
()
843 which $BABELTRACE_BIN >/dev
/null
844 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
846 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
847 if [ "$traced" -ne 0 ]; then
848 pass
"Validate trace for expression '${event_exp}', $traced events"
850 fail
"Validate trace for expression '${event_exp}'"
851 diag
"Found $traced occurences of '${event_exp}'"
857 function validate_trace_only_exp
()
862 which $BABELTRACE_BIN >/dev
/null
863 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
865 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
866 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
868 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
869 pass
"Trace match with $total for expression '${event_exp}"
872 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
878 function validate_trace_empty
()
882 which $BABELTRACE_BIN >/dev
/null
883 if [ $?
-ne 0 ]; then
884 skip
0 "Babeltrace binary not found. Skipping trace validation"
887 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
888 if [ "$traced" -eq 0 ]; then
889 pass
"Validate empty trace"
891 fail
"Validate empty trace"
892 diag
"Found $traced events in trace"