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" | |
34ab15c5 | 197 | ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected" |
8cfcd41c MD |
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" | |
34ab15c5 | 223 | ok $? "Enable channel $channel_name for session $sess_name failed as expected" |
d96f6315 MD |
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" | |
34ab15c5 | 249 | ok $? "Disable channel $channel_name for session $sess_name failed as expected" |
d96f6315 | 250 | else |
34ab15c5 | 251 | ok $ret "Disable channel $channel_name for session $sess_name" |
d96f6315 MD |
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 | ||
db7b260c | 272 | if [ -z $(pgrep --full 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 | ||
db7b260c | 304 | PID_RELAYD=`pgrep --full lt-$RELAYD_BIN` |
f4e40ab6 | 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 | |
db7b260c | 320 | out=$(pgrep --full lt-$RELAYD_BIN) |
f4e40ab6 DG |
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 | 361 | |
db7b260c | 362 | if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then |
8d51ddbc | 363 | # Have a load path ? |
05aa48da | 364 | if [ -n "$load_path" ]; then |
e4f8013b | 365 | $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 |
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 | ||
db7b260c | 398 | PID_SESSIOND=`pgrep --full lt-$SESSIOND_BIN` |
d3e8f6bb | 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 | |
db7b260c | 413 | out=$(pgrep --full lt-$SESSIOND_BIN) |
5fa32580 DG |
414 | sleep 0.5 |
415 | done | |
f7613992 MD |
416 | out=1 |
417 | while [ -n "$out" ]; do | |
db7b260c | 418 | out=$(pgrep --full $CONSUMERD_BIN) |
f7613992 MD |
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 | ||
db7b260c | 443 | PID_CONSUMERD=`pgrep --full $CONSUMERD_BIN` |
4c80129b JR |
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 | |
db7b260c | 464 | pid=$(pgrep --full $CONSUMERD_BIN) |
4c80129b JR |
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 | 519 | test "$ret" -ne "0" |
34ab15c5 | 520 | ok $? "Create session $sess_name in $trace_path failed as expected" |
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 | { |
34ab15c5 | 539 | local expected_to_fail=$1 |
827caf52 JR |
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=$? |
34ab15c5 | 546 | if [[ $expected_to_fail -eq "1" ]]; then |
01513c3e | 547 | test "$ret" -ne "0" |
34ab15c5 | 548 | ok $? "Enable channel $channel_name for session $sess_name failed as expected" |
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 | 608 | test $ret -ne "0" |
34ab15c5 | 609 | ok $? "Enable ust event $event_name for session $session_name failed as expected" |
01513c3e | 610 | else |
34ab15c5 | 611 | ok $ret "Enable ust event $event_name for session $sess_name" |
01513c3e | 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 | 812 | test "$ret" -ne "0" |
34ab15c5 | 813 | ok $? "Start tracing for session $sess_name failed as expected" |
01513c3e JRJ |
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 | 837 | test "$ret" -ne "0" |
34ab15c5 | 838 | ok $? "Stop lttng tracing for session $sess_name failed as expected" |
01513c3e JRJ |
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 | 862 | test "$ret" -ne "0" |
34ab15c5 | 863 | ok $? "Destroy session $sess_name failed as expected" |
01513c3e JRJ |
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 | 896 | test "$ret" -ne "0" |
34ab15c5 | 897 | ok $? "Added snapshot output file://$trace_path failed as expected" |
01513c3e JRJ |
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 | 922 | test "$ret" -ne "0" |
34ab15c5 | 923 | ok $? "Deleted snapshot output id $id failed as expected" |
01513c3e JRJ |
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 |
34ab15c5 | 961 | ok $? "Session saved" |
e02b109b DG |
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 |
34ab15c5 | 969 | ok $? "Load command with opts: $opts" |
e02b109b DG |
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 | |
34ab15c5 | 982 | ok $ret "Track command with opts: $opts" |
e83a8bdb JR |
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 | |
34ab15c5 | 1006 | ok $ret "Untrack command with opts: $opts" |
e83a8bdb JR |
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 | ||
8dcef147 JR |
1020 | function add_context_lttng() |
1021 | { | |
1022 | local expected_to_fail="$1" | |
1023 | local domain="$2" | |
1024 | local session_name="$3" | |
1025 | local channel_name="$4" | |
1026 | local type="$5" | |
1027 | ||
1028 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST | |
1029 | ret=$? | |
1030 | if [[ $expected_to_fail -eq "1" ]]; then | |
1031 | test $ret -ne "0" | |
1032 | ok $? "Add context command failed as expected for type: $type" | |
1033 | else | |
1034 | ok $ret "Add context command for type: $type" | |
1035 | fi | |
1036 | } | |
1037 | ||
1038 | function add_context_ust_ok() | |
1039 | { | |
1040 | add_context_lttng 0 -u "$@" | |
1041 | } | |
1042 | ||
1043 | function add_context_ust_fail() | |
1044 | { | |
1045 | add_context_lttng 1 -u "$@" | |
1046 | } | |
1047 | ||
1048 | function add_context_kernel_ok() | |
1049 | { | |
1050 | add_context_lttng 0 -k "$@" | |
1051 | } | |
1052 | ||
1053 | function add_context_kernel_fail() | |
1054 | { | |
1055 | add_context_lttng 1 -k "$@" | |
1056 | } | |
1057 | ||
d3e8f6bb DG |
1058 | function trace_matches () |
1059 | { | |
7d0ad314 JRJ |
1060 | local event_name=$1 |
1061 | local nr_iter=$2 | |
1062 | local trace_path=$3 | |
d3e8f6bb | 1063 | |
317eef93 | 1064 | which $BABELTRACE_BIN >/dev/null |
29655db7 | 1065 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
d3e8f6bb | 1066 | |
7d0ad314 | 1067 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
29655db7 | 1068 | |
d3e8f6bb | 1069 | if [ "$count" -ne "$nr_iter" ]; then |
29655db7 CB |
1070 | fail "Trace match" |
1071 | diag "$count events found in trace" | |
d3e8f6bb | 1072 | else |
29655db7 | 1073 | pass "Trace match" |
d3e8f6bb DG |
1074 | fi |
1075 | } | |
f4e40ab6 | 1076 | |
d53addeb DG |
1077 | function trace_match_only() |
1078 | { | |
1079 | local event_name=$1 | |
1080 | local nr_iter=$2 | |
1081 | local trace_path=$3 | |
1082 | ||
1083 | which $BABELTRACE_BIN >/dev/null | |
1084 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" | |
1085 | ||
1086 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) | |
1087 | local total=$($BABELTRACE_BIN $trace_path | wc -l) | |
1088 | ||
1089 | if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then | |
1090 | pass "Trace match with $total event $event_name" | |
1091 | else | |
1092 | fail "Trace match" | |
1093 | diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count" | |
1094 | fi | |
1095 | } | |
1096 | ||
f4e40ab6 DG |
1097 | function validate_trace |
1098 | { | |
7d0ad314 JRJ |
1099 | local event_name=$1 |
1100 | local trace_path=$2 | |
f4e40ab6 DG |
1101 | |
1102 | which $BABELTRACE_BIN >/dev/null | |
29655db7 CB |
1103 | if [ $? -ne 0 ]; then |
1104 | skip 0 "Babeltrace binary not found. Skipping trace validation" | |
f4e40ab6 DG |
1105 | fi |
1106 | ||
07b86b52 JD |
1107 | OLDIFS=$IFS |
1108 | IFS="," | |
1109 | for i in $event_name; do | |
1110 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) | |
1111 | if [ "$traced" -ne 0 ]; then | |
ebaaaf5e | 1112 | pass "Validate trace for event $i, $traced events" |
07b86b52 JD |
1113 | else |
1114 | fail "Validate trace for event $i" | |
1115 | diag "Found $traced occurences of $i" | |
1116 | fi | |
1117 | done | |
1118 | ret=$? | |
1119 | IFS=$OLDIFS | |
1120 | return $ret | |
f4e40ab6 | 1121 | } |
8cfcd41c MD |
1122 | |
1123 | function validate_trace_exp() | |
1124 | { | |
1125 | local event_exp=$1 | |
1126 | local trace_path=$2 | |
1127 | ||
1128 | which $BABELTRACE_BIN >/dev/null | |
1129 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation" | |
1130 | ||
1131 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | wc -l) | |
1132 | if [ "$traced" -ne 0 ]; then | |
1133 | pass "Validate trace for expression '${event_exp}', $traced events" | |
1134 | else | |
1135 | fail "Validate trace for expression '${event_exp}'" | |
1136 | diag "Found $traced occurences of '${event_exp}'" | |
1137 | fi | |
1138 | ret=$? | |
1139 | return $ret | |
1140 | } | |
1141 | ||
1142 | function validate_trace_only_exp() | |
1143 | { | |
1144 | local event_exp=$1 | |
1145 | local trace_path=$2 | |
1146 | ||
1147 | which $BABELTRACE_BIN >/dev/null | |
1148 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" | |
1149 | ||
1150 | local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l) | |
1151 | local total=$($BABELTRACE_BIN $trace_path | wc -l) | |
1152 | ||
1153 | if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then | |
1154 | pass "Trace match with $total for expression '${event_exp}" | |
1155 | else | |
1156 | fail "Trace match" | |
1157 | diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected" | |
1158 | fi | |
1159 | ret=$? | |
1160 | return $ret | |
1161 | } | |
1162 | ||
1163 | function validate_trace_empty() | |
1164 | { | |
1165 | local trace_path=$1 | |
1166 | ||
1167 | which $BABELTRACE_BIN >/dev/null | |
1168 | if [ $? -ne 0 ]; then | |
1169 | skip 0 "Babeltrace binary not found. Skipping trace validation" | |
1170 | fi | |
1171 | ||
1172 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | wc -l) | |
1173 | if [ "$traced" -eq 0 ]; then | |
1174 | pass "Validate empty trace" | |
1175 | else | |
1176 | fail "Validate empty trace" | |
1177 | diag "Found $traced events in trace" | |
1178 | fi | |
1179 | ret=$? | |
1180 | return $ret | |
1181 | } |