1 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
3 # This library is free software; you can redistribute it and/or modify it under
4 # the terms of the GNU Lesser General Public License as published by the Free
5 # Software Foundation; version 2.1 of the License.
7 # This library is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 # You should have received a copy of the GNU Lesser General Public License
13 # along with this library; if not, write to the Free Software Foundation, Inc.,
14 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 SESSIOND_BIN
="lttng-sessiond"
17 SESSIOND_MATCH
=".*lttng-sess.*"
19 RUNAS_BIN
="lttng-runas"
20 RUNAS_MATCH
=".*lttng-runas.*"
21 CONSUMERD_BIN
="lttng-consumerd"
22 CONSUMERD_MATCH
=".*lttng-consumerd.*"
23 RELAYD_BIN
="lttng-relayd"
24 RELAYD_MATCH
=".*lttng-relayd.*"
27 BABELTRACE_BIN
="babeltrace"
29 ERROR_OUTPUT_DEST
=/dev
/null
31 # Minimal kernel version supported for session daemon tests
32 KERNEL_MAJOR_VERSION
=2
33 KERNEL_MINOR_VERSION
=6
34 KERNEL_PATCHLEVEL_VERSION
=27
36 # We set the default UST register timeout and network and app socket timeout to
37 # "wait forever", so that basic tests don't have to worry about hitting
38 # timeouts on busy systems. Specialized tests should test those corner-cases.
39 export LTTNG_UST_REGISTER_TIMEOUT
=-1
40 export LTTNG_NETWORK_SOCKET_TIMEOUT
=-1
41 export LTTNG_APP_SOCKET_TIMEOUT
=-1
43 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
44 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
45 # its own sessiond if none is running. It also ensures that 'lttng create'
46 # fails when no sessiond is running.
47 export LTTNG_SESSIOND_PATH
="/bin/true"
49 source $TESTDIR/utils
/tap
/tap.sh
51 function full_cleanup
()
53 if [ -n "${SESSIOND_PIDS}" ] ||
[ -n "${RELAYD_PIDS}" ]; then
54 kill -9 ${SESSIOND_PIDS} ${RELAYD_PIDS} > /dev
/null
2>&1
57 # Disable trap for SIGTERM since the following kill to the
58 # pidgroup will be SIGTERM. Otherwise it loops.
59 # The '-' before the pid number ($$) indicates 'kill' to signal the
60 # whole process group.
61 trap - SIGTERM
&& kill -- -$$
65 trap full_cleanup SIGINT SIGTERM
69 # Check if we are a terminal
71 echo -e "\e[1;32mOK\e[0m"
77 function print_fail
()
79 # Check if we are a terminal
81 echo -e "\e[1;31mFAIL\e[0m"
87 function print_test_banner
()
93 function validate_kernel_version
()
95 local kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
96 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
99 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
102 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
108 # Generate a random string
109 # $1 = number of characters; defaults to 16
110 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
111 function randstring
()
113 [ "$2" == "0" ] && CHAR
="[:alnum:]" || CHAR
="[:graph:]"
114 cat /dev
/urandom
2>/dev
/null |
tr -cd "$CHAR" 2>/dev
/null |
head -c ${1:-16} 2>/dev
/null
118 # Return the number of _configured_ CPUs.
119 function conf_proc_count
()
121 getconf _NPROCESSORS_CONF
122 if [ $?
-ne 0 ]; then
123 diag
"Failed to get the number of configured CPUs"
128 function enable_kernel_lttng_event
130 local expected_to_fail
="$1"
132 local event_name
="$3"
133 local channel_name
="$4"
135 if [ -z "$event_name" ]; then
136 # Enable all event if no event name specified
140 if [ -z "$channel_name" ]; then
141 # default channel if none specified
144 chan
="-c $channel_name"
147 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
149 if [[ $expected_to_fail -eq "1" ]]; then
151 ok $?
"Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
153 ok
$ret "Enable kernel event $event_name for session $sess_name"
157 function enable_kernel_lttng_event_ok
()
159 enable_kernel_lttng_event
0 "$@"
162 function enable_kernel_lttng_event_fail
()
164 enable_kernel_lttng_event
1 "$@"
168 function lttng_enable_kernel_event
170 enable_kernel_lttng_event_ok
"$@"
173 function lttng_enable_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 enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
194 if [[ $expected_to_fail -eq "1" ]]; then
196 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
198 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
202 function lttng_enable_kernel_syscall_ok
()
204 lttng_enable_kernel_syscall
0 "$@"
207 function lttng_enable_kernel_syscall_fail
()
209 lttng_enable_kernel_syscall
1 "$@"
212 function lttng_disable_kernel_syscall
()
214 local expected_to_fail
=$1
216 local syscall_name
=$3
217 local channel_name
=$4
219 if [ -z $syscall_name ]; then
220 # Enable all event if no syscall name specified
224 if [ -z $channel_name ]; then
225 # default channel if none specified
228 chan
="-c $channel_name"
231 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
234 if [[ $expected_to_fail -eq "1" ]]; then
236 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
238 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
242 function lttng_disable_kernel_syscall_ok
()
244 lttng_disable_kernel_syscall
0 "$@"
247 function lttng_disable_kernel_syscall_fail
()
249 lttng_disable_kernel_syscall
1 "$@"
252 function lttng_enable_kernel_channel
()
254 local expected_to_fail
=$1
256 local channel_name
=$3
258 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
260 if [[ $expected_to_fail -eq "1" ]]; then
262 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
264 ok
$ret "Enable channel $channel_name for session $sess_name"
268 function lttng_enable_kernel_channel_ok
()
270 lttng_enable_kernel_channel
0 "$@"
273 function lttng_enable_kernel_channel_fail
()
275 lttng_enable_kernel_channel
1 "$@"
278 function lttng_disable_kernel_channel
()
280 local expected_to_fail
=$1
282 local channel_name
=$3
284 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
286 if [[ $expected_to_fail -eq "1" ]]; then
288 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
290 ok
$ret "Disable channel $channel_name for session $sess_name"
294 function lttng_disable_kernel_channel_ok
()
296 lttng_disable_kernel_channel
0 "$@"
299 function lttng_disable_kernel_channel_fail
()
301 lttng_disable_kernel_channel
1 "$@"
304 function start_lttng_relayd_opt
()
309 DIR
=$
(readlink
-f $TESTDIR)
311 if [ -z $
(pgrep
$RELAYD_MATCH) ]; then
312 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
313 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
314 if [ $?
-eq 1 ]; then
315 if [ $withtap -eq "1" ]; then
316 fail
"Start lttng-relayd (opt: $opt)"
320 if [ $withtap -eq "1" ]; then
321 pass
"Start lttng-relayd (opt: $opt)"
325 pass
"Start lttng-relayd (opt: $opt)"
328 RELAYD_PIDS
=$
(pgrep
$RELAYD_MATCH)
331 function start_lttng_relayd
()
333 start_lttng_relayd_opt
1 "$@"
336 function start_lttng_relayd_notap
()
338 start_lttng_relayd_opt
0 "$@"
341 function stop_lttng_relayd_opt
()
345 if [ $withtap -eq "1" ]; then
346 diag
"Killing lttng-relayd (pid: $RELAYD_PIDS)"
348 kill $RELAYD_PIDS 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
351 if [ $?
-eq 1 ]; then
352 if [ $withtap -eq "1" ]; then
353 fail
"Kill relay daemon"
358 while [ -n "$out" ]; do
359 out
=$
(pgrep
$RELAYD_MATCH)
362 if [ $withtap -eq "1" ]; then
363 pass
"Kill relay daemon"
370 function stop_lttng_relayd
()
372 stop_lttng_relayd_opt
1 "$@"
375 function stop_lttng_relayd_notap
()
377 stop_lttng_relayd_opt
0 "$@"
380 #First arg: show tap output
381 #Second argument: load path for automatic loading
382 function start_lttng_sessiond_opt
()
389 local long_bit_value
=$
(getconf LONG_BIT
)
391 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
392 # Env variable requested no session daemon
396 DIR
=$
(readlink
-f $TESTDIR)
398 # Get long_bit value for 32/64 consumerd
399 case "$long_bit_value" in
401 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
404 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
411 # Check for env. variable. Allow the use of LD_PRELOAD etc.
412 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
413 env_vars
=${LTTNG_SESSIOND_ENV_VARS}
416 validate_kernel_version
417 if [ $?
-ne 0 ]; then
418 fail
"Start session daemon"
419 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
422 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
423 export LTTNG_SESSION_CONFIG_XSD_PATH
425 if [ -z $
(pgrep
${SESSIOND_MATCH}) ]; then
427 if [ -n "$load_path" ]; then
428 env
$env_vars $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --load "$load_path" --background $consumerd
430 env
$env_vars $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --background $consumerd
432 #$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
434 if [ $withtap -eq "1" ]; then
435 ok
$status "Start session daemon"
438 SESSIOND_PIDS
=$
(pgrep
$SESSIOND_MATCH)
441 function start_lttng_sessiond
()
443 start_lttng_sessiond_opt
1 "$@"
446 function start_lttng_sessiond_notap
()
448 start_lttng_sessiond_opt
0 "$@"
451 function stop_lttng_sessiond_opt
()
457 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
458 # Env variable requested no session daemon
462 local pids
="${SESSIOND_PIDS} $(pgrep $RUNAS_MATCH)"
465 kill_opt
="$kill_opt -s $signal"
467 if [ $withtap -eq "1" ]; then
468 diag
"Killing $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo $pids | tr '\n' ' ')"
470 kill $kill_opt $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
472 if [ $?
-eq 1 ]; then
473 if [ $withtap -eq "1" ]; then
474 fail
"Kill sessions daemon"
478 while [ -n "$out" ]; do
479 out
=$
(pgrep
${SESSIOND_MATCH})
483 while [ -n "$out" ]; do
484 out
=$
(pgrep
$CONSUMERD_MATCH)
489 if [ $withtap -eq "1" ]; then
490 pass
"Kill session daemon"
495 function stop_lttng_sessiond
()
497 stop_lttng_sessiond_opt
1 "$@"
500 function stop_lttng_sessiond_notap
()
502 stop_lttng_sessiond_opt
0 "$@"
505 function sigstop_lttng_sessiond_opt
()
511 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
512 # Env variable requested no session daemon
516 PID_SESSIOND
="$(pgrep ${SESSIOND_MATCH}) $(pgrep $RUNAS_MATCH)"
518 kill_opt
="$kill_opt -s $signal"
520 if [ $withtap -eq "1" ]; then
521 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
523 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
525 if [ $?
-eq 1 ]; then
526 if [ $withtap -eq "1" ]; then
527 fail
"Sending SIGSTOP to session daemon"
531 while [ $out -ne 0 ]; do
532 pid
=$
(pgrep
$SESSIOND_MATCH)
534 # Wait until state becomes stopped for session
537 for sessiond_pid
in $pid; do
538 state
=$
(ps
-p $sessiond_pid -o state
= )
539 if [[ -n "$state" && "$state" != "T" ]]; then
545 if [ $withtap -eq "1" ]; then
546 pass
"Sending SIGSTOP to session daemon"
551 function sigstop_lttng_sessiond
()
553 sigstop_lttng_sessiond_opt
1 "$@"
556 function sigstop_lttng_sessiond_notap
()
558 sigstop_lttng_sessiond_opt
0 "$@"
561 function stop_lttng_consumerd_opt
()
567 PID_CONSUMERD
=$
(pgrep
$CONSUMERD_MATCH)
570 kill_opt
="$kill_opt -s $signal"
573 if [ $withtap -eq "1" ]; then
574 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
576 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
580 if [ $?
-eq 1 ]; then
581 if [ $withtap -eq "1" ]; then
582 fail
"Kill consumer daemon"
587 while [ $out -ne 0 ]; do
588 pid
=$
(pgrep
$CONSUMERD_MATCH)
590 # If consumerds are still present check their status.
591 # A zombie status qualifies the consumerd as *killed*
593 for consumer_pid
in $pid; do
594 state
=$
(ps
-p $consumer_pid -o state
= )
595 if [[ -n "$state" && "$state" != "Z" ]]; then
601 if [ $withtap -eq "1" ]; then
602 pass
"Kill consumer daemon"
608 function stop_lttng_consumerd
()
610 stop_lttng_consumerd_opt
1 "$@"
613 function stop_lttng_consumerd_notap
()
615 stop_lttng_consumerd_opt
0 "$@"
618 function sigstop_lttng_consumerd_opt
()
624 PID_CONSUMERD
=$
(pgrep
$CONSUMERD_MATCH)
626 kill_opt
="$kill_opt -s $signal"
628 if [ $withtap -eq "1" ]; then
629 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
631 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
635 if [ $?
-eq 1 ]; then
636 if [ $withtap -eq "1" ]; then
637 fail
"Sending SIGSTOP to consumer daemon"
642 while [ $out -ne 0 ]; do
643 pid
=$
(pgrep
$CONSUMERD_MATCH)
645 # Wait until state becomes stopped for all
648 for consumer_pid
in $pid; do
649 state
=$
(ps
-p $consumer_pid -o state
= )
650 if [[ -n "$state" && "$state" != "T" ]]; then
656 if [ $withtap -eq "1" ]; then
657 pass
"Sending SIGSTOP to consumer daemon"
663 function sigstop_lttng_consumerd
()
665 sigstop_lttng_consumerd_opt
1 "$@"
668 function sigstop_lttng_consumerd_notap
()
670 sigstop_lttng_consumerd_opt
0 "$@"
673 function list_lttng_with_opts
()
676 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
677 ok $?
"Lttng-tool list command with option $opts"
680 function create_lttng_session_no_output
()
684 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
685 ok $?
"Create session $sess_name in no-output mode"
688 function create_lttng_session
()
691 local expected_to_fail
=$2
696 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
698 if [ $expected_to_fail -eq "1" ]; then
701 if [ $withtap -eq "1" ]; then
702 ok
$ret "Create session $sess_name in $trace_path failed as expected"
705 if [ $withtap -eq "1" ]; then
706 ok
$ret "Create session $sess_name in $trace_path"
712 function create_lttng_session_ok
()
714 create_lttng_session
1 0 "$@"
717 function create_lttng_session_fail
()
719 create_lttng_session
1 1 "$@"
722 function create_lttng_session_notap
()
724 create_lttng_session
0 0 "$@"
728 function enable_ust_lttng_channel
()
731 local expected_to_fail
=$2
733 local channel_name
=$4
736 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
738 if [[ $expected_to_fail -eq "1" ]]; then
741 if [ $withtap -eq "1" ]; then
742 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
745 if [ $withtap -eq "1" ]; then
746 ok
$ret "Enable channel $channel_name for session $sess_name"
752 function enable_ust_lttng_channel_ok
()
754 enable_ust_lttng_channel
1 0 "$@"
757 function enable_ust_lttng_channel_fail
()
759 enable_ust_lttng_channel
1 1 "$@"
762 function enable_ust_lttng_channel_notap
()
764 enable_ust_lttng_channel
0 0 "$@"
767 function disable_ust_lttng_channel
()
770 local channel_name
=$2
772 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
773 ok $?
"Disable channel $channel_name for session $sess_name"
776 function enable_lttng_mmap_overwrite_kernel_channel
()
779 local channel_name
=$2
781 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
782 ok $?
"Enable channel $channel_name for session $sess_name"
785 function enable_lttng_mmap_discard_small_kernel_channel
()
788 local channel_name
=$2
790 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--discard --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
791 ok $?
"Enable small discard channel $channel_name for session $sess_name"
794 function enable_lttng_mmap_overwrite_small_kernel_channel
()
797 local channel_name
=$2
799 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite --subbuf-size=$
(getconf PAGE_SIZE
) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
800 ok $?
"Enable small discard channel $channel_name for session $sess_name"
803 function enable_lttng_mmap_overwrite_ust_channel
()
806 local channel_name
=$2
808 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
809 ok $?
"Enable channel $channel_name for session $sess_name"
812 function enable_ust_lttng_event
()
815 local expected_to_fail
=$2
817 local event_name
="$4"
818 local channel_name
=$5
820 if [ -z $channel_name ]; then
821 # default channel if none specified
824 chan
="-c $channel_name"
827 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
829 if [[ $expected_to_fail -eq "1" ]]; then
832 if [[ $withtap -eq "1" ]]; then
833 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
836 if [[ $withtap -eq "1" ]]; then
837 ok
$ret "Enable ust event $event_name for session $sess_name"
843 function enable_ust_lttng_event_ok
()
845 enable_ust_lttng_event
1 0 "$@"
848 function enable_ust_lttng_event_fail
()
850 enable_ust_lttng_event
1 1 "$@"
853 function enable_ust_lttng_event_notap
()
855 enable_ust_lttng_event
0 0 "$@"
858 function enable_jul_lttng_event
()
864 if [ -z $channel_name ]; then
865 # default channel if none specified
868 chan
="-c $channel_name"
871 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
872 ok $?
"Enable JUL event $event_name for session $sess_name"
875 function enable_jul_lttng_event_loglevel
()
878 local event_name
="$2"
880 local channel_name
=$4
882 if [ -z $channel_name ]; then
883 # default channel if none specified
886 chan
="-c $channel_name"
889 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
890 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
893 function enable_log4j_lttng_event
()
899 if [ -z $channel_name ]; then
900 # default channel if none specified
903 chan
="-c $channel_name"
906 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
907 ok $?
"Enable LOG4J event $event_name for session $sess_name"
910 function enable_log4j_lttng_event_loglevel
()
913 local event_name
="$2"
915 local channel_name
=$4
917 if [ -z $channel_name ]; then
918 # default channel if none specified
921 chan
="-c $channel_name"
924 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
925 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
928 function enable_python_lttng_event
()
934 if [ -z $channel_name ]; then
935 # default channel if none specified
938 chan
="-c $channel_name"
941 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
942 ok $?
"Enable Python event $event_name for session $sess_name"
945 function enable_python_lttng_event_loglevel
()
948 local event_name
="$2"
950 local channel_name
=$4
952 if [ -z $channel_name ]; then
953 # default channel if none specified
956 chan
="-c $channel_name"
959 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
960 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
963 function enable_ust_lttng_event_filter
()
966 local event_name
="$2"
969 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
970 ok $?
"Enable event $event_name with filtering for session $sess_name"
973 function enable_ust_lttng_event_loglevel
()
976 local event_name
="$2"
979 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
980 ok $?
"Enable event $event_name with loglevel $loglevel"
983 function enable_ust_lttng_event_loglevel_only
()
986 local event_name
="$2"
989 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
990 ok $?
"Enable event $event_name with loglevel-only $loglevel"
993 function disable_ust_lttng_event
()
996 local event_name
="$2"
997 local channel_name
="$3"
999 if [ -z $channel_name ]; then
1000 # default channel if none specified
1003 chan
="-c $channel_name"
1006 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1007 ok $?
"Disable event $event_name for session $sess_name"
1010 function disable_jul_lttng_event
()
1012 local sess_name
="$1"
1013 local event_name
="$2"
1015 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1016 ok $?
"Disable JUL event $event_name for session $sess_name"
1019 function disable_log4j_lttng_event
()
1021 local sess_name
="$1"
1022 local event_name
="$2"
1024 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1025 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1028 function disable_python_lttng_event
()
1030 local sess_name
="$1"
1031 local event_name
="$2"
1033 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1034 ok $?
"Disable Python event $event_name for session $sess_name"
1037 function start_lttng_tracing
()
1039 local expected_to_fail
=$1
1042 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1044 if [[ $expected_to_fail -eq "1" ]]; then
1046 ok $?
"Start tracing for session $sess_name failed as expected"
1048 ok
$ret "Start tracing for session $sess_name"
1052 function start_lttng_tracing_ok
()
1054 start_lttng_tracing
0 "$@"
1057 function start_lttng_tracing_fail
()
1059 start_lttng_tracing
1 "$@"
1062 function stop_lttng_tracing
()
1064 local expected_to_fail
=$1
1067 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1069 if [[ $expected_to_fail -eq "1" ]]; then
1071 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1073 ok
$ret "Stop lttng tracing for session $sess_name"
1077 function stop_lttng_tracing_ok
()
1079 stop_lttng_tracing
0 "$@"
1082 function stop_lttng_tracing_fail
()
1084 stop_lttng_tracing
1 "$@"
1087 function destroy_lttng_session
()
1089 local expected_to_fail
=$1
1092 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1094 if [[ $expected_to_fail -eq "1" ]]; then
1096 ok $?
"Destroy session $sess_name failed as expected"
1098 ok
$ret "Destroy session $sess_name"
1102 function destroy_lttng_session_ok
()
1104 destroy_lttng_session
0 "$@"
1108 function destroy_lttng_session_fail
()
1110 destroy_lttng_session
1 "$@"
1114 function destroy_lttng_sessions
()
1116 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1117 ok $?
"Destroy all lttng sessions"
1120 function lttng_snapshot_add_output
()
1122 local expected_to_fail
=$1
1126 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1128 if [[ $expected_to_fail -eq 1 ]]; then
1130 ok $?
"Added snapshot output file://$trace_path failed as expected"
1132 ok
$ret "Added snapshot output file://$trace_path"
1136 function lttng_snapshot_add_output_ok
()
1138 lttng_snapshot_add_output
0 "$@"
1141 function lttng_snapshot_add_output_fail
()
1143 lttng_snapshot_add_output
1 "$@"
1146 function lttng_snapshot_del_output
()
1148 local expected_to_fail
=$1
1152 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1154 if [[ $expected_to_fail -eq "1" ]]; then
1156 ok $?
"Deleted snapshot output id $id failed as expected"
1158 ok
$ret "Deleted snapshot output id $id"
1162 function lttng_snapshot_del_output_ok
()
1164 lttng_snapshot_del_output
0 "$@"
1167 function lttng_snapshot_del_output_fail
()
1169 lttng_snapshot_del_output
1 "$@"
1172 function lttng_snapshot_record
()
1177 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1178 ok $?
"Snapshot recorded"
1181 function lttng_snapshot_list
()
1184 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1185 ok $?
"Snapshot list"
1188 function lttng_save
()
1193 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1194 ok $?
"Session saved"
1197 function lttng_load
()
1199 local expected_to_fail
=$1
1202 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1204 if [[ $expected_to_fail -eq "1" ]]; then
1206 ok $?
"Load command failed as expected with opts: $opts"
1208 ok
$ret "Load command with opts: $opts"
1212 function lttng_load_ok
()
1217 function lttng_load_fail
()
1222 function lttng_track
()
1224 local expected_to_fail
=$1
1226 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1228 if [[ $expected_to_fail -eq "1" ]]; then
1230 ok $?
"Track command failed as expected with opts: $opts"
1232 ok
$ret "Track command with opts: $opts"
1236 function lttng_track_ok
()
1241 function lttng_track_fail
()
1246 function lttng_untrack
()
1248 local expected_to_fail
=$1
1250 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1252 if [[ $expected_to_fail -eq "1" ]]; then
1254 ok $?
"Untrack command failed as expected with opts: $opts"
1256 ok
$ret "Untrack command with opts: $opts"
1260 function lttng_untrack_ok
()
1262 lttng_untrack
0 "$@"
1265 function lttng_untrack_fail
()
1267 lttng_untrack
1 "$@"
1270 function add_context_lttng
()
1272 local expected_to_fail
="$1"
1274 local session_name
="$3"
1275 local channel_name
="$4"
1278 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1280 if [[ $expected_to_fail -eq "1" ]]; then
1282 ok $?
"Add context command failed as expected for type: $type"
1284 ok
$ret "Add context command for type: $type"
1288 function add_context_ust_ok
()
1290 add_context_lttng
0 -u "$@"
1293 function add_context_ust_fail
()
1295 add_context_lttng
1 -u "$@"
1298 function add_context_kernel_ok
()
1300 add_context_lttng
0 -k "$@"
1303 function add_context_kernel_fail
()
1305 add_context_lttng
1 -k "$@"
1308 function trace_matches
()
1314 which $BABELTRACE_BIN >/dev
/null
1315 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1317 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1319 if [ "$count" -ne "$nr_iter" ]; then
1321 diag
"$count matching events found in trace"
1327 function trace_match_only
()
1333 which $BABELTRACE_BIN >/dev
/null
1334 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1336 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1337 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1339 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1340 pass
"Trace match with $total event $event_name"
1343 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1347 function validate_trace
1352 which $BABELTRACE_BIN >/dev
/null
1353 if [ $?
-ne 0 ]; then
1354 skip
0 "Babeltrace binary not found. Skipping trace validation"
1359 for i
in $event_name; do
1360 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1361 if [ "$traced" -ne 0 ]; then
1362 pass
"Validate trace for event $i, $traced events"
1364 fail
"Validate trace for event $i"
1365 diag
"Found $traced occurences of $i"
1373 function validate_trace_count
1377 local expected_count
=$3
1379 which $BABELTRACE_BIN >/dev
/null
1380 if [ $?
-ne 0 ]; then
1381 skip
0 "Babeltrace binary not found. Skipping trace validation"
1387 for i
in $event_name; do
1388 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1389 if [ "$traced" -ne 0 ]; then
1390 pass
"Validate trace for event $i, $traced events"
1392 fail
"Validate trace for event $i"
1393 diag
"Found $traced occurences of $i"
1395 cnt
=$
(($cnt + $traced))
1398 test $cnt -eq $expected_count
1399 ok $?
"Read a total of $cnt events, expected $expected_count"
1402 function trace_first_line
1406 which $BABELTRACE_BIN >/dev
/null
1407 if [ $?
-ne 0 ]; then
1408 skip
0 "Babeltrace binary not found. Skipping trace validation"
1411 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1414 function validate_trace_exp
()
1419 which $BABELTRACE_BIN >/dev
/null
1420 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1422 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1423 if [ "$traced" -ne 0 ]; then
1424 pass
"Validate trace for expression '${event_exp}', $traced events"
1426 fail
"Validate trace for expression '${event_exp}'"
1427 diag
"Found $traced occurences of '${event_exp}'"
1433 function validate_trace_only_exp
()
1438 which $BABELTRACE_BIN >/dev
/null
1439 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1441 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1442 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1444 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1445 pass
"Trace match with $total for expression '${event_exp}"
1448 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1454 function validate_trace_empty
()
1458 which $BABELTRACE_BIN >/dev
/null
1459 if [ $?
-ne 0 ]; then
1460 skip
0 "Babeltrace binary not found. Skipping trace validation"
1463 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
wc -l)
1464 if [ "$traced" -eq 0 ]; then
1465 pass
"Validate empty trace"
1467 fail
"Validate empty trace"
1468 diag
"Found $traced events in trace"
1474 function regenerate_metadata
()
1476 local expected_to_fail
=$1
1479 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1481 if [[ $expected_to_fail -eq "1" ]]; then
1483 ok $?
"Expected fail on regenerate metadata $sess_name"
1485 ok
$ret "Metadata regenerate $sess_name"
1489 function regenerate_metadata_ok
()
1491 regenerate_metadata
0 "$@"
1494 function regenerate_metadata_fail
()
1496 regenerate_metadata
1 "$@"
1499 function regenerate_statedump
()
1501 local expected_to_fail
=$1
1504 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1506 if [[ $expected_to_fail -eq "1" ]]; then
1508 ok $?
"Expected fail on regenerate statedump $sess_name"
1510 ok
$ret "Metadata regenerate $sess_name"
1514 function regenerate_statedump_ok
()
1516 regenerate_statedump
0 "$@"
1519 function regenerate_statedump_fail
()
1521 regenerate_statedump
1 "$@"
1524 function destructive_tests_enabled
()
1526 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then