Commit | Line | Data |
---|---|---|
10a8a223 | 1 | #!/src/bin/bash |
d3e8f6bb DG |
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" | |
f7613992 | 19 | CONSUMERD_BIN="lttng-consumerd" |
f4e40ab6 | 20 | RELAYD_BIN="lttng-relayd" |
d3e8f6bb DG |
21 | LTTNG_BIN="lttng" |
22 | BABELTRACE_BIN="babeltrace" | |
2cf48300 JR |
23 | OUTPUT_DEST=/dev/null |
24 | ERROR_OUTPUT_DEST=/dev/null | |
d3e8f6bb | 25 | |
fd4dfcec DG |
26 | # Minimal kernel version supported for session daemon tests |
27 | KERNEL_MAJOR_VERSION=2 | |
28 | KERNEL_MINOR_VERSION=6 | |
29 | KERNEL_PATCHLEVEL_VERSION=27 | |
30 | ||
629b9335 MD |
31 | # We set the default UST register timeout to "wait forever", so that |
32 | # basic tests don't have to worry about hitting timeouts on busy | |
33 | # systems. Specialized tests should test those corner-cases. | |
34 | export LTTNG_UST_REGISTER_TIMEOUT=-1 | |
35 | ||
29655db7 CB |
36 | source $TESTDIR/utils/tap/tap.sh |
37 | ||
fec81a7e CB |
38 | function print_ok () |
39 | { | |
40 | # Check if we are a terminal | |
41 | if [ -t 1 ]; then | |
42 | echo -e "\e[1;32mOK\e[0m" | |
43 | else | |
44 | echo -e "OK" | |
45 | fi | |
46 | } | |
47 | ||
48 | function print_fail () | |
49 | { | |
50 | # Check if we are a terminal | |
51 | if [ -t 1 ]; then | |
52 | echo -e "\e[1;31mFAIL\e[0m" | |
53 | else | |
54 | echo -e "FAIL" | |
55 | fi | |
56 | } | |
57 | ||
58 | function print_test_banner () | |
59 | { | |
7d0ad314 | 60 | local desc="$1" |
29655db7 | 61 | diag "$desc" |
fec81a7e CB |
62 | } |
63 | ||
fd4dfcec DG |
64 | function validate_kernel_version () |
65 | { | |
7d0ad314 | 66 | local kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n')) |
fd4dfcec DG |
67 | if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then |
68 | return 0 | |
69 | fi | |
70 | if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then | |
71 | return 0 | |
72 | fi | |
73 | if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then | |
74 | return 0 | |
75 | fi | |
76 | return 1 | |
77 | } | |
78 | ||
9ac429ef | 79 | # Generate a random string |
f4e40ab6 DG |
80 | # $1 = number of characters; defaults to 16 |
81 | # $2 = include special characters; 1 = yes, 0 = no; defaults to yes | |
9ac429ef | 82 | function randstring() |
f4e40ab6 DG |
83 | { |
84 | [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]" | |
85 | cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16} | |
86 | echo | |
87 | } | |
88 | ||
f4e40ab6 DG |
89 | function lttng_enable_kernel_event |
90 | { | |
7d0ad314 JRJ |
91 | local sess_name=$1 |
92 | local event_name=$2 | |
93 | local channel_name=$3 | |
f4e40ab6 DG |
94 | |
95 | if [ -z $event_name ]; then | |
96 | # Enable all event if no event name specified | |
29655db7 | 97 | event_name="-a" |
f4e40ab6 DG |
98 | fi |
99 | ||
07b86b52 JD |
100 | if [ -z $channel_name ]; then |
101 | # default channel if none specified | |
102 | chan="" | |
103 | else | |
104 | chan="-c $channel_name" | |
105 | fi | |
106 | ||
2cf48300 | 107 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 108 | ok $? "Enable kernel event $event_name for session $sess_name" |
f4e40ab6 DG |
109 | } |
110 | ||
8cfcd41c MD |
111 | function lttng_enable_kernel_syscall() |
112 | { | |
113 | local expected_to_fail=$1 | |
114 | local sess_name=$2 | |
115 | local syscall_name=$3 | |
116 | local channel_name=$4 | |
117 | ||
118 | if [ -z $syscall_name ]; then | |
119 | # Enable all event if no syscall name specified | |
120 | syscall_name="-a" | |
121 | fi | |
122 | ||
123 | if [ -z $channel_name ]; then | |
124 | # default channel if none specified | |
125 | chan="" | |
126 | else | |
127 | chan="-c $channel_name" | |
128 | fi | |
129 | ||
2cf48300 | 130 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
8cfcd41c MD |
131 | ret=$? |
132 | if [[ $expected_to_fail -eq "1" ]]; then | |
133 | test $ret -ne "0" | |
134 | ok $? "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected" | |
135 | else | |
136 | ok $ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name" | |
137 | fi | |
138 | } | |
139 | ||
140 | function lttng_enable_kernel_syscall_ok() | |
141 | { | |
421b83dc | 142 | lttng_enable_kernel_syscall 0 "$@" |
8cfcd41c MD |
143 | } |
144 | ||
145 | function lttng_enable_kernel_syscall_fail() | |
146 | { | |
421b83dc | 147 | lttng_enable_kernel_syscall 1 "$@" |
8cfcd41c MD |
148 | } |
149 | ||
150 | function lttng_disable_kernel_syscall() | |
151 | { | |
152 | local expected_to_fail=$1 | |
153 | local sess_name=$2 | |
154 | local syscall_name=$3 | |
155 | local channel_name=$4 | |
156 | ||
157 | if [ -z $syscall_name ]; then | |
158 | # Enable all event if no syscall name specified | |
159 | syscall_name="-a" | |
160 | fi | |
161 | ||
162 | if [ -z $channel_name ]; then | |
163 | # default channel if none specified | |
164 | chan="" | |
165 | else | |
166 | chan="-c $channel_name" | |
167 | fi | |
168 | ||
2cf48300 | 169 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
8cfcd41c MD |
170 | |
171 | ret=$? | |
172 | if [[ $expected_to_fail -eq "1" ]]; then | |
173 | test $ret -ne "0" | |
174 | ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected" | |
175 | else | |
176 | ok $ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name" | |
177 | fi | |
178 | } | |
179 | ||
180 | function lttng_disable_kernel_syscall_ok() | |
181 | { | |
421b83dc | 182 | lttng_disable_kernel_syscall 0 "$@" |
8cfcd41c MD |
183 | } |
184 | ||
185 | function lttng_disable_kernel_syscall_fail() | |
186 | { | |
421b83dc | 187 | lttng_disable_kernel_syscall 1 "$@" |
8cfcd41c MD |
188 | } |
189 | ||
d96f6315 MD |
190 | function lttng_enable_kernel_channel() |
191 | { | |
192 | local expected_to_fail=$1 | |
193 | local sess_name=$2 | |
194 | local channel_name=$3 | |
195 | ||
2cf48300 | 196 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
d96f6315 MD |
197 | ret=$? |
198 | if [[ $expected_to_fail -eq "1" ]]; then | |
199 | test "$ret" -ne "0" | |
200 | ok $? "Expected failure on kernel channel creation $channel_name in $sess_name" | |
201 | else | |
202 | ok $ret "Enable channel $channel_name for session $sess_name" | |
203 | fi | |
204 | } | |
205 | ||
206 | function lttng_enable_kernel_channel_ok() | |
207 | { | |
421b83dc | 208 | lttng_enable_kernel_channel 0 "$@" |
d96f6315 MD |
209 | } |
210 | ||
211 | function lttng_enable_kernel_channel_fail() | |
212 | { | |
421b83dc | 213 | lttng_enable_kernel_channel 1 "$@" |
d96f6315 MD |
214 | } |
215 | ||
216 | function lttng_disable_kernel_channel() | |
217 | { | |
218 | local expected_to_fail=$1 | |
219 | local sess_name=$2 | |
220 | local channel_name=$3 | |
221 | ||
2cf48300 | 222 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
d96f6315 MD |
223 | ret=$? |
224 | if [[ $expected_to_fail -eq "1" ]]; then | |
225 | test "$ret" -ne "0" | |
226 | ok $? "Expected failure on kernel channel creation $channel_name in $sess_name" | |
227 | else | |
228 | ok $ret "disable channel $channel_name for session $sess_name" | |
229 | fi | |
230 | } | |
231 | ||
232 | function lttng_disable_kernel_channel_ok() | |
233 | { | |
421b83dc | 234 | lttng_disable_kernel_channel 0 "$@" |
d96f6315 MD |
235 | } |
236 | ||
237 | function lttng_disable_kernel_channel_fail() | |
238 | { | |
421b83dc | 239 | lttng_disable_kernel_channel 1 "$@" |
d96f6315 MD |
240 | } |
241 | ||
05aa48da | 242 | function start_lttng_relayd_opt() |
f4e40ab6 | 243 | { |
05aa48da MD |
244 | local withtap=$1 |
245 | local opt=$2 | |
173af62f | 246 | |
f4e40ab6 DG |
247 | DIR=$(readlink -f $TESTDIR) |
248 | ||
249 | if [ -z $(pidof lt-$RELAYD_BIN) ]; then | |
2cf48300 | 250 | $DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
25a818af | 251 | #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 & |
f4e40ab6 | 252 | if [ $? -eq 1 ]; then |
05aa48da MD |
253 | if [ $withtap -eq "1" ]; then |
254 | fail "Start lttng-relayd (opt: $opt)" | |
255 | fi | |
f4e40ab6 DG |
256 | return 1 |
257 | else | |
05aa48da MD |
258 | if [ $withtap -eq "1" ]; then |
259 | pass "Start lttng-relayd (opt: $opt)" | |
260 | fi | |
f4e40ab6 DG |
261 | fi |
262 | else | |
29655db7 | 263 | pass "Start lttng-relayd (opt: $opt)" |
f4e40ab6 DG |
264 | fi |
265 | } | |
266 | ||
05aa48da | 267 | function start_lttng_relayd() |
f4e40ab6 | 268 | { |
05aa48da MD |
269 | start_lttng_relayd_opt 1 "$@" |
270 | } | |
271 | ||
272 | function start_lttng_relayd_notap() | |
273 | { | |
274 | start_lttng_relayd_opt 0 "$@" | |
275 | } | |
276 | ||
277 | function stop_lttng_relayd_opt() | |
278 | { | |
279 | local withtap=$1 | |
280 | ||
f4e40ab6 DG |
281 | PID_RELAYD=`pidof lt-$RELAYD_BIN` |
282 | ||
05aa48da MD |
283 | if [ $withtap -eq "1" ]; then |
284 | diag "Killing lttng-relayd (pid: $PID_RELAYD)" | |
285 | fi | |
2cf48300 | 286 | kill $PID_RELAYD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
1fb23888 | 287 | retval=$? |
29655db7 | 288 | |
05aa48da MD |
289 | if [ $? -eq 1 ]; then |
290 | if [ $withtap -eq "1" ]; then | |
291 | fail "Kill relay daemon" | |
292 | fi | |
293 | return 1 | |
294 | else | |
f4e40ab6 DG |
295 | out=1 |
296 | while [ -n "$out" ]; do | |
297 | out=$(pidof lt-$RELAYD_BIN) | |
298 | sleep 0.5 | |
299 | done | |
05aa48da MD |
300 | if [ $withtap -eq "1" ]; then |
301 | pass "Kill relay daemon" | |
302 | fi | |
1fb23888 MD |
303 | fi |
304 | return $retval | |
305 | } | |
306 | ||
05aa48da | 307 | function stop_lttng_relayd() |
1fb23888 | 308 | { |
05aa48da MD |
309 | stop_lttng_relayd_opt 1 "$@" |
310 | } | |
1fb23888 | 311 | |
05aa48da MD |
312 | function stop_lttng_relayd_notap() |
313 | { | |
314 | stop_lttng_relayd_opt 0 "$@" | |
f4e40ab6 DG |
315 | } |
316 | ||
05aa48da MD |
317 | #First arg: show tap output |
318 | #Second argument: load path for automatic loading | |
319 | function start_lttng_sessiond_opt() | |
355f483d | 320 | { |
05aa48da MD |
321 | local withtap=$1 |
322 | local load_path=$2 | |
8d51ddbc | 323 | |
355f483d DG |
324 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
325 | # Env variable requested no session daemon | |
326 | return | |
327 | fi | |
328 | ||
29655db7 CB |
329 | validate_kernel_version |
330 | if [ $? -ne 0 ]; then | |
331 | fail "Start session daemon" | |
332 | BAIL_OUT "*** Kernel too old for session daemon tests ***" | |
355f483d DG |
333 | fi |
334 | ||
29655db7 | 335 | DIR=$(readlink -f $TESTDIR) |
d3d97763 JG |
336 | : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/} |
337 | export LTTNG_SESSION_CONFIG_XSD_PATH | |
29655db7 CB |
338 | |
339 | if [ -z $(pidof lt-$SESSIOND_BIN) ]; then | |
8d51ddbc | 340 | # Have a load path ? |
05aa48da | 341 | if [ -n "$load_path" ]; then |
8d51ddbc JRJ |
342 | $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" |
343 | else | |
344 | $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" | |
345 | fi | |
0fc2834c | 346 | #$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 |
29655db7 | 347 | status=$? |
05aa48da MD |
348 | if [ $withtap -eq "1" ]; then |
349 | ok $status "Start session daemon" | |
350 | fi | |
29655db7 | 351 | fi |
355f483d DG |
352 | } |
353 | ||
05aa48da MD |
354 | function start_lttng_sessiond() |
355 | { | |
356 | start_lttng_sessiond_opt 1 "$@" | |
357 | } | |
358 | ||
359 | function start_lttng_sessiond_notap() | |
d3e8f6bb | 360 | { |
05aa48da MD |
361 | start_lttng_sessiond_opt 0 "$@" |
362 | } | |
363 | ||
364 | function stop_lttng_sessiond_opt() | |
365 | { | |
366 | local withtap=$1 | |
367 | ||
355f483d DG |
368 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
369 | # Env variable requested no session daemon | |
370 | return | |
371 | fi | |
372 | ||
d3e8f6bb DG |
373 | PID_SESSIOND=`pidof lt-$SESSIOND_BIN` |
374 | ||
2cf48300 | 375 | kill $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 376 | |
d3e8f6bb | 377 | if [ $? -eq 1 ]; then |
05aa48da MD |
378 | if [ $withtap -eq "1" ]; then |
379 | fail "Kill sessions daemon" | |
380 | fi | |
d3e8f6bb | 381 | else |
5fa32580 DG |
382 | out=1 |
383 | while [ -n "$out" ]; do | |
384 | out=$(pidof lt-$SESSIOND_BIN) | |
385 | sleep 0.5 | |
386 | done | |
f7613992 MD |
387 | out=1 |
388 | while [ -n "$out" ]; do | |
389 | out=$(pidof $CONSUMERD_BIN) | |
390 | sleep 0.5 | |
391 | done | |
05aa48da MD |
392 | if [ $withtap -eq "1" ]; then |
393 | pass "Kill session daemon" | |
394 | fi | |
d3e8f6bb DG |
395 | fi |
396 | } | |
397 | ||
05aa48da MD |
398 | function stop_lttng_sessiond() |
399 | { | |
400 | stop_lttng_sessiond_opt 1 "$@" | |
401 | } | |
402 | ||
403 | function stop_lttng_sessiond_notap() | |
404 | { | |
405 | stop_lttng_sessiond_opt 0 "$@" | |
406 | } | |
407 | ||
873c2aae JRJ |
408 | function list_lttng_with_opts () |
409 | { | |
7d0ad314 | 410 | local opts=$1 |
2cf48300 | 411 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
873c2aae JRJ |
412 | ok $? "Lttng-tool list command with option $opts" |
413 | } | |
414 | ||
07b86b52 JD |
415 | function create_lttng_session_no_output () |
416 | { | |
7d0ad314 | 417 | local sess_name=$1 |
07b86b52 | 418 | |
2cf48300 | 419 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
07b86b52 JD |
420 | ok $? "Create session $sess_name in no-output mode" |
421 | } | |
422 | ||
d3e8f6bb DG |
423 | function create_lttng_session () |
424 | { | |
bf6ae429 JR |
425 | local expected_to_fail=$1 |
426 | local sess_name=$2 | |
427 | local trace_path=$3 | |
d3e8f6bb | 428 | |
873c2aae JRJ |
429 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path > $OUTPUT_DEST |
430 | ret=$? | |
bf6ae429 | 431 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e JRJ |
432 | test "$ret" -ne "0" |
433 | ok $? "Expected fail on session creation $sess_name in $trace_path" | |
873c2aae JRJ |
434 | else |
435 | ok $ret "Create session $sess_name in $trace_path" | |
436 | fi | |
d4018451 DG |
437 | } |
438 | ||
bf6ae429 JR |
439 | function create_lttng_session_ok () |
440 | { | |
441 | create_lttng_session 0 "$@" | |
442 | } | |
443 | ||
444 | function create_lttng_session_fail () | |
445 | { | |
446 | create_lttng_session 1 "$@" | |
447 | } | |
448 | ||
449 | ||
827caf52 | 450 | function enable_ust_lttng_channel () |
d4018451 | 451 | { |
827caf52 JR |
452 | local expect_fail=$1 |
453 | local sess_name=$2 | |
454 | local channel_name=$3 | |
d4018451 | 455 | |
2cf48300 | 456 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
312dabc3 | 457 | ret=$? |
827caf52 | 458 | if [[ $expect_fail -eq "1" ]]; then |
01513c3e JRJ |
459 | test "$ret" -ne "0" |
460 | ok $? "Expected fail on ust channel creation $channel_name in $sess_name" | |
312dabc3 JRJ |
461 | else |
462 | ok $ret "Enable channel $channel_name for session $sess_name" | |
463 | fi | |
d4018451 DG |
464 | } |
465 | ||
827caf52 JR |
466 | function enable_ust_lttng_channel_ok () |
467 | { | |
468 | enable_ust_lttng_channel 0 "$@" | |
469 | } | |
470 | ||
471 | function enable_ust_lttng_channel_fail () | |
472 | { | |
473 | enable_ust_lttng_channel 1 "$@" | |
474 | } | |
475 | ||
29655db7 | 476 | function disable_ust_lttng_channel() |
d4018451 | 477 | { |
7d0ad314 JRJ |
478 | local sess_name=$1 |
479 | local channel_name=$2 | |
d4018451 | 480 | |
2cf48300 | 481 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 482 | ok $? "Disable channel $channel_name for session $sess_name" |
d3e8f6bb DG |
483 | } |
484 | ||
07b86b52 JD |
485 | function enable_lttng_mmap_overwrite_kernel_channel() |
486 | { | |
7d0ad314 JRJ |
487 | local sess_name=$1 |
488 | local channel_name=$2 | |
07b86b52 | 489 | |
2cf48300 | 490 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
07b86b52 JD |
491 | ok $? "Enable channel $channel_name for session $sess_name" |
492 | } | |
493 | ||
ebaaaf5e JD |
494 | function enable_lttng_mmap_overwrite_ust_channel() |
495 | { | |
7d0ad314 JRJ |
496 | local sess_name=$1 |
497 | local channel_name=$2 | |
ebaaaf5e | 498 | |
2cf48300 | 499 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
ebaaaf5e JD |
500 | ok $? "Enable channel $channel_name for session $sess_name" |
501 | } | |
502 | ||
d3e8f6bb DG |
503 | function enable_ust_lttng_event () |
504 | { | |
c4926bb5 JR |
505 | local expected_to_fail=$1 |
506 | local sess_name=$2 | |
507 | local event_name="$3" | |
508 | local channel_name=$4 | |
ebaaaf5e JD |
509 | |
510 | if [ -z $channel_name ]; then | |
511 | # default channel if none specified | |
512 | chan="" | |
513 | else | |
514 | chan="-c $channel_name" | |
515 | fi | |
d3e8f6bb | 516 | |
2cf48300 | 517 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e | 518 | ret=$? |
c4926bb5 | 519 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e JRJ |
520 | test $ret -ne "0" |
521 | ok $? "Enable ust event $event_name for session $session_name on channel $channel_name failed as expected" | |
522 | else | |
523 | ok $ret "Enable event $event_name for session $sess_name" | |
524 | fi | |
26b53d3b DG |
525 | } |
526 | ||
c4926bb5 JR |
527 | function enable_ust_lttng_event_ok () |
528 | { | |
529 | enable_ust_lttng_event 0 "$@" | |
530 | } | |
531 | ||
532 | function enable_ust_lttng_event_fail () | |
533 | { | |
534 | enable_ust_lttng_event 1 "$@" | |
535 | } | |
536 | ||
37175ce4 DG |
537 | function enable_jul_lttng_event() |
538 | { | |
539 | sess_name=$1 | |
540 | event_name="$2" | |
541 | channel_name=$3 | |
542 | ||
543 | if [ -z $channel_name ]; then | |
544 | # default channel if none specified | |
545 | chan="" | |
546 | else | |
547 | chan="-c $channel_name" | |
548 | fi | |
549 | ||
2cf48300 | 550 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
37175ce4 DG |
551 | ok $? "Enable JUL event $event_name for session $sess_name" |
552 | } | |
553 | ||
b2064f54 DG |
554 | function enable_jul_lttng_event_loglevel() |
555 | { | |
7d0ad314 JRJ |
556 | local sess_name=$1 |
557 | local event_name="$2" | |
558 | local loglevel=$3 | |
559 | local channel_name=$4 | |
b2064f54 DG |
560 | |
561 | if [ -z $channel_name ]; then | |
562 | # default channel if none specified | |
563 | chan="" | |
564 | else | |
565 | chan="-c $channel_name" | |
566 | fi | |
567 | ||
2cf48300 | 568 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
b2064f54 DG |
569 | ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel" |
570 | } | |
571 | ||
504d4ace DG |
572 | function enable_log4j_lttng_event() |
573 | { | |
574 | sess_name=$1 | |
575 | event_name="$2" | |
576 | channel_name=$3 | |
577 | ||
578 | if [ -z $channel_name ]; then | |
579 | # default channel if none specified | |
580 | chan="" | |
581 | else | |
582 | chan="-c $channel_name" | |
583 | fi | |
584 | ||
2cf48300 | 585 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
504d4ace DG |
586 | ok $? "Enable LOG4J event $event_name for session $sess_name" |
587 | } | |
588 | ||
589 | function enable_log4j_lttng_event_loglevel() | |
590 | { | |
591 | local sess_name=$1 | |
592 | local event_name="$2" | |
593 | local loglevel=$3 | |
594 | local channel_name=$4 | |
595 | ||
596 | if [ -z $channel_name ]; then | |
597 | # default channel if none specified | |
598 | chan="" | |
599 | else | |
600 | chan="-c $channel_name" | |
601 | fi | |
602 | ||
2cf48300 | 603 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
504d4ace DG |
604 | ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel" |
605 | } | |
606 | ||
0e115563 DG |
607 | function enable_python_lttng_event() |
608 | { | |
609 | sess_name=$1 | |
610 | event_name="$2" | |
611 | channel_name=$3 | |
612 | ||
613 | if [ -z $channel_name ]; then | |
614 | # default channel if none specified | |
615 | chan="" | |
616 | else | |
617 | chan="-c $channel_name" | |
618 | fi | |
619 | ||
2cf48300 | 620 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
0e115563 DG |
621 | ok $? "Enable Python event $event_name for session $sess_name" |
622 | } | |
623 | ||
624 | function enable_python_lttng_event_loglevel() | |
625 | { | |
626 | local sess_name=$1 | |
627 | local event_name="$2" | |
628 | local loglevel=$3 | |
629 | local channel_name=$4 | |
630 | ||
631 | if [ -z $channel_name ]; then | |
632 | # default channel if none specified | |
633 | chan="" | |
634 | else | |
635 | chan="-c $channel_name" | |
636 | fi | |
637 | ||
2cf48300 | 638 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
0e115563 DG |
639 | ok $? "Enable Python event $event_name for session $sess_name with loglevel $loglevel" |
640 | } | |
641 | ||
26b53d3b DG |
642 | function enable_ust_lttng_event_filter() |
643 | { | |
7d0ad314 JRJ |
644 | local sess_name="$1" |
645 | local event_name="$2" | |
646 | local filter="$3" | |
26b53d3b | 647 | |
2cf48300 | 648 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 649 | ok $? "Enable event $event_name with filtering for session $sess_name" |
26b53d3b DG |
650 | } |
651 | ||
652 | function enable_ust_lttng_event_loglevel() | |
653 | { | |
7d0ad314 JRJ |
654 | local sess_name="$1" |
655 | local event_name="$2" | |
656 | local loglevel="$3" | |
26b53d3b | 657 | |
2cf48300 | 658 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 659 | ok $? "Enable event $event_name with loglevel $loglevel" |
26b53d3b DG |
660 | } |
661 | ||
662 | function enable_ust_lttng_event_loglevel_only() | |
663 | { | |
7d0ad314 JRJ |
664 | local sess_name="$1" |
665 | local event_name="$2" | |
666 | local loglevel="$3" | |
26b53d3b | 667 | |
2cf48300 | 668 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 669 | ok $? "Enable event $event_name with loglevel-only $loglevel" |
26b53d3b DG |
670 | } |
671 | ||
672 | function disable_ust_lttng_event () | |
673 | { | |
7d0ad314 JRJ |
674 | local sess_name="$1" |
675 | local event_name="$2" | |
01513c3e | 676 | local channel_name="$3" |
26b53d3b | 677 | |
01513c3e JRJ |
678 | if [ -z $channel_name ]; then |
679 | # default channel if none specified | |
680 | chan="" | |
681 | else | |
682 | chan="-c $channel_name" | |
683 | fi | |
684 | ||
2cf48300 | 685 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
29655db7 | 686 | ok $? "Disable event $event_name for session $sess_name" |
d3e8f6bb DG |
687 | } |
688 | ||
1d842d5a DG |
689 | function disable_jul_lttng_event () |
690 | { | |
691 | local sess_name="$1" | |
692 | local event_name="$2" | |
693 | ||
694 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1 | |
695 | ok $? "Disable JUL event $event_name for session $sess_name" | |
696 | } | |
697 | ||
504d4ace DG |
698 | function disable_log4j_lttng_event () |
699 | { | |
700 | local sess_name="$1" | |
701 | local event_name="$2" | |
702 | ||
703 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1 | |
704 | ok $? "Disable LOG4J event $event_name for session $sess_name" | |
705 | } | |
706 | ||
0e115563 DG |
707 | function disable_python_lttng_event () |
708 | { | |
709 | local sess_name="$1" | |
710 | local event_name="$2" | |
711 | ||
2cf48300 | 712 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
0e115563 DG |
713 | ok $? "Disable Python event $event_name for session $sess_name" |
714 | } | |
715 | ||
fb3268e3 | 716 | function start_lttng_tracing () |
d3e8f6bb | 717 | { |
e563bbdb JR |
718 | local expected_to_fail=$1 |
719 | local sess_name=$2 | |
d3e8f6bb | 720 | |
2cf48300 | 721 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e | 722 | ret=$? |
e563bbdb | 723 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e JRJ |
724 | test "$ret" -ne "0" |
725 | ok $? "Expected fail on start tracing for session: $sess_name" | |
726 | else | |
727 | ok $ret "Start tracing for session $sess_name" | |
728 | fi | |
d3e8f6bb DG |
729 | } |
730 | ||
e563bbdb JR |
731 | function start_lttng_tracing_ok () |
732 | { | |
733 | start_lttng_tracing 0 "$@" | |
734 | } | |
735 | ||
736 | function start_lttng_tracing_fail () | |
737 | { | |
738 | start_lttng_tracing 1 "$@" | |
739 | } | |
740 | ||
fb3268e3 | 741 | function stop_lttng_tracing () |
d3e8f6bb | 742 | { |
96340a01 JR |
743 | local expected_to_fail=$1 |
744 | local sess_name=$2 | |
d3e8f6bb | 745 | |
2cf48300 | 746 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e | 747 | ret=$? |
96340a01 | 748 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e JRJ |
749 | test "$ret" -ne "0" |
750 | ok $? "Expected fail on stop tracing for session: $sess_name" | |
751 | else | |
752 | ok $ret "Stop lttng tracing for session $sess_name" | |
753 | fi | |
d3e8f6bb DG |
754 | } |
755 | ||
96340a01 JR |
756 | function stop_lttng_tracing_ok () |
757 | { | |
758 | stop_lttng_tracing 0 "$@" | |
759 | } | |
760 | ||
761 | function stop_lttng_tracing_fail () | |
762 | { | |
763 | stop_lttng_tracing 1 "$@" | |
764 | } | |
765 | ||
d3e8f6bb DG |
766 | function destroy_lttng_session () |
767 | { | |
67b4c664 JR |
768 | local expected_to_fail=$1 |
769 | local sess_name=$2 | |
d3e8f6bb | 770 | |
2cf48300 | 771 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e | 772 | ret=$? |
96340a01 | 773 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e JRJ |
774 | test "$ret" -ne "0" |
775 | ok $? "Expected fail on session deletion $sess_name" | |
776 | else | |
777 | ok $ret "Destroy session $sess_name" | |
778 | fi | |
d3e8f6bb DG |
779 | } |
780 | ||
67b4c664 JR |
781 | function destroy_lttng_session_ok () |
782 | { | |
783 | destroy_lttng_session 0 "$@" | |
784 | ||
785 | } | |
786 | ||
787 | function destroy_lttng_session_fail () | |
788 | { | |
789 | destroy_lttng_session 1 "$@" | |
790 | } | |
791 | ||
792 | ||
873c2aae JRJ |
793 | function destroy_lttng_sessions () |
794 | { | |
2cf48300 | 795 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
873c2aae JRJ |
796 | ok $? "Destroy all lttng sessions" |
797 | } | |
798 | ||
07b86b52 JD |
799 | function lttng_snapshot_add_output () |
800 | { | |
b5633831 JR |
801 | local expected_to_fail=$1 |
802 | local sess_name=$2 | |
803 | local trace_path=$3 | |
07b86b52 | 804 | |
2cf48300 | 805 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e | 806 | ret=$? |
b5633831 | 807 | if [[ $expected_to_fail -eq 1 ]]; then |
01513c3e JRJ |
808 | test "$ret" -ne "0" |
809 | ok $? "Failed to add a snapshot output file://$trace_path as expected" | |
810 | else | |
811 | ok $ret "Added snapshot output file://$trace_path" | |
812 | fi | |
07b86b52 JD |
813 | } |
814 | ||
b5633831 JR |
815 | function lttng_snapshot_add_output_ok () |
816 | { | |
817 | lttng_snapshot_add_output 0 "$@" | |
818 | } | |
819 | ||
820 | function lttng_snapshot_add_output_fail () | |
821 | { | |
822 | lttng_snapshot_add_output 1 "$@" | |
823 | } | |
824 | ||
26402e0c DG |
825 | function lttng_snapshot_del_output () |
826 | { | |
31580dc7 JR |
827 | local expected_to_fail=$1 |
828 | local sess_name=$2 | |
829 | local id=$3 | |
26402e0c | 830 | |
2cf48300 | 831 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e | 832 | ret=$? |
31580dc7 | 833 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e JRJ |
834 | test "$ret" -ne "0" |
835 | ok $? "Expect fail on deletion of snapshot output id $id" | |
836 | else | |
837 | ok $ret "Deleted snapshot output id $id" | |
838 | fi | |
26402e0c DG |
839 | } |
840 | ||
31580dc7 JR |
841 | function lttng_snapshot_del_output_ok () |
842 | { | |
843 | lttng_snapshot_del_output 0 "$@" | |
844 | } | |
845 | ||
846 | function lttng_snapshot_del_output_fail () | |
847 | { | |
848 | lttng_snapshot_del_output 1 "$@" | |
849 | } | |
850 | ||
07b86b52 JD |
851 | function lttng_snapshot_record () |
852 | { | |
7d0ad314 JRJ |
853 | local sess_name=$1 |
854 | local trace_path=$2 | |
07b86b52 | 855 | |
2cf48300 | 856 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
07b86b52 JD |
857 | ok $? "Snapshot recorded" |
858 | } | |
859 | ||
01513c3e JRJ |
860 | function lttng_snapshot_list () |
861 | { | |
862 | local sess_name=$1 | |
2cf48300 | 863 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
01513c3e JRJ |
864 | ok $? "Snapshot list" |
865 | } | |
866 | ||
e02b109b DG |
867 | function lttng_save() |
868 | { | |
869 | local sess_name=$1 | |
870 | local opts=$2 | |
871 | ||
2cf48300 | 872 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
e02b109b DG |
873 | ok $? "Session successfully saved" |
874 | } | |
875 | ||
876 | function lttng_load() | |
877 | { | |
878 | local opts=$1 | |
879 | ||
2cf48300 | 880 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
e02b109b DG |
881 | ok $? "Load command successful" |
882 | } | |
883 | ||
e83a8bdb JR |
884 | function lttng_track() |
885 | { | |
886 | local expected_to_fail=$1 | |
887 | local opts=$2 | |
888 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST | |
889 | ret=$? | |
890 | if [[ $expected_to_fail -eq "1" ]]; then | |
891 | test $ret -ne "0" | |
892 | ok $? "Track command failed as expected with opts: $opts" | |
893 | else | |
894 | ok $ret "Track command success as expected with opts: $opts" | |
895 | fi | |
896 | } | |
897 | ||
898 | function lttng_track_ok() | |
899 | { | |
900 | lttng_track 0 "$@" | |
901 | } | |
902 | ||
903 | function lttng_track_fail() | |
904 | { | |
905 | lttng_track 1 "$@" | |
906 | } | |
907 | ||
908 | function lttng_untrack() | |
909 | { | |
910 | local expected_to_fail=$1 | |
911 | local opts=$2 | |
912 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST | |
913 | ret=$? | |
914 | if [[ $expected_to_fail -eq "1" ]]; then | |
915 | test $ret -ne "0" | |
916 | ok $? "Untrack command failed as expected with opts: $opts" | |
917 | else | |
918 | ok $ret "Untrack command success as expected with opts: $opts" | |
919 | fi | |
920 | } | |
921 | ||
922 | function lttng_untrack_ok() | |
923 | { | |
924 | lttng_untrack 0 "$@" | |
925 | } | |
926 | ||
927 | function lttng_untrack_fail() | |
928 | { | |
929 | lttng_untrack 1 "$@" | |
930 | } | |
931 | ||
d3e8f6bb DG |
932 | function trace_matches () |
933 | { | |
7d0ad314 JRJ |
934 | local event_name=$1 |
935 | local nr_iter=$2 | |
936 | local trace_path=$3 | |
d3e8f6bb | 937 | |
317eef93 | 938 | which $BABELTRACE_BIN >/dev/null |
29655db7 | 939 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
d3e8f6bb | 940 | |
7d0ad314 | 941 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
29655db7 | 942 | |
d3e8f6bb | 943 | if [ "$count" -ne "$nr_iter" ]; then |
29655db7 CB |
944 | fail "Trace match" |
945 | diag "$count events found in trace" | |
d3e8f6bb | 946 | else |
29655db7 | 947 | pass "Trace match" |
d3e8f6bb DG |
948 | fi |
949 | } | |
f4e40ab6 | 950 | |
d53addeb DG |
951 | function trace_match_only() |
952 | { | |
953 | local event_name=$1 | |
954 | local nr_iter=$2 | |
955 | local trace_path=$3 | |
956 | ||
957 | which $BABELTRACE_BIN >/dev/null | |
958 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" | |
959 | ||
960 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) | |
961 | local total=$($BABELTRACE_BIN $trace_path | wc -l) | |
962 | ||
963 | if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then | |
964 | pass "Trace match with $total event $event_name" | |
965 | else | |
966 | fail "Trace match" | |
967 | diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count" | |
968 | fi | |
969 | } | |
970 | ||
f4e40ab6 DG |
971 | function validate_trace |
972 | { | |
7d0ad314 JRJ |
973 | local event_name=$1 |
974 | local trace_path=$2 | |
f4e40ab6 DG |
975 | |
976 | which $BABELTRACE_BIN >/dev/null | |
29655db7 CB |
977 | if [ $? -ne 0 ]; then |
978 | skip 0 "Babeltrace binary not found. Skipping trace validation" | |
f4e40ab6 DG |
979 | fi |
980 | ||
07b86b52 JD |
981 | OLDIFS=$IFS |
982 | IFS="," | |
983 | for i in $event_name; do | |
984 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) | |
985 | if [ "$traced" -ne 0 ]; then | |
ebaaaf5e | 986 | pass "Validate trace for event $i, $traced events" |
07b86b52 JD |
987 | else |
988 | fail "Validate trace for event $i" | |
989 | diag "Found $traced occurences of $i" | |
990 | fi | |
991 | done | |
992 | ret=$? | |
993 | IFS=$OLDIFS | |
994 | return $ret | |
f4e40ab6 | 995 | } |
8cfcd41c MD |
996 | |
997 | function validate_trace_exp() | |
998 | { | |
999 | local event_exp=$1 | |
1000 | local trace_path=$2 | |
1001 | ||
1002 | which $BABELTRACE_BIN >/dev/null | |
1003 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation" | |
1004 | ||
1005 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | wc -l) | |
1006 | if [ "$traced" -ne 0 ]; then | |
1007 | pass "Validate trace for expression '${event_exp}', $traced events" | |
1008 | else | |
1009 | fail "Validate trace for expression '${event_exp}'" | |
1010 | diag "Found $traced occurences of '${event_exp}'" | |
1011 | fi | |
1012 | ret=$? | |
1013 | return $ret | |
1014 | } | |
1015 | ||
1016 | function validate_trace_only_exp() | |
1017 | { | |
1018 | local event_exp=$1 | |
1019 | local trace_path=$2 | |
1020 | ||
1021 | which $BABELTRACE_BIN >/dev/null | |
1022 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" | |
1023 | ||
1024 | local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l) | |
1025 | local total=$($BABELTRACE_BIN $trace_path | wc -l) | |
1026 | ||
1027 | if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then | |
1028 | pass "Trace match with $total for expression '${event_exp}" | |
1029 | else | |
1030 | fail "Trace match" | |
1031 | diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected" | |
1032 | fi | |
1033 | ret=$? | |
1034 | return $ret | |
1035 | } | |
1036 | ||
1037 | function validate_trace_empty() | |
1038 | { | |
1039 | local trace_path=$1 | |
1040 | ||
1041 | which $BABELTRACE_BIN >/dev/null | |
1042 | if [ $? -ne 0 ]; then | |
1043 | skip 0 "Babeltrace binary not found. Skipping trace validation" | |
1044 | fi | |
1045 | ||
1046 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | wc -l) | |
1047 | if [ "$traced" -eq 0 ]; then | |
1048 | pass "Validate empty trace" | |
1049 | else | |
1050 | fail "Validate empty trace" | |
1051 | diag "Found $traced events in trace" | |
1052 | fi | |
1053 | ret=$? | |
1054 | return $ret | |
1055 | } |