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
()
307 local process_mode
=$2
310 DIR
=$
(readlink
-f $TESTDIR)
312 if [ -z $
(pgrep
$RELAYD_MATCH) ]; then
313 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
314 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
315 if [ $?
-eq 1 ]; then
316 if [ $withtap -eq "1" ]; then
317 fail
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
321 if [ $withtap -eq "1" ]; then
322 pass
"Start lttng-relayd (process mode: $process_mode opt: $opt)"
326 pass
"Start lttng-relayd (opt: $opt)"
329 RELAYD_PIDS
=$
(pgrep
$RELAYD_MATCH)
332 function start_lttng_relayd
()
334 start_lttng_relayd_opt
1 "-b" "$@"
337 function start_lttng_relayd_notap
()
339 start_lttng_relayd_opt
0 "-b" "$@"
342 function stop_lttng_relayd_opt
()
346 if [ $withtap -eq "1" ]; then
347 diag
"Killing lttng-relayd (pid: $RELAYD_PIDS)"
349 kill $RELAYD_PIDS 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
352 if [ $?
-eq 1 ]; then
353 if [ $withtap -eq "1" ]; then
354 fail
"Kill relay daemon"
359 while [ -n "$out" ]; do
360 out
=$
(pgrep
$RELAYD_MATCH)
363 if [ $withtap -eq "1" ]; then
364 pass
"Kill relay daemon"
371 function stop_lttng_relayd
()
373 stop_lttng_relayd_opt
1 "$@"
376 function stop_lttng_relayd_notap
()
378 stop_lttng_relayd_opt
0 "$@"
381 #First arg: show tap output
382 #Second argument: load path for automatic loading
383 function start_lttng_sessiond_opt
()
388 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
389 # Env variable requested no session daemon
393 validate_kernel_version
394 if [ $?
-ne 0 ]; then
395 fail
"Start session daemon"
396 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
399 DIR
=$
(readlink
-f $TESTDIR)
400 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
401 export LTTNG_SESSION_CONFIG_XSD_PATH
403 if [ -z $
(pgrep
${SESSIOND_MATCH}) ]; then
405 if [ -n "$load_path" ]; then
406 $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --load "$load_path" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
408 $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"
410 #$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
412 if [ $withtap -eq "1" ]; then
413 ok
$status "Start session daemon"
416 SESSIOND_PIDS
=$
(pgrep
$SESSIOND_MATCH)
419 function start_lttng_sessiond
()
421 start_lttng_sessiond_opt
1 "$@"
424 function start_lttng_sessiond_notap
()
426 start_lttng_sessiond_opt
0 "$@"
429 function stop_lttng_sessiond_opt
()
435 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
436 # Env variable requested no session daemon
440 local pids
="${SESSIOND_PIDS} $(pgrep $RUNAS_MATCH)"
443 kill_opt
="$kill_opt -s $signal"
445 if [ $withtap -eq "1" ]; then
446 diag
"Killing $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo $pids | tr '\n' ' ')"
448 kill $kill_opt $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
450 if [ $?
-eq 1 ]; then
451 if [ $withtap -eq "1" ]; then
452 fail
"Kill sessions daemon"
456 while [ -n "$out" ]; do
457 out
=$
(pgrep
${SESSIOND_MATCH})
461 while [ -n "$out" ]; do
462 out
=$
(pgrep
$CONSUMERD_MATCH)
467 if [ $withtap -eq "1" ]; then
468 pass
"Kill session daemon"
473 function stop_lttng_sessiond
()
475 stop_lttng_sessiond_opt
1 "$@"
478 function stop_lttng_sessiond_notap
()
480 stop_lttng_sessiond_opt
0 "$@"
483 function sigstop_lttng_sessiond_opt
()
489 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
490 # Env variable requested no session daemon
494 PID_SESSIOND
="$(pgrep ${SESSIOND_MATCH}) $(pgrep $RUNAS_MATCH)"
496 kill_opt
="$kill_opt -s $signal"
498 if [ $withtap -eq "1" ]; then
499 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
501 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
503 if [ $?
-eq 1 ]; then
504 if [ $withtap -eq "1" ]; then
505 fail
"Sending SIGSTOP to session daemon"
509 while [ $out -ne 0 ]; do
510 pid
=$
(pgrep
$SESSIOND_MATCH)
512 # Wait until state becomes stopped for session
515 for sessiond_pid
in $pid; do
516 state
=$
(ps
-p $sessiond_pid -o state
= )
517 if [[ -n "$state" && "$state" != "T" ]]; then
523 if [ $withtap -eq "1" ]; then
524 pass
"Sending SIGSTOP to session daemon"
529 function sigstop_lttng_sessiond
()
531 sigstop_lttng_sessiond_opt
1 "$@"
534 function sigstop_lttng_sessiond_notap
()
536 sigstop_lttng_sessiond_opt
0 "$@"
539 function stop_lttng_consumerd_opt
()
545 PID_CONSUMERD
=$
(pgrep
$CONSUMERD_MATCH)
548 kill_opt
="$kill_opt -s $signal"
551 if [ $withtap -eq "1" ]; then
552 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
554 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
558 if [ $?
-eq 1 ]; then
559 if [ $withtap -eq "1" ]; then
560 fail
"Kill consumer daemon"
565 while [ $out -ne 0 ]; do
566 pid
=$
(pgrep
$CONSUMERD_MATCH)
568 # If consumerds are still present check their status.
569 # A zombie status qualifies the consumerd as *killed*
571 for consumer_pid
in $pid; do
572 state
=$
(ps
-p $consumer_pid -o state
= )
573 if [[ -n "$state" && "$state" != "Z" ]]; then
579 if [ $withtap -eq "1" ]; then
580 pass
"Kill consumer daemon"
586 function stop_lttng_consumerd
()
588 stop_lttng_consumerd_opt
1 "$@"
591 function stop_lttng_consumerd_notap
()
593 stop_lttng_consumerd_opt
0 "$@"
596 function sigstop_lttng_consumerd_opt
()
602 PID_CONSUMERD
=$
(pgrep
$CONSUMERD_MATCH)
604 kill_opt
="$kill_opt -s $signal"
606 if [ $withtap -eq "1" ]; then
607 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
609 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
613 if [ $?
-eq 1 ]; then
614 if [ $withtap -eq "1" ]; then
615 fail
"Sending SIGSTOP to consumer daemon"
620 while [ $out -ne 0 ]; do
621 pid
=$
(pgrep
$CONSUMERD_MATCH)
623 # Wait until state becomes stopped for all
626 for consumer_pid
in $pid; do
627 state
=$
(ps
-p $consumer_pid -o state
= )
628 if [[ -n "$state" && "$state" != "T" ]]; then
634 if [ $withtap -eq "1" ]; then
635 pass
"Sending SIGSTOP to consumer daemon"
641 function sigstop_lttng_consumerd
()
643 sigstop_lttng_consumerd_opt
1 "$@"
646 function sigstop_lttng_consumerd_notap
()
648 sigstop_lttng_consumerd_opt
0 "$@"
651 function list_lttng_with_opts
()
654 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
655 ok $?
"Lttng-tool list command with option $opts"
658 function create_lttng_session_no_output
()
662 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
663 ok $?
"Create session $sess_name in no-output mode"
666 function create_lttng_session_uri
() {
671 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
672 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
675 function create_lttng_session
()
677 local expected_to_fail
=$1
682 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
684 if [[ $expected_to_fail -eq "1" ]]; then
686 ok $?
"Create session $sess_name in $trace_path failed as expected"
688 ok
$ret "Create session $sess_name in $trace_path"
692 function create_lttng_session_ok
()
694 create_lttng_session
0 "$@"
697 function create_lttng_session_fail
()
699 create_lttng_session
1 "$@"
703 function enable_ust_lttng_channel
()
705 local expected_to_fail
=$1
707 local channel_name
=$3
710 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
712 if [[ $expected_to_fail -eq "1" ]]; then
714 ok $?
"Enable channel $channel_name for session $sess_name failed as expected"
716 ok
$ret "Enable channel $channel_name for session $sess_name"
720 function enable_ust_lttng_channel_ok
()
722 enable_ust_lttng_channel
0 "$@"
725 function enable_ust_lttng_channel_fail
()
727 enable_ust_lttng_channel
1 "$@"
730 function disable_ust_lttng_channel
()
733 local channel_name
=$2
735 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
736 ok $?
"Disable channel $channel_name for session $sess_name"
739 function enable_lttng_mmap_overwrite_kernel_channel
()
742 local channel_name
=$2
744 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
745 ok $?
"Enable channel $channel_name for session $sess_name"
748 function enable_lttng_mmap_discard_small_kernel_channel
()
751 local channel_name
=$2
753 $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
754 ok $?
"Enable small discard channel $channel_name for session $sess_name"
757 function enable_lttng_mmap_overwrite_small_kernel_channel
()
760 local channel_name
=$2
762 $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
763 ok $?
"Enable small discard channel $channel_name for session $sess_name"
766 function enable_lttng_mmap_overwrite_ust_channel
()
769 local channel_name
=$2
771 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
772 ok $?
"Enable channel $channel_name for session $sess_name"
775 function enable_ust_lttng_event
()
777 local expected_to_fail
=$1
779 local event_name
="$3"
780 local channel_name
=$4
782 if [ -z $channel_name ]; then
783 # default channel if none specified
786 chan
="-c $channel_name"
789 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
791 if [[ $expected_to_fail -eq "1" ]]; then
793 ok $?
"Enable ust event $event_name for session $session_name failed as expected"
795 ok
$ret "Enable ust event $event_name for session $sess_name"
799 function enable_ust_lttng_event_ok
()
801 enable_ust_lttng_event
0 "$@"
804 function enable_ust_lttng_event_fail
()
806 enable_ust_lttng_event
1 "$@"
809 function enable_jul_lttng_event
()
815 if [ -z $channel_name ]; then
816 # default channel if none specified
819 chan
="-c $channel_name"
822 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
823 ok $?
"Enable JUL event $event_name for session $sess_name"
826 function enable_jul_lttng_event_loglevel
()
829 local event_name
="$2"
831 local channel_name
=$4
833 if [ -z $channel_name ]; then
834 # default channel if none specified
837 chan
="-c $channel_name"
840 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
841 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
844 function enable_log4j_lttng_event
()
850 if [ -z $channel_name ]; then
851 # default channel if none specified
854 chan
="-c $channel_name"
857 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
858 ok $?
"Enable LOG4J event $event_name for session $sess_name"
861 function enable_log4j_lttng_event_loglevel
()
864 local event_name
="$2"
866 local channel_name
=$4
868 if [ -z $channel_name ]; then
869 # default channel if none specified
872 chan
="-c $channel_name"
875 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
876 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
879 function enable_python_lttng_event
()
885 if [ -z $channel_name ]; then
886 # default channel if none specified
889 chan
="-c $channel_name"
892 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
893 ok $?
"Enable Python event $event_name for session $sess_name"
896 function enable_python_lttng_event_loglevel
()
899 local event_name
="$2"
901 local channel_name
=$4
903 if [ -z $channel_name ]; then
904 # default channel if none specified
907 chan
="-c $channel_name"
910 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
911 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
914 function enable_ust_lttng_event_filter
()
917 local event_name
="$2"
920 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
921 ok $?
"Enable event $event_name with filtering for session $sess_name"
924 function enable_ust_lttng_event_loglevel
()
927 local event_name
="$2"
930 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
931 ok $?
"Enable event $event_name with loglevel $loglevel"
934 function enable_ust_lttng_event_loglevel_only
()
937 local event_name
="$2"
940 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
941 ok $?
"Enable event $event_name with loglevel-only $loglevel"
944 function disable_ust_lttng_event
()
947 local event_name
="$2"
948 local channel_name
="$3"
950 if [ -z $channel_name ]; then
951 # default channel if none specified
954 chan
="-c $channel_name"
957 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
958 ok $?
"Disable event $event_name for session $sess_name"
961 function disable_jul_lttng_event
()
964 local event_name
="$2"
966 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
967 ok $?
"Disable JUL event $event_name for session $sess_name"
970 function disable_log4j_lttng_event
()
973 local event_name
="$2"
975 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
976 ok $?
"Disable LOG4J event $event_name for session $sess_name"
979 function disable_python_lttng_event
()
982 local event_name
="$2"
984 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
985 ok $?
"Disable Python event $event_name for session $sess_name"
988 function start_lttng_tracing
()
990 local expected_to_fail
=$1
993 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
995 if [[ $expected_to_fail -eq "1" ]]; then
997 ok $?
"Start tracing for session $sess_name failed as expected"
999 ok
$ret "Start tracing for session $sess_name"
1003 function start_lttng_tracing_ok
()
1005 start_lttng_tracing
0 "$@"
1008 function start_lttng_tracing_fail
()
1010 start_lttng_tracing
1 "$@"
1013 function stop_lttng_tracing
()
1015 local expected_to_fail
=$1
1018 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1020 if [[ $expected_to_fail -eq "1" ]]; then
1022 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1024 ok
$ret "Stop lttng tracing for session $sess_name"
1028 function stop_lttng_tracing_ok
()
1030 stop_lttng_tracing
0 "$@"
1033 function stop_lttng_tracing_fail
()
1035 stop_lttng_tracing
1 "$@"
1038 function destroy_lttng_session
()
1040 local expected_to_fail
=$1
1043 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1045 if [[ $expected_to_fail -eq "1" ]]; then
1047 ok $?
"Destroy session $sess_name failed as expected"
1049 ok
$ret "Destroy session $sess_name"
1053 function destroy_lttng_session_ok
()
1055 destroy_lttng_session
0 "$@"
1059 function destroy_lttng_session_fail
()
1061 destroy_lttng_session
1 "$@"
1065 function destroy_lttng_sessions
()
1067 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1068 ok $?
"Destroy all lttng sessions"
1071 function lttng_snapshot_add_output
()
1073 local expected_to_fail
=$1
1078 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1080 if [[ $expected_to_fail -eq 1 ]]; then
1082 ok $?
"Added snapshot output $trace_path failed as expected"
1084 ok
$ret "Added snapshot output $trace_path"
1088 function lttng_snapshot_add_output_ok
()
1090 lttng_snapshot_add_output
0 "$@"
1093 function lttng_snapshot_add_output_fail
()
1095 lttng_snapshot_add_output
1 "$@"
1098 function lttng_snapshot_del_output
()
1100 local expected_to_fail
=$1
1104 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1106 if [[ $expected_to_fail -eq "1" ]]; then
1108 ok $?
"Deleted snapshot output id $id failed as expected"
1110 ok
$ret "Deleted snapshot output id $id"
1114 function lttng_snapshot_del_output_ok
()
1116 lttng_snapshot_del_output
0 "$@"
1119 function lttng_snapshot_del_output_fail
()
1121 lttng_snapshot_del_output
1 "$@"
1124 function lttng_snapshot_record
()
1129 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1130 ok $?
"Snapshot recorded"
1133 function lttng_snapshot_list
()
1136 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1137 ok $?
"Snapshot list"
1140 function lttng_save
()
1145 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1146 ok $?
"Session saved"
1149 function lttng_load
()
1151 local expected_to_fail
=$1
1154 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1156 if [[ $expected_to_fail -eq "1" ]]; then
1158 ok $?
"Load command failed as expected with opts: $opts"
1160 ok
$ret "Load command with opts: $opts"
1164 function lttng_load_ok
()
1169 function lttng_load_fail
()
1174 function lttng_track
()
1176 local expected_to_fail
=$1
1178 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1180 if [[ $expected_to_fail -eq "1" ]]; then
1182 ok $?
"Track command failed as expected with opts: $opts"
1184 ok
$ret "Track command with opts: $opts"
1188 function lttng_track_ok
()
1193 function lttng_track_fail
()
1198 function lttng_untrack
()
1200 local expected_to_fail
=$1
1202 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1204 if [[ $expected_to_fail -eq "1" ]]; then
1206 ok $?
"Untrack command failed as expected with opts: $opts"
1208 ok
$ret "Untrack command with opts: $opts"
1212 function lttng_untrack_ok
()
1214 lttng_untrack
0 "$@"
1217 function lttng_untrack_fail
()
1219 lttng_untrack
1 "$@"
1222 function add_context_lttng
()
1224 local expected_to_fail
="$1"
1226 local session_name
="$3"
1227 local channel_name
="$4"
1230 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1232 if [[ $expected_to_fail -eq "1" ]]; then
1234 ok $?
"Add context command failed as expected for type: $type"
1236 ok
$ret "Add context command for type: $type"
1240 function add_context_ust_ok
()
1242 add_context_lttng
0 -u "$@"
1245 function add_context_ust_fail
()
1247 add_context_lttng
1 -u "$@"
1250 function add_context_kernel_ok
()
1252 add_context_lttng
0 -k "$@"
1255 function add_context_kernel_fail
()
1257 add_context_lttng
1 -k "$@"
1260 function trace_matches
()
1266 which $BABELTRACE_BIN >/dev
/null
1267 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1269 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1271 if [ "$count" -ne "$nr_iter" ]; then
1273 diag
"$count matching events found in trace"
1279 function trace_match_only
()
1285 which $BABELTRACE_BIN >/dev
/null
1286 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1288 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1289 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1291 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1292 pass
"Trace match with $total event $event_name"
1295 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1299 function validate_trace
1304 which $BABELTRACE_BIN >/dev
/null
1305 if [ $?
-ne 0 ]; then
1306 skip
0 "Babeltrace binary not found. Skipping trace validation"
1311 for i
in $event_name; do
1312 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1313 if [ "$traced" -ne 0 ]; then
1314 pass
"Validate trace for event $i, $traced events"
1316 fail
"Validate trace for event $i"
1317 diag
"Found $traced occurences of $i"
1325 function validate_trace_count
1329 local expected_count
=$3
1331 which $BABELTRACE_BIN >/dev
/null
1332 if [ $?
-ne 0 ]; then
1333 skip
0 "Babeltrace binary not found. Skipping trace validation"
1339 for i
in $event_name; do
1340 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1341 if [ "$traced" -ne 0 ]; then
1342 pass
"Validate trace for event $i, $traced events"
1344 fail
"Validate trace for event $i"
1345 diag
"Found $traced occurences of $i"
1347 cnt
=$
(($cnt + $traced))
1350 test $cnt -eq $expected_count
1351 ok $?
"Read a total of $cnt events, expected $expected_count"
1354 function trace_first_line
1358 which $BABELTRACE_BIN >/dev
/null
1359 if [ $?
-ne 0 ]; then
1360 skip
0 "Babeltrace binary not found. Skipping trace validation"
1363 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1366 function validate_trace_exp
()
1371 which $BABELTRACE_BIN >/dev
/null
1372 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1374 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1375 if [ "$traced" -ne 0 ]; then
1376 pass
"Validate trace for expression '${event_exp}', $traced events"
1378 fail
"Validate trace for expression '${event_exp}'"
1379 diag
"Found $traced occurences of '${event_exp}'"
1385 function validate_trace_only_exp
()
1390 which $BABELTRACE_BIN >/dev
/null
1391 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1393 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1394 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1396 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1397 pass
"Trace match with $total for expression '${event_exp}"
1400 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1406 function validate_trace_empty
()
1410 which $BABELTRACE_BIN >/dev
/null
1411 if [ $?
-ne 0 ]; then
1412 skip
0 "Babeltrace binary not found. Skipping trace validation"
1415 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1417 if [ $ret -ne 0 ]; then
1418 fail
"Failed to parse trace"
1422 traced
=$
(echo -n "$events" |
wc -l)
1423 if [ "$traced" -eq 0 ]; then
1424 pass
"Validate empty trace"
1426 fail
"Validate empty trace"
1427 diag
"Found $traced events in trace"
1433 function regenerate_metadata
()
1435 local expected_to_fail
=$1
1438 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1440 if [[ $expected_to_fail -eq "1" ]]; then
1442 ok $?
"Expected fail on regenerate metadata $sess_name"
1444 ok
$ret "Metadata regenerate $sess_name"
1448 function regenerate_metadata_ok
()
1450 regenerate_metadata
0 "$@"
1453 function regenerate_metadata_fail
()
1455 regenerate_metadata
1 "$@"
1458 function regenerate_statedump
()
1460 local expected_to_fail
=$1
1463 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1465 if [[ $expected_to_fail -eq "1" ]]; then
1467 ok $?
"Expected fail on regenerate statedump $sess_name"
1469 ok
$ret "Metadata regenerate $sess_name"
1473 function regenerate_statedump_ok
()
1475 regenerate_statedump
0 "$@"
1478 function regenerate_statedump_fail
()
1480 regenerate_statedump
1 "$@"
1483 function destructive_tests_enabled
()
1485 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then