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 # Check if base lttng-modules are present.
129 # Bail out on failure
130 function validate_lttng_modules_present
()
132 modprobe
-n lttng-tracer
2>/dev
/null
133 if [ $?
-ne 0 ]; then
134 BAIL_OUT
"LTTng modules not detected."
138 function enable_kernel_lttng_event
141 local expected_to_fail
="$2"
143 local event_name
="$4"
144 local channel_name
="$5"
146 if [ -z "$event_name" ]; then
147 # Enable all event if no event name specified
151 if [ -z "$channel_name" ]; then
152 # default channel if none specified
155 chan
="-c $channel_name"
158 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
160 if [[ $expected_to_fail -eq "1" ]]; then
163 if [ $withtap -eq "1" ]; then
164 ok
$ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
167 if [ $withtap -eq "1" ]; then
168 ok
$ret "Enable kernel event $event_name for session $sess_name"
173 function enable_kernel_lttng_event_ok
()
175 enable_kernel_lttng_event
1 0 "$@"
178 function enable_kernel_lttng_event_fail
()
180 enable_kernel_lttng_event
1 1 "$@"
183 function enable_kernel_lttng_event_notap
()
185 enable_kernel_lttng_event
0 0 "$@"
189 function lttng_enable_kernel_event
191 enable_kernel_lttng_event_ok
"$@"
194 function lttng_enable_kernel_syscall
()
196 local expected_to_fail
=$1
198 local syscall_name
=$3
199 local channel_name
=$4
201 if [ -z $syscall_name ]; then
202 # Enable all event if no syscall name specified
206 if [ -z $channel_name ]; then
207 # default channel if none specified
210 chan
="-c $channel_name"
213 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
215 if [[ $expected_to_fail -eq "1" ]]; then
217 ok $?
"Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
219 ok
$ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
223 function lttng_enable_kernel_syscall_ok
()
225 lttng_enable_kernel_syscall
0 "$@"
228 function lttng_enable_kernel_syscall_fail
()
230 lttng_enable_kernel_syscall
1 "$@"
233 function lttng_disable_kernel_syscall
()
235 local expected_to_fail
=$1
237 local syscall_name
=$3
238 local channel_name
=$4
240 if [ -z $syscall_name ]; then
241 # Enable all event if no syscall name specified
245 if [ -z $channel_name ]; then
246 # default channel if none specified
249 chan
="-c $channel_name"
252 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
--syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
255 if [[ $expected_to_fail -eq "1" ]]; then
257 ok $?
"Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
259 ok
$ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
263 function lttng_disable_kernel_syscall_ok
()
265 lttng_disable_kernel_syscall
0 "$@"
268 function lttng_disable_kernel_syscall_fail
()
270 lttng_disable_kernel_syscall
1 "$@"
273 function lttng_enable_kernel_channel
()
276 local expected_to_fail
=$2
278 local channel_name
=$4
281 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-k $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
283 if [[ $expected_to_fail -eq "1" ]]; then
286 if [ $withtap -eq "1" ]; then
287 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
290 if [ $withtap -eq "1" ]; then
291 ok
$ret "Enable channel $channel_name for session $sess_name"
296 function lttng_enable_kernel_channel_ok
()
298 lttng_enable_kernel_channel
1 0 "$@"
301 function lttng_enable_kernel_channel_fail
()
303 lttng_enable_kernel_channel
1 1 "$@"
306 function lttng_enable_kernel_channel_notap
()
308 lttng_enable_kernel_channel
0 0 "$@"
311 function enable_kernel_lttng_channel_ok
()
313 lttng_enable_kernel_channel
1 0 "$@"
316 function lttng_disable_kernel_channel
()
318 local expected_to_fail
=$1
320 local channel_name
=$3
322 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
324 if [[ $expected_to_fail -eq "1" ]]; then
326 ok $?
"Disable channel $channel_name for session $sess_name failed as expected"
328 ok
$ret "Disable channel $channel_name for session $sess_name"
332 function lttng_disable_kernel_channel_ok
()
334 lttng_disable_kernel_channel
0 "$@"
337 function lttng_disable_kernel_channel_fail
()
339 lttng_disable_kernel_channel
1 "$@"
342 function start_lttng_relayd_opt
()
347 DIR
=$
(readlink
-f $TESTDIR)
349 if [ -z $
(pgrep
$RELAYD_MATCH) ]; then
350 $DIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
351 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
352 if [ $?
-eq 1 ]; then
353 if [ $withtap -eq "1" ]; then
354 fail
"Start lttng-relayd (opt: $opt)"
358 if [ $withtap -eq "1" ]; then
359 pass
"Start lttng-relayd (opt: $opt)"
363 pass
"Start lttng-relayd (opt: $opt)"
366 RELAYD_PIDS
=$
(pgrep
$RELAYD_MATCH)
369 function start_lttng_relayd
()
371 start_lttng_relayd_opt
1 "$@"
374 function start_lttng_relayd_notap
()
376 start_lttng_relayd_opt
0 "$@"
379 function stop_lttng_relayd_opt
()
383 if [ $withtap -eq "1" ]; then
384 diag
"Killing lttng-relayd (pid: $RELAYD_PIDS)"
386 kill $RELAYD_PIDS 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
389 if [ $?
-eq 1 ]; then
390 if [ $withtap -eq "1" ]; then
391 fail
"Kill relay daemon"
396 while [ -n "$out" ]; do
397 out
=$
(pgrep
$RELAYD_MATCH)
400 if [ $withtap -eq "1" ]; then
401 pass
"Kill relay daemon"
408 function stop_lttng_relayd
()
410 stop_lttng_relayd_opt
1 "$@"
413 function stop_lttng_relayd_notap
()
415 stop_lttng_relayd_opt
0 "$@"
418 #First arg: show tap output
419 #Second argument: load path for automatic loading
420 function start_lttng_sessiond_opt
()
427 local long_bit_value
=$
(getconf LONG_BIT
)
429 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
430 # Env variable requested no session daemon
434 DIR
=$
(readlink
-f $TESTDIR)
436 # Get long_bit value for 32/64 consumerd
437 case "$long_bit_value" in
439 consumerd
="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
442 consumerd
="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
449 # Check for env. variable. Allow the use of LD_PRELOAD etc.
450 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
451 env_vars
=${LTTNG_SESSIOND_ENV_VARS}
454 validate_kernel_version
455 if [ $?
-ne 0 ]; then
456 fail
"Start session daemon"
457 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
460 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
461 export LTTNG_SESSION_CONFIG_XSD_PATH
463 if [ -z $
(pgrep
${SESSIOND_MATCH}) ]; then
465 if [ -n "$load_path" ]; then
466 env
$env_vars $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --load "$load_path" --background $consumerd
468 env
$env_vars $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --background $consumerd
470 #$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
472 if [ $withtap -eq "1" ]; then
473 ok
$status "Start session daemon"
476 SESSIOND_PIDS
=$
(pgrep
$SESSIOND_MATCH)
479 function start_lttng_sessiond
()
481 start_lttng_sessiond_opt
1 "$@"
484 function start_lttng_sessiond_notap
()
486 start_lttng_sessiond_opt
0 "$@"
489 function stop_lttng_sessiond_opt
()
495 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
496 # Env variable requested no session daemon
500 local pids
="${SESSIOND_PIDS} $(pgrep $RUNAS_MATCH)"
503 kill_opt
="$kill_opt -s $signal"
505 if [ $withtap -eq "1" ]; then
506 diag
"Killing $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo $pids | tr '\n' ' ')"
508 kill $kill_opt $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
510 if [ $?
-eq 1 ]; then
511 if [ $withtap -eq "1" ]; then
512 fail
"Kill sessions daemon"
516 while [ -n "$out" ]; do
517 out
=$
(pgrep
${SESSIOND_MATCH})
521 while [ -n "$out" ]; do
522 out
=$
(pgrep
$CONSUMERD_MATCH)
527 if [ $withtap -eq "1" ]; then
528 pass
"Kill session daemon"
533 function stop_lttng_sessiond
()
535 stop_lttng_sessiond_opt
1 "$@"
538 function stop_lttng_sessiond_notap
()
540 stop_lttng_sessiond_opt
0 "$@"
543 function sigstop_lttng_sessiond_opt
()
549 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
550 # Env variable requested no session daemon
554 PID_SESSIOND
="$(pgrep ${SESSIOND_MATCH}) $(pgrep $RUNAS_MATCH)"
556 kill_opt
="$kill_opt -s $signal"
558 if [ $withtap -eq "1" ]; then
559 diag
"Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
561 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
563 if [ $?
-eq 1 ]; then
564 if [ $withtap -eq "1" ]; then
565 fail
"Sending SIGSTOP to session daemon"
569 while [ $out -ne 0 ]; do
570 pid
=$
(pgrep
$SESSIOND_MATCH)
572 # Wait until state becomes stopped for session
575 for sessiond_pid
in $pid; do
576 state
=$
(ps
-p $sessiond_pid -o state
= )
577 if [[ -n "$state" && "$state" != "T" ]]; then
583 if [ $withtap -eq "1" ]; then
584 pass
"Sending SIGSTOP to session daemon"
589 function sigstop_lttng_sessiond
()
591 sigstop_lttng_sessiond_opt
1 "$@"
594 function sigstop_lttng_sessiond_notap
()
596 sigstop_lttng_sessiond_opt
0 "$@"
599 function stop_lttng_consumerd_opt
()
605 PID_CONSUMERD
=$
(pgrep
$CONSUMERD_MATCH)
608 kill_opt
="$kill_opt -s $signal"
611 if [ $withtap -eq "1" ]; then
612 diag
"Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
615 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
618 if [ $?
-eq 1 ]; then
619 if [ $withtap -eq "1" ]; then
620 fail
"Kill consumer daemon"
625 while [ $out -ne 0 ]; do
626 pid
=$
(pgrep
$CONSUMERD_MATCH)
628 # If consumerds are still present check their status.
629 # A zombie status qualifies the consumerd as *killed*
631 for consumer_pid
in $pid; do
632 state
=$
(ps
-p $consumer_pid -o state
= )
633 if [[ -n "$state" && "$state" != "Z" ]]; then
639 if [ $withtap -eq "1" ]; then
640 pass
"Kill consumer daemon"
646 function stop_lttng_consumerd
()
648 stop_lttng_consumerd_opt
1 "$@"
651 function stop_lttng_consumerd_notap
()
653 stop_lttng_consumerd_opt
0 "$@"
656 function sigstop_lttng_consumerd_opt
()
662 PID_CONSUMERD
=$
(pgrep
$CONSUMERD_MATCH)
664 kill_opt
="$kill_opt -s $signal"
666 if [ $withtap -eq "1" ]; then
667 diag
"Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
669 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
672 if [ $?
-eq 1 ]; then
673 if [ $withtap -eq "1" ]; then
674 fail
"Sending SIGSTOP to consumer daemon"
679 while [ $out -ne 0 ]; do
680 pid
=$
(pgrep
$CONSUMERD_MATCH)
682 # Wait until state becomes stopped for all
685 for consumer_pid
in $pid; do
686 state
=$
(ps
-p $consumer_pid -o state
= )
687 if [[ -n "$state" && "$state" != "T" ]]; then
693 if [ $withtap -eq "1" ]; then
694 pass
"Sending SIGSTOP to consumer daemon"
700 function sigstop_lttng_consumerd
()
702 sigstop_lttng_consumerd_opt
1 "$@"
705 function sigstop_lttng_consumerd_notap
()
707 sigstop_lttng_consumerd_opt
0 "$@"
710 function list_lttng_with_opts
()
713 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
714 ok $?
"Lttng-tool list command with option $opts"
717 function create_lttng_session_no_output
()
721 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
722 ok $?
"Create session $sess_name in no-output mode"
725 function create_lttng_session_uri
() {
730 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
731 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
734 function create_lttng_session
()
737 local expected_to_fail
=$2
742 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
744 if [ $expected_to_fail -eq "1" ]; then
747 if [ $withtap -eq "1" ]; then
748 ok
$ret "Create session $sess_name in $trace_path failed as expected"
751 if [ $withtap -eq "1" ]; then
752 ok
$ret "Create session $sess_name in $trace_path"
758 function create_lttng_session_ok
()
760 create_lttng_session
1 0 "$@"
763 function create_lttng_session_fail
()
765 create_lttng_session
1 1 "$@"
768 function create_lttng_session_notap
()
770 create_lttng_session
0 0 "$@"
774 function enable_ust_lttng_channel
()
777 local expected_to_fail
=$2
779 local channel_name
=$4
782 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
784 if [[ $expected_to_fail -eq "1" ]]; then
787 if [ $withtap -eq "1" ]; then
788 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
791 if [ $withtap -eq "1" ]; then
792 ok
$ret "Enable channel $channel_name for session $sess_name"
798 function enable_ust_lttng_channel_ok
()
800 enable_ust_lttng_channel
1 0 "$@"
803 function enable_ust_lttng_channel_fail
()
805 enable_ust_lttng_channel
1 1 "$@"
808 function enable_ust_lttng_channel_notap
()
810 enable_ust_lttng_channel
0 0 "$@"
813 function disable_ust_lttng_channel
()
816 local channel_name
=$2
818 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
819 ok $?
"Disable channel $channel_name for session $sess_name"
822 function enable_lttng_mmap_overwrite_kernel_channel
()
825 local channel_name
=$2
827 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
828 ok $?
"Enable channel $channel_name for session $sess_name"
831 function enable_lttng_mmap_discard_small_kernel_channel
()
834 local channel_name
=$2
836 $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
837 ok $?
"Enable small discard channel $channel_name for session $sess_name"
840 function enable_lttng_mmap_overwrite_small_kernel_channel
()
843 local channel_name
=$2
845 $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
846 ok $?
"Enable small discard channel $channel_name for session $sess_name"
849 function enable_lttng_mmap_overwrite_ust_channel
()
852 local channel_name
=$2
854 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
855 ok $?
"Enable channel $channel_name for session $sess_name"
858 function enable_ust_lttng_event
()
861 local expected_to_fail
=$2
863 local event_name
="$4"
864 local channel_name
=$5
866 if [ -z $channel_name ]; then
867 # default channel if none specified
870 chan
="-c $channel_name"
873 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
875 if [[ $expected_to_fail -eq "1" ]]; then
878 if [[ $withtap -eq "1" ]]; then
879 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
882 if [[ $withtap -eq "1" ]]; then
883 ok
$ret "Enable ust event $event_name for session $sess_name"
889 function enable_ust_lttng_event_ok
()
891 enable_ust_lttng_event
1 0 "$@"
894 function enable_ust_lttng_event_fail
()
896 enable_ust_lttng_event
1 1 "$@"
899 function enable_ust_lttng_event_notap
()
901 enable_ust_lttng_event
0 0 "$@"
904 function enable_jul_lttng_event
()
910 if [ -z $channel_name ]; then
911 # default channel if none specified
914 chan
="-c $channel_name"
917 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
918 ok $?
"Enable JUL event $event_name for session $sess_name"
921 function enable_jul_lttng_event_loglevel
()
924 local event_name
="$2"
926 local channel_name
=$4
928 if [ -z $channel_name ]; then
929 # default channel if none specified
932 chan
="-c $channel_name"
935 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
936 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
939 function enable_log4j_lttng_event
()
945 if [ -z $channel_name ]; then
946 # default channel if none specified
949 chan
="-c $channel_name"
952 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
953 ok $?
"Enable LOG4J event $event_name for session $sess_name"
956 function enable_log4j_lttng_event_loglevel
()
959 local event_name
="$2"
961 local channel_name
=$4
963 if [ -z $channel_name ]; then
964 # default channel if none specified
967 chan
="-c $channel_name"
970 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
971 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
974 function enable_python_lttng_event
()
980 if [ -z $channel_name ]; then
981 # default channel if none specified
984 chan
="-c $channel_name"
987 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
988 ok $?
"Enable Python event $event_name for session $sess_name"
991 function enable_python_lttng_event_loglevel
()
994 local event_name
="$2"
996 local channel_name
=$4
998 if [ -z $channel_name ]; then
999 # default channel if none specified
1002 chan
="-c $channel_name"
1005 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1006 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1009 function enable_ust_lttng_event_filter
()
1011 local sess_name
="$1"
1012 local event_name
="$2"
1015 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1016 ok $?
"Enable event $event_name with filtering for session $sess_name"
1019 function enable_ust_lttng_event_loglevel
()
1021 local sess_name
="$1"
1022 local event_name
="$2"
1025 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1026 ok $?
"Enable event $event_name with loglevel $loglevel"
1029 function enable_ust_lttng_event_loglevel_only
()
1031 local sess_name
="$1"
1032 local event_name
="$2"
1035 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1036 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1039 function disable_ust_lttng_event
()
1041 local sess_name
="$1"
1042 local event_name
="$2"
1043 local channel_name
="$3"
1045 if [ -z $channel_name ]; then
1046 # default channel if none specified
1049 chan
="-c $channel_name"
1052 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1053 ok $?
"Disable event $event_name for session $sess_name"
1056 function disable_jul_lttng_event
()
1058 local sess_name
="$1"
1059 local event_name
="$2"
1061 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1062 ok $?
"Disable JUL event $event_name for session $sess_name"
1065 function disable_log4j_lttng_event
()
1067 local sess_name
="$1"
1068 local event_name
="$2"
1070 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1071 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1074 function disable_python_lttng_event
()
1076 local sess_name
="$1"
1077 local event_name
="$2"
1079 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1080 ok $?
"Disable Python event $event_name for session $sess_name"
1083 function start_lttng_tracing
()
1085 local expected_to_fail
=$1
1088 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1090 if [[ $expected_to_fail -eq "1" ]]; then
1092 ok $?
"Start tracing for session $sess_name failed as expected"
1094 ok
$ret "Start tracing for session $sess_name"
1098 function start_lttng_tracing_ok
()
1100 start_lttng_tracing
0 "$@"
1103 function start_lttng_tracing_fail
()
1105 start_lttng_tracing
1 "$@"
1108 function stop_lttng_tracing
()
1110 local expected_to_fail
=$1
1113 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1115 if [[ $expected_to_fail -eq "1" ]]; then
1117 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1119 ok
$ret "Stop lttng tracing for session $sess_name"
1123 function stop_lttng_tracing_ok
()
1125 stop_lttng_tracing
0 "$@"
1128 function stop_lttng_tracing_fail
()
1130 stop_lttng_tracing
1 "$@"
1133 function destroy_lttng_session
()
1136 local expected_to_fail
=$2
1139 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1141 if [[ $expected_to_fail -eq "1" ]]; then
1144 if [ $withtap -eq "1" ]; then
1145 ok
$ret "Destroy session $sess_name failed as expected"
1148 if [ $withtap -eq "1" ]; then
1149 ok
$ret "Destroy session $sess_name"
1154 function destroy_lttng_session_ok
()
1156 destroy_lttng_session
1 0 "$@"
1160 function destroy_lttng_session_fail
()
1162 destroy_lttng_session
1 1 "$@"
1165 function destroy_lttng_session_notap
()
1167 destroy_lttng_session
0 0 "$@"
1170 function destroy_lttng_sessions
()
1172 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1173 ok $?
"Destroy all lttng sessions"
1176 function lttng_snapshot_add_output
()
1178 local expected_to_fail
=$1
1182 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1184 if [[ $expected_to_fail -eq 1 ]]; then
1186 ok $?
"Added snapshot output file://$trace_path failed as expected"
1188 ok
$ret "Added snapshot output file://$trace_path"
1192 function lttng_snapshot_add_output_ok
()
1194 lttng_snapshot_add_output
0 "$@"
1197 function lttng_snapshot_add_output_fail
()
1199 lttng_snapshot_add_output
1 "$@"
1202 function lttng_snapshot_del_output
()
1204 local expected_to_fail
=$1
1208 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1210 if [[ $expected_to_fail -eq "1" ]]; then
1212 ok $?
"Deleted snapshot output id $id failed as expected"
1214 ok
$ret "Deleted snapshot output id $id"
1218 function lttng_snapshot_del_output_ok
()
1220 lttng_snapshot_del_output
0 "$@"
1223 function lttng_snapshot_del_output_fail
()
1225 lttng_snapshot_del_output
1 "$@"
1228 function lttng_snapshot_record
()
1233 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1234 ok $?
"Snapshot recorded"
1237 function lttng_snapshot_list
()
1240 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1241 ok $?
"Snapshot list"
1244 function lttng_save
()
1249 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1250 ok $?
"Session saved"
1253 function lttng_load
()
1255 local expected_to_fail
=$1
1258 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1260 if [[ $expected_to_fail -eq "1" ]]; then
1262 ok $?
"Load command failed as expected with opts: $opts"
1264 ok
$ret "Load command with opts: $opts"
1268 function lttng_load_ok
()
1273 function lttng_load_fail
()
1278 function lttng_track
()
1280 local expected_to_fail
=$1
1282 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1284 if [[ $expected_to_fail -eq "1" ]]; then
1286 ok $?
"Track command failed as expected with opts: $opts"
1288 ok
$ret "Track command with opts: $opts"
1292 function lttng_track_ok
()
1297 function lttng_track_fail
()
1302 function lttng_untrack
()
1304 local expected_to_fail
=$1
1306 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1308 if [[ $expected_to_fail -eq "1" ]]; then
1310 ok $?
"Untrack command failed as expected with opts: $opts"
1312 ok
$ret "Untrack command with opts: $opts"
1316 function lttng_untrack_ok
()
1318 lttng_untrack
0 "$@"
1321 function lttng_untrack_fail
()
1323 lttng_untrack
1 "$@"
1326 function add_context_lttng
()
1328 local expected_to_fail
="$1"
1330 local session_name
="$3"
1331 local channel_name
="$4"
1334 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1336 if [[ $expected_to_fail -eq "1" ]]; then
1338 ok $?
"Add context command failed as expected for type: $type"
1340 ok
$ret "Add context command for type: $type"
1344 function add_context_ust_ok
()
1346 add_context_lttng
0 -u "$@"
1349 function add_context_ust_fail
()
1351 add_context_lttng
1 -u "$@"
1354 function add_context_kernel_ok
()
1356 add_context_lttng
0 -k "$@"
1359 function add_context_kernel_fail
()
1361 add_context_lttng
1 -k "$@"
1364 function trace_matches
()
1370 which $BABELTRACE_BIN >/dev
/null
1371 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1373 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1375 if [ "$count" -ne "$nr_iter" ]; then
1377 diag
"$count matching events found in trace"
1383 function trace_match_only
()
1389 which $BABELTRACE_BIN >/dev
/null
1390 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1392 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1393 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1395 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1396 pass
"Trace match with $total event $event_name"
1399 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1403 function validate_trace
1408 which $BABELTRACE_BIN >/dev
/null
1409 if [ $?
-ne 0 ]; then
1410 skip
0 "Babeltrace binary not found. Skipping trace validation"
1415 for i
in $event_name; do
1416 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1417 if [ "$traced" -ne 0 ]; then
1418 pass
"Validate trace for event $i, $traced events"
1420 fail
"Validate trace for event $i"
1421 diag
"Found $traced occurences of $i"
1429 function validate_trace_count
1433 local expected_count
=$3
1435 which $BABELTRACE_BIN >/dev
/null
1436 if [ $?
-ne 0 ]; then
1437 skip
0 "Babeltrace binary not found. Skipping trace validation"
1443 for i
in $event_name; do
1444 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1445 if [ "$traced" -ne 0 ]; then
1446 pass
"Validate trace for event $i, $traced events"
1448 fail
"Validate trace for event $i"
1449 diag
"Found $traced occurences of $i"
1451 cnt
=$
(($cnt + $traced))
1454 test $cnt -eq $expected_count
1455 ok $?
"Read a total of $cnt events, expected $expected_count"
1458 function trace_first_line
1462 which $BABELTRACE_BIN >/dev
/null
1463 if [ $?
-ne 0 ]; then
1464 skip
0 "Babeltrace binary not found. Skipping trace validation"
1467 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1470 function validate_trace_exp
()
1475 which $BABELTRACE_BIN >/dev
/null
1476 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1478 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep ${event_exp} |
wc -l)
1479 if [ "$traced" -ne 0 ]; then
1480 pass
"Validate trace for expression '${event_exp}', $traced events"
1482 fail
"Validate trace for expression '${event_exp}'"
1483 diag
"Found $traced occurences of '${event_exp}'"
1489 function validate_trace_only_exp
()
1494 which $BABELTRACE_BIN >/dev
/null
1495 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1497 local count
=$
($BABELTRACE_BIN $trace_path |
grep ${event_exp} |
wc -l)
1498 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1500 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1501 pass
"Trace match with $total for expression '${event_exp}"
1504 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1510 function validate_trace_empty
()
1514 which $BABELTRACE_BIN >/dev
/null
1515 if [ $?
-ne 0 ]; then
1516 skip
0 "Babeltrace binary not found. Skipping trace validation"
1519 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1521 if [ $ret -ne 0 ]; then
1522 fail
"Failed to parse trace"
1526 traced
=$
(echo -n "$events" |
wc -l)
1527 if [ "$traced" -eq 0 ]; then
1528 pass
"Validate empty trace"
1530 fail
"Validate empty trace"
1531 diag
"Found $traced events in trace"
1537 function regenerate_metadata
()
1539 local expected_to_fail
=$1
1542 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1544 if [[ $expected_to_fail -eq "1" ]]; then
1546 ok $?
"Expected fail on regenerate metadata $sess_name"
1548 ok
$ret "Metadata regenerate $sess_name"
1552 function regenerate_metadata_ok
()
1554 regenerate_metadata
0 "$@"
1557 function regenerate_metadata_fail
()
1559 regenerate_metadata
1 "$@"
1562 function regenerate_statedump
()
1564 local expected_to_fail
=$1
1567 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1569 if [[ $expected_to_fail -eq "1" ]]; then
1571 ok $?
"Expected fail on regenerate statedump $sess_name"
1573 ok
$ret "Metadata regenerate $sess_name"
1577 function regenerate_statedump_ok
()
1579 regenerate_statedump
0 "$@"
1582 function regenerate_statedump_fail
()
1584 regenerate_statedump
1 "$@"
1587 function destructive_tests_enabled
()
1589 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then