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