| 1 | # Copyright (C) 2012 David Goulet <dgoulet@efficios.com> |
| 2 | # |
| 3 | # SPDX-License-Identifier: LGPL-2.1-only |
| 4 | # |
| 5 | |
| 6 | SESSIOND_BIN="lttng-sessiond" |
| 7 | SESSIOND_MATCH=".*lttng-sess.*" |
| 8 | RUNAS_BIN="lttng-runas" |
| 9 | RUNAS_MATCH=".*lttng-runas.*" |
| 10 | CONSUMERD_BIN="lttng-consumerd" |
| 11 | CONSUMERD_MATCH=".*lttng-consumerd.*" |
| 12 | RELAYD_BIN="lttng-relayd" |
| 13 | RELAYD_MATCH=".*lttng-relayd.*" |
| 14 | LTTNG_BIN="lttng" |
| 15 | BABELTRACE_BIN="babeltrace" |
| 16 | OUTPUT_DEST=/dev/null |
| 17 | ERROR_OUTPUT_DEST=/dev/null |
| 18 | |
| 19 | # Minimal kernel version supported for session daemon tests |
| 20 | KERNEL_MAJOR_VERSION=2 |
| 21 | KERNEL_MINOR_VERSION=6 |
| 22 | KERNEL_PATCHLEVEL_VERSION=27 |
| 23 | |
| 24 | # We set the default UST register timeout and network and app socket timeout to |
| 25 | # "wait forever", so that basic tests don't have to worry about hitting |
| 26 | # timeouts on busy systems. Specialized tests should test those corner-cases. |
| 27 | export LTTNG_UST_REGISTER_TIMEOUT=-1 |
| 28 | export LTTNG_NETWORK_SOCKET_TIMEOUT=-1 |
| 29 | export LTTNG_APP_SOCKET_TIMEOUT=-1 |
| 30 | |
| 31 | # We set the default lttng-sessiond path to /bin/true to prevent the spawning |
| 32 | # of a daemonized sessiond. This is necessary since 'lttng create' will spawn |
| 33 | # its own sessiond if none is running. It also ensures that 'lttng create' |
| 34 | # fails when no sessiond is running. |
| 35 | export LTTNG_SESSIOND_PATH="/bin/true" |
| 36 | |
| 37 | source $TESTDIR/utils/tap/tap.sh |
| 38 | |
| 39 | if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then |
| 40 | LTTNG_TEST_TEARDOWN_TIMEOUT=60 |
| 41 | fi |
| 42 | |
| 43 | # Enable job monitor mode. |
| 44 | # Here we are mostly interested in the following from the monitor mode: |
| 45 | # All processes run in a separate process group. |
| 46 | # This allows us to ensure that all subprocesses from all background tasks are |
| 47 | # cleaned up correctly using signal to process group id. |
| 48 | set -m |
| 49 | |
| 50 | kill_background_jobs () |
| 51 | { |
| 52 | local pids |
| 53 | pids=$(jobs -p) |
| 54 | |
| 55 | if [ -z "$pids" ]; then |
| 56 | # Empty |
| 57 | return 0 |
| 58 | fi |
| 59 | |
| 60 | while read -r pid; |
| 61 | do |
| 62 | # Use negative number to send the signal to the process group. |
| 63 | # This ensure that any subprocesses receive the signal. |
| 64 | # /dev/null is used since there is an acceptable race between |
| 65 | # the moments the pids are listed and the moment we send a |
| 66 | # signal. |
| 67 | kill -SIGTERM -- "-$pid" 2>/dev/null |
| 68 | done <<< "$pids" |
| 69 | } |
| 70 | |
| 71 | function cleanup () |
| 72 | { |
| 73 | # Try to kill daemons gracefully |
| 74 | stop_lttng_relayd_cleanup SIGTERM $LTTNG_TEST_TEARDOWN_TIMEOUT |
| 75 | stop_lttng_sessiond_cleanup SIGTERM $LTTNG_TEST_TEARDOWN_TIMEOUT |
| 76 | |
| 77 | # If daemons are still present, forcibly kill them |
| 78 | stop_lttng_relayd_cleanup SIGKILL $LTTNG_TEST_TEARDOWN_TIMEOUT |
| 79 | stop_lttng_sessiond_cleanup SIGKILL $LTTNG_TEST_TEARDOWN_TIMEOUT |
| 80 | stop_lttng_consumerd_cleanup SIGKILL $LTTNG_TEST_TEARDOWN_TIMEOUT |
| 81 | |
| 82 | kill_background_jobs |
| 83 | } |
| 84 | |
| 85 | function full_cleanup () |
| 86 | { |
| 87 | cleanup |
| 88 | exit 1 |
| 89 | } |
| 90 | |
| 91 | function LTTNG_BAIL_OUT () |
| 92 | { |
| 93 | cleanup |
| 94 | BAIL_OUT "$@" |
| 95 | } |
| 96 | |
| 97 | function null_pipes () |
| 98 | { |
| 99 | exec 0>/dev/null |
| 100 | exec 1>/dev/null |
| 101 | exec 2>/dev/null |
| 102 | } |
| 103 | |
| 104 | trap full_cleanup SIGINT SIGTERM |
| 105 | |
| 106 | # perl prove closes its child pipes before giving it a chance to run its |
| 107 | # signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught |
| 108 | # to allow those trap handlers to proceed. |
| 109 | |
| 110 | trap null_pipes SIGPIPE |
| 111 | |
| 112 | # Check pgrep from env, default to pgrep if none |
| 113 | if [ -z "$PGREP" ]; then |
| 114 | PGREP=pgrep |
| 115 | fi |
| 116 | |
| 117 | # Due to the renaming of threads we need to use the full command (pgrep -f) to |
| 118 | # identify the pids for multiple lttng related processes. The problem with "pgrep |
| 119 | # -f" is that it ends up also looking at the arguments. We use a two stage |
| 120 | # lookup. The first one is using "pgrep -f" yielding potential candidate. |
| 121 | # The second on perform grep on the basename of the first field of the |
| 122 | # /proc/pid/cmdline of the previously identified pids. The first field |
| 123 | # correspond to the actual command. |
| 124 | function lttng_pgrep () |
| 125 | { |
| 126 | local pattern=$1 |
| 127 | local possible_pids |
| 128 | local full_command_no_argument |
| 129 | local command_basename |
| 130 | |
| 131 | possible_pids=$($PGREP -f "$pattern") |
| 132 | if [ -z "$possible_pids" ]; then |
| 133 | return 0 |
| 134 | fi |
| 135 | |
| 136 | while IFS= read -r pid ; do |
| 137 | # /proc/pid/cmdline is null separated. |
| 138 | if full_command_no_argument=$(cut -d '' -f 1 2>/dev/null < /proc/"$pid"/cmdline); then |
| 139 | command_basename=$(basename "$full_command_no_argument") |
| 140 | if grep -q "$pattern" <<< "$command_basename"; then |
| 141 | echo "$pid" |
| 142 | fi |
| 143 | fi |
| 144 | done <<< "$possible_pids" |
| 145 | return 0 |
| 146 | } |
| 147 | |
| 148 | function print_ok () |
| 149 | { |
| 150 | # Check if we are a terminal |
| 151 | if [ -t 1 ]; then |
| 152 | echo -e "\e[1;32mOK\e[0m" |
| 153 | else |
| 154 | echo -e "OK" |
| 155 | fi |
| 156 | } |
| 157 | |
| 158 | function print_fail () |
| 159 | { |
| 160 | # Check if we are a terminal |
| 161 | if [ -t 1 ]; then |
| 162 | echo -e "\e[1;31mFAIL\e[0m" |
| 163 | else |
| 164 | echo -e "FAIL" |
| 165 | fi |
| 166 | } |
| 167 | |
| 168 | function print_test_banner () |
| 169 | { |
| 170 | local desc="$1" |
| 171 | diag "$desc" |
| 172 | } |
| 173 | |
| 174 | function validate_kernel_version () |
| 175 | { |
| 176 | local kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n')) |
| 177 | if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then |
| 178 | return 0 |
| 179 | fi |
| 180 | if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then |
| 181 | return 0 |
| 182 | fi |
| 183 | if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then |
| 184 | return 0 |
| 185 | fi |
| 186 | return 1 |
| 187 | } |
| 188 | |
| 189 | # Generate a random string |
| 190 | # $1 = number of characters; defaults to 16 |
| 191 | # $2 = include special characters; 1 = yes, 0 = no; defaults to yes |
| 192 | function randstring() |
| 193 | { |
| 194 | [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]" |
| 195 | cat /dev/urandom 2>/dev/null | tr -cd "$CHAR" 2>/dev/null | head -c ${1:-16} 2>/dev/null |
| 196 | echo |
| 197 | } |
| 198 | |
| 199 | # Return the number of _configured_ CPUs. |
| 200 | function conf_proc_count() |
| 201 | { |
| 202 | getconf _NPROCESSORS_CONF |
| 203 | if [ $? -ne 0 ]; then |
| 204 | diag "Failed to get the number of configured CPUs" |
| 205 | fi |
| 206 | echo |
| 207 | } |
| 208 | |
| 209 | # Check if base lttng-modules are present. |
| 210 | # Bail out on failure |
| 211 | function validate_lttng_modules_present () |
| 212 | { |
| 213 | # Check for loadable modules. |
| 214 | modprobe -n lttng-tracer 2>/dev/null |
| 215 | if [ $? -eq 0 ]; then |
| 216 | return 0 |
| 217 | fi |
| 218 | |
| 219 | # Check for builtin modules. |
| 220 | ls /proc/lttng > /dev/null 2>&1 |
| 221 | if [ $? -eq 0 ]; then |
| 222 | return 0 |
| 223 | fi |
| 224 | |
| 225 | LTTNG_BAIL_OUT "LTTng modules not detected." |
| 226 | } |
| 227 | |
| 228 | function enable_kernel_lttng_event |
| 229 | { |
| 230 | local withtap="$1" |
| 231 | local expected_to_fail="$2" |
| 232 | local sess_name="$3" |
| 233 | local event_name="$4" |
| 234 | local channel_name="$5" |
| 235 | |
| 236 | if [ -z "$event_name" ]; then |
| 237 | # Enable all event if no event name specified |
| 238 | event_name="-a" |
| 239 | fi |
| 240 | |
| 241 | if [ -z "$channel_name" ]; then |
| 242 | # default channel if none specified |
| 243 | chan="" |
| 244 | else |
| 245 | chan="-c $channel_name" |
| 246 | fi |
| 247 | |
| 248 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 249 | ret=$? |
| 250 | if [[ $expected_to_fail -eq "1" ]]; then |
| 251 | test $ret -ne "0" |
| 252 | ret=$? |
| 253 | if [ $withtap -eq "1" ]; then |
| 254 | ok $ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected" |
| 255 | fi |
| 256 | else |
| 257 | if [ $withtap -eq "1" ]; then |
| 258 | ok $ret "Enable kernel event $event_name for session $sess_name" |
| 259 | fi |
| 260 | fi |
| 261 | } |
| 262 | |
| 263 | function enable_kernel_lttng_event_ok () |
| 264 | { |
| 265 | enable_kernel_lttng_event 1 0 "$@" |
| 266 | } |
| 267 | |
| 268 | function enable_kernel_lttng_event_fail () |
| 269 | { |
| 270 | enable_kernel_lttng_event 1 1 "$@" |
| 271 | } |
| 272 | |
| 273 | function enable_kernel_lttng_event_notap () |
| 274 | { |
| 275 | enable_kernel_lttng_event 0 0 "$@" |
| 276 | } |
| 277 | |
| 278 | # Old interface |
| 279 | function lttng_enable_kernel_event |
| 280 | { |
| 281 | enable_kernel_lttng_event_ok "$@" |
| 282 | } |
| 283 | |
| 284 | function lttng_enable_kernel_syscall() |
| 285 | { |
| 286 | local expected_to_fail=$1 |
| 287 | local sess_name=$2 |
| 288 | local syscall_name=$3 |
| 289 | local channel_name=$4 |
| 290 | |
| 291 | if [ -z $syscall_name ]; then |
| 292 | # Enable all event if no syscall name specified |
| 293 | syscall_name="-a" |
| 294 | fi |
| 295 | |
| 296 | if [ -z $channel_name ]; then |
| 297 | # default channel if none specified |
| 298 | chan="" |
| 299 | else |
| 300 | chan="-c $channel_name" |
| 301 | fi |
| 302 | |
| 303 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 304 | ret=$? |
| 305 | if [[ $expected_to_fail -eq "1" ]]; then |
| 306 | test $ret -ne "0" |
| 307 | ok $? "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected" |
| 308 | else |
| 309 | ok $ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name" |
| 310 | fi |
| 311 | } |
| 312 | |
| 313 | function lttng_enable_kernel_syscall_ok() |
| 314 | { |
| 315 | lttng_enable_kernel_syscall 0 "$@" |
| 316 | } |
| 317 | |
| 318 | function lttng_enable_kernel_syscall_fail() |
| 319 | { |
| 320 | lttng_enable_kernel_syscall 1 "$@" |
| 321 | } |
| 322 | |
| 323 | function lttng_disable_kernel_syscall() |
| 324 | { |
| 325 | local expected_to_fail=$1 |
| 326 | local sess_name=$2 |
| 327 | local syscall_name=$3 |
| 328 | local channel_name=$4 |
| 329 | |
| 330 | if [ -z $syscall_name ]; then |
| 331 | # Enable all event if no syscall name specified |
| 332 | syscall_name="-a" |
| 333 | fi |
| 334 | |
| 335 | if [ -z $channel_name ]; then |
| 336 | # default channel if none specified |
| 337 | chan="" |
| 338 | else |
| 339 | chan="-c $channel_name" |
| 340 | fi |
| 341 | |
| 342 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 343 | |
| 344 | ret=$? |
| 345 | if [[ $expected_to_fail -eq "1" ]]; then |
| 346 | test $ret -ne "0" |
| 347 | ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected" |
| 348 | else |
| 349 | ok $ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name" |
| 350 | fi |
| 351 | } |
| 352 | |
| 353 | function lttng_disable_kernel_syscall_ok() |
| 354 | { |
| 355 | lttng_disable_kernel_syscall 0 "$@" |
| 356 | } |
| 357 | |
| 358 | function lttng_disable_kernel_syscall_fail() |
| 359 | { |
| 360 | lttng_disable_kernel_syscall 1 "$@" |
| 361 | } |
| 362 | |
| 363 | function lttng_enable_kernel_function_event () |
| 364 | { |
| 365 | local expected_to_fail="$1" |
| 366 | local sess_name="$2" |
| 367 | local target="$3" |
| 368 | local event_name="$4" |
| 369 | |
| 370 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event --kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST" |
| 371 | ret=$? |
| 372 | if [[ $expected_to_fail -eq "1" ]]; then |
| 373 | test $ret -ne "0" |
| 374 | ok $? "Enable kernel function event for session $sess_name failed as expected" |
| 375 | else |
| 376 | ok $ret "Enable kernel function event for session $sess_name" |
| 377 | fi |
| 378 | } |
| 379 | |
| 380 | function lttng_enable_kernel_function_event_ok () |
| 381 | { |
| 382 | lttng_enable_kernel_function_event 0 "$@" |
| 383 | } |
| 384 | |
| 385 | function lttng_enable_kernel_userspace_probe_event () |
| 386 | { |
| 387 | local expected_to_fail="$1" |
| 388 | local sess_name="$2" |
| 389 | local target="$3" |
| 390 | local event_name="$4" |
| 391 | |
| 392 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event --kernel --userspace-probe="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST" |
| 393 | ret=$? |
| 394 | if [[ $expected_to_fail -eq "1" ]]; then |
| 395 | test $ret -ne "0" |
| 396 | ok $? "Enable kernel userspace probe event for session $sess_name failed as expected" |
| 397 | else |
| 398 | ok $ret "Enable kernel userspace probe event for session $sess_name" |
| 399 | fi |
| 400 | } |
| 401 | |
| 402 | function lttng_enable_kernel_userspace_probe_event_fail () |
| 403 | { |
| 404 | lttng_enable_kernel_userspace_probe_event 1 "$@" |
| 405 | } |
| 406 | |
| 407 | function lttng_enable_kernel_userspace_probe_event_ok () |
| 408 | { |
| 409 | lttng_enable_kernel_userspace_probe_event 0 "$@" |
| 410 | } |
| 411 | |
| 412 | function disable_kernel_lttng_userspace_probe_event_ok () |
| 413 | { |
| 414 | local sess_name="$1" |
| 415 | local event_name="$2" |
| 416 | |
| 417 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" disable-event --kernel "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST" |
| 418 | ok $? "Disable kernel event $target for session $sess_name" |
| 419 | } |
| 420 | function lttng_enable_kernel_channel() |
| 421 | { |
| 422 | local withtap=$1 |
| 423 | local expected_to_fail=$2 |
| 424 | local sess_name=$3 |
| 425 | local channel_name=$4 |
| 426 | local opts="${@:5}" |
| 427 | |
| 428 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 429 | ret=$? |
| 430 | if [[ $expected_to_fail -eq "1" ]]; then |
| 431 | test "$ret" -ne "0" |
| 432 | ret=$? |
| 433 | if [ $withtap -eq "1" ]; then |
| 434 | ok $ret "Enable channel $channel_name for session $sess_name failed as expected" |
| 435 | fi |
| 436 | else |
| 437 | if [ $withtap -eq "1" ]; then |
| 438 | ok $ret "Enable channel $channel_name for session $sess_name" |
| 439 | fi |
| 440 | fi |
| 441 | } |
| 442 | |
| 443 | function lttng_enable_kernel_channel_ok() |
| 444 | { |
| 445 | lttng_enable_kernel_channel 1 0 "$@" |
| 446 | } |
| 447 | |
| 448 | function lttng_enable_kernel_channel_fail() |
| 449 | { |
| 450 | lttng_enable_kernel_channel 1 1 "$@" |
| 451 | } |
| 452 | |
| 453 | function lttng_enable_kernel_channel_notap() |
| 454 | { |
| 455 | lttng_enable_kernel_channel 0 0 "$@" |
| 456 | } |
| 457 | |
| 458 | function enable_kernel_lttng_channel_ok() |
| 459 | { |
| 460 | lttng_enable_kernel_channel 1 0 "$@" |
| 461 | } |
| 462 | |
| 463 | function lttng_disable_kernel_channel() |
| 464 | { |
| 465 | local expected_to_fail=$1 |
| 466 | local sess_name=$2 |
| 467 | local channel_name=$3 |
| 468 | |
| 469 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 470 | ret=$? |
| 471 | if [[ $expected_to_fail -eq "1" ]]; then |
| 472 | test "$ret" -ne "0" |
| 473 | ok $? "Disable channel $channel_name for session $sess_name failed as expected" |
| 474 | else |
| 475 | ok $ret "Disable channel $channel_name for session $sess_name" |
| 476 | fi |
| 477 | } |
| 478 | |
| 479 | function lttng_disable_kernel_channel_ok() |
| 480 | { |
| 481 | lttng_disable_kernel_channel 0 "$@" |
| 482 | } |
| 483 | |
| 484 | function lttng_disable_kernel_channel_fail() |
| 485 | { |
| 486 | lttng_disable_kernel_channel 1 "$@" |
| 487 | } |
| 488 | |
| 489 | function start_lttng_relayd_opt() |
| 490 | { |
| 491 | local withtap=$1 |
| 492 | local process_mode=$2 |
| 493 | local opt=$3 |
| 494 | |
| 495 | DIR=$(readlink -f "$TESTDIR") |
| 496 | |
| 497 | if [ -z $(lttng_pgrep "$RELAYD_MATCH") ]; then |
| 498 | # shellcheck disable=SC2086 |
| 499 | $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 500 | #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 & |
| 501 | if [ $? -eq 1 ]; then |
| 502 | if [ $withtap -eq "1" ]; then |
| 503 | fail "Start lttng-relayd (process mode: $process_mode opt: $opt)" |
| 504 | fi |
| 505 | return 1 |
| 506 | else |
| 507 | if [ $withtap -eq "1" ]; then |
| 508 | pass "Start lttng-relayd (process mode: $process_mode opt: $opt)" |
| 509 | fi |
| 510 | fi |
| 511 | else |
| 512 | pass "Start lttng-relayd (opt: $opt)" |
| 513 | fi |
| 514 | } |
| 515 | |
| 516 | function start_lttng_relayd() |
| 517 | { |
| 518 | start_lttng_relayd_opt 1 "-b" "$@" |
| 519 | } |
| 520 | |
| 521 | function start_lttng_relayd_notap() |
| 522 | { |
| 523 | start_lttng_relayd_opt 0 "-b" "$@" |
| 524 | } |
| 525 | |
| 526 | function stop_lttng_relayd_opt() |
| 527 | { |
| 528 | local withtap=$1 |
| 529 | local is_cleanup=$2 |
| 530 | local signal=$3 |
| 531 | local timeout_s=$4 |
| 532 | local dtimeleft_s= |
| 533 | local retval=0 |
| 534 | local pids |
| 535 | |
| 536 | if [ -z "$signal" ]; then |
| 537 | signal="SIGTERM" |
| 538 | fi |
| 539 | |
| 540 | |
| 541 | # Multiply time by 2 to simplify integer arithmetic |
| 542 | if [ -n "$timeout_s" ]; then |
| 543 | dtimeleft_s=$((timeout_s * 2)) |
| 544 | fi |
| 545 | |
| 546 | |
| 547 | pids=$(lttng_pgrep "$RELAYD_MATCH") |
| 548 | if [ -z "$pids" ]; then |
| 549 | if [ "$is_cleanup" -eq 1 ]; then |
| 550 | : |
| 551 | elif [ "$withtap" -eq "1" ]; then |
| 552 | fail "No relay daemon to kill" |
| 553 | else |
| 554 | LTTNG_BAIL_OUT "No relay daemon to kill" |
| 555 | fi |
| 556 | return 0 |
| 557 | fi |
| 558 | |
| 559 | diag "Killing (signal $signal) lttng-relayd (pid: $pids)" |
| 560 | |
| 561 | # shellcheck disable=SC2086 |
| 562 | if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then |
| 563 | retval=1 |
| 564 | if [ "$withtap" -eq "1" ]; then |
| 565 | fail "Kill relay daemon" |
| 566 | fi |
| 567 | else |
| 568 | out=1 |
| 569 | while [ -n "$out" ]; do |
| 570 | out=$(lttng_pgrep "$RELAYD_MATCH") |
| 571 | if [ -n "$dtimeleft_s" ]; then |
| 572 | if [ $dtimeleft_s -lt 0 ]; then |
| 573 | out= |
| 574 | retval=1 |
| 575 | fi |
| 576 | dtimeleft_s=$((dtimeleft_s - 1)) |
| 577 | fi |
| 578 | sleep 0.5 |
| 579 | done |
| 580 | if [ "$withtap" -eq "1" ]; then |
| 581 | if [ "$retval" -eq "0" ]; then |
| 582 | pass "Wait after kill relay daemon" |
| 583 | else |
| 584 | fail "Wait after kill relay daemon" |
| 585 | fi |
| 586 | fi |
| 587 | fi |
| 588 | return $retval |
| 589 | } |
| 590 | |
| 591 | function stop_lttng_relayd() |
| 592 | { |
| 593 | stop_lttng_relayd_opt 1 0 "$@" |
| 594 | } |
| 595 | |
| 596 | function stop_lttng_relayd_notap() |
| 597 | { |
| 598 | stop_lttng_relayd_opt 0 0 "$@" |
| 599 | } |
| 600 | |
| 601 | function stop_lttng_relayd_cleanup() |
| 602 | { |
| 603 | stop_lttng_relayd_opt 0 1 "$@" |
| 604 | } |
| 605 | |
| 606 | #First arg: show tap output |
| 607 | #Second argument: load path for automatic loading |
| 608 | function start_lttng_sessiond_opt() |
| 609 | { |
| 610 | local withtap=$1 |
| 611 | local load_path=$2 |
| 612 | |
| 613 | # The rest of the arguments will be passed directly to lttng-sessiond. |
| 614 | shift 2 |
| 615 | |
| 616 | local env_vars="" |
| 617 | local consumerd="" |
| 618 | |
| 619 | local long_bit_value= |
| 620 | long_bit_value=$(getconf LONG_BIT) |
| 621 | |
| 622 | if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
| 623 | # Env variable requested no session daemon |
| 624 | return |
| 625 | fi |
| 626 | |
| 627 | DIR=$(readlink -f "$TESTDIR") |
| 628 | |
| 629 | # Get long_bit value for 32/64 consumerd |
| 630 | case "$long_bit_value" in |
| 631 | 32) |
| 632 | consumerd="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd" |
| 633 | ;; |
| 634 | 64) |
| 635 | consumerd="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd" |
| 636 | ;; |
| 637 | *) |
| 638 | return |
| 639 | ;; |
| 640 | esac |
| 641 | |
| 642 | # Check for env. variable. Allow the use of LD_PRELOAD etc. |
| 643 | if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then |
| 644 | env_vars="${LTTNG_SESSIOND_ENV_VARS} " |
| 645 | fi |
| 646 | env_vars="${env_vars}$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN" |
| 647 | |
| 648 | if ! validate_kernel_version; then |
| 649 | fail "Start session daemon" |
| 650 | LTTNG_BAIL_OUT "*** Kernel too old for session daemon tests ***" |
| 651 | fi |
| 652 | |
| 653 | : "${LTTNG_SESSION_CONFIG_XSD_PATH="${DIR}/../src/common/config/"}" |
| 654 | export LTTNG_SESSION_CONFIG_XSD_PATH |
| 655 | |
| 656 | if [ -z "$(lttng_pgrep "${SESSIOND_MATCH}")" ]; then |
| 657 | # Have a load path ? |
| 658 | if [ -n "$load_path" ]; then |
| 659 | # shellcheck disable=SC2086 |
| 660 | env $env_vars --load "$load_path" --background "$consumerd" "$@" |
| 661 | else |
| 662 | # shellcheck disable=SC2086 |
| 663 | env $env_vars --background "$consumerd" "$@" |
| 664 | fi |
| 665 | #$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 |
| 666 | status=$? |
| 667 | if [ "$withtap" -eq "1" ]; then |
| 668 | ok $status "Start session daemon" |
| 669 | fi |
| 670 | fi |
| 671 | } |
| 672 | |
| 673 | function start_lttng_sessiond() |
| 674 | { |
| 675 | start_lttng_sessiond_opt 1 "$@" |
| 676 | } |
| 677 | |
| 678 | function start_lttng_sessiond_notap() |
| 679 | { |
| 680 | start_lttng_sessiond_opt 0 "$@" |
| 681 | } |
| 682 | |
| 683 | function stop_lttng_sessiond_opt() |
| 684 | { |
| 685 | local withtap=$1 |
| 686 | local is_cleanup=$2 |
| 687 | local signal=$3 |
| 688 | local timeout_s=$4 |
| 689 | local dtimeleft_s= |
| 690 | local retval=0 |
| 691 | local runas_pids |
| 692 | local pids |
| 693 | |
| 694 | if [ -z "$signal" ]; then |
| 695 | signal=SIGTERM |
| 696 | fi |
| 697 | |
| 698 | # Multiply time by 2 to simplify integer arithmetic |
| 699 | if [ -n "$timeout_s" ]; then |
| 700 | dtimeleft_s=$((timeout_s * 2)) |
| 701 | fi |
| 702 | |
| 703 | if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
| 704 | # Env variable requested no session daemon |
| 705 | return 0 |
| 706 | fi |
| 707 | |
| 708 | runas_pids=$(lttng_pgrep "$RUNAS_MATCH") |
| 709 | pids=$(lttng_pgrep "$SESSIOND_MATCH") |
| 710 | |
| 711 | if [ -n "$runas_pids" ]; then |
| 712 | pids="$pids $runas_pids" |
| 713 | fi |
| 714 | |
| 715 | if [ -z "$pids" ]; then |
| 716 | if [ "$is_cleanup" -eq 1 ]; then |
| 717 | : |
| 718 | elif [ "$withtap" -eq "1" ]; then |
| 719 | fail "No session daemon to kill" |
| 720 | else |
| 721 | LTTNG_BAIL_OUT "No session daemon to kill" |
| 722 | fi |
| 723 | return 0 |
| 724 | fi |
| 725 | |
| 726 | diag "Killing (signal $signal) $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')" |
| 727 | |
| 728 | # shellcheck disable=SC2086 |
| 729 | if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then |
| 730 | retval=1 |
| 731 | if [ "$withtap" -eq "1" ]; then |
| 732 | fail "Kill sessions daemon" |
| 733 | fi |
| 734 | else |
| 735 | out=1 |
| 736 | while [ -n "$out" ]; do |
| 737 | out=$(lttng_pgrep "${SESSIOND_MATCH}") |
| 738 | if [ -n "$dtimeleft_s" ]; then |
| 739 | if [ $dtimeleft_s -lt 0 ]; then |
| 740 | out= |
| 741 | retval=1 |
| 742 | fi |
| 743 | dtimeleft_s=$((dtimeleft_s - 1)) |
| 744 | fi |
| 745 | sleep 0.5 |
| 746 | done |
| 747 | out=1 |
| 748 | while [ -n "$out" ]; do |
| 749 | out=$(lttng_pgrep "$CONSUMERD_MATCH") |
| 750 | if [ -n "$dtimeleft_s" ]; then |
| 751 | if [ $dtimeleft_s -lt 0 ]; then |
| 752 | out= |
| 753 | retval=1 |
| 754 | fi |
| 755 | dtimeleft_s=$((dtimeleft_s - 1)) |
| 756 | fi |
| 757 | sleep 0.5 |
| 758 | done |
| 759 | |
| 760 | if [ "$withtap" -eq "1" ]; then |
| 761 | if [ "$retval" -eq "0" ]; then |
| 762 | pass "Wait after kill session daemon" |
| 763 | else |
| 764 | fail "Wait after kill session daemon" |
| 765 | fi |
| 766 | fi |
| 767 | fi |
| 768 | if [ "$signal" = "SIGKILL" ]; then |
| 769 | if [ "$(id -u)" -eq "0" ]; then |
| 770 | local modules= |
| 771 | modules="$(lsmod | grep ^lttng | awk '{print $1}')" |
| 772 | |
| 773 | if [ -n "$modules" ]; then |
| 774 | diag "Unloading all LTTng modules" |
| 775 | modprobe --remove "$modules" |
| 776 | fi |
| 777 | fi |
| 778 | fi |
| 779 | |
| 780 | return $retval |
| 781 | } |
| 782 | |
| 783 | function stop_lttng_sessiond() |
| 784 | { |
| 785 | stop_lttng_sessiond_opt 1 0 "$@" |
| 786 | } |
| 787 | |
| 788 | function stop_lttng_sessiond_notap() |
| 789 | { |
| 790 | stop_lttng_sessiond_opt 0 0 "$@" |
| 791 | } |
| 792 | |
| 793 | function stop_lttng_sessiond_cleanup() |
| 794 | { |
| 795 | stop_lttng_sessiond_opt 0 1 "$@" |
| 796 | } |
| 797 | |
| 798 | function sigstop_lttng_sessiond_opt() |
| 799 | { |
| 800 | local withtap=$1 |
| 801 | local signal=SIGSTOP |
| 802 | local pids |
| 803 | |
| 804 | if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
| 805 | # Env variable requested no session daemon |
| 806 | return |
| 807 | fi |
| 808 | |
| 809 | pids="$(lttng_pgrep "${SESSIOND_MATCH}") $(lttng_pgrep "$RUNAS_MATCH")" |
| 810 | |
| 811 | if [ "$withtap" -eq "1" ]; then |
| 812 | diag "Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo "$pids" | tr '\n' ' ')" |
| 813 | fi |
| 814 | |
| 815 | # shellcheck disable=SC2086 |
| 816 | if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then |
| 817 | if [ "$withtap" -eq "1" ]; then |
| 818 | fail "Sending SIGSTOP to session daemon" |
| 819 | fi |
| 820 | else |
| 821 | out=1 |
| 822 | while [ $out -ne 0 ]; do |
| 823 | pids="$(lttng_pgrep "$SESSIOND_MATCH")" |
| 824 | |
| 825 | # Wait until state becomes stopped for session |
| 826 | # daemon(s). |
| 827 | out=0 |
| 828 | for sessiond_pid in $pids; do |
| 829 | state="$(ps -p "$sessiond_pid" -o state= )" |
| 830 | if [[ -n "$state" && "$state" != "T" ]]; then |
| 831 | out=1 |
| 832 | fi |
| 833 | done |
| 834 | sleep 0.5 |
| 835 | done |
| 836 | if [ "$withtap" -eq "1" ]; then |
| 837 | pass "Sending SIGSTOP to session daemon" |
| 838 | fi |
| 839 | fi |
| 840 | } |
| 841 | |
| 842 | function sigstop_lttng_sessiond() |
| 843 | { |
| 844 | sigstop_lttng_sessiond_opt 1 "$@" |
| 845 | } |
| 846 | |
| 847 | function sigstop_lttng_sessiond_notap() |
| 848 | { |
| 849 | sigstop_lttng_sessiond_opt 0 "$@" |
| 850 | } |
| 851 | |
| 852 | function stop_lttng_consumerd_opt() |
| 853 | { |
| 854 | local withtap=$1 |
| 855 | local is_cleanup=$2 |
| 856 | local signal=$3 |
| 857 | local timeout_s=$4 |
| 858 | local dtimeleft_s= |
| 859 | local retval=0 |
| 860 | local pids |
| 861 | |
| 862 | if [ -z "$signal" ]; then |
| 863 | signal=SIGTERM |
| 864 | fi |
| 865 | |
| 866 | # Multiply time by 2 to simplify integer arithmetic |
| 867 | if [ -n "$timeout_s" ]; then |
| 868 | dtimeleft_s=$((timeout_s * 2)) |
| 869 | fi |
| 870 | |
| 871 | pids="$(lttng_pgrep "$CONSUMERD_MATCH")" |
| 872 | |
| 873 | if [ -z "$pids" ]; then |
| 874 | if [ "$is_cleanup" -eq 1 ]; then |
| 875 | : |
| 876 | elif [ "$withtap" -eq "1" ]; then |
| 877 | fail "No consumerd daemon to kill" |
| 878 | else |
| 879 | LTTNG_BAIL_OUT "No consumerd daemon to kill" |
| 880 | fi |
| 881 | return 0 |
| 882 | fi |
| 883 | |
| 884 | diag "Killing (signal $signal) $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')" |
| 885 | |
| 886 | # shellcheck disable=SC2086 |
| 887 | if ! kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST; then |
| 888 | retval=1 |
| 889 | if [ "$withtap" -eq "1" ]; then |
| 890 | fail "Kill consumer daemon" |
| 891 | fi |
| 892 | else |
| 893 | out=1 |
| 894 | while [ $out -ne 0 ]; do |
| 895 | pids="$(lttng_pgrep "$CONSUMERD_MATCH")" |
| 896 | |
| 897 | # If consumerds are still present check their status. |
| 898 | # A zombie status qualifies the consumerd as *killed* |
| 899 | out=0 |
| 900 | for consumer_pid in $pids; do |
| 901 | state="$(ps -p "$consumer_pid" -o state= )" |
| 902 | if [[ -n "$state" && "$state" != "Z" ]]; then |
| 903 | out=1 |
| 904 | fi |
| 905 | done |
| 906 | if [ -n "$dtimeleft_s" ]; then |
| 907 | if [ $dtimeleft_s -lt 0 ]; then |
| 908 | out=0 |
| 909 | retval=1 |
| 910 | fi |
| 911 | dtimeleft_s=$((dtimeleft_s - 1)) |
| 912 | fi |
| 913 | sleep 0.5 |
| 914 | done |
| 915 | if [ "$withtap" -eq "1" ]; then |
| 916 | if [ "$retval" -eq "0" ]; then |
| 917 | pass "Wait after kill consumer daemon" |
| 918 | else |
| 919 | fail "Wait after kill consumer daemon" |
| 920 | fi |
| 921 | fi |
| 922 | fi |
| 923 | |
| 924 | return $retval |
| 925 | } |
| 926 | |
| 927 | function stop_lttng_consumerd() |
| 928 | { |
| 929 | stop_lttng_consumerd_opt 1 0 "$@" |
| 930 | } |
| 931 | |
| 932 | function stop_lttng_consumerd_notap() |
| 933 | { |
| 934 | stop_lttng_consumerd_opt 0 0 "$@" |
| 935 | } |
| 936 | |
| 937 | function stop_lttng_consumerd_cleanup() |
| 938 | { |
| 939 | stop_lttng_consumerd_opt 0 1 "$@" |
| 940 | } |
| 941 | |
| 942 | function sigstop_lttng_consumerd_opt() |
| 943 | { |
| 944 | local withtap=$1 |
| 945 | local signal=SIGSTOP |
| 946 | local pids |
| 947 | |
| 948 | pids="$(lttng_pgrep "$CONSUMERD_MATCH")" |
| 949 | |
| 950 | diag "Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo "$pids" | tr '\n' ' ')" |
| 951 | |
| 952 | # shellcheck disable=SC2086 |
| 953 | kill -s $signal $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 954 | retval=$? |
| 955 | |
| 956 | if [ $retval -eq 1 ]; then |
| 957 | if [ "$withtap" -eq "1" ]; then |
| 958 | fail "Sending SIGSTOP to consumer daemon" |
| 959 | fi |
| 960 | return 1 |
| 961 | else |
| 962 | out=1 |
| 963 | while [ $out -ne 0 ]; do |
| 964 | pids="$(lttng_pgrep "$CONSUMERD_MATCH")" |
| 965 | |
| 966 | # Wait until state becomes stopped for all |
| 967 | # consumers. |
| 968 | out=0 |
| 969 | for consumer_pid in $pids; do |
| 970 | state="$(ps -p "$consumer_pid" -o state= )" |
| 971 | if [[ -n "$state" && "$state" != "T" ]]; then |
| 972 | out=1 |
| 973 | fi |
| 974 | done |
| 975 | sleep 0.5 |
| 976 | done |
| 977 | if [ "$withtap" -eq "1" ]; then |
| 978 | pass "Sending SIGSTOP to consumer daemon" |
| 979 | fi |
| 980 | fi |
| 981 | return $retval |
| 982 | } |
| 983 | |
| 984 | function sigstop_lttng_consumerd() |
| 985 | { |
| 986 | sigstop_lttng_consumerd_opt 1 "$@" |
| 987 | } |
| 988 | |
| 989 | function sigstop_lttng_consumerd_notap() |
| 990 | { |
| 991 | sigstop_lttng_consumerd_opt 0 "$@" |
| 992 | } |
| 993 | |
| 994 | function list_lttng_with_opts () |
| 995 | { |
| 996 | local opts=$1 |
| 997 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 998 | ok $? "Lttng-tool list command with option $opts" |
| 999 | } |
| 1000 | |
| 1001 | function create_lttng_session_no_output () |
| 1002 | { |
| 1003 | local sess_name=$1 |
| 1004 | local opts="${@:2}" |
| 1005 | |
| 1006 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1007 | ok $? "Create session $sess_name in no-output mode" |
| 1008 | } |
| 1009 | |
| 1010 | function create_lttng_session_uri () { |
| 1011 | local sess_name=$1 |
| 1012 | local uri=$2 |
| 1013 | local opts="${@:3}" |
| 1014 | |
| 1015 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1016 | ok $? "Create session $sess_name with uri:$uri and opts: $opts" |
| 1017 | } |
| 1018 | |
| 1019 | function create_lttng_session () |
| 1020 | { |
| 1021 | local withtap=$1 |
| 1022 | local expected_to_fail=$2 |
| 1023 | local sess_name=$3 |
| 1024 | local trace_path=$4 |
| 1025 | local opt=$5 |
| 1026 | |
| 1027 | if [ -z "$trace_path" ]; then |
| 1028 | # Use lttng-sessiond default output. |
| 1029 | trace_path="" |
| 1030 | else |
| 1031 | trace_path="-o $trace_path" |
| 1032 | fi |
| 1033 | |
| 1034 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create "$sess_name" $trace_path $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1035 | ret=$? |
| 1036 | if [ $expected_to_fail -eq "1" ]; then |
| 1037 | test "$ret" -ne "0" |
| 1038 | ret=$? |
| 1039 | if [ $withtap -eq "1" ]; then |
| 1040 | ok $ret "Create session $sess_name in $trace_path failed as expected" |
| 1041 | fi |
| 1042 | else |
| 1043 | if [ $withtap -eq "1" ]; then |
| 1044 | ok $ret "Create session $sess_name in $trace_path" |
| 1045 | fi |
| 1046 | fi |
| 1047 | return $ret |
| 1048 | } |
| 1049 | |
| 1050 | function create_lttng_session_ok () |
| 1051 | { |
| 1052 | create_lttng_session 1 0 "$@" |
| 1053 | } |
| 1054 | |
| 1055 | function create_lttng_session_fail () |
| 1056 | { |
| 1057 | create_lttng_session 1 1 "$@" |
| 1058 | } |
| 1059 | |
| 1060 | function create_lttng_session_notap () |
| 1061 | { |
| 1062 | create_lttng_session 0 0 "$@" |
| 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | function enable_ust_lttng_channel () |
| 1067 | { |
| 1068 | local withtap=$1 |
| 1069 | local expected_to_fail=$2 |
| 1070 | local sess_name=$3 |
| 1071 | local channel_name=$4 |
| 1072 | local opts="${@:5}" |
| 1073 | |
| 1074 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1075 | ret=$? |
| 1076 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1077 | test "$ret" -ne "0" |
| 1078 | ret=$? |
| 1079 | if [ $withtap -eq "1" ]; then |
| 1080 | ok $ret "Enable channel $channel_name for session $sess_name failed as expected" |
| 1081 | fi |
| 1082 | else |
| 1083 | if [ $withtap -eq "1" ]; then |
| 1084 | ok $ret "Enable channel $channel_name for session $sess_name" |
| 1085 | fi |
| 1086 | fi |
| 1087 | return $ret |
| 1088 | } |
| 1089 | |
| 1090 | function enable_ust_lttng_channel_ok () |
| 1091 | { |
| 1092 | enable_ust_lttng_channel 1 0 "$@" |
| 1093 | } |
| 1094 | |
| 1095 | function enable_ust_lttng_channel_fail () |
| 1096 | { |
| 1097 | enable_ust_lttng_channel 1 1 "$@" |
| 1098 | } |
| 1099 | |
| 1100 | function enable_ust_lttng_channel_notap () |
| 1101 | { |
| 1102 | enable_ust_lttng_channel 0 0 "$@" |
| 1103 | } |
| 1104 | |
| 1105 | function disable_ust_lttng_channel() |
| 1106 | { |
| 1107 | local sess_name=$1 |
| 1108 | local channel_name=$2 |
| 1109 | |
| 1110 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1111 | ok $? "Disable channel $channel_name for session $sess_name" |
| 1112 | } |
| 1113 | |
| 1114 | function enable_lttng_mmap_overwrite_kernel_channel() |
| 1115 | { |
| 1116 | local sess_name=$1 |
| 1117 | local channel_name=$2 |
| 1118 | |
| 1119 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1120 | ok $? "Enable channel $channel_name for session $sess_name" |
| 1121 | } |
| 1122 | |
| 1123 | function enable_lttng_mmap_discard_small_kernel_channel() |
| 1124 | { |
| 1125 | local sess_name=$1 |
| 1126 | local channel_name=$2 |
| 1127 | |
| 1128 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --discard --subbuf-size=$(getconf PAGE_SIZE) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1129 | ok $? "Enable small discard channel $channel_name for session $sess_name" |
| 1130 | } |
| 1131 | |
| 1132 | function enable_lttng_mmap_overwrite_small_kernel_channel() |
| 1133 | { |
| 1134 | local sess_name=$1 |
| 1135 | local channel_name=$2 |
| 1136 | |
| 1137 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite --subbuf-size=$(getconf PAGE_SIZE) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1138 | ok $? "Enable small discard channel $channel_name for session $sess_name" |
| 1139 | } |
| 1140 | |
| 1141 | function enable_lttng_mmap_overwrite_ust_channel() |
| 1142 | { |
| 1143 | local sess_name=$1 |
| 1144 | local channel_name=$2 |
| 1145 | |
| 1146 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1147 | ok $? "Enable channel $channel_name for session $sess_name" |
| 1148 | } |
| 1149 | |
| 1150 | function enable_ust_lttng_event () |
| 1151 | { |
| 1152 | local withtap=$1 |
| 1153 | local expected_to_fail=$2 |
| 1154 | local sess_name=$3 |
| 1155 | local event_name="$4" |
| 1156 | local channel_name=$5 |
| 1157 | |
| 1158 | if [ -z $channel_name ]; then |
| 1159 | # default channel if none specified |
| 1160 | chan="" |
| 1161 | else |
| 1162 | chan="-c $channel_name" |
| 1163 | fi |
| 1164 | |
| 1165 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1166 | ret=$? |
| 1167 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1168 | test $ret -ne "0" |
| 1169 | ret=$? |
| 1170 | if [[ $withtap -eq "1" ]]; then |
| 1171 | ok $ret "Enable ust event $event_name for session $session_name failed as expected" |
| 1172 | fi |
| 1173 | else |
| 1174 | if [[ $withtap -eq "1" ]]; then |
| 1175 | ok $ret "Enable ust event $event_name for session $sess_name" |
| 1176 | fi |
| 1177 | fi |
| 1178 | return $ret |
| 1179 | } |
| 1180 | |
| 1181 | function enable_ust_lttng_event_ok () |
| 1182 | { |
| 1183 | enable_ust_lttng_event 1 0 "$@" |
| 1184 | } |
| 1185 | |
| 1186 | function enable_ust_lttng_event_fail () |
| 1187 | { |
| 1188 | enable_ust_lttng_event 1 1 "$@" |
| 1189 | } |
| 1190 | |
| 1191 | function enable_ust_lttng_event_notap () |
| 1192 | { |
| 1193 | enable_ust_lttng_event 0 0 "$@" |
| 1194 | } |
| 1195 | |
| 1196 | function enable_jul_lttng_event() |
| 1197 | { |
| 1198 | sess_name=$1 |
| 1199 | event_name="$2" |
| 1200 | channel_name=$3 |
| 1201 | |
| 1202 | if [ -z $channel_name ]; then |
| 1203 | # default channel if none specified |
| 1204 | chan="" |
| 1205 | else |
| 1206 | chan="-c $channel_name" |
| 1207 | fi |
| 1208 | |
| 1209 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1210 | ok $? "Enable JUL event $event_name for session $sess_name" |
| 1211 | } |
| 1212 | |
| 1213 | function enable_jul_lttng_event_loglevel() |
| 1214 | { |
| 1215 | local sess_name=$1 |
| 1216 | local event_name="$2" |
| 1217 | local loglevel=$3 |
| 1218 | local channel_name=$4 |
| 1219 | |
| 1220 | if [ -z $channel_name ]; then |
| 1221 | # default channel if none specified |
| 1222 | chan="" |
| 1223 | else |
| 1224 | chan="-c $channel_name" |
| 1225 | fi |
| 1226 | |
| 1227 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1228 | ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel" |
| 1229 | } |
| 1230 | |
| 1231 | function enable_log4j_lttng_event() |
| 1232 | { |
| 1233 | sess_name=$1 |
| 1234 | event_name="$2" |
| 1235 | channel_name=$3 |
| 1236 | |
| 1237 | if [ -z $channel_name ]; then |
| 1238 | # default channel if none specified |
| 1239 | chan="" |
| 1240 | else |
| 1241 | chan="-c $channel_name" |
| 1242 | fi |
| 1243 | |
| 1244 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1245 | ok $? "Enable LOG4J event $event_name for session $sess_name" |
| 1246 | } |
| 1247 | |
| 1248 | function enable_log4j_lttng_event_loglevel() |
| 1249 | { |
| 1250 | local sess_name=$1 |
| 1251 | local event_name="$2" |
| 1252 | local loglevel=$3 |
| 1253 | local channel_name=$4 |
| 1254 | |
| 1255 | if [ -z $channel_name ]; then |
| 1256 | # default channel if none specified |
| 1257 | chan="" |
| 1258 | else |
| 1259 | chan="-c $channel_name" |
| 1260 | fi |
| 1261 | |
| 1262 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1263 | ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel" |
| 1264 | } |
| 1265 | |
| 1266 | function enable_python_lttng_event() |
| 1267 | { |
| 1268 | sess_name=$1 |
| 1269 | event_name="$2" |
| 1270 | channel_name=$3 |
| 1271 | |
| 1272 | if [ -z $channel_name ]; then |
| 1273 | # default channel if none specified |
| 1274 | chan="" |
| 1275 | else |
| 1276 | chan="-c $channel_name" |
| 1277 | fi |
| 1278 | |
| 1279 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1280 | ok $? "Enable Python event $event_name for session $sess_name" |
| 1281 | } |
| 1282 | |
| 1283 | function enable_python_lttng_event_loglevel() |
| 1284 | { |
| 1285 | local sess_name=$1 |
| 1286 | local event_name="$2" |
| 1287 | local loglevel=$3 |
| 1288 | local channel_name=$4 |
| 1289 | |
| 1290 | if [ -z $channel_name ]; then |
| 1291 | # default channel if none specified |
| 1292 | chan="" |
| 1293 | else |
| 1294 | chan="-c $channel_name" |
| 1295 | fi |
| 1296 | |
| 1297 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1298 | ok $? "Enable Python event $event_name for session $sess_name with loglevel $loglevel" |
| 1299 | } |
| 1300 | |
| 1301 | function enable_ust_lttng_event_filter() |
| 1302 | { |
| 1303 | local sess_name="$1" |
| 1304 | local event_name="$2" |
| 1305 | local filter="$3" |
| 1306 | local channel_name=$4 |
| 1307 | |
| 1308 | if [ -z $channel_name ]; then |
| 1309 | # default channel if none specified |
| 1310 | chan="" |
| 1311 | else |
| 1312 | chan="-c $channel_name" |
| 1313 | fi |
| 1314 | |
| 1315 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1316 | ok $? "Enable event $event_name with filtering for session $sess_name" |
| 1317 | } |
| 1318 | |
| 1319 | function enable_ust_lttng_event_loglevel() |
| 1320 | { |
| 1321 | local sess_name="$1" |
| 1322 | local event_name="$2" |
| 1323 | local loglevel="$3" |
| 1324 | |
| 1325 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1326 | ok $? "Enable event $event_name with loglevel $loglevel" |
| 1327 | } |
| 1328 | |
| 1329 | function enable_ust_lttng_event_loglevel_only() |
| 1330 | { |
| 1331 | local sess_name="$1" |
| 1332 | local event_name="$2" |
| 1333 | local loglevel="$3" |
| 1334 | |
| 1335 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1336 | ok $? "Enable event $event_name with loglevel-only $loglevel" |
| 1337 | } |
| 1338 | |
| 1339 | function disable_ust_lttng_event () |
| 1340 | { |
| 1341 | local sess_name="$1" |
| 1342 | local event_name="$2" |
| 1343 | local channel_name="$3" |
| 1344 | |
| 1345 | if [ -z $channel_name ]; then |
| 1346 | # default channel if none specified |
| 1347 | chan="" |
| 1348 | else |
| 1349 | chan="-c $channel_name" |
| 1350 | fi |
| 1351 | |
| 1352 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1353 | ok $? "Disable event $event_name for session $sess_name" |
| 1354 | } |
| 1355 | |
| 1356 | function disable_jul_lttng_event () |
| 1357 | { |
| 1358 | local sess_name="$1" |
| 1359 | local event_name="$2" |
| 1360 | |
| 1361 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1 |
| 1362 | ok $? "Disable JUL event $event_name for session $sess_name" |
| 1363 | } |
| 1364 | |
| 1365 | function disable_log4j_lttng_event () |
| 1366 | { |
| 1367 | local sess_name="$1" |
| 1368 | local event_name="$2" |
| 1369 | |
| 1370 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1 |
| 1371 | ok $? "Disable LOG4J event $event_name for session $sess_name" |
| 1372 | } |
| 1373 | |
| 1374 | function disable_python_lttng_event () |
| 1375 | { |
| 1376 | local sess_name="$1" |
| 1377 | local event_name="$2" |
| 1378 | |
| 1379 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1380 | ok $? "Disable Python event $event_name for session $sess_name" |
| 1381 | } |
| 1382 | |
| 1383 | function start_lttng_tracing_opt () |
| 1384 | { |
| 1385 | local withtap=$1 |
| 1386 | local expected_to_fail=$2 |
| 1387 | local sess_name=$3 |
| 1388 | |
| 1389 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1390 | ret=$? |
| 1391 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1392 | test "$ret" -ne "0" |
| 1393 | ret=$? |
| 1394 | if [ $withtap -eq "1" ]; then |
| 1395 | ok $? "Start tracing for session $sess_name failed as expected" |
| 1396 | fi |
| 1397 | else |
| 1398 | if [ $withtap -eq "1" ]; then |
| 1399 | ok $ret "Start tracing for session $sess_name" |
| 1400 | fi |
| 1401 | fi |
| 1402 | } |
| 1403 | |
| 1404 | function start_lttng_tracing_ok () |
| 1405 | { |
| 1406 | start_lttng_tracing_opt 1 0 "$@" |
| 1407 | } |
| 1408 | |
| 1409 | function start_lttng_tracing_fail () |
| 1410 | { |
| 1411 | start_lttng_tracing_opt 1 1 "$@" |
| 1412 | } |
| 1413 | |
| 1414 | function start_lttng_tracing_notap () |
| 1415 | { |
| 1416 | start_lttng_tracing_opt 0 1 "$@" |
| 1417 | } |
| 1418 | |
| 1419 | function stop_lttng_tracing_opt () |
| 1420 | { |
| 1421 | local withtap=$1 |
| 1422 | local expected_to_fail=$2 |
| 1423 | local sess_name=$3 |
| 1424 | |
| 1425 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1426 | ret=$? |
| 1427 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1428 | test "$ret" -ne "0" |
| 1429 | ret=$? |
| 1430 | if [ $withtap -eq "1" ]; then |
| 1431 | ok $? "Stop lttng tracing for session $sess_name failed as expected" |
| 1432 | fi |
| 1433 | else |
| 1434 | if [ $withtap -eq "1" ]; then |
| 1435 | ok $ret "Stop lttng tracing for session $sess_name" |
| 1436 | fi |
| 1437 | fi |
| 1438 | } |
| 1439 | |
| 1440 | function stop_lttng_tracing_ok () |
| 1441 | { |
| 1442 | stop_lttng_tracing_opt 1 0 "$@" |
| 1443 | } |
| 1444 | |
| 1445 | function stop_lttng_tracing_fail () |
| 1446 | { |
| 1447 | stop_lttng_tracing_opt 1 1 "$@" |
| 1448 | } |
| 1449 | |
| 1450 | function stop_lttng_tracing_notap () |
| 1451 | { |
| 1452 | stop_lttng_tracing_opt 0 0 "$@" |
| 1453 | } |
| 1454 | |
| 1455 | function destroy_lttng_session () |
| 1456 | { |
| 1457 | local withtap=$1 |
| 1458 | local expected_to_fail=$2 |
| 1459 | local sess_name=$3 |
| 1460 | |
| 1461 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1462 | ret=$? |
| 1463 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1464 | test "$ret" -ne "0" |
| 1465 | ret=$? |
| 1466 | if [ $withtap -eq "1" ]; then |
| 1467 | ok $ret "Destroy session $sess_name failed as expected" |
| 1468 | fi |
| 1469 | else |
| 1470 | if [ $withtap -eq "1" ]; then |
| 1471 | ok $ret "Destroy session $sess_name" |
| 1472 | fi |
| 1473 | fi |
| 1474 | } |
| 1475 | |
| 1476 | function destroy_lttng_session_ok () |
| 1477 | { |
| 1478 | destroy_lttng_session 1 0 "$@" |
| 1479 | |
| 1480 | } |
| 1481 | |
| 1482 | function destroy_lttng_session_fail () |
| 1483 | { |
| 1484 | destroy_lttng_session 1 1 "$@" |
| 1485 | } |
| 1486 | |
| 1487 | function destroy_lttng_session_notap () |
| 1488 | { |
| 1489 | destroy_lttng_session 0 0 "$@" |
| 1490 | } |
| 1491 | |
| 1492 | function destroy_lttng_sessions () |
| 1493 | { |
| 1494 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1495 | ok $? "Destroy all lttng sessions" |
| 1496 | } |
| 1497 | |
| 1498 | function lttng_snapshot_add_output () |
| 1499 | { |
| 1500 | local expected_to_fail=$1 |
| 1501 | local sess_name=$2 |
| 1502 | local trace_path=$3 |
| 1503 | local opts=$4 |
| 1504 | |
| 1505 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name $trace_path $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1506 | ret=$? |
| 1507 | if [[ $expected_to_fail -eq 1 ]]; then |
| 1508 | test "$ret" -ne "0" |
| 1509 | ok $? "Added snapshot output $trace_path failed as expected" |
| 1510 | else |
| 1511 | ok $ret "Added snapshot output $trace_path" |
| 1512 | fi |
| 1513 | } |
| 1514 | |
| 1515 | function lttng_snapshot_add_output_ok () |
| 1516 | { |
| 1517 | lttng_snapshot_add_output 0 "$@" |
| 1518 | } |
| 1519 | |
| 1520 | function lttng_snapshot_add_output_fail () |
| 1521 | { |
| 1522 | lttng_snapshot_add_output 1 "$@" |
| 1523 | } |
| 1524 | |
| 1525 | function lttng_snapshot_del_output () |
| 1526 | { |
| 1527 | local expected_to_fail=$1 |
| 1528 | local sess_name=$2 |
| 1529 | local id=$3 |
| 1530 | |
| 1531 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1532 | ret=$? |
| 1533 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1534 | test "$ret" -ne "0" |
| 1535 | ok $? "Deleted snapshot output id $id failed as expected" |
| 1536 | else |
| 1537 | ok $ret "Deleted snapshot output id $id" |
| 1538 | fi |
| 1539 | } |
| 1540 | |
| 1541 | function lttng_snapshot_del_output_ok () |
| 1542 | { |
| 1543 | lttng_snapshot_del_output 0 "$@" |
| 1544 | } |
| 1545 | |
| 1546 | function lttng_snapshot_del_output_fail () |
| 1547 | { |
| 1548 | lttng_snapshot_del_output 1 "$@" |
| 1549 | } |
| 1550 | |
| 1551 | function lttng_snapshot_record () |
| 1552 | { |
| 1553 | local sess_name=$1 |
| 1554 | local trace_path=$2 |
| 1555 | |
| 1556 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s "$sess_name" "$trace_path" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1557 | ok $? "Snapshot recorded" |
| 1558 | } |
| 1559 | |
| 1560 | function lttng_snapshot_list () |
| 1561 | { |
| 1562 | local sess_name=$1 |
| 1563 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1564 | ok $? "Snapshot list" |
| 1565 | } |
| 1566 | |
| 1567 | function lttng_save() |
| 1568 | { |
| 1569 | local sess_name=$1 |
| 1570 | local opts=$2 |
| 1571 | |
| 1572 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1573 | ok $? "Session saved" |
| 1574 | } |
| 1575 | |
| 1576 | function lttng_load() |
| 1577 | { |
| 1578 | local expected_to_fail=$1 |
| 1579 | local opts=$2 |
| 1580 | |
| 1581 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1582 | ret=$? |
| 1583 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1584 | test $ret -ne "0" |
| 1585 | ok $? "Load command failed as expected with opts: $opts" |
| 1586 | else |
| 1587 | ok $ret "Load command with opts: $opts" |
| 1588 | fi |
| 1589 | } |
| 1590 | |
| 1591 | function lttng_load_ok() |
| 1592 | { |
| 1593 | lttng_load 0 "$@" |
| 1594 | } |
| 1595 | |
| 1596 | function lttng_load_fail() |
| 1597 | { |
| 1598 | lttng_load 1 "$@" |
| 1599 | } |
| 1600 | |
| 1601 | function lttng_track() |
| 1602 | { |
| 1603 | local expected_to_fail="$1" |
| 1604 | shift 1 |
| 1605 | local opts="$@" |
| 1606 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST |
| 1607 | ret=$? |
| 1608 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1609 | test $ret -ne "0" |
| 1610 | ok $? "Track command failed as expected with opts: $opts" |
| 1611 | else |
| 1612 | ok $ret "Track command with opts: $opts" |
| 1613 | fi |
| 1614 | } |
| 1615 | |
| 1616 | function lttng_track_ok() |
| 1617 | { |
| 1618 | lttng_track 0 "$@" |
| 1619 | } |
| 1620 | |
| 1621 | function lttng_track_fail() |
| 1622 | { |
| 1623 | lttng_track 1 "$@" |
| 1624 | } |
| 1625 | |
| 1626 | function lttng_untrack() |
| 1627 | { |
| 1628 | local expected_to_fail="$1" |
| 1629 | shift 1 |
| 1630 | local opts="$@" |
| 1631 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST |
| 1632 | ret=$? |
| 1633 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1634 | test $ret -ne "0" |
| 1635 | ok $? "Untrack command failed as expected with opts: $opts" |
| 1636 | else |
| 1637 | ok $ret "Untrack command with opts: $opts" |
| 1638 | fi |
| 1639 | } |
| 1640 | |
| 1641 | function lttng_untrack_ok() |
| 1642 | { |
| 1643 | lttng_untrack 0 "$@" |
| 1644 | } |
| 1645 | |
| 1646 | function lttng_untrack_fail() |
| 1647 | { |
| 1648 | lttng_untrack 1 "$@" |
| 1649 | } |
| 1650 | |
| 1651 | function lttng_track_pid_ok() |
| 1652 | { |
| 1653 | PID=$1 |
| 1654 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track --kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1655 | ok $? "Lttng track pid on the kernel domain" |
| 1656 | } |
| 1657 | |
| 1658 | function lttng_untrack_kernel_all_ok() |
| 1659 | { |
| 1660 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack --kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1661 | ok $? "Lttng untrack all pid on the kernel domain" |
| 1662 | } |
| 1663 | |
| 1664 | function lttng_track_ust_ok() |
| 1665 | { |
| 1666 | lttng_track_ok -u "$@" |
| 1667 | } |
| 1668 | |
| 1669 | function lttng_track_ust_fail() |
| 1670 | { |
| 1671 | lttng_track_fail -u "$@" |
| 1672 | } |
| 1673 | |
| 1674 | function lttng_track_kernel_ok() |
| 1675 | { |
| 1676 | lttng_track_ok -k "$@" |
| 1677 | } |
| 1678 | |
| 1679 | function lttng_track_kernel_fail() |
| 1680 | { |
| 1681 | lttng_track_fail -k "$@" |
| 1682 | } |
| 1683 | |
| 1684 | function lttng_untrack_ust_ok() |
| 1685 | { |
| 1686 | lttng_untrack_ok -u "$@" |
| 1687 | } |
| 1688 | |
| 1689 | function lttng_untrack_ust_fail() |
| 1690 | { |
| 1691 | lttng_untrack_fail -u "$@" |
| 1692 | } |
| 1693 | |
| 1694 | function lttng_untrack_kernel_ok() |
| 1695 | { |
| 1696 | lttng_untrack_ok -k "$@" |
| 1697 | } |
| 1698 | |
| 1699 | function lttng_untrack_kernel_fail() |
| 1700 | { |
| 1701 | lttng_untrack_fail -k "$@" |
| 1702 | } |
| 1703 | |
| 1704 | function lttng_add_context_list() |
| 1705 | { |
| 1706 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context --list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1707 | ret=$? |
| 1708 | ok $ret "Context listing" |
| 1709 | } |
| 1710 | |
| 1711 | function add_context_lttng() |
| 1712 | { |
| 1713 | local expected_to_fail="$1" |
| 1714 | local domain="$2" |
| 1715 | local session_name="$3" |
| 1716 | local channel_name="$4" |
| 1717 | local type="$5" |
| 1718 | |
| 1719 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1720 | ret=$? |
| 1721 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1722 | test $ret -ne "0" |
| 1723 | ok $? "Add context command failed as expected for type: $type" |
| 1724 | else |
| 1725 | ok $ret "Add context command for type: $type" |
| 1726 | fi |
| 1727 | } |
| 1728 | |
| 1729 | function add_context_ust_ok() |
| 1730 | { |
| 1731 | add_context_lttng 0 -u "$@" |
| 1732 | } |
| 1733 | |
| 1734 | function add_context_ust_fail() |
| 1735 | { |
| 1736 | add_context_lttng 1 -u "$@" |
| 1737 | } |
| 1738 | |
| 1739 | function add_context_kernel_ok() |
| 1740 | { |
| 1741 | add_context_lttng 0 -k "$@" |
| 1742 | } |
| 1743 | |
| 1744 | function add_context_kernel_fail() |
| 1745 | { |
| 1746 | add_context_lttng 1 -k "$@" |
| 1747 | } |
| 1748 | |
| 1749 | function wait_live_trace_ready () |
| 1750 | { |
| 1751 | local url=$1 |
| 1752 | local zero_client_match=0 |
| 1753 | |
| 1754 | diag "Waiting for live trace at url: $url" |
| 1755 | while [ $zero_client_match -eq 0 ]; do |
| 1756 | zero_client_match=$($BABELTRACE_BIN -i lttng-live $url | grep "0 client(s) connected" | wc -l) |
| 1757 | sleep 0.5 |
| 1758 | done |
| 1759 | pass "Waiting for live trace at url: $url" |
| 1760 | } |
| 1761 | |
| 1762 | function wait_live_viewer_connect () |
| 1763 | { |
| 1764 | local url=$1 |
| 1765 | local one_client_match=0 |
| 1766 | |
| 1767 | diag "Waiting for live viewers on url: $url" |
| 1768 | while [ $one_client_match -eq 0 ]; do |
| 1769 | one_client_match=$($BABELTRACE_BIN -i lttng-live $url | grep "1 client(s) connected" | wc -l) |
| 1770 | sleep 0.5 |
| 1771 | done |
| 1772 | pass "Waiting for live viewers on url: $url" |
| 1773 | } |
| 1774 | |
| 1775 | function validate_metadata_event () |
| 1776 | { |
| 1777 | local event_name=$1 |
| 1778 | local nr_event_id=$2 |
| 1779 | local trace_path=$3 |
| 1780 | |
| 1781 | local metadata_file=$(find $trace_path | grep metadata) |
| 1782 | local metadata_path=$(dirname $metadata_file) |
| 1783 | |
| 1784 | which $BABELTRACE_BIN >/dev/null |
| 1785 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1786 | |
| 1787 | local count=$($BABELTRACE_BIN --output-format=ctf-metadata $metadata_path | grep $event_name | wc -l) |
| 1788 | |
| 1789 | if [ "$count" -ne "$nr_event_id" ]; then |
| 1790 | fail "Metadata match with the metadata of $count event(s) named $event_name" |
| 1791 | diag "$count matching event id found in metadata" |
| 1792 | else |
| 1793 | pass "Metadata match with the metadata of $count event(s) named $event_name" |
| 1794 | fi |
| 1795 | |
| 1796 | } |
| 1797 | |
| 1798 | function trace_matches () |
| 1799 | { |
| 1800 | local event_name=$1 |
| 1801 | local nr_iter=$2 |
| 1802 | local trace_path=$3 |
| 1803 | |
| 1804 | which $BABELTRACE_BIN >/dev/null |
| 1805 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1806 | |
| 1807 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
| 1808 | |
| 1809 | if [ "$count" -ne "$nr_iter" ]; then |
| 1810 | fail "Trace match" |
| 1811 | diag "$count matching events found in trace" |
| 1812 | else |
| 1813 | pass "Trace match" |
| 1814 | fi |
| 1815 | } |
| 1816 | |
| 1817 | function trace_match_only() |
| 1818 | { |
| 1819 | local event_name=$1 |
| 1820 | local nr_iter=$2 |
| 1821 | local trace_path=$3 |
| 1822 | |
| 1823 | which $BABELTRACE_BIN >/dev/null |
| 1824 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1825 | |
| 1826 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
| 1827 | local total=$($BABELTRACE_BIN $trace_path | wc -l) |
| 1828 | |
| 1829 | if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then |
| 1830 | pass "Trace match with $total event $event_name" |
| 1831 | else |
| 1832 | fail "Trace match" |
| 1833 | diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count" |
| 1834 | fi |
| 1835 | } |
| 1836 | |
| 1837 | function validate_trace |
| 1838 | { |
| 1839 | local event_name=$1 |
| 1840 | local trace_path=$2 |
| 1841 | |
| 1842 | which $BABELTRACE_BIN >/dev/null |
| 1843 | if [ $? -ne 0 ]; then |
| 1844 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1845 | fi |
| 1846 | |
| 1847 | OLDIFS=$IFS |
| 1848 | IFS="," |
| 1849 | for i in $event_name; do |
| 1850 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) |
| 1851 | if [ "$traced" -ne 0 ]; then |
| 1852 | pass "Validate trace for event $i, $traced events" |
| 1853 | else |
| 1854 | fail "Validate trace for event $i" |
| 1855 | diag "Found $traced occurences of $i" |
| 1856 | fi |
| 1857 | done |
| 1858 | ret=$? |
| 1859 | IFS=$OLDIFS |
| 1860 | return $ret |
| 1861 | } |
| 1862 | |
| 1863 | function validate_trace_count |
| 1864 | { |
| 1865 | local event_name=$1 |
| 1866 | local trace_path=$2 |
| 1867 | local expected_count=$3 |
| 1868 | |
| 1869 | which $BABELTRACE_BIN >/dev/null |
| 1870 | if [ $? -ne 0 ]; then |
| 1871 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1872 | fi |
| 1873 | |
| 1874 | cnt=0 |
| 1875 | OLDIFS=$IFS |
| 1876 | IFS="," |
| 1877 | for i in $event_name; do |
| 1878 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) |
| 1879 | if [ "$traced" -ne 0 ]; then |
| 1880 | pass "Validate trace for event $i, $traced events" |
| 1881 | else |
| 1882 | fail "Validate trace for event $i" |
| 1883 | diag "Found $traced occurences of $i" |
| 1884 | fi |
| 1885 | cnt=$(($cnt + $traced)) |
| 1886 | done |
| 1887 | IFS=$OLDIFS |
| 1888 | test $cnt -eq $expected_count |
| 1889 | ok $? "Read a total of $cnt events, expected $expected_count" |
| 1890 | } |
| 1891 | |
| 1892 | function validate_trace_count_range_incl_min_excl_max |
| 1893 | { |
| 1894 | local event_name=$1 |
| 1895 | local trace_path=$2 |
| 1896 | local expected_min=$3 |
| 1897 | local expected_max=$4 |
| 1898 | |
| 1899 | which $BABELTRACE_BIN >/dev/null |
| 1900 | if [ $? -ne 0 ]; then |
| 1901 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1902 | fi |
| 1903 | |
| 1904 | cnt=0 |
| 1905 | OLDIFS=$IFS |
| 1906 | IFS="," |
| 1907 | for i in $event_name; do |
| 1908 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) |
| 1909 | if [ "$traced" -ge $expected_min ]; then |
| 1910 | pass "Validate trace for event $i, $traced events" |
| 1911 | else |
| 1912 | fail "Validate trace for event $i" |
| 1913 | diag "Found $traced occurences of $i" |
| 1914 | fi |
| 1915 | cnt=$(($cnt + $traced)) |
| 1916 | done |
| 1917 | IFS=$OLDIFS |
| 1918 | test $cnt -lt $expected_max |
| 1919 | ok $? "Read a total of $cnt events, expected between [$expected_min, $expected_max[" |
| 1920 | } |
| 1921 | |
| 1922 | function trace_first_line |
| 1923 | { |
| 1924 | local trace_path=$1 |
| 1925 | |
| 1926 | which $BABELTRACE_BIN >/dev/null |
| 1927 | if [ $? -ne 0 ]; then |
| 1928 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1929 | fi |
| 1930 | |
| 1931 | $BABELTRACE_BIN $trace_path 2>/dev/null | head -n 1 |
| 1932 | } |
| 1933 | |
| 1934 | function validate_trace_exp() |
| 1935 | { |
| 1936 | local event_exp=$1 |
| 1937 | local trace_path=$2 |
| 1938 | |
| 1939 | which $BABELTRACE_BIN >/dev/null |
| 1940 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation" |
| 1941 | |
| 1942 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep --extended-regexp ${event_exp} | wc -l) |
| 1943 | if [ "$traced" -ne 0 ]; then |
| 1944 | pass "Validate trace for expression '${event_exp}', $traced events" |
| 1945 | else |
| 1946 | fail "Validate trace for expression '${event_exp}'" |
| 1947 | diag "Found $traced occurences of '${event_exp}'" |
| 1948 | fi |
| 1949 | ret=$? |
| 1950 | return $ret |
| 1951 | } |
| 1952 | |
| 1953 | function validate_trace_only_exp() |
| 1954 | { |
| 1955 | local event_exp=$1 |
| 1956 | local trace_path=$2 |
| 1957 | |
| 1958 | which $BABELTRACE_BIN >/dev/null |
| 1959 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1960 | |
| 1961 | local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp ${event_exp} | wc -l) |
| 1962 | local total=$($BABELTRACE_BIN $trace_path | wc -l) |
| 1963 | |
| 1964 | if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then |
| 1965 | pass "Trace match with $total for expression '${event_exp}'" |
| 1966 | else |
| 1967 | fail "Trace match" |
| 1968 | diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected" |
| 1969 | fi |
| 1970 | ret=$? |
| 1971 | return $ret |
| 1972 | } |
| 1973 | |
| 1974 | function validate_trace_empty() |
| 1975 | { |
| 1976 | local trace_path=$1 |
| 1977 | |
| 1978 | which $BABELTRACE_BIN >/dev/null |
| 1979 | if [ $? -ne 0 ]; then |
| 1980 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1981 | fi |
| 1982 | |
| 1983 | events=$($BABELTRACE_BIN $trace_path 2>/dev/null) |
| 1984 | ret=$? |
| 1985 | if [ $ret -ne 0 ]; then |
| 1986 | fail "Failed to parse trace" |
| 1987 | return $ret |
| 1988 | fi |
| 1989 | |
| 1990 | traced=$(echo -n "$events" | wc -l) |
| 1991 | if [ "$traced" -eq 0 ]; then |
| 1992 | pass "Validate empty trace" |
| 1993 | else |
| 1994 | fail "Validate empty trace" |
| 1995 | diag "Found $traced events in trace" |
| 1996 | fi |
| 1997 | ret=$? |
| 1998 | return $ret |
| 1999 | } |
| 2000 | |
| 2001 | function validate_directory_empty () |
| 2002 | { |
| 2003 | local trace_path="$1" |
| 2004 | |
| 2005 | # Do not double quote `$trace_path` below as we want wildcards to be |
| 2006 | # expanded. |
| 2007 | files="$(ls -A $trace_path)" |
| 2008 | ret=$? |
| 2009 | if [ $ret -ne 0 ]; then |
| 2010 | fail "Failed to list content of directory \"$trace_path\"" |
| 2011 | return $ret |
| 2012 | fi |
| 2013 | |
| 2014 | nb_files="$(echo -n "$files" | wc -l)" |
| 2015 | ok $nb_files "Directory \"$trace_path\" is empty" |
| 2016 | } |
| 2017 | |
| 2018 | function validate_trace_session_ust_empty() |
| 2019 | { |
| 2020 | validate_directory_empty "$1"/ust |
| 2021 | } |
| 2022 | |
| 2023 | function validate_trace_session_kernel_empty() |
| 2024 | { |
| 2025 | validate_trace_empty "$1"/kernel |
| 2026 | } |
| 2027 | |
| 2028 | function regenerate_metadata () |
| 2029 | { |
| 2030 | local expected_to_fail=$1 |
| 2031 | local sess_name=$2 |
| 2032 | |
| 2033 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate metadata -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2034 | ret=$? |
| 2035 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2036 | test "$ret" -ne "0" |
| 2037 | ok $? "Expected fail on regenerate metadata $sess_name" |
| 2038 | else |
| 2039 | ok $ret "Metadata regenerate $sess_name" |
| 2040 | fi |
| 2041 | } |
| 2042 | |
| 2043 | function regenerate_metadata_ok () |
| 2044 | { |
| 2045 | regenerate_metadata 0 "$@" |
| 2046 | } |
| 2047 | |
| 2048 | function regenerate_metadata_fail () |
| 2049 | { |
| 2050 | regenerate_metadata 1 "$@" |
| 2051 | } |
| 2052 | |
| 2053 | function regenerate_statedump () |
| 2054 | { |
| 2055 | local expected_to_fail=$1 |
| 2056 | local sess_name=$2 |
| 2057 | |
| 2058 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate statedump -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2059 | ret=$? |
| 2060 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2061 | test "$ret" -ne "0" |
| 2062 | ok $? "Expected fail on regenerate statedump $sess_name" |
| 2063 | else |
| 2064 | ok $ret "Statedump regenerate $sess_name" |
| 2065 | fi |
| 2066 | } |
| 2067 | |
| 2068 | function regenerate_statedump_ok () |
| 2069 | { |
| 2070 | regenerate_statedump 0 "$@" |
| 2071 | } |
| 2072 | |
| 2073 | function regenerate_statedump_fail () |
| 2074 | { |
| 2075 | regenerate_statedump 1 "$@" |
| 2076 | } |
| 2077 | |
| 2078 | function rotate_session () |
| 2079 | { |
| 2080 | local expected_to_fail=$1 |
| 2081 | local sess_name=$2 |
| 2082 | |
| 2083 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN rotate $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2084 | ret=$? |
| 2085 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2086 | test "$ret" -ne "0" |
| 2087 | ok $? "Expected fail on rotate session $sess_name" |
| 2088 | else |
| 2089 | ok $ret "Rotate session $sess_name" |
| 2090 | fi |
| 2091 | } |
| 2092 | |
| 2093 | function rotate_session_ok () |
| 2094 | { |
| 2095 | rotate_session 0 "$@" |
| 2096 | } |
| 2097 | |
| 2098 | function rotate_session_fail () |
| 2099 | { |
| 2100 | rotate_session 1 "$@" |
| 2101 | } |
| 2102 | |
| 2103 | function destructive_tests_enabled () |
| 2104 | { |
| 2105 | if [ "$LTTNG_ENABLE_DESTRUCTIVE_TESTS" = "will-break-my-system" ]; then |
| 2106 | return 0 |
| 2107 | else |
| 2108 | return 1 |
| 2109 | fi |
| 2110 | } |
| 2111 | |
| 2112 | function lttng_enable_rotation_timer () |
| 2113 | { |
| 2114 | local expected_to_fail=$1 |
| 2115 | local sess_name=$2 |
| 2116 | local period=$3 |
| 2117 | |
| 2118 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2119 | ret=$? |
| 2120 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2121 | test "$ret" -ne "0" |
| 2122 | ok $? "Expected fail when setting periodic rotation ($period) of session $sess_name" |
| 2123 | else |
| 2124 | ok $ret "Set periodic rotation ($period) of session $sess_name" |
| 2125 | fi |
| 2126 | } |
| 2127 | |
| 2128 | function lttng_enable_rotation_timer_ok () |
| 2129 | { |
| 2130 | lttng_enable_rotation_timer 0 $@ |
| 2131 | } |
| 2132 | |
| 2133 | function lttng_enable_rotation_timer_fail () |
| 2134 | { |
| 2135 | lttng_enable_rotation_timer 1 $@ |
| 2136 | } |
| 2137 | |
| 2138 | function lttng_enable_rotation_size () |
| 2139 | { |
| 2140 | local expected_to_fail=$1 |
| 2141 | local sess_name=$2 |
| 2142 | local size=$3 |
| 2143 | |
| 2144 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2145 | ret=$? |
| 2146 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2147 | test "$ret" -ne "0" |
| 2148 | ok $? "Expected fail on rotate session $sess_name" |
| 2149 | else |
| 2150 | ok $ret "Rotate session $sess_name" |
| 2151 | fi |
| 2152 | } |
| 2153 | |
| 2154 | function lttng_enable_rotation_size_ok () |
| 2155 | { |
| 2156 | lttng_enable_rotation_size 0 $@ |
| 2157 | } |
| 2158 | |
| 2159 | function lttng_enable_rotation_size_fail () |
| 2160 | { |
| 2161 | lttng_enable_rotation_size 1 $@ |
| 2162 | } |
| 2163 | |
| 2164 | function lttng_clear_session () |
| 2165 | { |
| 2166 | local expected_to_fail=$1 |
| 2167 | local sess_name=$2 |
| 2168 | |
| 2169 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN clear $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2170 | ret=$? |
| 2171 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2172 | test "$ret" -ne "0" |
| 2173 | ok $? "Expected fail on clear session $sess_name" |
| 2174 | else |
| 2175 | ok $ret "Clear session $sess_name" |
| 2176 | fi |
| 2177 | } |
| 2178 | |
| 2179 | function lttng_clear_session_ok () |
| 2180 | { |
| 2181 | lttng_clear_session 0 $@ |
| 2182 | } |
| 2183 | |
| 2184 | function lttng_clear_session_fail () |
| 2185 | { |
| 2186 | lttng_clear_session 1 $@ |
| 2187 | } |
| 2188 | |
| 2189 | function lttng_clear_all () |
| 2190 | { |
| 2191 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 2192 | ok $? "Clear all lttng sessions" |
| 2193 | } |
| 2194 | |
| 2195 | function lttng_add_trigger() |
| 2196 | { |
| 2197 | local expected_to_fail="$1" |
| 2198 | local trigger_name="$2" |
| 2199 | shift 2 |
| 2200 | local args=("$@") |
| 2201 | |
| 2202 | diag "$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}" |
| 2203 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name "$trigger_name" "${args[@]}" 1> /dev/null 2> /dev/null |
| 2204 | ret=$? |
| 2205 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2206 | test "$ret" -ne "0" |
| 2207 | ok $? "Add trigger $trigger_name failed as expected" |
| 2208 | else |
| 2209 | ok $ret "Add trigger $trigger_name" |
| 2210 | fi |
| 2211 | } |
| 2212 | |
| 2213 | function lttng_remove_trigger() |
| 2214 | { |
| 2215 | local expected_to_fail="$1" |
| 2216 | local trigger_name="$2" |
| 2217 | shift 2 |
| 2218 | |
| 2219 | diag "$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name $*" |
| 2220 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" remove-trigger "$trigger_name" "$@" 1> /dev/null 2> /dev/null |
| 2221 | ret=$? |
| 2222 | if [[ $expected_to_fail -eq "1" ]]; then |
| 2223 | test "$ret" -ne "0" |
| 2224 | ok $? "Remove trigger $trigger_name failed as expected" |
| 2225 | else |
| 2226 | ok $ret "Remove trigger $trigger_name" |
| 2227 | fi |
| 2228 | } |
| 2229 | |
| 2230 | function lttng_add_trigger_ok() |
| 2231 | { |
| 2232 | lttng_add_trigger 0 "$@" |
| 2233 | } |
| 2234 | |
| 2235 | function lttng_add_trigger_fail() |
| 2236 | { |
| 2237 | lttng_add_trigger 1 "$@" |
| 2238 | } |
| 2239 | |
| 2240 | function lttng_remove_trigger_ok() |
| 2241 | { |
| 2242 | lttng_remove_trigger 0 "$@" |
| 2243 | } |