2647769f27106087ecf4f72e0c92d7590b652fa5
[lttng-tools.git] / tests / utils / utils.sh
1 #!/src/bin/bash
2 #
3 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4 #
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18 SESSIOND_BIN="lttng-sessiond"
19 CONSUMERD_BIN="lttng-consumerd"
20 RELAYD_BIN="lttng-relayd"
21 LTTNG_BIN="lttng"
22 BABELTRACE_BIN="babeltrace"
23 OUTPUT_DEST=/dev/null 2>&1
24
25 # Minimal kernel version supported for session daemon tests
26 KERNEL_MAJOR_VERSION=2
27 KERNEL_MINOR_VERSION=6
28 KERNEL_PATCHLEVEL_VERSION=27
29
30 source $TESTDIR/utils/tap/tap.sh
31
32 function print_ok ()
33 {
34 # Check if we are a terminal
35 if [ -t 1 ]; then
36 echo -e "\e[1;32mOK\e[0m"
37 else
38 echo -e "OK"
39 fi
40 }
41
42 function print_fail ()
43 {
44 # Check if we are a terminal
45 if [ -t 1 ]; then
46 echo -e "\e[1;31mFAIL\e[0m"
47 else
48 echo -e "FAIL"
49 fi
50 }
51
52 function print_test_banner ()
53 {
54 local desc="$1"
55 diag "$desc"
56 }
57
58 function validate_kernel_version ()
59 {
60 local kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
61 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
62 return 0
63 fi
64 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
65 return 0
66 fi
67 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
68 return 0
69 fi
70 return 1
71 }
72
73 # Generate a random string
74 # $1 = number of characters; defaults to 16
75 # $2 = include special characters; 1 = yes, 0 = no; defaults to yes
76 function randstring()
77 {
78 [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
79 cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16}
80 echo
81 }
82
83 function lttng_enable_kernel_event
84 {
85 local sess_name=$1
86 local event_name=$2
87 local channel_name=$3
88
89 if [ -z $event_name ]; then
90 # Enable all event if no event name specified
91 event_name="-a"
92 fi
93
94 if [ -z $channel_name ]; then
95 # default channel if none specified
96 chan=""
97 else
98 chan="-c $channel_name"
99 fi
100
101 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k >$OUTPUT_DEST
102 ok $? "Enable kernel event $event_name for session $sess_name"
103 }
104
105 function lttng_enable_kernel_syscall()
106 {
107 local expected_to_fail=$1
108 local sess_name=$2
109 local syscall_name=$3
110 local channel_name=$4
111
112 if [ -z $syscall_name ]; then
113 # Enable all event if no syscall name specified
114 syscall_name="-a"
115 fi
116
117 if [ -z $channel_name ]; then
118 # default channel if none specified
119 chan=""
120 else
121 chan="-c $channel_name"
122 fi
123
124 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --syscall "$syscall_name" $chan -s $sess_name -k >$OUTPUT_DEST
125 ret=$?
126 if [[ $expected_to_fail -eq "1" ]]; then
127 test $ret -ne "0"
128 ok $? "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
129 else
130 ok $ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
131 fi
132 }
133
134 function lttng_enable_kernel_syscall_ok()
135 {
136 lttng_enable_kernel_syscall 0 ${*}
137 }
138
139 function lttng_enable_kernel_syscall_fail()
140 {
141 lttng_enable_kernel_syscall 1 ${*}
142 }
143
144 function lttng_disable_kernel_syscall()
145 {
146 local expected_to_fail=$1
147 local sess_name=$2
148 local syscall_name=$3
149 local channel_name=$4
150
151 if [ -z $syscall_name ]; then
152 # Enable all event if no syscall name specified
153 syscall_name="-a"
154 fi
155
156 if [ -z $channel_name ]; then
157 # default channel if none specified
158 chan=""
159 else
160 chan="-c $channel_name"
161 fi
162
163 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event --syscall "$syscall_name" $chan -s $sess_name -k >$OUTPUT_DEST
164
165 ret=$?
166 if [[ $expected_to_fail -eq "1" ]]; then
167 test $ret -ne "0"
168 ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected"
169 else
170 ok $ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name"
171 fi
172 }
173
174 function lttng_disable_kernel_syscall_ok()
175 {
176 lttng_disable_kernel_syscall 0 ${*}
177 }
178
179 function lttng_disable_kernel_syscall_fail()
180 {
181 lttng_disable_kernel_syscall 1 ${*}
182 }
183
184 function start_lttng_relayd
185 {
186 local opt=$1
187
188 DIR=$(readlink -f $TESTDIR)
189
190 if [ -z $(pidof lt-$RELAYD_BIN) ]; then
191 $DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt >$OUTPUT_DEST
192 #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
193 if [ $? -eq 1 ]; then
194 fail "Start lttng-relayd (opt: $opt)"
195 return 1
196 else
197 pass "Start lttng-relayd (opt: $opt)"
198 fi
199 else
200 pass "Start lttng-relayd (opt: $opt)"
201 fi
202 }
203
204 function stop_lttng_relayd_nocheck
205 {
206 PID_RELAYD=`pidof lt-$RELAYD_BIN`
207
208 diag "Killing lttng-relayd (pid: $PID_RELAYD)"
209 kill $PID_RELAYD >$OUTPUT_DEST
210 retval=$?
211
212 if [ $retval -eq 1 ]; then
213 out=1
214 while [ -n "$out" ]; do
215 out=$(pidof lt-$RELAYD_BIN)
216 sleep 0.5
217 done
218 fi
219 return $retval
220 }
221
222 function stop_lttng_relayd
223 {
224 stop_lttng_relayd_nocheck
225
226 if [ $? -eq 1 ]; then
227 fail "Killed lttng-relayd (pid: $PID_RELAYD)"
228 return 1
229 else
230 pass "Killed lttng-relayd (pid: $PID_RELAYD)"
231 return 0
232 fi
233 }
234
235 #First argument: load path for automatic loading
236 function start_lttng_sessiond()
237 {
238
239 local load_path="$1"
240 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
241 # Env variable requested no session daemon
242 return
243 fi
244
245 validate_kernel_version
246 if [ $? -ne 0 ]; then
247 fail "Start session daemon"
248 BAIL_OUT "*** Kernel too old for session daemon tests ***"
249 fi
250
251 DIR=$(readlink -f $TESTDIR)
252 : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
253 export LTTNG_SESSION_CONFIG_XSD_PATH
254
255 if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
256 # Have a load path ?
257 if [ -n "$1" ]; then
258 $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$1" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
259 else
260 $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"
261 fi
262 #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --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 &
263 status=$?
264 ok $status "Start session daemon"
265 fi
266 }
267
268 function stop_lttng_sessiond ()
269 {
270 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
271 # Env variable requested no session daemon
272 return
273 fi
274
275 PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
276
277 kill $PID_SESSIOND >$OUTPUT_DEST
278
279 if [ $? -eq 1 ]; then
280 fail "Kill sessions daemon"
281 return 1
282 else
283 out=1
284 while [ -n "$out" ]; do
285 out=$(pidof lt-$SESSIOND_BIN)
286 sleep 0.5
287 done
288 out=1
289 while [ -n "$out" ]; do
290 out=$(pidof $CONSUMERD_BIN)
291 sleep 0.5
292 done
293 pass "Kill session daemon"
294 fi
295 }
296
297 function list_lttng_with_opts ()
298 {
299 local opts=$1
300 $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts >$OUTPUT_DEST
301 ok $? "Lttng-tool list command with option $opts"
302 }
303
304 function create_lttng_session_no_output ()
305 {
306 local sess_name=$1
307
308 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output >$OUTPUT_DEST
309 ok $? "Create session $sess_name in no-output mode"
310 }
311
312 function create_lttng_session ()
313 {
314 local sess_name=$1
315 local trace_path=$2
316 local expected_to_fail=$3
317
318 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path > $OUTPUT_DEST
319 ret=$?
320 if [[ $expected_to_fail ]]; then
321 test "$ret" -ne "0"
322 ok $? "Expected fail on session creation $sess_name in $trace_path"
323 else
324 ok $ret "Create session $sess_name in $trace_path"
325 fi
326 }
327
328 function enable_ust_lttng_channel()
329 {
330 local sess_name=$1
331 local channel_name=$2
332 local expect_fail=$3
333
334 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name >$OUTPUT_DEST
335 ret=$?
336 if [[ $expect_fail ]]; then
337 test "$ret" -ne "0"
338 ok $? "Expected fail on ust channel creation $channel_name in $sess_name"
339 else
340 ok $ret "Enable channel $channel_name for session $sess_name"
341 fi
342 }
343
344 function disable_ust_lttng_channel()
345 {
346 local sess_name=$1
347 local channel_name=$2
348
349 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name >$OUTPUT_DEST
350 ok $? "Disable channel $channel_name for session $sess_name"
351 }
352
353 function enable_lttng_mmap_overwrite_kernel_channel()
354 {
355 local sess_name=$1
356 local channel_name=$2
357
358 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite >$OUTPUT_DEST
359 ok $? "Enable channel $channel_name for session $sess_name"
360 }
361
362 function enable_lttng_mmap_overwrite_ust_channel()
363 {
364 local sess_name=$1
365 local channel_name=$2
366
367 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite >$OUTPUT_DEST
368 ok $? "Enable channel $channel_name for session $sess_name"
369 }
370
371 function enable_ust_lttng_event ()
372 {
373 local sess_name=$1
374 local event_name="$2"
375 local channel_name=$3
376 local expected_to_fail=$4
377
378 if [ -z $channel_name ]; then
379 # default channel if none specified
380 chan=""
381 else
382 chan="-c $channel_name"
383 fi
384
385 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u >$OUTPUT_DEST
386 ret=$?
387 if [[ $expected_to_fail ]]; then
388 test $ret -ne "0"
389 ok $? "Enable ust event $event_name for session $session_name on channel $channel_name failed as expected"
390 else
391 ok $ret "Enable event $event_name for session $sess_name"
392 fi
393 }
394
395 function enable_jul_lttng_event()
396 {
397 sess_name=$1
398 event_name="$2"
399 channel_name=$3
400
401 if [ -z $channel_name ]; then
402 # default channel if none specified
403 chan=""
404 else
405 chan="-c $channel_name"
406 fi
407
408 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j >$OUTPUT_DEST
409 ok $? "Enable JUL event $event_name for session $sess_name"
410 }
411
412 function enable_jul_lttng_event_loglevel()
413 {
414 local sess_name=$1
415 local event_name="$2"
416 local loglevel=$3
417 local channel_name=$4
418
419 if [ -z $channel_name ]; then
420 # default channel if none specified
421 chan=""
422 else
423 chan="-c $channel_name"
424 fi
425
426 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j >$OUTPUT_DEST
427 ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel"
428 }
429
430 function enable_log4j_lttng_event()
431 {
432 sess_name=$1
433 event_name="$2"
434 channel_name=$3
435
436 if [ -z $channel_name ]; then
437 # default channel if none specified
438 chan=""
439 else
440 chan="-c $channel_name"
441 fi
442
443 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l >$OUTPUT_DEST
444 ok $? "Enable LOG4J event $event_name for session $sess_name"
445 }
446
447 function enable_log4j_lttng_event_loglevel()
448 {
449 local sess_name=$1
450 local event_name="$2"
451 local loglevel=$3
452 local channel_name=$4
453
454 if [ -z $channel_name ]; then
455 # default channel if none specified
456 chan=""
457 else
458 chan="-c $channel_name"
459 fi
460
461 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l >$OUTPUT_DEST
462 ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel"
463 }
464
465 function enable_ust_lttng_event_filter()
466 {
467 local sess_name="$1"
468 local event_name="$2"
469 local filter="$3"
470
471 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" >$OUTPUT_DEST
472 ok $? "Enable event $event_name with filtering for session $sess_name"
473 }
474
475 function enable_ust_lttng_event_loglevel()
476 {
477 local sess_name="$1"
478 local event_name="$2"
479 local loglevel="$3"
480
481 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel >$OUTPUT_DEST
482 ok $? "Enable event $event_name with loglevel $loglevel"
483 }
484
485 function enable_ust_lttng_event_loglevel_only()
486 {
487 local sess_name="$1"
488 local event_name="$2"
489 local loglevel="$3"
490
491 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel >$OUTPUT_DEST
492 ok $? "Enable event $event_name with loglevel-only $loglevel"
493 }
494
495 function disable_ust_lttng_event ()
496 {
497 local sess_name="$1"
498 local event_name="$2"
499 local channel_name="$3"
500
501 if [ -z $channel_name ]; then
502 # default channel if none specified
503 chan=""
504 else
505 chan="-c $channel_name"
506 fi
507
508 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u >$OUTPUT_DEST
509 ok $? "Disable event $event_name for session $sess_name"
510 }
511
512 function disable_jul_lttng_event ()
513 {
514 local sess_name="$1"
515 local event_name="$2"
516
517 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1
518 ok $? "Disable JUL event $event_name for session $sess_name"
519 }
520
521 function disable_log4j_lttng_event ()
522 {
523 local sess_name="$1"
524 local event_name="$2"
525
526 $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1
527 ok $? "Disable LOG4J event $event_name for session $sess_name"
528 }
529
530 function start_lttng_tracing ()
531 {
532 local sess_name=$1
533 local expected_to_fail=$2
534
535 $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >$OUTPUT_DEST
536 ret=$?
537 if [[ $expected_to_fail ]]; then
538 test "$ret" -ne "0"
539 ok $? "Expected fail on start tracing for session: $sess_name"
540 else
541 ok $ret "Start tracing for session $sess_name"
542 fi
543 }
544
545 function stop_lttng_tracing ()
546 {
547 local sess_name=$1
548 local expected_to_fail=$2
549
550 $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >$OUTPUT_DEST
551 ret=$?
552 if [[ $expected_to_fail ]]; then
553 test "$ret" -ne "0"
554 ok $? "Expected fail on stop tracing for session: $sess_name"
555 else
556 ok $ret "Stop lttng tracing for session $sess_name"
557 fi
558 }
559
560 function destroy_lttng_session ()
561 {
562 local sess_name=$1
563 local expected_to_fail=$2
564
565 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >$OUTPUT_DEST
566 ret=$?
567 if [[ $expected_to_fail ]]; then
568 test "$ret" -ne "0"
569 ok $? "Expected fail on session deletion $sess_name"
570 else
571 ok $ret "Destroy session $sess_name"
572 fi
573 }
574
575 function destroy_lttng_sessions ()
576 {
577 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all >$OUTPUT_DEST
578 ok $? "Destroy all lttng sessions"
579 }
580
581 function lttng_snapshot_add_output ()
582 {
583 local sess_name=$1
584 local trace_path=$2
585 local expected_to_fail=$3
586
587 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name file://$trace_path >$OUTPUT_DEST
588 ret=$?
589 if [[ $expected_to_fail ]]; then
590 test "$ret" -ne "0"
591 ok $? "Failed to add a snapshot output file://$trace_path as expected"
592 else
593 ok $ret "Added snapshot output file://$trace_path"
594 fi
595 }
596
597 function lttng_snapshot_del_output ()
598 {
599 local sess_name=$1
600 local id=$2
601 local expected_to_fail=$3
602
603 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id >$OUTPUT_DEST
604 ret=$?
605 if [[ $expected_to_fail ]]; then
606 test "$ret" -ne "0"
607 ok $? "Expect fail on deletion of snapshot output id $id"
608 else
609 ok $ret "Deleted snapshot output id $id"
610 fi
611 }
612
613 function lttng_snapshot_record ()
614 {
615 local sess_name=$1
616 local trace_path=$2
617
618 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s $sess_name >$OUTPUT_DEST
619 ok $? "Snapshot recorded"
620 }
621
622 function lttng_snapshot_list ()
623 {
624 local sess_name=$1
625 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name >$OUTPUT_DEST
626 ok $? "Snapshot list"
627 }
628
629 function lttng_save()
630 {
631 local sess_name=$1
632 local opts=$2
633
634 $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts >$OUTPUT_DEST
635 ok $? "Session successfully saved"
636 }
637
638 function lttng_load()
639 {
640 local opts=$1
641
642 $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts >$OUTPUT_DEST
643 ok $? "Load command successful"
644 }
645
646 function trace_matches ()
647 {
648 local event_name=$1
649 local nr_iter=$2
650 local trace_path=$3
651
652 which $BABELTRACE_BIN >/dev/null
653 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
654
655 local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
656
657 if [ "$count" -ne "$nr_iter" ]; then
658 fail "Trace match"
659 diag "$count events found in trace"
660 else
661 pass "Trace match"
662 fi
663 }
664
665 function trace_match_only()
666 {
667 local event_name=$1
668 local nr_iter=$2
669 local trace_path=$3
670
671 which $BABELTRACE_BIN >/dev/null
672 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
673
674 local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
675 local total=$($BABELTRACE_BIN $trace_path | wc -l)
676
677 if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
678 pass "Trace match with $total event $event_name"
679 else
680 fail "Trace match"
681 diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
682 fi
683 }
684
685 function validate_trace
686 {
687 local event_name=$1
688 local trace_path=$2
689
690 which $BABELTRACE_BIN >/dev/null
691 if [ $? -ne 0 ]; then
692 skip 0 "Babeltrace binary not found. Skipping trace validation"
693 fi
694
695 OLDIFS=$IFS
696 IFS=","
697 for i in $event_name; do
698 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
699 if [ "$traced" -ne 0 ]; then
700 pass "Validate trace for event $i, $traced events"
701 else
702 fail "Validate trace for event $i"
703 diag "Found $traced occurences of $i"
704 fi
705 done
706 ret=$?
707 IFS=$OLDIFS
708 return $ret
709 }
710
711 function validate_trace_exp()
712 {
713 local event_exp=$1
714 local trace_path=$2
715
716 which $BABELTRACE_BIN >/dev/null
717 skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation"
718
719 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | wc -l)
720 if [ "$traced" -ne 0 ]; then
721 pass "Validate trace for expression '${event_exp}', $traced events"
722 else
723 fail "Validate trace for expression '${event_exp}'"
724 diag "Found $traced occurences of '${event_exp}'"
725 fi
726 ret=$?
727 return $ret
728 }
729
730 function validate_trace_only_exp()
731 {
732 local event_exp=$1
733 local trace_path=$2
734
735 which $BABELTRACE_BIN >/dev/null
736 skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
737
738 local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l)
739 local total=$($BABELTRACE_BIN $trace_path | wc -l)
740
741 if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
742 pass "Trace match with $total for expression '${event_exp}"
743 else
744 fail "Trace match"
745 diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"
746 fi
747 ret=$?
748 return $ret
749 }
750
751 function validate_trace_empty()
752 {
753 local trace_path=$1
754
755 which $BABELTRACE_BIN >/dev/null
756 if [ $? -ne 0 ]; then
757 skip 0 "Babeltrace binary not found. Skipping trace validation"
758 fi
759
760 traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | wc -l)
761 if [ "$traced" -eq 0 ]; then
762 pass "Validate empty trace"
763 else
764 fail "Validate empty trace"
765 diag "Found $traced events in trace"
766 fi
767 ret=$?
768 return $ret
769 }
This page took 0.04993 seconds and 3 git commands to generate.