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' ' ')"
614 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
673 if [ $?
-eq 1 ]; then
674 if [ $withtap -eq "1" ]; then
675 fail
"Sending SIGSTOP to consumer daemon"
680 while [ $out -ne 0 ]; do
681 pid
=$
(pgrep
$CONSUMERD_MATCH)
683 # Wait until state becomes stopped for all
686 for consumer_pid
in $pid; do
687 state
=$
(ps
-p $consumer_pid -o state
= )
688 if [[ -n "$state" && "$state" != "T" ]]; then
694 if [ $withtap -eq "1" ]; then
695 pass
"Sending SIGSTOP to consumer daemon"
701 function sigstop_lttng_consumerd
()
703 sigstop_lttng_consumerd_opt
1 "$@"
706 function sigstop_lttng_consumerd_notap
()
708 sigstop_lttng_consumerd_opt
0 "$@"
711 function list_lttng_with_opts
()
714 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN list
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
715 ok $?
"Lttng-tool list command with option $opts"
718 function create_lttng_session_no_output
()
722 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
723 ok $?
"Create session $sess_name in no-output mode"
726 function create_lttng_session_uri
() {
731 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
732 ok $?
"Create session $sess_name with uri:$uri and opts: $opts"
735 function create_lttng_session
()
738 local expected_to_fail
=$2
743 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path $opt > $OUTPUT_DEST
745 if [ $expected_to_fail -eq "1" ]; then
748 if [ $withtap -eq "1" ]; then
749 ok
$ret "Create session $sess_name in $trace_path failed as expected"
752 if [ $withtap -eq "1" ]; then
753 ok
$ret "Create session $sess_name in $trace_path"
759 function create_lttng_session_ok
()
761 create_lttng_session
1 0 "$@"
764 function create_lttng_session_fail
()
766 create_lttng_session
1 1 "$@"
769 function create_lttng_session_notap
()
771 create_lttng_session
0 0 "$@"
775 function enable_ust_lttng_channel
()
778 local expected_to_fail
=$2
780 local channel_name
=$4
783 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
785 if [[ $expected_to_fail -eq "1" ]]; then
788 if [ $withtap -eq "1" ]; then
789 ok
$ret "Enable channel $channel_name for session $sess_name failed as expected"
792 if [ $withtap -eq "1" ]; then
793 ok
$ret "Enable channel $channel_name for session $sess_name"
799 function enable_ust_lttng_channel_ok
()
801 enable_ust_lttng_channel
1 0 "$@"
804 function enable_ust_lttng_channel_fail
()
806 enable_ust_lttng_channel
1 1 "$@"
809 function enable_ust_lttng_channel_notap
()
811 enable_ust_lttng_channel
0 0 "$@"
814 function disable_ust_lttng_channel
()
817 local channel_name
=$2
819 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
-u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
820 ok $?
"Disable channel $channel_name for session $sess_name"
823 function enable_lttng_mmap_overwrite_kernel_channel
()
826 local channel_name
=$2
828 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -k --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
829 ok $?
"Enable channel $channel_name for session $sess_name"
832 function enable_lttng_mmap_discard_small_kernel_channel
()
835 local channel_name
=$2
837 $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
838 ok $?
"Enable small discard channel $channel_name for session $sess_name"
841 function enable_lttng_mmap_overwrite_small_kernel_channel
()
844 local channel_name
=$2
846 $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
847 ok $?
"Enable small discard channel $channel_name for session $sess_name"
850 function enable_lttng_mmap_overwrite_ust_channel
()
853 local channel_name
=$2
855 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
-s $sess_name $channel_name -u --output mmap
--overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
856 ok $?
"Enable channel $channel_name for session $sess_name"
859 function enable_ust_lttng_event
()
862 local expected_to_fail
=$2
864 local event_name
="$4"
865 local channel_name
=$5
867 if [ -z $channel_name ]; then
868 # default channel if none specified
871 chan
="-c $channel_name"
874 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
876 if [[ $expected_to_fail -eq "1" ]]; then
879 if [[ $withtap -eq "1" ]]; then
880 ok
$ret "Enable ust event $event_name for session $session_name failed as expected"
883 if [[ $withtap -eq "1" ]]; then
884 ok
$ret "Enable ust event $event_name for session $sess_name"
890 function enable_ust_lttng_event_ok
()
892 enable_ust_lttng_event
1 0 "$@"
895 function enable_ust_lttng_event_fail
()
897 enable_ust_lttng_event
1 1 "$@"
900 function enable_ust_lttng_event_notap
()
902 enable_ust_lttng_event
0 0 "$@"
905 function enable_jul_lttng_event
()
911 if [ -z $channel_name ]; then
912 # default channel if none specified
915 chan
="-c $channel_name"
918 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
919 ok $?
"Enable JUL event $event_name for session $sess_name"
922 function enable_jul_lttng_event_loglevel
()
925 local event_name
="$2"
927 local channel_name
=$4
929 if [ -z $channel_name ]; then
930 # default channel if none specified
933 chan
="-c $channel_name"
936 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
937 ok $?
"Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
940 function enable_log4j_lttng_event
()
946 if [ -z $channel_name ]; then
947 # default channel if none specified
950 chan
="-c $channel_name"
953 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
954 ok $?
"Enable LOG4J event $event_name for session $sess_name"
957 function enable_log4j_lttng_event_loglevel
()
960 local event_name
="$2"
962 local channel_name
=$4
964 if [ -z $channel_name ]; then
965 # default channel if none specified
968 chan
="-c $channel_name"
971 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
972 ok $?
"Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
975 function enable_python_lttng_event
()
981 if [ -z $channel_name ]; then
982 # default channel if none specified
985 chan
="-c $channel_name"
988 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
989 ok $?
"Enable Python event $event_name for session $sess_name"
992 function enable_python_lttng_event_loglevel
()
995 local event_name
="$2"
997 local channel_name
=$4
999 if [ -z $channel_name ]; then
1000 # default channel if none specified
1003 chan
="-c $channel_name"
1006 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
--loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1007 ok $?
"Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1010 function enable_ust_lttng_event_filter
()
1012 local sess_name
="$1"
1013 local event_name
="$2"
1016 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1017 ok $?
"Enable event $event_name with filtering for session $sess_name"
1020 function enable_ust_lttng_event_loglevel
()
1022 local sess_name
="$1"
1023 local event_name
="$2"
1026 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1027 ok $?
"Enable event $event_name with loglevel $loglevel"
1030 function enable_ust_lttng_event_loglevel_only
()
1032 local sess_name
="$1"
1033 local event_name
="$2"
1036 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1037 ok $?
"Enable event $event_name with loglevel-only $loglevel"
1040 function disable_ust_lttng_event
()
1042 local sess_name
="$1"
1043 local event_name
="$2"
1044 local channel_name
="$3"
1046 if [ -z $channel_name ]; then
1047 # default channel if none specified
1050 chan
="-c $channel_name"
1053 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1054 ok $?
"Disable event $event_name for session $sess_name"
1057 function disable_jul_lttng_event
()
1059 local sess_name
="$1"
1060 local event_name
="$2"
1062 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -j >/dev
/null
2>&1
1063 ok $?
"Disable JUL event $event_name for session $sess_name"
1066 function disable_log4j_lttng_event
()
1068 local sess_name
="$1"
1069 local event_name
="$2"
1071 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -l >/dev
/null
2>&1
1072 ok $?
"Disable LOG4J event $event_name for session $sess_name"
1075 function disable_python_lttng_event
()
1077 local sess_name
="$1"
1078 local event_name
="$2"
1080 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-event
"$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1081 ok $?
"Disable Python event $event_name for session $sess_name"
1084 function start_lttng_tracing
()
1086 local expected_to_fail
=$1
1089 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1091 if [[ $expected_to_fail -eq "1" ]]; then
1093 ok $?
"Start tracing for session $sess_name failed as expected"
1095 ok
$ret "Start tracing for session $sess_name"
1099 function start_lttng_tracing_ok
()
1101 start_lttng_tracing
0 "$@"
1104 function start_lttng_tracing_fail
()
1106 start_lttng_tracing
1 "$@"
1109 function stop_lttng_tracing
()
1111 local expected_to_fail
=$1
1114 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1116 if [[ $expected_to_fail -eq "1" ]]; then
1118 ok $?
"Stop lttng tracing for session $sess_name failed as expected"
1120 ok
$ret "Stop lttng tracing for session $sess_name"
1124 function stop_lttng_tracing_ok
()
1126 stop_lttng_tracing
0 "$@"
1129 function stop_lttng_tracing_fail
()
1131 stop_lttng_tracing
1 "$@"
1134 function destroy_lttng_session
()
1137 local expected_to_fail
=$2
1140 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1142 if [[ $expected_to_fail -eq "1" ]]; then
1145 if [ $withtap -eq "1" ]; then
1146 ok
$ret "Destroy session $sess_name failed as expected"
1149 if [ $withtap -eq "1" ]; then
1150 ok
$ret "Destroy session $sess_name"
1155 function destroy_lttng_session_ok
()
1157 destroy_lttng_session
1 0 "$@"
1161 function destroy_lttng_session_fail
()
1163 destroy_lttng_session
1 1 "$@"
1166 function destroy_lttng_session_notap
()
1168 destroy_lttng_session
0 0 "$@"
1171 function destroy_lttng_sessions
()
1173 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
--all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1174 ok $?
"Destroy all lttng sessions"
1177 function lttng_snapshot_add_output
()
1179 local expected_to_fail
=$1
1183 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1185 if [[ $expected_to_fail -eq 1 ]]; then
1187 ok $?
"Added snapshot output file://$trace_path failed as expected"
1189 ok
$ret "Added snapshot output file://$trace_path"
1193 function lttng_snapshot_add_output_ok
()
1195 lttng_snapshot_add_output
0 "$@"
1198 function lttng_snapshot_add_output_fail
()
1200 lttng_snapshot_add_output
1 "$@"
1203 function lttng_snapshot_del_output
()
1205 local expected_to_fail
=$1
1209 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot del-output
-s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1211 if [[ $expected_to_fail -eq "1" ]]; then
1213 ok $?
"Deleted snapshot output id $id failed as expected"
1215 ok
$ret "Deleted snapshot output id $id"
1219 function lttng_snapshot_del_output_ok
()
1221 lttng_snapshot_del_output
0 "$@"
1224 function lttng_snapshot_del_output_fail
()
1226 lttng_snapshot_del_output
1 "$@"
1229 function lttng_snapshot_record
()
1234 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot record
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1235 ok $?
"Snapshot recorded"
1238 function lttng_snapshot_list
()
1241 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot list-output
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1242 ok $?
"Snapshot list"
1245 function lttng_save
()
1250 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1251 ok $?
"Session saved"
1254 function lttng_load
()
1256 local expected_to_fail
=$1
1259 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN load
$opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1261 if [[ $expected_to_fail -eq "1" ]]; then
1263 ok $?
"Load command failed as expected with opts: $opts"
1265 ok
$ret "Load command with opts: $opts"
1269 function lttng_load_ok
()
1274 function lttng_load_fail
()
1279 function lttng_track
()
1281 local expected_to_fail
=$1
1283 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN track
$opts >$OUTPUT_DEST
1285 if [[ $expected_to_fail -eq "1" ]]; then
1287 ok $?
"Track command failed as expected with opts: $opts"
1289 ok
$ret "Track command with opts: $opts"
1293 function lttng_track_ok
()
1298 function lttng_track_fail
()
1303 function lttng_untrack
()
1305 local expected_to_fail
=$1
1307 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN untrack
$opts >$OUTPUT_DEST
1309 if [[ $expected_to_fail -eq "1" ]]; then
1311 ok $?
"Untrack command failed as expected with opts: $opts"
1313 ok
$ret "Untrack command with opts: $opts"
1317 function lttng_untrack_ok
()
1319 lttng_untrack
0 "$@"
1322 function lttng_untrack_fail
()
1324 lttng_untrack
1 "$@"
1327 function lttng_track_pid_ok
()
1330 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track
--kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1331 ok $?
"Lttng track pid on the kernel domain"
1334 function lttng_untrack_kernel_all_ok
()
1336 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack
--kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1337 ok $?
"Lttng untrack all pid on the kernel domain"
1340 function lttng_add_context_list
()
1342 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
--list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1344 ok
$ret "Context listing"
1347 function add_context_lttng
()
1349 local expected_to_fail
="$1"
1351 local session_name
="$3"
1352 local channel_name
="$4"
1355 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN add-context
-s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1357 if [[ $expected_to_fail -eq "1" ]]; then
1359 ok $?
"Add context command failed as expected for type: $type"
1361 ok
$ret "Add context command for type: $type"
1365 function add_context_ust_ok
()
1367 add_context_lttng
0 -u "$@"
1370 function add_context_ust_fail
()
1372 add_context_lttng
1 -u "$@"
1375 function add_context_kernel_ok
()
1377 add_context_lttng
0 -k "$@"
1380 function add_context_kernel_fail
()
1382 add_context_lttng
1 -k "$@"
1385 function trace_matches
()
1391 which $BABELTRACE_BIN >/dev
/null
1392 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1394 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1396 if [ "$count" -ne "$nr_iter" ]; then
1398 diag
"$count matching events found in trace"
1404 function trace_match_only
()
1410 which $BABELTRACE_BIN >/dev
/null
1411 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1413 local count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
1414 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1416 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1417 pass
"Trace match with $total event $event_name"
1420 diag
"$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1424 function validate_trace
1429 which $BABELTRACE_BIN >/dev
/null
1430 if [ $?
-ne 0 ]; then
1431 skip
0 "Babeltrace binary not found. Skipping trace validation"
1436 for i
in $event_name; do
1437 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1438 if [ "$traced" -ne 0 ]; then
1439 pass
"Validate trace for event $i, $traced events"
1441 fail
"Validate trace for event $i"
1442 diag
"Found $traced occurences of $i"
1450 function validate_trace_count
1454 local expected_count
=$3
1456 which $BABELTRACE_BIN >/dev
/null
1457 if [ $?
-ne 0 ]; then
1458 skip
0 "Babeltrace binary not found. Skipping trace validation"
1464 for i
in $event_name; do
1465 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep $i |
wc -l)
1466 if [ "$traced" -ne 0 ]; then
1467 pass
"Validate trace for event $i, $traced events"
1469 fail
"Validate trace for event $i"
1470 diag
"Found $traced occurences of $i"
1472 cnt
=$
(($cnt + $traced))
1475 test $cnt -eq $expected_count
1476 ok $?
"Read a total of $cnt events, expected $expected_count"
1479 function trace_first_line
1483 which $BABELTRACE_BIN >/dev
/null
1484 if [ $?
-ne 0 ]; then
1485 skip
0 "Babeltrace binary not found. Skipping trace validation"
1488 $BABELTRACE_BIN $trace_path 2>/dev
/null |
head -n 1
1491 function validate_trace_exp
()
1496 which $BABELTRACE_BIN >/dev
/null
1497 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace validation"
1499 traced
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null |
grep --extended-regexp ${event_exp} |
wc -l)
1500 if [ "$traced" -ne 0 ]; then
1501 pass
"Validate trace for expression '${event_exp}', $traced events"
1503 fail
"Validate trace for expression '${event_exp}'"
1504 diag
"Found $traced occurences of '${event_exp}'"
1510 function validate_trace_only_exp
()
1515 which $BABELTRACE_BIN >/dev
/null
1516 skip $?
-ne 0 "Babeltrace binary not found. Skipping trace matches"
1518 local count
=$
($BABELTRACE_BIN $trace_path |
grep --extended-regexp ${event_exp} |
wc -l)
1519 local total
=$
($BABELTRACE_BIN $trace_path |
wc -l)
1521 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1522 pass
"Trace match with $total for expression '${event_exp}'"
1525 diag
"$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1531 function validate_trace_empty
()
1535 which $BABELTRACE_BIN >/dev
/null
1536 if [ $?
-ne 0 ]; then
1537 skip
0 "Babeltrace binary not found. Skipping trace validation"
1540 events
=$
($BABELTRACE_BIN $trace_path 2>/dev
/null
)
1542 if [ $ret -ne 0 ]; then
1543 fail
"Failed to parse trace"
1547 traced
=$
(echo -n "$events" |
wc -l)
1548 if [ "$traced" -eq 0 ]; then
1549 pass
"Validate empty trace"
1551 fail
"Validate empty trace"
1552 diag
"Found $traced events in trace"
1558 function regenerate_metadata
()
1560 local expected_to_fail
=$1
1563 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate metadata
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1565 if [[ $expected_to_fail -eq "1" ]]; then
1567 ok $?
"Expected fail on regenerate metadata $sess_name"
1569 ok
$ret "Metadata regenerate $sess_name"
1573 function regenerate_metadata_ok
()
1575 regenerate_metadata
0 "$@"
1578 function regenerate_metadata_fail
()
1580 regenerate_metadata
1 "$@"
1583 function regenerate_statedump
()
1585 local expected_to_fail
=$1
1588 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN regenerate statedump
-s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1590 if [[ $expected_to_fail -eq "1" ]]; then
1592 ok $?
"Expected fail on regenerate statedump $sess_name"
1594 ok
$ret "Metadata regenerate $sess_name"
1598 function regenerate_statedump_ok
()
1600 regenerate_statedump
0 "$@"
1603 function regenerate_statedump_fail
()
1605 regenerate_statedump
1 "$@"
1608 function rotate_session
()
1610 local expected_to_fail
=$1
1613 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN rotate
$sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1615 if [[ $expected_to_fail -eq "1" ]]; then
1617 ok $?
"Expected fail on rotate session $sess_name"
1619 ok
$ret "Rotate session $sess_name"
1623 function rotate_session_ok
()
1625 rotate_session
0 "$@"
1628 function rotate_session_fail
()
1630 rotate_session
1 "$@"
1633 function destructive_tests_enabled
()
1635 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
1642 function lttng_enable_rotation_timer
()
1644 local expected_to_fail
=$1
1648 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1650 if [[ $expected_to_fail -eq "1" ]]; then
1652 ok $?
"Expected fail on rotate session $sess_name"
1654 ok
$ret "Rotate session $sess_name"
1658 function lttng_enable_rotation_timer_ok
()
1660 lttng_enable_rotation_timer
0 $@
1663 function lttng_enable_rotation_timer_fail
()
1665 lttng_enable_rotation_timer
1 $@
1668 function lttng_enable_rotation_size
()
1670 local expected_to_fail
=$1
1674 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-rotation
-s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1676 if [[ $expected_to_fail -eq "1" ]]; then
1678 ok $?
"Expected fail on rotate session $sess_name"
1680 ok
$ret "Rotate session $sess_name"
1684 function lttng_enable_rotation_size_ok
()
1686 lttng_enable_rotation_size
0 $@
1689 function lttng_enable_rotation_size_fail
()
1691 lttng_enable_rotation_size
1 $@