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