15d7e8b5639c75fdaea1fae4772659efde6d7d35
[lttng-tools.git] / tests / utils / utils.sh
1 # Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
2 #
3 # SPDX-License-Identifier: LGPL-2.1-only
4 #
5
6 SESSIOND_BIN="lttng-sessiond"
7 SESSIOND_MATCH=".*lttng-sess.*"
8 RUNAS_BIN="lttng-runas"
9 RUNAS_MATCH=".*lttng-runas.*"
10 CONSUMERD_BIN="lttng-consumerd"
11 CONSUMERD_MATCH=".*lttng-consumerd.*"
12 RELAYD_BIN="lttng-relayd"
13 RELAYD_MATCH=".*lttng-relayd.*"
14 LTTNG_BIN="lttng"
15 BABELTRACE_BIN="babeltrace"
16 OUTPUT_DEST=/dev/null
17 ERROR_OUTPUT_DEST=/dev/null
18
19 # Minimal kernel version supported for session daemon tests
20 KERNEL_MAJOR_VERSION=2
21 KERNEL_MINOR_VERSION=6
22 KERNEL_PATCHLEVEL_VERSION=27
23
24 # We set the default UST register timeout and network and app socket timeout to
25 # "wait forever", so that basic tests don't have to worry about hitting
26 # timeouts on busy systems. Specialized tests should test those corner-cases.
27 export LTTNG_UST_REGISTER_TIMEOUT=-1
28 export LTTNG_NETWORK_SOCKET_TIMEOUT=-1
29 export LTTNG_APP_SOCKET_TIMEOUT=-1
30
31 # We set the default lttng-sessiond path to /bin/true to prevent the spawning
32 # of a daemonized sessiond. This is necessary since 'lttng create' will spawn
33 # its own sessiond if none is running. It also ensures that 'lttng create'
34 # fails when no sessiond is running.
35 export LTTNG_SESSIOND_PATH="/bin/true"
36
37 source $TESTDIR/utils/tap/tap.sh
38
39 if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then
40 LTTNG_TEST_TEARDOWN_TIMEOUT=60
41 fi
42
43 function full_cleanup ()
44 {
45 # Try to kill daemons gracefully
46 stop_lttng_relayd_notap SIGTERM $LTTNG_TEST_TEARDOWN_TIMEOUT
47 stop_lttng_sessiond_notap SIGTERM $LTTNG_TEST_TEARDOWN_TIMEOUT
48
49 # If daemons are still present, forcibly kill them
50 stop_lttng_relayd_notap SIGKILL $LTTNG_TEST_TEARDOWN_TIMEOUT
51 stop_lttng_sessiond_notap SIGKILL $LTTNG_TEST_TEARDOWN_TIMEOUT
52 stop_lttng_consumerd_notap SIGKILL $LTTNG_TEST_TEARDOWN_TIMEOUT
53
54 # Disable trap for SIGTERM since the following kill to the
55 # pidgroup will be SIGTERM. Otherwise it loops.
56 # The '-' before the pid number ($$) indicates 'kill' to signal the
57 # whole process group.
58 trap - SIGTERM && kill -- -$$
59 exit 1
60 }
61
62 function null_pipes ()
63 {
64 exec 0>/dev/null
65 exec 1>/dev/null
66 exec 2>/dev/null
67 }
68
69 trap full_cleanup SIGINT SIGTERM
70
71 # perl prove closes its child pipes before giving it a chance to run its
72 # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
73 # to allow those trap handlers to proceed.
74
75 trap null_pipes SIGPIPE
76
77 # Check pgrep from env, default to pgrep if none
78 if [ -z "$PGREP" ]; then
79 PGREP=pgrep
80 fi
81
82 # Due to the renaming of threads we need to use the full command (pgrep -f) to
83 # identify the pids for multiple lttng related processes. The problem with "pgrep
84 # -f" is that it ends up also looking at the arguments. We use a two stage
85 # lookup. The first one is using "pgrep -f" yielding potential candidate.
86 # The second on perform grep on the basename of the first field of the
87 # /proc/pid/cmdline of the previously identified pids. The first field
88 # correspond to the actual command.
89 function lttng_pgrep ()
90 {
91 local pattern=$1
92 local possible_pids
93 local full_command_no_argument
94 local command_basename
95
96 possible_pids=$($PGREP -f "$pattern")
97 if [ -z "$possible_pids" ]; then
98 return 0
99 fi
100
101 while IFS= read -r pid ; do
102 # /proc/pid/cmdline is null separated.
103 if full_command_no_argument=$(cut -d '' -f 1 2>/dev/null < /proc/"$pid"/cmdline); then
104 command_basename=$(basename "$full_command_no_argument")
105 if grep -q "$pattern" <<< "$command_basename"; then
106 echo "$pid"
107 fi
108 fi
109 done <<< "$possible_pids"
110 return 0
111 }
112
113 function print_ok ()
114 {
115 # Check if we are a terminal
116 if [ -t 1 ]; then
117 echo -e "\e[1;32mOK\e[0m"
118 else
119 echo -e "OK"
120 fi
121 }
122
123 function print_fail ()
124 {
125 # Check if we are a terminal
126 if [ -t 1 ]; then
127 echo -e "\e[1;31mFAIL\e[0m"
128 else
129 echo -e "FAIL"
130 fi
131 }
132
133 function print_test_banner ()
134 {
135 local desc="$1"
136 diag "$desc"
137 }
138
139 function validate_kernel_version ()
140 {
141 local kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
142 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
143 return 0
144 fi
145 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
146 return 0
147 fi
148 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
149 return 0
150 fi
151 return 1
152 }
153
154 # Generate a random string
155 # $1 = number of characters; defaults to 16
156 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
157 function randstring()
158 {
159 [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
160 cat /dev/urandom 2>/dev/null | tr -cd "$CHAR" 2>/dev/null | head -c ${1:-16} 2>/dev/null
161 echo
162 }
163
164 # Return the number of _configured_ CPUs.
165 function conf_proc_count()
166 {
167 getconf _NPROCESSORS_CONF
168 if [ $? -ne 0 ]; then
169 diag "Failed to get the number of configured CPUs"
170 fi
171 echo
172 }
173
174 # Check if base lttng-modules are present.
175 # Bail out on failure
176 function validate_lttng_modules_present ()
177 {
178 # Check for loadable modules.
179 modprobe -n lttng-tracer 2>/dev/null
180 if [ $? -eq 0 ]; then
181 return 0
182 fi
183
184 # Check for builtin modules.
185 ls /proc/lttng > /dev/null 2>&1
186 if [ $? -eq 0 ]; then
187 return 0
188 fi
189
190 BAIL_OUT "LTTng modules not detected."
191 }
192
193 function enable_kernel_lttng_event
194 {
195 local withtap="$1"
196 local expected_to_fail="$2"
197 local sess_name="$3"
198 local event_name="$4"
199 local channel_name="$5"
200
201 if [ -z "$event_name" ]; then
202 # Enable all event if no event name specified
203 event_name="-a"
204 fi
205
206 if [ -z "$channel_name" ]; then
207 # default channel if none specified
208 chan=""
209 else
210 chan="-c $channel_name"
211 fi
212
213 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
214 ret=$?
215 if [[ $expected_to_fail -eq "1" ]]; then
216 test $ret -ne "0"
217 ret=$?
218 if [ $withtap -eq "1" ]; then
219 ok $ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
220 fi
221 else
222 if [ $withtap -eq "1" ]; then
223 ok $ret "Enable kernel event $event_name for session $sess_name"
224 fi
225 fi
226 }
227
228 function enable_kernel_lttng_event_ok ()
229 {
230 enable_kernel_lttng_event 1 0 "$@"
231 }
232
233 function enable_kernel_lttng_event_fail ()
234 {
235 enable_kernel_lttng_event 1 1 "$@"
236 }
237
238 function enable_kernel_lttng_event_notap ()
239 {
240 enable_kernel_lttng_event 0 0 "$@"
241 }
242
243 # Old interface
244 function lttng_enable_kernel_event
245 {
246 enable_kernel_lttng_event_ok "$@"
247 }
248
249 function lttng_enable_kernel_syscall()
250 {
251 local expected_to_fail=$1
252 local sess_name=$2
253 local syscall_name=$3
254 local channel_name=$4
255
256 if [ -z $syscall_name ]; then
257 # Enable all event if no syscall name specified
258 syscall_name="-a"
259 fi
260
261 if [ -z $channel_name ]; then
262 # default channel if none specified
263 chan=""
264 else
265 chan="-c $channel_name"
266 fi
267
268 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
269 ret=$?
270 if [[ $expected_to_fail -eq "1" ]]; then
271 test $ret -ne "0"
272 ok $? "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
273 else
274 ok $ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
275 fi
276 }
277
278 function lttng_enable_kernel_syscall_ok()
279 {
280 lttng_enable_kernel_syscall 0 "$@"
281 }
282
283 function lttng_enable_kernel_syscall_fail()
284 {
285 lttng_enable_kernel_syscall 1 "$@"
286 }
287
288 function lttng_disable_kernel_syscall()
289 {
290 local expected_to_fail=$1
291 local sess_name=$2
292 local syscall_name=$3
293 local channel_name=$4
294
295 if [ -z $syscall_name ]; then
296 # Enable all event if no syscall name specified
297 syscall_name="-a"
298 fi
299
300 if [ -z $channel_name ]; then
301 # default channel if none specified
302 chan=""
303 else
304 chan="-c $channel_name"
305 fi
306
307 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
308
309 ret=$?
310 if [[ $expected_to_fail -eq "1" ]]; then
311 test $ret -ne "0"
312 ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
313 else
314 ok $ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
315 fi
316 }
317
318 function lttng_disable_kernel_syscall_ok()
319 {
320 lttng_disable_kernel_syscall 0 "$@"
321 }
322
323 function lttng_disable_kernel_syscall_fail()
324 {
325 lttng_disable_kernel_syscall 1 "$@"
326 }
327
328 function lttng_enable_kernel_function_event ()
329 {
330 local expected_to_fail="$1"
331 local sess_name="$2"
332 local target="$3"
333 local event_name="$4"
334
335 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event --kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
336 ret=$?
337 if [[ $expected_to_fail -eq "1" ]]; then
338 test $ret -ne "0"
339 ok $? "Enable kernel function event for session $sess_name failed as expected"
340 else
341 ok $ret "Enable kernel function event for session $sess_name"
342 fi
343 }
344
345 function lttng_enable_kernel_function_event_ok ()
346 {
347 lttng_enable_kernel_function_event 0 "$@"
348 }
349
350 function lttng_enable_kernel_userspace_probe_event ()
351 {
352 local expected_to_fail="$1"
353 local sess_name="$2"
354 local target="$3"
355 local event_name="$4"
356
357 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event --kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
358 ret=$?
359 if [[ $expected_to_fail -eq "1" ]]; then
360 test $ret -ne "0"
361 ok $? "Enable kernel userspace probe event for session $sess_name failed as expected"
362 else
363 ok $ret "Enable kernel userspace probe event for session $sess_name"
364 fi
365 }
366
367 function lttng_enable_kernel_userspace_probe_event_fail ()
368 {
369 lttng_enable_kernel_userspace_probe_event 1 "$@"
370 }
371
372 function lttng_enable_kernel_userspace_probe_event_ok ()
373 {
374 lttng_enable_kernel_userspace_probe_event 0 "$@"
375 }
376
377 function disable_kernel_lttng_userspace_probe_event_ok ()
378 {
379 local sess_name="$1"
380 local event_name="$2"
381
382 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event --kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
383 ok $? "Disable kernel event $target for session $sess_name"
384 }
385 function lttng_enable_kernel_channel()
386 {
387 local withtap=$1
388 local expected_to_fail=$2
389 local sess_name=$3
390 local channel_name=$4
391 local opts="${@:5}"
392
393 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
394 ret=$?
395 if [[ $expected_to_fail -eq "1" ]]; then
396 test "$ret" -ne "0"
397 ret=$?
398 if [ $withtap -eq "1" ]; then
399 ok $ret "Enable channel $channel_name for session $sess_name failed as expected"
400 fi
401 else
402 if [ $withtap -eq "1" ]; then
403 ok $ret "Enable channel $channel_name for session $sess_name"
404 fi
405 fi
406 }
407
408 function lttng_enable_kernel_channel_ok()
409 {
410 lttng_enable_kernel_channel 1 0 "$@"
411 }
412
413 function lttng_enable_kernel_channel_fail()
414 {
415 lttng_enable_kernel_channel 1 1 "$@"
416 }
417
418 function lttng_enable_kernel_channel_notap()
419 {
420 lttng_enable_kernel_channel 0 0 "$@"
421 }
422
423 function enable_kernel_lttng_channel_ok()
424 {
425 lttng_enable_kernel_channel 1 0 "$@"
426 }
427
428 function lttng_disable_kernel_channel()
429 {
430 local expected_to_fail=$1
431 local sess_name=$2
432 local channel_name=$3
433
434 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
435 ret=$?
436 if [[ $expected_to_fail -eq "1" ]]; then
437 test "$ret" -ne "0"
438 ok $? "Disable channel $channel_name for session $sess_name failed as expected"
439 else
440 ok $ret "Disable channel $channel_name for session $sess_name"
441 fi
442 }
443
444 function lttng_disable_kernel_channel_ok()
445 {
446 lttng_disable_kernel_channel 0 "$@"
447 }
448
449 function lttng_disable_kernel_channel_fail()
450 {
451 lttng_disable_kernel_channel 1 "$@"
452 }
453
454 function start_lttng_relayd_opt()
455 {
456 local withtap=$1
457 local process_mode=$2
458 local opt=$3
459
460 DIR=$(readlink -f "$TESTDIR")
461
462 if [ -z $(lttng_pgrep "$RELAYD_MATCH") ]; then
463 # shellcheck disable=SC2086
464 $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
465 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
466 if [ $? -eq 1 ]; then
467 if [ $withtap -eq "1" ]; then
468 fail "Start lttng-relayd (process mode: $process_mode opt: $opt)"
469 fi
470 return 1
471 else
472 if [ $withtap -eq "1" ]; then
473 pass "Start lttng-relayd (process mode: $process_mode opt: $opt)"
474 fi
475 fi
476 else
477 pass "Start lttng-relayd (opt: $opt)"
478 fi
479 }
480
481 function start_lttng_relayd()
482 {
483 start_lttng_relayd_opt 1 "-b" "$@"
484 }
485
486 function start_lttng_relayd_notap()
487 {
488 start_lttng_relayd_opt 0 "-b" "$@"
489 }
490
491 function stop_lttng_relayd_opt()
492 {
493 local withtap=$1
494 local signal=$2
495
496 if [ -z "$signal" ]; then
497 signal="SIGTERM"
498 fi
499
500 local timeout_s=$3
501 local dtimeleft_s=
502
503 # Multiply time by 2 to simplify integer arithmetic
504 if [ -n "$timeout_s" ]; then
505 dtimeleft_s=$((timeout_s * 2))
506 fi
507
508 local retval=0
509 local pids=
510
511 pids=$(lttng_pgrep "$RELAYD_MATCH")
512 if [ -z "$pids" ]; then
513 if [ "$withtap" -eq "1" ]; then
514 pass "No relay daemon to kill"
515 fi
516 return 0
517 fi
518
519 diag "Killing (signal $signal) lttng-relayd (pid: $pids)"
520
521 # shellcheck disable=SC2086
522 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
523 retval=1
524 if [ "$withtap" -eq "1" ]; then
525 fail "Kill relay daemon"
526 fi
527 else
528 out=1
529 while [ -n "$out" ]; do
530 out=$(lttng_pgrep "$RELAYD_MATCH")
531 if [ -n "$dtimeleft_s" ]; then
532 if [ $dtimeleft_s -lt 0 ]; then
533 out=
534 retval=1
535 fi
536 dtimeleft_s=$((dtimeleft_s - 1))
537 fi
538 sleep 0.5
539 done
540 if [ "$withtap" -eq "1" ]; then
541 if [ "$retval" -eq "0" ]; then
542 pass "Wait after kill relay daemon"
543 else
544 fail "Wait after kill relay daemon"
545 fi
546 fi
547 fi
548 return $retval
549 }
550
551 function stop_lttng_relayd()
552 {
553 stop_lttng_relayd_opt 1 "$@"
554 }
555
556 function stop_lttng_relayd_notap()
557 {
558 stop_lttng_relayd_opt 0 "$@"
559 }
560
561 #First arg: show tap output
562 #Second argument: load path for automatic loading
563 function start_lttng_sessiond_opt()
564 {
565 local withtap=$1
566 local load_path=$2
567
568 # The rest of the arguments will be passed directly to lttng-sessiond.
569 shift 2
570
571 local env_vars=""
572 local consumerd=""
573
574 local long_bit_value=
575 long_bit_value=$(getconf LONG_BIT)
576
577 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
578 # Env variable requested no session daemon
579 return
580 fi
581
582 DIR=$(readlink -f "$TESTDIR")
583
584 # Get long_bit value for 32/64 consumerd
585 case "$long_bit_value" in
586 32)
587 consumerd="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
588 ;;
589 64)
590 consumerd="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
591 ;;
592 *)
593 return
594 ;;
595 esac
596
597 # Check for env. variable. Allow the use of LD_PRELOAD etc.
598 if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then
599 env_vars="${LTTNG_SESSIOND_ENV_VARS} "
600 fi
601 env_vars="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN"
602
603 if ! validate_kernel_version; then
604 fail "Start session daemon"
605 BAIL_OUT "*** Kernel too old for session daemon tests ***"
606 fi
607
608 : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}"
609 export LTTNG_SESSION_CONFIG_XSD_PATH
610
611 if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then
612 # Have a load path ?
613 if [ -n "$load_path" ]; then
614 # shellcheck disable=SC2086
615 env $env_vars --load "$load_path" --background "$consumerd" "$@"
616 else
617 # shellcheck disable=SC2086
618 env $env_vars --background "$consumerd" "$@"
619 fi
620 #$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
621 status=$?
622 if [ "$withtap" -eq "1" ]; then
623 ok $status "Start session daemon"
624 fi
625 fi
626 }
627
628 function start_lttng_sessiond()
629 {
630 start_lttng_sessiond_opt 1 "$@"
631 }
632
633 function start_lttng_sessiond_notap()
634 {
635 start_lttng_sessiond_opt 0 "$@"
636 }
637
638 function stop_lttng_sessiond_opt()
639 {
640 local withtap=$1
641 local signal=$2
642
643 if [ -z "$signal" ]; then
644 signal=SIGTERM
645 fi
646
647 local timeout_s=$3
648 local dtimeleft_s=
649
650 # Multiply time by 2 to simplify integer arithmetic
651 if [ -n "$timeout_s" ]; then
652 dtimeleft_s=$((timeout_s * 2))
653 fi
654
655 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
656 # Env variable requested no session daemon
657 return 0
658 fi
659
660 local retval=0
661
662 local runas_pids=
663 runas_pids=$(lttng_pgrep "$RUNAS_MATCH")
664
665 local pids=
666 pids=$(lttng_pgrep "$SESSIOND_MATCH")
667
668 if [ -n "$runas_pids" ]; then
669 pids="$pids $runas_pids"
670 fi
671
672 if [ -z "$pids" ]; then
673 if [ "$withtap" -eq "1" ]; then
674 fail "No session daemon to kill"
675 else
676 BAIL_OUT "No session daemon to kill"
677 fi
678 return 0
679 fi
680
681 diag "Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')"
682
683 # shellcheck disable=SC2086
684 if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
685 retval=1
686 if [ "$withtap" -eq "1" ]; then
687 fail "Kill sessions daemon"
688 fi
689 else
690 out=1
691 while [ -n "$out" ]; do
692 out=$(lttng_pgrep "${SESSIOND_MATCH}")
693 if [ -n "$dtimeleft_s" ]; then
694 if [ $dtimeleft_s -lt 0 ]; then
695 out=
696 retval=1
697 fi
698 dtimeleft_s=$((dtimeleft_s - 1))
699 fi
700 sleep 0.5
701 done
702 out=1
703 while [ -n "$out" ]; do
704 out=$(lttng_pgrep "$CONSUMERD_MATCH")
705 if [ -n "$dtimeleft_s" ]; then
706 if [ $dtimeleft_s -lt 0 ]; then
707 out=
708 retval=1
709 fi
710 dtimeleft_s=$((dtimeleft_s - 1))
711 fi
712 sleep 0.5
713 done
714
715 if [ "$withtap" -eq "1" ]; then
716 if [ "$retval" -eq "0" ]; then
717 pass "Wait after kill session daemon"
718 else
719 fail "Wait after kill session daemon"
720 fi
721 fi
722 fi
723 if [ "$signal" = "SIGKILL" ]; then
724 if [ "$(id -u)" -eq "0" ]; then
725 local modules=
726 modules="$(lsmod | grep ^lttng | awk '{print $1}')"
727
728 if [ -n "$modules" ]; then
729 diag "Unloading all LTTng modules"
730 modprobe --remove "$modules"
731 fi
732 fi
733 fi
734
735 return $retval
736 }
737
738 function stop_lttng_sessiond()
739 {
740 stop_lttng_sessiond_opt 1 "$@"
741 }
742
743 function stop_lttng_sessiond_notap()
744 {
745 stop_lttng_sessiond_opt 0 "$@"
746 }
747
748 function sigstop_lttng_sessiond_opt()
749 {
750 local withtap=$1
751 local signal=SIGSTOP
752
753 if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
754 # Env variable requested no session daemon
755 return
756 fi
757
758 PID_SESSIOND="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")"
759
760 if [ "$withtap" -eq "1" ]; then
761 diag "Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$PID_SESSIOND" | tr '\n' ' ')"
762 fi
763
764 # shellcheck disable=SC2086
765 if ! kill -s $signal $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
766 if [ "$withtap" -eq "1" ]; then
767 fail "Sending SIGSTOP to session daemon"
768 fi
769 else
770 out=1
771 while [ $out -ne 0 ]; do
772 pid="$(lttng_pgrep "$SESSIOND_MATCH")"
773
774 # Wait until state becomes stopped for session
775 # daemon(s).
776 out=0
777 for sessiond_pid in $pid; do
778 state="$(ps -p "$sessiond_pid" -o state= )"
779 if [[ -n "$state" && "$state" != "T" ]]; then
780 out=1
781 fi
782 done
783 sleep 0.5
784 done
785 if [ "$withtap" -eq "1" ]; then
786 pass "Sending SIGSTOP to session daemon"
787 fi
788 fi
789 }
790
791 function sigstop_lttng_sessiond()
792 {
793 sigstop_lttng_sessiond_opt 1 "$@"
794 }
795
796 function sigstop_lttng_sessiond_notap()
797 {
798 sigstop_lttng_sessiond_opt 0 "$@"
799 }
800
801 function stop_lttng_consumerd_opt()
802 {
803 local withtap=$1
804 local signal=$2
805
806 if [ -z "$signal" ]; then
807 signal=SIGTERM
808 fi
809
810 local timeout_s=$3
811 local dtimeleft_s=
812
813 # Multiply time by 2 to simplify integer arithmetic
814 if [ -n "$timeout_s" ]; then
815 dtimeleft_s=$((timeout_s * 2))
816 fi
817
818 local retval=0
819
820 PID_CONSUMERD="$(lttng_pgrep "$CONSUMERD_MATCH")"
821
822 if [ -z "$PID_CONSUMERD" ]; then
823 if [ "$withtap" -eq "1" ]; then
824 pass "No consumer daemon to kill"
825 fi
826 return 0
827 fi
828
829 diag "Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
830
831 # shellcheck disable=SC2086
832 if ! kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then
833 retval=1
834 if [ "$withtap" -eq "1" ]; then
835 fail "Kill consumer daemon"
836 fi
837 else
838 out=1
839 while [ $out -ne 0 ]; do
840 pid="$(lttng_pgrep "$CONSUMERD_MATCH")"
841
842 # If consumerds are still present check their status.
843 # A zombie status qualifies the consumerd as *killed*
844 out=0
845 for consumer_pid in $pid; do
846 state="$(ps -p "$consumer_pid" -o state= )"
847 if [[ -n "$state" && "$state" != "Z" ]]; then
848 out=1
849 fi
850 done
851 if [ -n "$dtimeleft_s" ]; then
852 if [ $dtimeleft_s -lt 0 ]; then
853 out=0
854 retval=1
855 fi
856 dtimeleft_s=$((dtimeleft_s - 1))
857 fi
858 sleep 0.5
859 done
860 if [ "$withtap" -eq "1" ]; then
861 if [ "$retval" -eq "0" ]; then
862 pass "Wait after kill consumer daemon"
863 else
864 fail "Wait after kill consumer daemon"
865 fi
866 fi
867 fi
868
869 return $retval
870 }
871
872 function stop_lttng_consumerd()
873 {
874 stop_lttng_consumerd_opt 1 "$@"
875 }
876
877 function stop_lttng_consumerd_notap()
878 {
879 stop_lttng_consumerd_opt 0 "$@"
880 }
881
882 function sigstop_lttng_consumerd_opt()
883 {
884 local withtap=$1
885 local signal=SIGSTOP
886
887 PID_CONSUMERD="$(lttng_pgrep "$CONSUMERD_MATCH")"
888
889 diag "Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$PID_CONSUMERD" | tr '\n' ' ')"
890
891 # shellcheck disable=SC2086
892 kill -s $signal $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
893 retval=$?
894
895 if [ $retval -eq 1 ]; then
896 if [ "$withtap" -eq "1" ]; then
897 fail "Sending SIGSTOP to consumer daemon"
898 fi
899 return 1
900 else
901 out=1
902 while [ $out -ne 0 ]; do
903 pid="$(lttng_pgrep "$CONSUMERD_MATCH")"
904
905 # Wait until state becomes stopped for all
906 # consumers.
907 out=0
908 for consumer_pid in $pid; do
909 state="$(ps -p "$consumer_pid" -o state= )"
910 if [[ -n "$state" && "$state" != "T" ]]; then
911 out=1
912 fi
913 done
914 sleep 0.5
915 done
916 if [ "$withtap" -eq "1" ]; then
917 pass "Sending SIGSTOP to consumer daemon"
918 fi
919 fi
920 return $retval
921 }
922
923 function sigstop_lttng_consumerd()
924 {
925 sigstop_lttng_consumerd_opt 1 "$@"
926 }
927
928 function sigstop_lttng_consumerd_notap()
929 {
930 sigstop_lttng_consumerd_opt 0 "$@"
931 }
932
933 function list_lttng_with_opts ()
934 {
935 local opts=$1
936 $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
937 ok $? "Lttng-tool list command with option $opts"
938 }
939
940 function create_lttng_session_no_output ()
941 {
942 local sess_name=$1
943 local opts="${@:2}"
944
945 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
946 ok $? "Create session $sess_name in no-output mode"
947 }
948
949 function create_lttng_session_uri () {
950 local sess_name=$1
951 local uri=$2
952 local opts="${@:3}"
953
954 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
955 ok $? "Create session $sess_name with uri:$uri and opts: $opts"
956 }
957
958 function create_lttng_session ()
959 {
960 local withtap=$1
961 local expected_to_fail=$2
962 local sess_name=$3
963 local trace_path=$4
964 local opt=$5
965
966 if [ -z "$trace_path" ]; then
967 # Use lttng-sessiond default output.
968 trace_path=""
969 else
970 trace_path="-o $trace_path"
971 fi
972
973 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create "$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
974 ret=$?
975 if [ $expected_to_fail -eq "1" ]; then
976 test "$ret" -ne "0"
977 ret=$?
978 if [ $withtap -eq "1" ]; then
979 ok $ret "Create session $sess_name in $trace_path failed as expected"
980 fi
981 else
982 if [ $withtap -eq "1" ]; then
983 ok $ret "Create session $sess_name in $trace_path"
984 fi
985 fi
986 return $ret
987 }
988
989 function create_lttng_session_ok ()
990 {
991 create_lttng_session 1 0 "$@"
992 }
993
994 function create_lttng_session_fail ()
995 {
996 create_lttng_session 1 1 "$@"
997 }
998
999 function create_lttng_session_notap ()
1000 {
1001 create_lttng_session 0 0 "$@"
1002 }
1003
1004
1005 function enable_ust_lttng_channel ()
1006 {
1007 local withtap=$1
1008 local expected_to_fail=$2
1009 local sess_name=$3
1010 local channel_name=$4
1011 local opts="${@:5}"
1012
1013 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1014 ret=$?
1015 if [[ $expected_to_fail -eq "1" ]]; then
1016 test "$ret" -ne "0"
1017 ret=$?
1018 if [ $withtap -eq "1" ]; then
1019 ok $ret "Enable channel $channel_name for session $sess_name failed as expected"
1020 fi
1021 else
1022 if [ $withtap -eq "1" ]; then
1023 ok $ret "Enable channel $channel_name for session $sess_name"
1024 fi
1025 fi
1026 return $ret
1027 }
1028
1029 function enable_ust_lttng_channel_ok ()
1030 {
1031 enable_ust_lttng_channel 1 0 "$@"
1032 }
1033
1034 function enable_ust_lttng_channel_fail ()
1035 {
1036 enable_ust_lttng_channel 1 1 "$@"
1037 }
1038
1039 function enable_ust_lttng_channel_notap ()
1040 {
1041 enable_ust_lttng_channel 0 0 "$@"
1042 }
1043
1044 function disable_ust_lttng_channel()
1045 {
1046 local sess_name=$1
1047 local channel_name=$2
1048
1049 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1050 ok $? "Disable channel $channel_name for session $sess_name"
1051 }
1052
1053 function enable_lttng_mmap_overwrite_kernel_channel()
1054 {
1055 local sess_name=$1
1056 local channel_name=$2
1057
1058 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1059 ok $? "Enable channel $channel_name for session $sess_name"
1060 }
1061
1062 function enable_lttng_mmap_discard_small_kernel_channel()
1063 {
1064 local sess_name=$1
1065 local channel_name=$2
1066
1067 $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
1068 ok $? "Enable small discard channel $channel_name for session $sess_name"
1069 }
1070
1071 function enable_lttng_mmap_overwrite_small_kernel_channel()
1072 {
1073 local sess_name=$1
1074 local channel_name=$2
1075
1076 $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
1077 ok $? "Enable small discard channel $channel_name for session $sess_name"
1078 }
1079
1080 function enable_lttng_mmap_overwrite_ust_channel()
1081 {
1082 local sess_name=$1
1083 local channel_name=$2
1084
1085 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1086 ok $? "Enable channel $channel_name for session $sess_name"
1087 }
1088
1089 function enable_ust_lttng_event ()
1090 {
1091 local withtap=$1
1092 local expected_to_fail=$2
1093 local sess_name=$3
1094 local event_name="$4"
1095 local channel_name=$5
1096
1097 if [ -z $channel_name ]; then
1098 # default channel if none specified
1099 chan=""
1100 else
1101 chan="-c $channel_name"
1102 fi
1103
1104 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1105 ret=$?
1106 if [[ $expected_to_fail -eq "1" ]]; then
1107 test $ret -ne "0"
1108 ret=$?
1109 if [[ $withtap -eq "1" ]]; then
1110 ok $ret "Enable ust event $event_name for session $session_name failed as expected"
1111 fi
1112 else
1113 if [[ $withtap -eq "1" ]]; then
1114 ok $ret "Enable ust event $event_name for session $sess_name"
1115 fi
1116 fi
1117 return $ret
1118 }
1119
1120 function enable_ust_lttng_event_ok ()
1121 {
1122 enable_ust_lttng_event 1 0 "$@"
1123 }
1124
1125 function enable_ust_lttng_event_fail ()
1126 {
1127 enable_ust_lttng_event 1 1 "$@"
1128 }
1129
1130 function enable_ust_lttng_event_notap ()
1131 {
1132 enable_ust_lttng_event 0 0 "$@"
1133 }
1134
1135 function enable_jul_lttng_event()
1136 {
1137 sess_name=$1
1138 event_name="$2"
1139 channel_name=$3
1140
1141 if [ -z $channel_name ]; then
1142 # default channel if none specified
1143 chan=""
1144 else
1145 chan="-c $channel_name"
1146 fi
1147
1148 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1149 ok $? "Enable JUL event $event_name for session $sess_name"
1150 }
1151
1152 function enable_jul_lttng_event_loglevel()
1153 {
1154 local sess_name=$1
1155 local event_name="$2"
1156 local loglevel=$3
1157 local channel_name=$4
1158
1159 if [ -z $channel_name ]; then
1160 # default channel if none specified
1161 chan=""
1162 else
1163 chan="-c $channel_name"
1164 fi
1165
1166 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1167 ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
1168 }
1169
1170 function enable_log4j_lttng_event()
1171 {
1172 sess_name=$1
1173 event_name="$2"
1174 channel_name=$3
1175
1176 if [ -z $channel_name ]; then
1177 # default channel if none specified
1178 chan=""
1179 else
1180 chan="-c $channel_name"
1181 fi
1182
1183 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1184 ok $? "Enable LOG4J event $event_name for session $sess_name"
1185 }
1186
1187 function enable_log4j_lttng_event_loglevel()
1188 {
1189 local sess_name=$1
1190 local event_name="$2"
1191 local loglevel=$3
1192 local channel_name=$4
1193
1194 if [ -z $channel_name ]; then
1195 # default channel if none specified
1196 chan=""
1197 else
1198 chan="-c $channel_name"
1199 fi
1200
1201 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1202 ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
1203 }
1204
1205 function enable_python_lttng_event()
1206 {
1207 sess_name=$1
1208 event_name="$2"
1209 channel_name=$3
1210
1211 if [ -z $channel_name ]; then
1212 # default channel if none specified
1213 chan=""
1214 else
1215 chan="-c $channel_name"
1216 fi
1217
1218 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1219 ok $? "Enable Python event $event_name for session $sess_name"
1220 }
1221
1222 function enable_python_lttng_event_loglevel()
1223 {
1224 local sess_name=$1
1225 local event_name="$2"
1226 local loglevel=$3
1227 local channel_name=$4
1228
1229 if [ -z $channel_name ]; then
1230 # default channel if none specified
1231 chan=""
1232 else
1233 chan="-c $channel_name"
1234 fi
1235
1236 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1237 ok $? "Enable Python event $event_name for session $sess_name with loglevel $loglevel"
1238 }
1239
1240 function enable_ust_lttng_event_filter()
1241 {
1242 local sess_name="$1"
1243 local event_name="$2"
1244 local filter="$3"
1245 local channel_name=$4
1246
1247 if [ -z $channel_name ]; then
1248 # default channel if none specified
1249 chan=""
1250 else
1251 chan="-c $channel_name"
1252 fi
1253
1254 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1255 ok $? "Enable event $event_name with filtering for session $sess_name"
1256 }
1257
1258 function enable_ust_lttng_event_loglevel()
1259 {
1260 local sess_name="$1"
1261 local event_name="$2"
1262 local loglevel="$3"
1263
1264 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1265 ok $? "Enable event $event_name with loglevel $loglevel"
1266 }
1267
1268 function enable_ust_lttng_event_loglevel_only()
1269 {
1270 local sess_name="$1"
1271 local event_name="$2"
1272 local loglevel="$3"
1273
1274 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1275 ok $? "Enable event $event_name with loglevel-only $loglevel"
1276 }
1277
1278 function disable_ust_lttng_event ()
1279 {
1280 local sess_name="$1"
1281 local event_name="$2"
1282 local channel_name="$3"
1283
1284 if [ -z $channel_name ]; then
1285 # default channel if none specified
1286 chan=""
1287 else
1288 chan="-c $channel_name"
1289 fi
1290
1291 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1292 ok $? "Disable event $event_name for session $sess_name"
1293 }
1294
1295 function disable_jul_lttng_event ()
1296 {
1297 local sess_name="$1"
1298 local event_name="$2"
1299
1300 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1
1301 ok $? "Disable JUL event $event_name for session $sess_name"
1302 }
1303
1304 function disable_log4j_lttng_event ()
1305 {
1306 local sess_name="$1"
1307 local event_name="$2"
1308
1309 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1
1310 ok $? "Disable LOG4J event $event_name for session $sess_name"
1311 }
1312
1313 function disable_python_lttng_event ()
1314 {
1315 local sess_name="$1"
1316 local event_name="$2"
1317
1318 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1319 ok $? "Disable Python event $event_name for session $sess_name"
1320 }
1321
1322 function start_lttng_tracing_opt ()
1323 {
1324 local withtap=$1
1325 local expected_to_fail=$2
1326 local sess_name=$3
1327
1328 $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1329 ret=$?
1330 if [[ $expected_to_fail -eq "1" ]]; then
1331 test "$ret" -ne "0"
1332 ret=$?
1333 if [ $withtap -eq "1" ]; then
1334 ok $? "Start tracing for session $sess_name failed as expected"
1335 fi
1336 else
1337 if [ $withtap -eq "1" ]; then
1338 ok $ret "Start tracing for session $sess_name"
1339 fi
1340 fi
1341 }
1342
1343 function start_lttng_tracing_ok ()
1344 {
1345 start_lttng_tracing_opt 1 0 "$@"
1346 }
1347
1348 function start_lttng_tracing_fail ()
1349 {
1350 start_lttng_tracing_opt 1 1 "$@"
1351 }
1352
1353 function start_lttng_tracing_notap ()
1354 {
1355 start_lttng_tracing_opt 0 1 "$@"
1356 }
1357
1358 function stop_lttng_tracing_opt ()
1359 {
1360 local withtap=$1
1361 local expected_to_fail=$2
1362 local sess_name=$3
1363
1364 $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1365 ret=$?
1366 if [[ $expected_to_fail -eq "1" ]]; then
1367 test "$ret" -ne "0"
1368 ret=$?
1369 if [ $withtap -eq "1" ]; then
1370 ok $? "Stop lttng tracing for session $sess_name failed as expected"
1371 fi
1372 else
1373 if [ $withtap -eq "1" ]; then
1374 ok $ret "Stop lttng tracing for session $sess_name"
1375 fi
1376 fi
1377 }
1378
1379 function stop_lttng_tracing_ok ()
1380 {
1381 stop_lttng_tracing_opt 1 0 "$@"
1382 }
1383
1384 function stop_lttng_tracing_fail ()
1385 {
1386 stop_lttng_tracing_opt 1 1 "$@"
1387 }
1388
1389 function stop_lttng_tracing_notap ()
1390 {
1391 stop_lttng_tracing_opt 0 0 "$@"
1392 }
1393
1394 function destroy_lttng_session ()
1395 {
1396 local withtap=$1
1397 local expected_to_fail=$2
1398 local sess_name=$3
1399
1400 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1401 ret=$?
1402 if [[ $expected_to_fail -eq "1" ]]; then
1403 test "$ret" -ne "0"
1404 ret=$?
1405 if [ $withtap -eq "1" ]; then
1406 ok $ret "Destroy session $sess_name failed as expected"
1407 fi
1408 else
1409 if [ $withtap -eq "1" ]; then
1410 ok $ret "Destroy session $sess_name"
1411 fi
1412 fi
1413 }
1414
1415 function destroy_lttng_session_ok ()
1416 {
1417 destroy_lttng_session 1 0 "$@"
1418
1419 }
1420
1421 function destroy_lttng_session_fail ()
1422 {
1423 destroy_lttng_session 1 1 "$@"
1424 }
1425
1426 function destroy_lttng_session_notap ()
1427 {
1428 destroy_lttng_session 0 0 "$@"
1429 }
1430
1431 function destroy_lttng_sessions ()
1432 {
1433 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1434 ok $? "Destroy all lttng sessions"
1435 }
1436
1437 function lttng_snapshot_add_output ()
1438 {
1439 local expected_to_fail=$1
1440 local sess_name=$2
1441 local trace_path=$3
1442 local opts=$4
1443
1444 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1445 ret=$?
1446 if [[ $expected_to_fail -eq 1 ]]; then
1447 test "$ret" -ne "0"
1448 ok $? "Added snapshot output $trace_path failed as expected"
1449 else
1450 ok $ret "Added snapshot output $trace_path"
1451 fi
1452 }
1453
1454 function lttng_snapshot_add_output_ok ()
1455 {
1456 lttng_snapshot_add_output 0 "$@"
1457 }
1458
1459 function lttng_snapshot_add_output_fail ()
1460 {
1461 lttng_snapshot_add_output 1 "$@"
1462 }
1463
1464 function lttng_snapshot_del_output ()
1465 {
1466 local expected_to_fail=$1
1467 local sess_name=$2
1468 local id=$3
1469
1470 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1471 ret=$?
1472 if [[ $expected_to_fail -eq "1" ]]; then
1473 test "$ret" -ne "0"
1474 ok $? "Deleted snapshot output id $id failed as expected"
1475 else
1476 ok $ret "Deleted snapshot output id $id"
1477 fi
1478 }
1479
1480 function lttng_snapshot_del_output_ok ()
1481 {
1482 lttng_snapshot_del_output 0 "$@"
1483 }
1484
1485 function lttng_snapshot_del_output_fail ()
1486 {
1487 lttng_snapshot_del_output 1 "$@"
1488 }
1489
1490 function lttng_snapshot_record ()
1491 {
1492 local sess_name=$1
1493
1494 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s $sess_name $trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1495 ok $? "Snapshot recorded"
1496 }
1497
1498 function lttng_snapshot_list ()
1499 {
1500 local sess_name=$1
1501 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1502 ok $? "Snapshot list"
1503 }
1504
1505 function lttng_save()
1506 {
1507 local sess_name=$1
1508 local opts=$2
1509
1510 $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1511 ok $? "Session saved"
1512 }
1513
1514 function lttng_load()
1515 {
1516 local expected_to_fail=$1
1517 local opts=$2
1518
1519 $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1520 ret=$?
1521 if [[ $expected_to_fail -eq "1" ]]; then
1522 test $ret -ne "0"
1523 ok $? "Load command failed as expected with opts: $opts"
1524 else
1525 ok $ret "Load command with opts: $opts"
1526 fi
1527 }
1528
1529 function lttng_load_ok()
1530 {
1531 lttng_load 0 "$@"
1532 }
1533
1534 function lttng_load_fail()
1535 {
1536 lttng_load 1 "$@"
1537 }
1538
1539 function lttng_track()
1540 {
1541 local expected_to_fail="$1"
1542 shift 1
1543 local opts="$@"
1544 $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST
1545 ret=$?
1546 if [[ $expected_to_fail -eq "1" ]]; then
1547 test $ret -ne "0"
1548 ok $? "Track command failed as expected with opts: $opts"
1549 else
1550 ok $ret "Track command with opts: $opts"
1551 fi
1552 }
1553
1554 function lttng_track_ok()
1555 {
1556 lttng_track 0 "$@"
1557 }
1558
1559 function lttng_track_fail()
1560 {
1561 lttng_track 1 "$@"
1562 }
1563
1564 function lttng_untrack()
1565 {
1566 local expected_to_fail="$1"
1567 shift 1
1568 local opts="$@"
1569 $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST
1570 ret=$?
1571 if [[ $expected_to_fail -eq "1" ]]; then
1572 test $ret -ne "0"
1573 ok $? "Untrack command failed as expected with opts: $opts"
1574 else
1575 ok $ret "Untrack command with opts: $opts"
1576 fi
1577 }
1578
1579 function lttng_untrack_ok()
1580 {
1581 lttng_untrack 0 "$@"
1582 }
1583
1584 function lttng_untrack_fail()
1585 {
1586 lttng_untrack 1 "$@"
1587 }
1588
1589 function lttng_track_pid_ok()
1590 {
1591 PID=$1
1592 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track --kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1593 ok $? "Lttng track pid on the kernel domain"
1594 }
1595
1596 function lttng_untrack_kernel_all_ok()
1597 {
1598 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack --kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1599 ok $? "Lttng untrack all pid on the kernel domain"
1600 }
1601
1602 function lttng_track_ust_ok()
1603 {
1604 lttng_track_ok -u "$@"
1605 }
1606
1607 function lttng_track_ust_fail()
1608 {
1609 lttng_track_fail -u "$@"
1610 }
1611
1612 function lttng_track_kernel_ok()
1613 {
1614 lttng_track_ok -k "$@"
1615 }
1616
1617 function lttng_track_kernel_fail()
1618 {
1619 lttng_track_fail -k "$@"
1620 }
1621
1622 function lttng_untrack_ust_ok()
1623 {
1624 lttng_untrack_ok -u "$@"
1625 }
1626
1627 function lttng_untrack_ust_fail()
1628 {
1629 lttng_untrack_fail -u "$@"
1630 }
1631
1632 function lttng_untrack_kernel_ok()
1633 {
1634 lttng_untrack_ok -k "$@"
1635 }
1636
1637 function lttng_untrack_kernel_fail()
1638 {
1639 lttng_untrack_fail -k "$@"
1640 }
1641
1642 function lttng_add_context_list()
1643 {
1644 $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context --list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1645 ret=$?
1646 ok $ret "Context listing"
1647 }
1648
1649 function add_context_lttng()
1650 {
1651 local expected_to_fail="$1"
1652 local domain="$2"
1653 local session_name="$3"
1654 local channel_name="$4"
1655 local type="$5"
1656
1657 $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1658 ret=$?
1659 if [[ $expected_to_fail -eq "1" ]]; then
1660 test $ret -ne "0"
1661 ok $? "Add context command failed as expected for type: $type"
1662 else
1663 ok $ret "Add context command for type: $type"
1664 fi
1665 }
1666
1667 function add_context_ust_ok()
1668 {
1669 add_context_lttng 0 -u "$@"
1670 }
1671
1672 function add_context_ust_fail()
1673 {
1674 add_context_lttng 1 -u "$@"
1675 }
1676
1677 function add_context_kernel_ok()
1678 {
1679 add_context_lttng 0 -k "$@"
1680 }
1681
1682 function add_context_kernel_fail()
1683 {
1684 add_context_lttng 1 -k "$@"
1685 }
1686
1687 function wait_live_trace_ready ()
1688 {
1689 local url=$1
1690 local zero_client_match=0
1691
1692 diag "Waiting for live trace at url: $url"
1693 while [ $zero_client_match -eq 0 ]; do
1694 zero_client_match=$($BABELTRACE_BIN -i lttng-live $url | grep "0 client(s) connected" | wc -l)
1695 sleep 0.5
1696 done
1697 pass "Waiting for live trace at url: $url"
1698 }
1699
1700 function wait_live_viewer_connect ()
1701 {
1702 local url=$1
1703 local one_client_match=0
1704
1705 diag "Waiting for live viewers on url: $url"
1706 while [ $one_client_match -eq 0 ]; do
1707 one_client_match=$($BABELTRACE_BIN -i lttng-live $url | grep "1 client(s) connected" | wc -l)
1708 sleep 0.5
1709 done
1710 pass "Waiting for live viewers on url: $url"
1711 }
1712
1713 function validate_metadata_event ()
1714 {
1715 local event_name=$1
1716 local nr_event_id=$2
1717 local trace_path=$3
1718
1719 local metadata_file=$(find $trace_path | grep metadata)
1720 local metadata_path=$(dirname $metadata_file)
1721
1722 which $BABELTRACE_BIN >/dev/null
1723 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1724
1725 local count=$($BABELTRACE_BIN --output-format=ctf-metadata $metadata_path | grep $event_name | wc -l)
1726
1727 if [ "$count" -ne "$nr_event_id" ]; then
1728 fail "Metadata match with the metadata of $count event(s) named $event_name"
1729 diag "$count matching event id found in metadata"
1730 else
1731 pass "Metadata match with the metadata of $count event(s) named $event_name"
1732 fi
1733
1734 }
1735
1736 function trace_matches ()
1737 {
1738 local event_name=$1
1739 local nr_iter=$2
1740 local trace_path=$3
1741
1742 which $BABELTRACE_BIN >/dev/null
1743 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1744
1745 local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
1746
1747 if [ "$count" -ne "$nr_iter" ]; then
1748 fail "Trace match"
1749 diag "$count matching events found in trace"
1750 else
1751 pass "Trace match"
1752 fi
1753 }
1754
1755 function trace_match_only()
1756 {
1757 local event_name=$1
1758 local nr_iter=$2
1759 local trace_path=$3
1760
1761 which $BABELTRACE_BIN >/dev/null
1762 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1763
1764 local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
1765 local total=$($BABELTRACE_BIN $trace_path | wc -l)
1766
1767 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1768 pass "Trace match with $total event $event_name"
1769 else
1770 fail "Trace match"
1771 diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1772 fi
1773 }
1774
1775 function validate_trace
1776 {
1777 local event_name=$1
1778 local trace_path=$2
1779
1780 which $BABELTRACE_BIN >/dev/null
1781 if [ $? -ne 0 ]; then
1782 skip 0 "Babeltrace binary not found. Skipping trace validation"
1783 fi
1784
1785 OLDIFS=$IFS
1786 IFS=","
1787 for i in $event_name; do
1788 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
1789 if [ "$traced" -ne 0 ]; then
1790 pass "Validate trace for event $i, $traced events"
1791 else
1792 fail "Validate trace for event $i"
1793 diag "Found $traced occurences of $i"
1794 fi
1795 done
1796 ret=$?
1797 IFS=$OLDIFS
1798 return $ret
1799 }
1800
1801 function validate_trace_count
1802 {
1803 local event_name=$1
1804 local trace_path=$2
1805 local expected_count=$3
1806
1807 which $BABELTRACE_BIN >/dev/null
1808 if [ $? -ne 0 ]; then
1809 skip 0 "Babeltrace binary not found. Skipping trace validation"
1810 fi
1811
1812 cnt=0
1813 OLDIFS=$IFS
1814 IFS=","
1815 for i in $event_name; do
1816 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
1817 if [ "$traced" -ne 0 ]; then
1818 pass "Validate trace for event $i, $traced events"
1819 else
1820 fail "Validate trace for event $i"
1821 diag "Found $traced occurences of $i"
1822 fi
1823 cnt=$(($cnt + $traced))
1824 done
1825 IFS=$OLDIFS
1826 test $cnt -eq $expected_count
1827 ok $? "Read a total of $cnt events, expected $expected_count"
1828 }
1829
1830 function validate_trace_count_range_incl_min_excl_max
1831 {
1832 local event_name=$1
1833 local trace_path=$2
1834 local expected_min=$3
1835 local expected_max=$4
1836
1837 which $BABELTRACE_BIN >/dev/null
1838 if [ $? -ne 0 ]; then
1839 skip 0 "Babeltrace binary not found. Skipping trace validation"
1840 fi
1841
1842 cnt=0
1843 OLDIFS=$IFS
1844 IFS=","
1845 for i in $event_name; do
1846 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
1847 if [ "$traced" -ge $expected_min ]; then
1848 pass "Validate trace for event $i, $traced events"
1849 else
1850 fail "Validate trace for event $i"
1851 diag "Found $traced occurences of $i"
1852 fi
1853 cnt=$(($cnt + $traced))
1854 done
1855 IFS=$OLDIFS
1856 test $cnt -lt $expected_max
1857 ok $? "Read a total of $cnt events, expected between [$expected_min, $expected_max["
1858 }
1859
1860 function trace_first_line
1861 {
1862 local trace_path=$1
1863
1864 which $BABELTRACE_BIN >/dev/null
1865 if [ $? -ne 0 ]; then
1866 skip 0 "Babeltrace binary not found. Skipping trace validation"
1867 fi
1868
1869 $BABELTRACE_BIN $trace_path 2>/dev/null | head -n 1
1870 }
1871
1872 function validate_trace_exp()
1873 {
1874 local event_exp=$1
1875 local trace_path=$2
1876
1877 which $BABELTRACE_BIN >/dev/null
1878 skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation"
1879
1880 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep --extended-regexp ${event_exp} | wc -l)
1881 if [ "$traced" -ne 0 ]; then
1882 pass "Validate trace for expression '${event_exp}', $traced events"
1883 else
1884 fail "Validate trace for expression '${event_exp}'"
1885 diag "Found $traced occurences of '${event_exp}'"
1886 fi
1887 ret=$?
1888 return $ret
1889 }
1890
1891 function validate_trace_only_exp()
1892 {
1893 local event_exp=$1
1894 local trace_path=$2
1895
1896 which $BABELTRACE_BIN >/dev/null
1897 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1898
1899 local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp ${event_exp} | wc -l)
1900 local total=$($BABELTRACE_BIN $trace_path | wc -l)
1901
1902 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1903 pass "Trace match with $total for expression '${event_exp}'"
1904 else
1905 fail "Trace match"
1906 diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1907 fi
1908 ret=$?
1909 return $ret
1910 }
1911
1912 function validate_trace_empty()
1913 {
1914 local trace_path=$1
1915
1916 which $BABELTRACE_BIN >/dev/null
1917 if [ $? -ne 0 ]; then
1918 skip 0 "Babeltrace binary not found. Skipping trace validation"
1919 fi
1920
1921 events=$($BABELTRACE_BIN $trace_path 2>/dev/null)
1922 ret=$?
1923 if [ $ret -ne 0 ]; then
1924 fail "Failed to parse trace"
1925 return $ret
1926 fi
1927
1928 traced=$(echo -n "$events" | wc -l)
1929 if [ "$traced" -eq 0 ]; then
1930 pass "Validate empty trace"
1931 else
1932 fail "Validate empty trace"
1933 diag "Found $traced events in trace"
1934 fi
1935 ret=$?
1936 return $ret
1937 }
1938
1939 function validate_directory_empty ()
1940 {
1941 local trace_path="$1"
1942
1943 # Do not double quote `$trace_path` below as we want wildcards to be
1944 # expanded.
1945 files="$(ls -A $trace_path)"
1946 ret=$?
1947 if [ $ret -ne 0 ]; then
1948 fail "Failed to list content of directory \"$trace_path\""
1949 return $ret
1950 fi
1951
1952 nb_files="$(echo -n "$files" | wc -l)"
1953 ok $nb_files "Directory \"$trace_path\" is empty"
1954 }
1955
1956 function validate_trace_session_ust_empty()
1957 {
1958 validate_directory_empty "$1"/ust
1959 }
1960
1961 function validate_trace_session_kernel_empty()
1962 {
1963 validate_trace_empty "$1"/kernel
1964 }
1965
1966 function regenerate_metadata ()
1967 {
1968 local expected_to_fail=$1
1969 local sess_name=$2
1970
1971 $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate metadata -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1972 ret=$?
1973 if [[ $expected_to_fail -eq "1" ]]; then
1974 test "$ret" -ne "0"
1975 ok $? "Expected fail on regenerate metadata $sess_name"
1976 else
1977 ok $ret "Metadata regenerate $sess_name"
1978 fi
1979 }
1980
1981 function regenerate_metadata_ok ()
1982 {
1983 regenerate_metadata 0 "$@"
1984 }
1985
1986 function regenerate_metadata_fail ()
1987 {
1988 regenerate_metadata 1 "$@"
1989 }
1990
1991 function regenerate_statedump ()
1992 {
1993 local expected_to_fail=$1
1994 local sess_name=$2
1995
1996 $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate statedump -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1997 ret=$?
1998 if [[ $expected_to_fail -eq "1" ]]; then
1999 test "$ret" -ne "0"
2000 ok $? "Expected fail on regenerate statedump $sess_name"
2001 else
2002 ok $ret "Statedump regenerate $sess_name"
2003 fi
2004 }
2005
2006 function regenerate_statedump_ok ()
2007 {
2008 regenerate_statedump 0 "$@"
2009 }
2010
2011 function regenerate_statedump_fail ()
2012 {
2013 regenerate_statedump 1 "$@"
2014 }
2015
2016 function rotate_session ()
2017 {
2018 local expected_to_fail=$1
2019 local sess_name=$2
2020
2021 $TESTDIR/../src/bin/lttng/$LTTNG_BIN rotate $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2022 ret=$?
2023 if [[ $expected_to_fail -eq "1" ]]; then
2024 test "$ret" -ne "0"
2025 ok $? "Expected fail on rotate session $sess_name"
2026 else
2027 ok $ret "Rotate session $sess_name"
2028 fi
2029 }
2030
2031 function rotate_session_ok ()
2032 {
2033 rotate_session 0 "$@"
2034 }
2035
2036 function rotate_session_fail ()
2037 {
2038 rotate_session 1 "$@"
2039 }
2040
2041 function destructive_tests_enabled ()
2042 {
2043 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
2044 return 0
2045 else
2046 return 1
2047 fi
2048 }
2049
2050 function lttng_enable_rotation_timer ()
2051 {
2052 local expected_to_fail=$1
2053 local sess_name=$2
2054 local period=$3
2055
2056 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2057 ret=$?
2058 if [[ $expected_to_fail -eq "1" ]]; then
2059 test "$ret" -ne "0"
2060 ok $? "Expected fail when setting periodic rotation ($period) of session $sess_name"
2061 else
2062 ok $ret "Set periodic rotation ($period) of session $sess_name"
2063 fi
2064 }
2065
2066 function lttng_enable_rotation_timer_ok ()
2067 {
2068 lttng_enable_rotation_timer 0 $@
2069 }
2070
2071 function lttng_enable_rotation_timer_fail ()
2072 {
2073 lttng_enable_rotation_timer 1 $@
2074 }
2075
2076 function lttng_enable_rotation_size ()
2077 {
2078 local expected_to_fail=$1
2079 local sess_name=$2
2080 local size=$3
2081
2082 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2083 ret=$?
2084 if [[ $expected_to_fail -eq "1" ]]; then
2085 test "$ret" -ne "0"
2086 ok $? "Expected fail on rotate session $sess_name"
2087 else
2088 ok $ret "Rotate session $sess_name"
2089 fi
2090 }
2091
2092 function lttng_enable_rotation_size_ok ()
2093 {
2094 lttng_enable_rotation_size 0 $@
2095 }
2096
2097 function lttng_enable_rotation_size_fail ()
2098 {
2099 lttng_enable_rotation_size 1 $@
2100 }
2101
2102 function lttng_clear_session ()
2103 {
2104 local expected_to_fail=$1
2105 local sess_name=$2
2106
2107 $TESTDIR/../src/bin/lttng/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2108 ret=$?
2109 if [[ $expected_to_fail -eq "1" ]]; then
2110 test "$ret" -ne "0"
2111 ok $? "Expected fail on clear session $sess_name"
2112 else
2113 ok $ret "Clear session $sess_name"
2114 fi
2115 }
2116
2117 function lttng_clear_session_ok ()
2118 {
2119 lttng_clear_session 0 $@
2120 }
2121
2122 function lttng_clear_session_fail ()
2123 {
2124 lttng_clear_session 1 $@
2125 }
2126
2127 function lttng_clear_all ()
2128 {
2129 $TESTDIR/../src/bin/lttng/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
2130 ok $? "Clear all lttng sessions"
2131 }
2132
2133 function lttng_add_trigger()
2134 {
2135 local expected_to_fail="$1"
2136 local trigger_name="$2"
2137 shift 2
2138
2139 $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --id "$trigger_name" "$@" 1> /dev/null 2> /dev/null
2140 ret=$?
2141 if [[ $expected_to_fail -eq "1" ]]; then
2142 test "$ret" -ne "0"
2143 ok $? "Add trigger $trigger_name failed as expected"
2144 else
2145 ok $ret "Add trigger $trigger_name"
2146 fi
2147 }
2148
2149 function lttng_remove_trigger()
2150 {
2151 local expected_to_fail="$1"
2152 local trigger_name="$2"
2153
2154 $TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger "$trigger_name" 1> /dev/null 2> /dev/null
2155 ret=$?
2156 if [[ $expected_to_fail -eq "1" ]]; then
2157 test "$ret" -ne "0"
2158 ok $? "Remove trigger $trigger_name failed as expected"
2159 else
2160 ok $ret "Remove trigger $trigger_name"
2161 fi
2162 }
2163
2164 function lttng_add_trigger_ok()
2165 {
2166 lttng_add_trigger 0 "$@"
2167 }
2168
2169 function lttng_remove_trigger_ok()
2170 {
2171 lttng_remove_trigger 0 "$@"
2172 }
This page took 0.129587 seconds and 3 git commands to generate.