080aa4d5d684ce61eeeac8d4e4afeeceede792cd
[lttng-tools.git] / tests / utils / utils.sh
1 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
2 #
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.
6 #
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
10 # details.
11 #
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
15
16 SESSIOND_BIN="lttng-sessiond"
17 SESSIOND_MATCH=".*lttng-sess.*"
18 SESSIOND_PIDS=""
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.*"
25 RELAYD_PIDS=""
26 LTTNG_BIN="lttng"
27 BABELTRACE_BIN="babeltrace"
28 OUTPUT_DEST=/dev/null
29 ERROR_OUTPUT_DEST=/dev/null
30
31 # Minimal kernel version supported for session daemon tests
32 KERNEL_MAJOR_VERSION=2
33 KERNEL_MINOR_VERSION=6
34 KERNEL_PATCHLEVEL_VERSION=27
35
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
42
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"
48
49 source $TESTDIR/utils/tap/tap.sh
50
51 function full_cleanup ()
52 {
53 if [ -n "${SESSIOND_PIDS}" ] || [ -n "${RELAYD_PIDS}" ]; then
54 kill -9 ${SESSIOND_PIDS} ${RELAYD_PIDS} > /dev/null 2>&1
55 fi
56
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 -- -$$
62 }
63
64
65 trap full_cleanup SIGINT SIGTERM
66
67 function print_ok ()
68 {
69 # Check if we are a terminal
70 if [ -t 1 ]; then
71 echo -e "\e[1;32mOK\e[0m"
72 else
73 echo -e "OK"
74 fi
75 }
76
77 function print_fail ()
78 {
79 # Check if we are a terminal
80 if [ -t 1 ]; then
81 echo -e "\e[1;31mFAIL\e[0m"
82 else
83 echo -e "FAIL"
84 fi
85 }
86
87 function print_test_banner ()
88 {
89 local desc="$1"
90 diag "$desc"
91 }
92
93 function validate_kernel_version ()
94 {
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
97 return 0
98 fi
99 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
100 return 0
101 fi
102 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
103 return 0
104 fi
105 return 1
106 }
107
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()
112 {
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
115 echo
116 }
117
118 # Return the number of _configured_ CPUs.
119 function conf_proc_count()
120 {
121 getconf _NPROCESSORS_CONF
122 if [ $? -ne 0 ]; then
123 diag "Failed to get the number of configured CPUs"
124 fi
125 echo
126 }
127
128 function enable_kernel_lttng_event
129 {
130 local expected_to_fail="$1"
131 local sess_name="$2"
132 local event_name="$3"
133 local channel_name="$4"
134
135 if [ -z "$event_name" ]; then
136 # Enable all event if no event name specified
137 event_name="-a"
138 fi
139
140 if [ -z "$channel_name" ]; then
141 # default channel if none specified
142 chan=""
143 else
144 chan="-c $channel_name"
145 fi
146
147 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
148 ret=$?
149 if [[ $expected_to_fail -eq "1" ]]; then
150 test $ret -ne "0"
151 ok $? "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
152 else
153 ok $ret "Enable kernel event $event_name for session $sess_name"
154 fi
155 }
156
157 function enable_kernel_lttng_event_ok ()
158 {
159 enable_kernel_lttng_event 0 "$@"
160 }
161
162 function enable_kernel_lttng_event_fail ()
163 {
164 enable_kernel_lttng_event 1 "$@"
165 }
166
167 # Old interface
168 function lttng_enable_kernel_event
169 {
170 enable_kernel_lttng_event_ok "$@"
171 }
172
173 function lttng_enable_kernel_syscall()
174 {
175 local expected_to_fail=$1
176 local sess_name=$2
177 local syscall_name=$3
178 local channel_name=$4
179
180 if [ -z $syscall_name ]; then
181 # Enable all event if no syscall name specified
182 syscall_name="-a"
183 fi
184
185 if [ -z $channel_name ]; then
186 # default channel if none specified
187 chan=""
188 else
189 chan="-c $channel_name"
190 fi
191
192 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
193 ret=$?
194 if [[ $expected_to_fail -eq "1" ]]; then
195 test $ret -ne "0"
196 ok $? "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
197 else
198 ok $ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
199 fi
200 }
201
202 function lttng_enable_kernel_syscall_ok()
203 {
204 lttng_enable_kernel_syscall 0 "$@"
205 }
206
207 function lttng_enable_kernel_syscall_fail()
208 {
209 lttng_enable_kernel_syscall 1 "$@"
210 }
211
212 function lttng_disable_kernel_syscall()
213 {
214 local expected_to_fail=$1
215 local sess_name=$2
216 local syscall_name=$3
217 local channel_name=$4
218
219 if [ -z $syscall_name ]; then
220 # Enable all event if no syscall name specified
221 syscall_name="-a"
222 fi
223
224 if [ -z $channel_name ]; then
225 # default channel if none specified
226 chan=""
227 else
228 chan="-c $channel_name"
229 fi
230
231 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
232
233 ret=$?
234 if [[ $expected_to_fail -eq "1" ]]; then
235 test $ret -ne "0"
236 ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected"
237 else
238 ok $ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
239 fi
240 }
241
242 function lttng_disable_kernel_syscall_ok()
243 {
244 lttng_disable_kernel_syscall 0 "$@"
245 }
246
247 function lttng_disable_kernel_syscall_fail()
248 {
249 lttng_disable_kernel_syscall 1 "$@"
250 }
251
252 function lttng_enable_kernel_channel()
253 {
254 local expected_to_fail=$1
255 local sess_name=$2
256 local channel_name=$3
257
258 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
259 ret=$?
260 if [[ $expected_to_fail -eq "1" ]]; then
261 test "$ret" -ne "0"
262 ok $? "Enable channel $channel_name for session $sess_name failed as expected"
263 else
264 ok $ret "Enable channel $channel_name for session $sess_name"
265 fi
266 }
267
268 function lttng_enable_kernel_channel_ok()
269 {
270 lttng_enable_kernel_channel 0 "$@"
271 }
272
273 function lttng_enable_kernel_channel_fail()
274 {
275 lttng_enable_kernel_channel 1 "$@"
276 }
277
278 function lttng_disable_kernel_channel()
279 {
280 local expected_to_fail=$1
281 local sess_name=$2
282 local channel_name=$3
283
284 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
285 ret=$?
286 if [[ $expected_to_fail -eq "1" ]]; then
287 test "$ret" -ne "0"
288 ok $? "Disable channel $channel_name for session $sess_name failed as expected"
289 else
290 ok $ret "Disable channel $channel_name for session $sess_name"
291 fi
292 }
293
294 function lttng_disable_kernel_channel_ok()
295 {
296 lttng_disable_kernel_channel 0 "$@"
297 }
298
299 function lttng_disable_kernel_channel_fail()
300 {
301 lttng_disable_kernel_channel 1 "$@"
302 }
303
304 function start_lttng_relayd_opt()
305 {
306 local withtap=$1
307 local opt=$2
308
309 DIR=$(readlink -f $TESTDIR)
310
311 if [ -z $(pgrep $RELAYD_MATCH) ]; then
312 $DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
313 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
314 if [ $? -eq 1 ]; then
315 if [ $withtap -eq "1" ]; then
316 fail "Start lttng-relayd (opt: $opt)"
317 fi
318 return 1
319 else
320 if [ $withtap -eq "1" ]; then
321 pass "Start lttng-relayd (opt: $opt)"
322 fi
323 fi
324 else
325 pass "Start lttng-relayd (opt: $opt)"
326 fi
327
328 RELAYD_PIDS=$(pgrep $RELAYD_MATCH)
329 }
330
331 function start_lttng_relayd()
332 {
333 start_lttng_relayd_opt 1 "$@"
334 }
335
336 function start_lttng_relayd_notap()
337 {
338 start_lttng_relayd_opt 0 "$@"
339 }
340
341 function stop_lttng_relayd_opt()
342 {
343 local withtap=$1
344
345 if [ $withtap -eq "1" ]; then
346 diag "Killing lttng-relayd (pid: $RELAYD_PIDS)"
347 fi
348 kill $RELAYD_PIDS 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
349 retval=$?
350
351 if [ $? -eq 1 ]; then
352 if [ $withtap -eq "1" ]; then
353 fail "Kill relay daemon"
354 fi
355 return 1
356 else
357 out=1
358 while [ -n "$out" ]; do
359 out=$(pgrep $RELAYD_MATCH)
360 sleep 0.5
361 done
362 if [ $withtap -eq "1" ]; then
363 pass "Kill relay daemon"
364 fi
365 fi
366 RELAYD_PIDS=""
367 return $retval
368 }
369
370 function stop_lttng_relayd()
371 {
372 stop_lttng_relayd_opt 1 "$@"
373 }
374
375 function stop_lttng_relayd_notap()
376 {
377 stop_lttng_relayd_opt 0 "$@"
378 }
379
380 #First arg: show tap output
381 #Second argument: load path for automatic loading
382 function start_lttng_sessiond_opt()
383 {
384 local withtap=$1
385 local load_path=$2
386
387 local consumerd=""
388 local long_bit_value=$(getconf LONG_BIT)
389
390 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
391 # Env variable requested no session daemon
392 return
393 fi
394
395 DIR=$(readlink -f $TESTDIR)
396
397 # Get long_bit value for 32/64 consumerd
398 case "$long_bit_value" in
399 32)
400 consumerd="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
401 ;;
402 64)
403 consumerd="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
404 ;;
405 *)
406 return
407 ;;
408 esac
409
410 validate_kernel_version
411 if [ $? -ne 0 ]; then
412 fail "Start session daemon"
413 BAIL_OUT "*** Kernel too old for session daemon tests ***"
414 fi
415
416 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
417 export LTTNG_SESSION_CONFIG_XSD_PATH
418
419 if [ -z $(pgrep ${SESSIOND_MATCH}) ]; then
420 # Have a load path ?
421 if [ -n "$load_path" ]; then
422 $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$load_path" --background $consumerd
423 else
424 $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background $consumerd
425 fi
426 #$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
427 status=$?
428 if [ $withtap -eq "1" ]; then
429 ok $status "Start session daemon"
430 fi
431 fi
432 SESSIOND_PIDS=$(pgrep $SESSIOND_MATCH)
433 }
434
435 function start_lttng_sessiond()
436 {
437 start_lttng_sessiond_opt 1 "$@"
438 }
439
440 function start_lttng_sessiond_notap()
441 {
442 start_lttng_sessiond_opt 0 "$@"
443 }
444
445 function stop_lttng_sessiond_opt()
446 {
447 local withtap=$1
448 local signal=$2
449 local kill_opt=""
450
451 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
452 # Env variable requested no session daemon
453 return
454 fi
455
456 local pids="${SESSIOND_PIDS} $(pgrep $RUNAS_MATCH)"
457
458 if [ -n "$2" ]; then
459 kill_opt="$kill_opt -s $signal"
460 fi
461 if [ $withtap -eq "1" ]; then
462 diag "Killing $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo $pids | tr '\n' ' ')"
463 fi
464 kill $kill_opt $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
465
466 if [ $? -eq 1 ]; then
467 if [ $withtap -eq "1" ]; then
468 fail "Kill sessions daemon"
469 fi
470 else
471 out=1
472 while [ -n "$out" ]; do
473 out=$(pgrep ${SESSIOND_MATCH})
474 sleep 0.5
475 done
476 out=1
477 while [ -n "$out" ]; do
478 out=$(pgrep $CONSUMERD_MATCH)
479 sleep 0.5
480 done
481
482 SESSIOND_PIDS=""
483 if [ $withtap -eq "1" ]; then
484 pass "Kill session daemon"
485 fi
486 fi
487 }
488
489 function stop_lttng_sessiond()
490 {
491 stop_lttng_sessiond_opt 1 "$@"
492 }
493
494 function stop_lttng_sessiond_notap()
495 {
496 stop_lttng_sessiond_opt 0 "$@"
497 }
498
499 function sigstop_lttng_sessiond_opt()
500 {
501 local withtap=$1
502 local signal=SIGSTOP
503 local kill_opt=""
504
505 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
506 # Env variable requested no session daemon
507 return
508 fi
509
510 PID_SESSIOND="$(pgrep ${SESSIOND_MATCH}) $(pgrep $RUNAS_MATCH)"
511
512 kill_opt="$kill_opt -s $signal"
513
514 if [ $withtap -eq "1" ]; then
515 diag "Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')"
516 fi
517 kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
518
519 if [ $? -eq 1 ]; then
520 if [ $withtap -eq "1" ]; then
521 fail "Sending SIGSTOP to session daemon"
522 fi
523 else
524 out=1
525 while [ $out -ne 0 ]; do
526 pid=$(pgrep $SESSIOND_MATCH)
527
528 # Wait until state becomes stopped for session
529 # daemon(s).
530 out=0
531 for sessiond_pid in $pid; do
532 state=$(ps -p $sessiond_pid -o state= )
533 if [[ -n "$state" && "$state" != "T" ]]; then
534 out=1
535 fi
536 done
537 sleep 0.5
538 done
539 if [ $withtap -eq "1" ]; then
540 pass "Sending SIGSTOP to session daemon"
541 fi
542 fi
543 }
544
545 function sigstop_lttng_sessiond()
546 {
547 sigstop_lttng_sessiond_opt 1 "$@"
548 }
549
550 function sigstop_lttng_sessiond_notap()
551 {
552 sigstop_lttng_sessiond_opt 0 "$@"
553 }
554
555 function stop_lttng_consumerd_opt()
556 {
557 local withtap=$1
558 local signal=$2
559 local kill_opt=""
560
561 PID_CONSUMERD=$(pgrep $CONSUMERD_MATCH)
562
563 if [ -n "$2" ]; then
564 kill_opt="$kill_opt -s $signal"
565 fi
566
567 if [ $withtap -eq "1" ]; then
568 diag "Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
569 fi
570 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
571 retval=$?
572 set +x
573
574 if [ $? -eq 1 ]; then
575 if [ $withtap -eq "1" ]; then
576 fail "Kill consumer daemon"
577 fi
578 return 1
579 else
580 out=1
581 while [ $out -ne 0 ]; do
582 pid=$(pgrep $CONSUMERD_MATCH)
583
584 # If consumerds are still present check their status.
585 # A zombie status qualifies the consumerd as *killed*
586 out=0
587 for consumer_pid in $pid; do
588 state=$(ps -p $consumer_pid -o state= )
589 if [[ -n "$state" && "$state" != "Z" ]]; then
590 out=1
591 fi
592 done
593 sleep 0.5
594 done
595 if [ $withtap -eq "1" ]; then
596 pass "Kill consumer daemon"
597 fi
598 fi
599 return $retval
600 }
601
602 function stop_lttng_consumerd()
603 {
604 stop_lttng_consumerd_opt 1 "$@"
605 }
606
607 function stop_lttng_consumerd_notap()
608 {
609 stop_lttng_consumerd_opt 0 "$@"
610 }
611
612 function sigstop_lttng_consumerd_opt()
613 {
614 local withtap=$1
615 local signal=SIGSTOP
616 local kill_opt=""
617
618 PID_CONSUMERD=$(pgrep $CONSUMERD_MATCH)
619
620 kill_opt="$kill_opt -s $signal"
621
622 if [ $withtap -eq "1" ]; then
623 diag "Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')"
624 fi
625 kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
626 retval=$?
627 set +x
628
629 if [ $? -eq 1 ]; then
630 if [ $withtap -eq "1" ]; then
631 fail "Sending SIGSTOP to consumer daemon"
632 fi
633 return 1
634 else
635 out=1
636 while [ $out -ne 0 ]; do
637 pid=$(pgrep $CONSUMERD_MATCH)
638
639 # Wait until state becomes stopped for all
640 # consumers.
641 out=0
642 for consumer_pid in $pid; do
643 state=$(ps -p $consumer_pid -o state= )
644 if [[ -n "$state" && "$state" != "T" ]]; then
645 out=1
646 fi
647 done
648 sleep 0.5
649 done
650 if [ $withtap -eq "1" ]; then
651 pass "Sending SIGSTOP to consumer daemon"
652 fi
653 fi
654 return $retval
655 }
656
657 function sigstop_lttng_consumerd()
658 {
659 sigstop_lttng_consumerd_opt 1 "$@"
660 }
661
662 function sigstop_lttng_consumerd_notap()
663 {
664 sigstop_lttng_consumerd_opt 0 "$@"
665 }
666
667 function list_lttng_with_opts ()
668 {
669 local opts=$1
670 $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
671 ok $? "Lttng-tool list command with option $opts"
672 }
673
674 function create_lttng_session_no_output ()
675 {
676 local sess_name=$1
677
678 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
679 ok $? "Create session $sess_name in no-output mode"
680 }
681
682 function create_lttng_session ()
683 {
684 local expected_to_fail=$1
685 local sess_name=$2
686 local trace_path=$3
687 local opt=$4
688
689 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path $opt > $OUTPUT_DEST
690 ret=$?
691 if [[ $expected_to_fail -eq "1" ]]; then
692 test "$ret" -ne "0"
693 ok $? "Create session $sess_name in $trace_path failed as expected"
694 else
695 ok $ret "Create session $sess_name in $trace_path"
696 fi
697 }
698
699 function create_lttng_session_ok ()
700 {
701 create_lttng_session 0 "$@"
702 }
703
704 function create_lttng_session_fail ()
705 {
706 create_lttng_session 1 "$@"
707 }
708
709
710 function enable_ust_lttng_channel ()
711 {
712 local expected_to_fail=$1
713 local sess_name=$2
714 local channel_name=$3
715 local opt=$4
716
717 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
718 ret=$?
719 if [[ $expected_to_fail -eq "1" ]]; then
720 test "$ret" -ne "0"
721 ok $? "Enable channel $channel_name for session $sess_name failed as expected"
722 else
723 ok $ret "Enable channel $channel_name for session $sess_name"
724 fi
725 }
726
727 function enable_ust_lttng_channel_ok ()
728 {
729 enable_ust_lttng_channel 0 "$@"
730 }
731
732 function enable_ust_lttng_channel_fail ()
733 {
734 enable_ust_lttng_channel 1 "$@"
735 }
736
737 function disable_ust_lttng_channel()
738 {
739 local sess_name=$1
740 local channel_name=$2
741
742 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
743 ok $? "Disable channel $channel_name for session $sess_name"
744 }
745
746 function enable_lttng_mmap_overwrite_kernel_channel()
747 {
748 local sess_name=$1
749 local channel_name=$2
750
751 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
752 ok $? "Enable channel $channel_name for session $sess_name"
753 }
754
755 function enable_lttng_mmap_discard_small_kernel_channel()
756 {
757 local sess_name=$1
758 local channel_name=$2
759
760 $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
761 ok $? "Enable small discard channel $channel_name for session $sess_name"
762 }
763
764 function enable_lttng_mmap_overwrite_small_kernel_channel()
765 {
766 local sess_name=$1
767 local channel_name=$2
768
769 $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
770 ok $? "Enable small discard channel $channel_name for session $sess_name"
771 }
772
773 function enable_lttng_mmap_overwrite_ust_channel()
774 {
775 local sess_name=$1
776 local channel_name=$2
777
778 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
779 ok $? "Enable channel $channel_name for session $sess_name"
780 }
781
782 function enable_ust_lttng_event ()
783 {
784 local expected_to_fail=$1
785 local sess_name=$2
786 local event_name="$3"
787 local channel_name=$4
788
789 if [ -z $channel_name ]; then
790 # default channel if none specified
791 chan=""
792 else
793 chan="-c $channel_name"
794 fi
795
796 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
797 ret=$?
798 if [[ $expected_to_fail -eq "1" ]]; then
799 test $ret -ne "0"
800 ok $? "Enable ust event $event_name for session $session_name failed as expected"
801 else
802 ok $ret "Enable ust event $event_name for session $sess_name"
803 fi
804 }
805
806 function enable_ust_lttng_event_ok ()
807 {
808 enable_ust_lttng_event 0 "$@"
809 }
810
811 function enable_ust_lttng_event_fail ()
812 {
813 enable_ust_lttng_event 1 "$@"
814 }
815
816 function enable_jul_lttng_event()
817 {
818 sess_name=$1
819 event_name="$2"
820 channel_name=$3
821
822 if [ -z $channel_name ]; then
823 # default channel if none specified
824 chan=""
825 else
826 chan="-c $channel_name"
827 fi
828
829 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
830 ok $? "Enable JUL event $event_name for session $sess_name"
831 }
832
833 function enable_jul_lttng_event_loglevel()
834 {
835 local sess_name=$1
836 local event_name="$2"
837 local loglevel=$3
838 local channel_name=$4
839
840 if [ -z $channel_name ]; then
841 # default channel if none specified
842 chan=""
843 else
844 chan="-c $channel_name"
845 fi
846
847 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
848 ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
849 }
850
851 function enable_log4j_lttng_event()
852 {
853 sess_name=$1
854 event_name="$2"
855 channel_name=$3
856
857 if [ -z $channel_name ]; then
858 # default channel if none specified
859 chan=""
860 else
861 chan="-c $channel_name"
862 fi
863
864 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
865 ok $? "Enable LOG4J event $event_name for session $sess_name"
866 }
867
868 function enable_log4j_lttng_event_loglevel()
869 {
870 local sess_name=$1
871 local event_name="$2"
872 local loglevel=$3
873 local channel_name=$4
874
875 if [ -z $channel_name ]; then
876 # default channel if none specified
877 chan=""
878 else
879 chan="-c $channel_name"
880 fi
881
882 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
883 ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
884 }
885
886 function enable_python_lttng_event()
887 {
888 sess_name=$1
889 event_name="$2"
890 channel_name=$3
891
892 if [ -z $channel_name ]; then
893 # default channel if none specified
894 chan=""
895 else
896 chan="-c $channel_name"
897 fi
898
899 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
900 ok $? "Enable Python event $event_name for session $sess_name"
901 }
902
903 function enable_python_lttng_event_loglevel()
904 {
905 local sess_name=$1
906 local event_name="$2"
907 local loglevel=$3
908 local channel_name=$4
909
910 if [ -z $channel_name ]; then
911 # default channel if none specified
912 chan=""
913 else
914 chan="-c $channel_name"
915 fi
916
917 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
918 ok $? "Enable Python event $event_name for session $sess_name with loglevel $loglevel"
919 }
920
921 function enable_ust_lttng_event_filter()
922 {
923 local sess_name="$1"
924 local event_name="$2"
925 local filter="$3"
926
927 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
928 ok $? "Enable event $event_name with filtering for session $sess_name"
929 }
930
931 function enable_ust_lttng_event_loglevel()
932 {
933 local sess_name="$1"
934 local event_name="$2"
935 local loglevel="$3"
936
937 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
938 ok $? "Enable event $event_name with loglevel $loglevel"
939 }
940
941 function enable_ust_lttng_event_loglevel_only()
942 {
943 local sess_name="$1"
944 local event_name="$2"
945 local loglevel="$3"
946
947 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
948 ok $? "Enable event $event_name with loglevel-only $loglevel"
949 }
950
951 function disable_ust_lttng_event ()
952 {
953 local sess_name="$1"
954 local event_name="$2"
955 local channel_name="$3"
956
957 if [ -z $channel_name ]; then
958 # default channel if none specified
959 chan=""
960 else
961 chan="-c $channel_name"
962 fi
963
964 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
965 ok $? "Disable event $event_name for session $sess_name"
966 }
967
968 function disable_jul_lttng_event ()
969 {
970 local sess_name="$1"
971 local event_name="$2"
972
973 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1
974 ok $? "Disable JUL event $event_name for session $sess_name"
975 }
976
977 function disable_log4j_lttng_event ()
978 {
979 local sess_name="$1"
980 local event_name="$2"
981
982 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1
983 ok $? "Disable LOG4J event $event_name for session $sess_name"
984 }
985
986 function disable_python_lttng_event ()
987 {
988 local sess_name="$1"
989 local event_name="$2"
990
991 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
992 ok $? "Disable Python event $event_name for session $sess_name"
993 }
994
995 function start_lttng_tracing ()
996 {
997 local expected_to_fail=$1
998 local sess_name=$2
999
1000 $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1001 ret=$?
1002 if [[ $expected_to_fail -eq "1" ]]; then
1003 test "$ret" -ne "0"
1004 ok $? "Start tracing for session $sess_name failed as expected"
1005 else
1006 ok $ret "Start tracing for session $sess_name"
1007 fi
1008 }
1009
1010 function start_lttng_tracing_ok ()
1011 {
1012 start_lttng_tracing 0 "$@"
1013 }
1014
1015 function start_lttng_tracing_fail ()
1016 {
1017 start_lttng_tracing 1 "$@"
1018 }
1019
1020 function stop_lttng_tracing ()
1021 {
1022 local expected_to_fail=$1
1023 local sess_name=$2
1024
1025 $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1026 ret=$?
1027 if [[ $expected_to_fail -eq "1" ]]; then
1028 test "$ret" -ne "0"
1029 ok $? "Stop lttng tracing for session $sess_name failed as expected"
1030 else
1031 ok $ret "Stop lttng tracing for session $sess_name"
1032 fi
1033 }
1034
1035 function stop_lttng_tracing_ok ()
1036 {
1037 stop_lttng_tracing 0 "$@"
1038 }
1039
1040 function stop_lttng_tracing_fail ()
1041 {
1042 stop_lttng_tracing 1 "$@"
1043 }
1044
1045 function destroy_lttng_session ()
1046 {
1047 local expected_to_fail=$1
1048 local sess_name=$2
1049
1050 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1051 ret=$?
1052 if [[ $expected_to_fail -eq "1" ]]; then
1053 test "$ret" -ne "0"
1054 ok $? "Destroy session $sess_name failed as expected"
1055 else
1056 ok $ret "Destroy session $sess_name"
1057 fi
1058 }
1059
1060 function destroy_lttng_session_ok ()
1061 {
1062 destroy_lttng_session 0 "$@"
1063
1064 }
1065
1066 function destroy_lttng_session_fail ()
1067 {
1068 destroy_lttng_session 1 "$@"
1069 }
1070
1071
1072 function destroy_lttng_sessions ()
1073 {
1074 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1075 ok $? "Destroy all lttng sessions"
1076 }
1077
1078 function lttng_snapshot_add_output ()
1079 {
1080 local expected_to_fail=$1
1081 local sess_name=$2
1082 local trace_path=$3
1083
1084 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1085 ret=$?
1086 if [[ $expected_to_fail -eq 1 ]]; then
1087 test "$ret" -ne "0"
1088 ok $? "Added snapshot output file://$trace_path failed as expected"
1089 else
1090 ok $ret "Added snapshot output file://$trace_path"
1091 fi
1092 }
1093
1094 function lttng_snapshot_add_output_ok ()
1095 {
1096 lttng_snapshot_add_output 0 "$@"
1097 }
1098
1099 function lttng_snapshot_add_output_fail ()
1100 {
1101 lttng_snapshot_add_output 1 "$@"
1102 }
1103
1104 function lttng_snapshot_del_output ()
1105 {
1106 local expected_to_fail=$1
1107 local sess_name=$2
1108 local id=$3
1109
1110 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1111 ret=$?
1112 if [[ $expected_to_fail -eq "1" ]]; then
1113 test "$ret" -ne "0"
1114 ok $? "Deleted snapshot output id $id failed as expected"
1115 else
1116 ok $ret "Deleted snapshot output id $id"
1117 fi
1118 }
1119
1120 function lttng_snapshot_del_output_ok ()
1121 {
1122 lttng_snapshot_del_output 0 "$@"
1123 }
1124
1125 function lttng_snapshot_del_output_fail ()
1126 {
1127 lttng_snapshot_del_output 1 "$@"
1128 }
1129
1130 function lttng_snapshot_record ()
1131 {
1132 local sess_name=$1
1133 local trace_path=$2
1134
1135 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1136 ok $? "Snapshot recorded"
1137 }
1138
1139 function lttng_snapshot_list ()
1140 {
1141 local sess_name=$1
1142 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1143 ok $? "Snapshot list"
1144 }
1145
1146 function lttng_save()
1147 {
1148 local sess_name=$1
1149 local opts=$2
1150
1151 $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1152 ok $? "Session saved"
1153 }
1154
1155 function lttng_load()
1156 {
1157 local expected_to_fail=$1
1158 local opts=$2
1159
1160 $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1161 ret=$?
1162 if [[ $expected_to_fail -eq "1" ]]; then
1163 test $ret -ne "0"
1164 ok $? "Load command failed as expected with opts: $opts"
1165 else
1166 ok $ret "Load command with opts: $opts"
1167 fi
1168 }
1169
1170 function lttng_load_ok()
1171 {
1172 lttng_load 0 "$@"
1173 }
1174
1175 function lttng_load_fail()
1176 {
1177 lttng_load 1 "$@"
1178 }
1179
1180 function lttng_track()
1181 {
1182 local expected_to_fail=$1
1183 local opts=$2
1184 $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST
1185 ret=$?
1186 if [[ $expected_to_fail -eq "1" ]]; then
1187 test $ret -ne "0"
1188 ok $? "Track command failed as expected with opts: $opts"
1189 else
1190 ok $ret "Track command with opts: $opts"
1191 fi
1192 }
1193
1194 function lttng_track_ok()
1195 {
1196 lttng_track 0 "$@"
1197 }
1198
1199 function lttng_track_fail()
1200 {
1201 lttng_track 1 "$@"
1202 }
1203
1204 function lttng_untrack()
1205 {
1206 local expected_to_fail=$1
1207 local opts=$2
1208 $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST
1209 ret=$?
1210 if [[ $expected_to_fail -eq "1" ]]; then
1211 test $ret -ne "0"
1212 ok $? "Untrack command failed as expected with opts: $opts"
1213 else
1214 ok $ret "Untrack command with opts: $opts"
1215 fi
1216 }
1217
1218 function lttng_untrack_ok()
1219 {
1220 lttng_untrack 0 "$@"
1221 }
1222
1223 function lttng_untrack_fail()
1224 {
1225 lttng_untrack 1 "$@"
1226 }
1227
1228 function add_context_lttng()
1229 {
1230 local expected_to_fail="$1"
1231 local domain="$2"
1232 local session_name="$3"
1233 local channel_name="$4"
1234 local type="$5"
1235
1236 $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1237 ret=$?
1238 if [[ $expected_to_fail -eq "1" ]]; then
1239 test $ret -ne "0"
1240 ok $? "Add context command failed as expected for type: $type"
1241 else
1242 ok $ret "Add context command for type: $type"
1243 fi
1244 }
1245
1246 function add_context_ust_ok()
1247 {
1248 add_context_lttng 0 -u "$@"
1249 }
1250
1251 function add_context_ust_fail()
1252 {
1253 add_context_lttng 1 -u "$@"
1254 }
1255
1256 function add_context_kernel_ok()
1257 {
1258 add_context_lttng 0 -k "$@"
1259 }
1260
1261 function add_context_kernel_fail()
1262 {
1263 add_context_lttng 1 -k "$@"
1264 }
1265
1266 function trace_matches ()
1267 {
1268 local event_name=$1
1269 local nr_iter=$2
1270 local trace_path=$3
1271
1272 which $BABELTRACE_BIN >/dev/null
1273 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1274
1275 local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
1276
1277 if [ "$count" -ne "$nr_iter" ]; then
1278 fail "Trace match"
1279 diag "$count matching events found in trace"
1280 else
1281 pass "Trace match"
1282 fi
1283 }
1284
1285 function trace_match_only()
1286 {
1287 local event_name=$1
1288 local nr_iter=$2
1289 local trace_path=$3
1290
1291 which $BABELTRACE_BIN >/dev/null
1292 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1293
1294 local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
1295 local total=$($BABELTRACE_BIN $trace_path | wc -l)
1296
1297 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
1298 pass "Trace match with $total event $event_name"
1299 else
1300 fail "Trace match"
1301 diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
1302 fi
1303 }
1304
1305 function validate_trace
1306 {
1307 local event_name=$1
1308 local trace_path=$2
1309
1310 which $BABELTRACE_BIN >/dev/null
1311 if [ $? -ne 0 ]; then
1312 skip 0 "Babeltrace binary not found. Skipping trace validation"
1313 fi
1314
1315 OLDIFS=$IFS
1316 IFS=","
1317 for i in $event_name; do
1318 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
1319 if [ "$traced" -ne 0 ]; then
1320 pass "Validate trace for event $i, $traced events"
1321 else
1322 fail "Validate trace for event $i"
1323 diag "Found $traced occurences of $i"
1324 fi
1325 done
1326 ret=$?
1327 IFS=$OLDIFS
1328 return $ret
1329 }
1330
1331 function validate_trace_count
1332 {
1333 local event_name=$1
1334 local trace_path=$2
1335 local expected_count=$3
1336
1337 which $BABELTRACE_BIN >/dev/null
1338 if [ $? -ne 0 ]; then
1339 skip 0 "Babeltrace binary not found. Skipping trace validation"
1340 fi
1341
1342 cnt=0
1343 OLDIFS=$IFS
1344 IFS=","
1345 for i in $event_name; do
1346 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
1347 if [ "$traced" -ne 0 ]; then
1348 pass "Validate trace for event $i, $traced events"
1349 else
1350 fail "Validate trace for event $i"
1351 diag "Found $traced occurences of $i"
1352 fi
1353 cnt=$(($cnt + $traced))
1354 done
1355 IFS=$OLDIFS
1356 test $cnt -eq $expected_count
1357 ok $? "Read a total of $cnt events, expected $expected_count"
1358 }
1359
1360 function trace_first_line
1361 {
1362 local trace_path=$1
1363
1364 which $BABELTRACE_BIN >/dev/null
1365 if [ $? -ne 0 ]; then
1366 skip 0 "Babeltrace binary not found. Skipping trace validation"
1367 fi
1368
1369 $BABELTRACE_BIN $trace_path 2>/dev/null | head -n 1
1370 }
1371
1372 function validate_trace_exp()
1373 {
1374 local event_exp=$1
1375 local trace_path=$2
1376
1377 which $BABELTRACE_BIN >/dev/null
1378 skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation"
1379
1380 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | wc -l)
1381 if [ "$traced" -ne 0 ]; then
1382 pass "Validate trace for expression '${event_exp}', $traced events"
1383 else
1384 fail "Validate trace for expression '${event_exp}'"
1385 diag "Found $traced occurences of '${event_exp}'"
1386 fi
1387 ret=$?
1388 return $ret
1389 }
1390
1391 function validate_trace_only_exp()
1392 {
1393 local event_exp=$1
1394 local trace_path=$2
1395
1396 which $BABELTRACE_BIN >/dev/null
1397 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
1398
1399 local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l)
1400 local total=$($BABELTRACE_BIN $trace_path | wc -l)
1401
1402 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
1403 pass "Trace match with $total for expression '${event_exp}"
1404 else
1405 fail "Trace match"
1406 diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
1407 fi
1408 ret=$?
1409 return $ret
1410 }
1411
1412 function validate_trace_empty()
1413 {
1414 local trace_path=$1
1415
1416 which $BABELTRACE_BIN >/dev/null
1417 if [ $? -ne 0 ]; then
1418 skip 0 "Babeltrace binary not found. Skipping trace validation"
1419 fi
1420
1421 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | wc -l)
1422 if [ "$traced" -eq 0 ]; then
1423 pass "Validate empty trace"
1424 else
1425 fail "Validate empty trace"
1426 diag "Found $traced events in trace"
1427 fi
1428 ret=$?
1429 return $ret
1430 }
1431
1432 function regenerate_metadata ()
1433 {
1434 local expected_to_fail=$1
1435 local sess_name=$2
1436
1437 $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate metadata -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1438 ret=$?
1439 if [[ $expected_to_fail -eq "1" ]]; then
1440 test "$ret" -ne "0"
1441 ok $? "Expected fail on regenerate metadata $sess_name"
1442 else
1443 ok $ret "Metadata regenerate $sess_name"
1444 fi
1445 }
1446
1447 function regenerate_metadata_ok ()
1448 {
1449 regenerate_metadata 0 "$@"
1450 }
1451
1452 function regenerate_metadata_fail ()
1453 {
1454 regenerate_metadata 1 "$@"
1455 }
1456
1457 function regenerate_statedump ()
1458 {
1459 local expected_to_fail=$1
1460 local sess_name=$2
1461
1462 $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate statedump -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
1463 ret=$?
1464 if [[ $expected_to_fail -eq "1" ]]; then
1465 test "$ret" -ne "0"
1466 ok $? "Expected fail on regenerate statedump $sess_name"
1467 else
1468 ok $ret "Metadata regenerate $sess_name"
1469 fi
1470 }
1471
1472 function regenerate_statedump_ok ()
1473 {
1474 regenerate_statedump 0 "$@"
1475 }
1476
1477 function regenerate_statedump_fail ()
1478 {
1479 regenerate_statedump 1 "$@"
1480 }
1481
1482 function destructive_tests_enabled ()
1483 {
1484 if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
1485 return 0
1486 else
1487 return 1
1488 fi
1489 }
This page took 0.096958 seconds and 3 git commands to generate.