| 1 | # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com> |
| 2 | # |
| 3 | # This library is free software; you can redistribute it and/or modify it under |
| 4 | # the terms of the GNU Lesser General Public License as published by the Free |
| 5 | # Software Foundation; version 2.1 of the License. |
| 6 | # |
| 7 | # This library is distributed in the hope that it will be useful, but WITHOUT |
| 8 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 9 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 10 | # details. |
| 11 | # |
| 12 | # You should have received a copy of the GNU Lesser General Public License |
| 13 | # along with this library; if not, write to the Free Software Foundation, Inc., |
| 14 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | |
| 16 | SESSIOND_BIN="lttng-sessiond" |
| 17 | SESSIOND_MATCH=".*lttng-sess.*" |
| 18 | SESSIOND_PIDS="" |
| 19 | RUNAS_BIN="lttng-runas" |
| 20 | RUNAS_MATCH=".*lttng-runas.*" |
| 21 | CONSUMERD_BIN="lttng-consumerd" |
| 22 | CONSUMERD_MATCH=".*lttng-consumerd.*" |
| 23 | RELAYD_BIN="lttng-relayd" |
| 24 | RELAYD_MATCH=".*lttng-relayd.*" |
| 25 | RELAYD_PIDS="" |
| 26 | LTTNG_BIN="lttng" |
| 27 | BABELTRACE_BIN="babeltrace" |
| 28 | OUTPUT_DEST=/dev/null |
| 29 | ERROR_OUTPUT_DEST=/dev/null |
| 30 | |
| 31 | # Minimal kernel version supported for session daemon tests |
| 32 | KERNEL_MAJOR_VERSION=2 |
| 33 | KERNEL_MINOR_VERSION=6 |
| 34 | KERNEL_PATCHLEVEL_VERSION=27 |
| 35 | |
| 36 | # We set the default UST register timeout and network and app socket timeout to |
| 37 | # "wait forever", so that basic tests don't have to worry about hitting |
| 38 | # timeouts on busy systems. Specialized tests should test those corner-cases. |
| 39 | export LTTNG_UST_REGISTER_TIMEOUT=-1 |
| 40 | export LTTNG_NETWORK_SOCKET_TIMEOUT=-1 |
| 41 | export LTTNG_APP_SOCKET_TIMEOUT=-1 |
| 42 | |
| 43 | # We set the default lttng-sessiond path to /bin/true to prevent the spawning |
| 44 | # of a daemonized sessiond. This is necessary since 'lttng create' will spawn |
| 45 | # its own sessiond if none is running. It also ensures that 'lttng create' |
| 46 | # fails when no sessiond is running. |
| 47 | export LTTNG_SESSIOND_PATH="/bin/true" |
| 48 | |
| 49 | source $TESTDIR/utils/tap/tap.sh |
| 50 | |
| 51 | function full_cleanup () |
| 52 | { |
| 53 | if [ -n "${SESSIOND_PIDS}" ] || [ -n "${RELAYD_PIDS}" ]; then |
| 54 | kill -9 ${SESSIOND_PIDS} ${RELAYD_PIDS} > /dev/null 2>&1 |
| 55 | fi |
| 56 | |
| 57 | # Disable trap for SIGTERM since the following kill to the |
| 58 | # pidgroup will be SIGTERM. Otherwise it loops. |
| 59 | # The '-' before the pid number ($$) indicates 'kill' to signal the |
| 60 | # whole process group. |
| 61 | trap - SIGTERM && kill -- -$$ |
| 62 | } |
| 63 | |
| 64 | |
| 65 | trap full_cleanup SIGINT SIGTERM |
| 66 | |
| 67 | function print_ok () |
| 68 | { |
| 69 | # Check if we are a terminal |
| 70 | if [ -t 1 ]; then |
| 71 | echo -e "\e[1;32mOK\e[0m" |
| 72 | else |
| 73 | echo -e "OK" |
| 74 | fi |
| 75 | } |
| 76 | |
| 77 | function print_fail () |
| 78 | { |
| 79 | # Check if we are a terminal |
| 80 | if [ -t 1 ]; then |
| 81 | echo -e "\e[1;31mFAIL\e[0m" |
| 82 | else |
| 83 | echo -e "FAIL" |
| 84 | fi |
| 85 | } |
| 86 | |
| 87 | function print_test_banner () |
| 88 | { |
| 89 | local desc="$1" |
| 90 | diag "$desc" |
| 91 | } |
| 92 | |
| 93 | function validate_kernel_version () |
| 94 | { |
| 95 | local kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n')) |
| 96 | if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then |
| 97 | return 0 |
| 98 | fi |
| 99 | if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then |
| 100 | return 0 |
| 101 | fi |
| 102 | if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then |
| 103 | return 0 |
| 104 | fi |
| 105 | return 1 |
| 106 | } |
| 107 | |
| 108 | # Generate a random string |
| 109 | # $1 = number of characters; defaults to 16 |
| 110 | # $2 = include special characters; 1 = yes, 0 = no; defaults to yes |
| 111 | function randstring() |
| 112 | { |
| 113 | [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]" |
| 114 | cat /dev/urandom 2>/dev/null | tr -cd "$CHAR" 2>/dev/null | head -c ${1:-16} 2>/dev/null |
| 115 | echo |
| 116 | } |
| 117 | |
| 118 | # Return the number of _configured_ CPUs. |
| 119 | function conf_proc_count() |
| 120 | { |
| 121 | getconf _NPROCESSORS_CONF |
| 122 | if [ $? -ne 0 ]; then |
| 123 | diag "Failed to get the number of configured CPUs" |
| 124 | fi |
| 125 | echo |
| 126 | } |
| 127 | |
| 128 | # Check if base lttng-modules are present. |
| 129 | # Bail out on failure |
| 130 | function validate_lttng_modules_present () |
| 131 | { |
| 132 | modprobe -n lttng-tracer 2>/dev/null |
| 133 | if [ $? -ne 0 ]; then |
| 134 | BAIL_OUT "LTTng modules not detected." |
| 135 | fi |
| 136 | } |
| 137 | |
| 138 | function enable_kernel_lttng_event |
| 139 | { |
| 140 | local withtap="$1" |
| 141 | local expected_to_fail="$2" |
| 142 | local sess_name="$3" |
| 143 | local event_name="$4" |
| 144 | local channel_name="$5" |
| 145 | |
| 146 | if [ -z "$event_name" ]; then |
| 147 | # Enable all event if no event name specified |
| 148 | event_name="-a" |
| 149 | fi |
| 150 | |
| 151 | if [ -z "$channel_name" ]; then |
| 152 | # default channel if none specified |
| 153 | chan="" |
| 154 | else |
| 155 | chan="-c $channel_name" |
| 156 | fi |
| 157 | |
| 158 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 159 | ret=$? |
| 160 | if [[ $expected_to_fail -eq "1" ]]; then |
| 161 | test $ret -ne "0" |
| 162 | ret=$? |
| 163 | if [ $withtap -eq "1" ]; then |
| 164 | ok $ret "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected" |
| 165 | fi |
| 166 | else |
| 167 | if [ $withtap -eq "1" ]; then |
| 168 | ok $ret "Enable kernel event $event_name for session $sess_name" |
| 169 | fi |
| 170 | fi |
| 171 | } |
| 172 | |
| 173 | function enable_kernel_lttng_event_ok () |
| 174 | { |
| 175 | enable_kernel_lttng_event 1 0 "$@" |
| 176 | } |
| 177 | |
| 178 | function enable_kernel_lttng_event_fail () |
| 179 | { |
| 180 | enable_kernel_lttng_event 1 1 "$@" |
| 181 | } |
| 182 | |
| 183 | function enable_kernel_lttng_event_notap () |
| 184 | { |
| 185 | enable_kernel_lttng_event 0 0 "$@" |
| 186 | } |
| 187 | |
| 188 | # Old interface |
| 189 | function lttng_enable_kernel_event |
| 190 | { |
| 191 | enable_kernel_lttng_event_ok "$@" |
| 192 | } |
| 193 | |
| 194 | function lttng_enable_kernel_syscall() |
| 195 | { |
| 196 | local expected_to_fail=$1 |
| 197 | local sess_name=$2 |
| 198 | local syscall_name=$3 |
| 199 | local channel_name=$4 |
| 200 | |
| 201 | if [ -z $syscall_name ]; then |
| 202 | # Enable all event if no syscall name specified |
| 203 | syscall_name="-a" |
| 204 | fi |
| 205 | |
| 206 | if [ -z $channel_name ]; then |
| 207 | # default channel if none specified |
| 208 | chan="" |
| 209 | else |
| 210 | chan="-c $channel_name" |
| 211 | fi |
| 212 | |
| 213 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 214 | ret=$? |
| 215 | if [[ $expected_to_fail -eq "1" ]]; then |
| 216 | test $ret -ne "0" |
| 217 | ok $? "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name fail as expected" |
| 218 | else |
| 219 | ok $ret "Enable kernel syscall $syscall_name for session $sess_name on channel $channel_name" |
| 220 | fi |
| 221 | } |
| 222 | |
| 223 | function lttng_enable_kernel_syscall_ok() |
| 224 | { |
| 225 | lttng_enable_kernel_syscall 0 "$@" |
| 226 | } |
| 227 | |
| 228 | function lttng_enable_kernel_syscall_fail() |
| 229 | { |
| 230 | lttng_enable_kernel_syscall 1 "$@" |
| 231 | } |
| 232 | |
| 233 | function lttng_disable_kernel_syscall() |
| 234 | { |
| 235 | local expected_to_fail=$1 |
| 236 | local sess_name=$2 |
| 237 | local syscall_name=$3 |
| 238 | local channel_name=$4 |
| 239 | |
| 240 | if [ -z $syscall_name ]; then |
| 241 | # Enable all event if no syscall name specified |
| 242 | syscall_name="-a" |
| 243 | fi |
| 244 | |
| 245 | if [ -z $channel_name ]; then |
| 246 | # default channel if none specified |
| 247 | chan="" |
| 248 | else |
| 249 | chan="-c $channel_name" |
| 250 | fi |
| 251 | |
| 252 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event --syscall "$syscall_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 253 | |
| 254 | ret=$? |
| 255 | if [[ $expected_to_fail -eq "1" ]]; then |
| 256 | test $ret -ne "0" |
| 257 | ok $? "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name failed as expected" |
| 258 | else |
| 259 | ok $ret "Disable kernel syscall $syscall_name for session $sess_name on channel $channel_name" |
| 260 | fi |
| 261 | } |
| 262 | |
| 263 | function lttng_disable_kernel_syscall_ok() |
| 264 | { |
| 265 | lttng_disable_kernel_syscall 0 "$@" |
| 266 | } |
| 267 | |
| 268 | function lttng_disable_kernel_syscall_fail() |
| 269 | { |
| 270 | lttng_disable_kernel_syscall 1 "$@" |
| 271 | } |
| 272 | |
| 273 | function lttng_enable_kernel_channel() |
| 274 | { |
| 275 | local withtap=$1 |
| 276 | local expected_to_fail=$2 |
| 277 | local sess_name=$3 |
| 278 | local channel_name=$4 |
| 279 | local opt=$5 |
| 280 | |
| 281 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 282 | ret=$? |
| 283 | if [[ $expected_to_fail -eq "1" ]]; then |
| 284 | test "$ret" -ne "0" |
| 285 | ret=$? |
| 286 | if [ $withtap -eq "1" ]; then |
| 287 | ok $ret "Enable channel $channel_name for session $sess_name failed as expected" |
| 288 | fi |
| 289 | else |
| 290 | if [ $withtap -eq "1" ]; then |
| 291 | ok $ret "Enable channel $channel_name for session $sess_name" |
| 292 | fi |
| 293 | fi |
| 294 | } |
| 295 | |
| 296 | function lttng_enable_kernel_channel_ok() |
| 297 | { |
| 298 | lttng_enable_kernel_channel 1 0 "$@" |
| 299 | } |
| 300 | |
| 301 | function lttng_enable_kernel_channel_fail() |
| 302 | { |
| 303 | lttng_enable_kernel_channel 1 1 "$@" |
| 304 | } |
| 305 | |
| 306 | function lttng_enable_kernel_channel_notap() |
| 307 | { |
| 308 | lttng_enable_kernel_channel 0 0 "$@" |
| 309 | } |
| 310 | |
| 311 | function enable_kernel_lttng_channel_ok() |
| 312 | { |
| 313 | lttng_enable_kernel_channel 1 0 "$@" |
| 314 | } |
| 315 | |
| 316 | function lttng_disable_kernel_channel() |
| 317 | { |
| 318 | local expected_to_fail=$1 |
| 319 | local sess_name=$2 |
| 320 | local channel_name=$3 |
| 321 | |
| 322 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -k $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 323 | ret=$? |
| 324 | if [[ $expected_to_fail -eq "1" ]]; then |
| 325 | test "$ret" -ne "0" |
| 326 | ok $? "Disable channel $channel_name for session $sess_name failed as expected" |
| 327 | else |
| 328 | ok $ret "Disable channel $channel_name for session $sess_name" |
| 329 | fi |
| 330 | } |
| 331 | |
| 332 | function lttng_disable_kernel_channel_ok() |
| 333 | { |
| 334 | lttng_disable_kernel_channel 0 "$@" |
| 335 | } |
| 336 | |
| 337 | function lttng_disable_kernel_channel_fail() |
| 338 | { |
| 339 | lttng_disable_kernel_channel 1 "$@" |
| 340 | } |
| 341 | |
| 342 | function start_lttng_relayd_opt() |
| 343 | { |
| 344 | local withtap=$1 |
| 345 | local opt=$2 |
| 346 | |
| 347 | DIR=$(readlink -f $TESTDIR) |
| 348 | |
| 349 | if [ -z $(pgrep $RELAYD_MATCH) ]; then |
| 350 | $DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 351 | #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 & |
| 352 | if [ $? -eq 1 ]; then |
| 353 | if [ $withtap -eq "1" ]; then |
| 354 | fail "Start lttng-relayd (opt: $opt)" |
| 355 | fi |
| 356 | return 1 |
| 357 | else |
| 358 | if [ $withtap -eq "1" ]; then |
| 359 | pass "Start lttng-relayd (opt: $opt)" |
| 360 | fi |
| 361 | fi |
| 362 | else |
| 363 | pass "Start lttng-relayd (opt: $opt)" |
| 364 | fi |
| 365 | |
| 366 | RELAYD_PIDS=$(pgrep $RELAYD_MATCH) |
| 367 | } |
| 368 | |
| 369 | function start_lttng_relayd() |
| 370 | { |
| 371 | start_lttng_relayd_opt 1 "$@" |
| 372 | } |
| 373 | |
| 374 | function start_lttng_relayd_notap() |
| 375 | { |
| 376 | start_lttng_relayd_opt 0 "$@" |
| 377 | } |
| 378 | |
| 379 | function stop_lttng_relayd_opt() |
| 380 | { |
| 381 | local withtap=$1 |
| 382 | |
| 383 | if [ $withtap -eq "1" ]; then |
| 384 | diag "Killing lttng-relayd (pid: $RELAYD_PIDS)" |
| 385 | fi |
| 386 | kill $RELAYD_PIDS 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 387 | retval=$? |
| 388 | |
| 389 | if [ $? -eq 1 ]; then |
| 390 | if [ $withtap -eq "1" ]; then |
| 391 | fail "Kill relay daemon" |
| 392 | fi |
| 393 | return 1 |
| 394 | else |
| 395 | out=1 |
| 396 | while [ -n "$out" ]; do |
| 397 | out=$(pgrep $RELAYD_MATCH) |
| 398 | sleep 0.5 |
| 399 | done |
| 400 | if [ $withtap -eq "1" ]; then |
| 401 | pass "Kill relay daemon" |
| 402 | fi |
| 403 | fi |
| 404 | RELAYD_PIDS="" |
| 405 | return $retval |
| 406 | } |
| 407 | |
| 408 | function stop_lttng_relayd() |
| 409 | { |
| 410 | stop_lttng_relayd_opt 1 "$@" |
| 411 | } |
| 412 | |
| 413 | function stop_lttng_relayd_notap() |
| 414 | { |
| 415 | stop_lttng_relayd_opt 0 "$@" |
| 416 | } |
| 417 | |
| 418 | #First arg: show tap output |
| 419 | #Second argument: load path for automatic loading |
| 420 | function start_lttng_sessiond_opt() |
| 421 | { |
| 422 | local withtap=$1 |
| 423 | local load_path=$2 |
| 424 | |
| 425 | local env_vars="" |
| 426 | local consumerd="" |
| 427 | local long_bit_value=$(getconf LONG_BIT) |
| 428 | |
| 429 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
| 430 | # Env variable requested no session daemon |
| 431 | return |
| 432 | fi |
| 433 | |
| 434 | DIR=$(readlink -f $TESTDIR) |
| 435 | |
| 436 | # Get long_bit value for 32/64 consumerd |
| 437 | case "$long_bit_value" in |
| 438 | 32) |
| 439 | consumerd="--consumerd32-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd" |
| 440 | ;; |
| 441 | 64) |
| 442 | consumerd="--consumerd64-path=$DIR/../src/bin/lttng-consumerd/lttng-consumerd" |
| 443 | ;; |
| 444 | *) |
| 445 | return |
| 446 | ;; |
| 447 | esac |
| 448 | |
| 449 | # Check for env. variable. Allow the use of LD_PRELOAD etc. |
| 450 | if [[ "x${LTTNG_SESSIOND_ENV_VARS}" != "x" ]]; then |
| 451 | env_vars=${LTTNG_SESSIOND_ENV_VARS} |
| 452 | fi |
| 453 | |
| 454 | validate_kernel_version |
| 455 | if [ $? -ne 0 ]; then |
| 456 | fail "Start session daemon" |
| 457 | BAIL_OUT "*** Kernel too old for session daemon tests ***" |
| 458 | fi |
| 459 | |
| 460 | : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/} |
| 461 | export LTTNG_SESSION_CONFIG_XSD_PATH |
| 462 | |
| 463 | if [ -z $(pgrep ${SESSIOND_MATCH}) ]; then |
| 464 | # Have a load path ? |
| 465 | if [ -n "$load_path" ]; then |
| 466 | env $env_vars $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$load_path" --background $consumerd |
| 467 | else |
| 468 | env $env_vars $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background $consumerd |
| 469 | fi |
| 470 | #$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 |
| 471 | status=$? |
| 472 | if [ $withtap -eq "1" ]; then |
| 473 | ok $status "Start session daemon" |
| 474 | fi |
| 475 | fi |
| 476 | SESSIOND_PIDS=$(pgrep $SESSIOND_MATCH) |
| 477 | } |
| 478 | |
| 479 | function start_lttng_sessiond() |
| 480 | { |
| 481 | start_lttng_sessiond_opt 1 "$@" |
| 482 | } |
| 483 | |
| 484 | function start_lttng_sessiond_notap() |
| 485 | { |
| 486 | start_lttng_sessiond_opt 0 "$@" |
| 487 | } |
| 488 | |
| 489 | function stop_lttng_sessiond_opt() |
| 490 | { |
| 491 | local withtap=$1 |
| 492 | local signal=$2 |
| 493 | local kill_opt="" |
| 494 | |
| 495 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
| 496 | # Env variable requested no session daemon |
| 497 | return |
| 498 | fi |
| 499 | |
| 500 | local pids="${SESSIOND_PIDS} $(pgrep $RUNAS_MATCH)" |
| 501 | |
| 502 | if [ -n "$2" ]; then |
| 503 | kill_opt="$kill_opt -s $signal" |
| 504 | fi |
| 505 | if [ $withtap -eq "1" ]; then |
| 506 | diag "Killing $SESSIOND_BIN and lt-$SESSIOND_BIN pids: $(echo $pids | tr '\n' ' ')" |
| 507 | fi |
| 508 | kill $kill_opt $pids 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 509 | |
| 510 | if [ $? -eq 1 ]; then |
| 511 | if [ $withtap -eq "1" ]; then |
| 512 | fail "Kill sessions daemon" |
| 513 | fi |
| 514 | else |
| 515 | out=1 |
| 516 | while [ -n "$out" ]; do |
| 517 | out=$(pgrep ${SESSIOND_MATCH}) |
| 518 | sleep 0.5 |
| 519 | done |
| 520 | out=1 |
| 521 | while [ -n "$out" ]; do |
| 522 | out=$(pgrep $CONSUMERD_MATCH) |
| 523 | sleep 0.5 |
| 524 | done |
| 525 | |
| 526 | SESSIOND_PIDS="" |
| 527 | if [ $withtap -eq "1" ]; then |
| 528 | pass "Kill session daemon" |
| 529 | fi |
| 530 | fi |
| 531 | } |
| 532 | |
| 533 | function stop_lttng_sessiond() |
| 534 | { |
| 535 | stop_lttng_sessiond_opt 1 "$@" |
| 536 | } |
| 537 | |
| 538 | function stop_lttng_sessiond_notap() |
| 539 | { |
| 540 | stop_lttng_sessiond_opt 0 "$@" |
| 541 | } |
| 542 | |
| 543 | function sigstop_lttng_sessiond_opt() |
| 544 | { |
| 545 | local withtap=$1 |
| 546 | local signal=SIGSTOP |
| 547 | local kill_opt="" |
| 548 | |
| 549 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
| 550 | # Env variable requested no session daemon |
| 551 | return |
| 552 | fi |
| 553 | |
| 554 | PID_SESSIOND="$(pgrep ${SESSIOND_MATCH}) $(pgrep $RUNAS_MATCH)" |
| 555 | |
| 556 | kill_opt="$kill_opt -s $signal" |
| 557 | |
| 558 | if [ $withtap -eq "1" ]; then |
| 559 | diag "Sending SIGSTOP to lt-$SESSIOND_BIN and $SESSIOND_BIN pids: $(echo $PID_SESSIOND | tr '\n' ' ')" |
| 560 | fi |
| 561 | kill $kill_opt $PID_SESSIOND 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 562 | |
| 563 | if [ $? -eq 1 ]; then |
| 564 | if [ $withtap -eq "1" ]; then |
| 565 | fail "Sending SIGSTOP to session daemon" |
| 566 | fi |
| 567 | else |
| 568 | out=1 |
| 569 | while [ $out -ne 0 ]; do |
| 570 | pid=$(pgrep $SESSIOND_MATCH) |
| 571 | |
| 572 | # Wait until state becomes stopped for session |
| 573 | # daemon(s). |
| 574 | out=0 |
| 575 | for sessiond_pid in $pid; do |
| 576 | state=$(ps -p $sessiond_pid -o state= ) |
| 577 | if [[ -n "$state" && "$state" != "T" ]]; then |
| 578 | out=1 |
| 579 | fi |
| 580 | done |
| 581 | sleep 0.5 |
| 582 | done |
| 583 | if [ $withtap -eq "1" ]; then |
| 584 | pass "Sending SIGSTOP to session daemon" |
| 585 | fi |
| 586 | fi |
| 587 | } |
| 588 | |
| 589 | function sigstop_lttng_sessiond() |
| 590 | { |
| 591 | sigstop_lttng_sessiond_opt 1 "$@" |
| 592 | } |
| 593 | |
| 594 | function sigstop_lttng_sessiond_notap() |
| 595 | { |
| 596 | sigstop_lttng_sessiond_opt 0 "$@" |
| 597 | } |
| 598 | |
| 599 | function stop_lttng_consumerd_opt() |
| 600 | { |
| 601 | local withtap=$1 |
| 602 | local signal=$2 |
| 603 | local kill_opt="" |
| 604 | |
| 605 | PID_CONSUMERD=$(pgrep $CONSUMERD_MATCH) |
| 606 | |
| 607 | if [ -n "$2" ]; then |
| 608 | kill_opt="$kill_opt -s $signal" |
| 609 | fi |
| 610 | |
| 611 | if [ $withtap -eq "1" ]; then |
| 612 | diag "Killing $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')" |
| 613 | fi |
| 614 | kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 615 | retval=$? |
| 616 | set +x |
| 617 | |
| 618 | if [ $? -eq 1 ]; then |
| 619 | if [ $withtap -eq "1" ]; then |
| 620 | fail "Kill consumer daemon" |
| 621 | fi |
| 622 | return 1 |
| 623 | else |
| 624 | out=1 |
| 625 | while [ $out -ne 0 ]; do |
| 626 | pid=$(pgrep $CONSUMERD_MATCH) |
| 627 | |
| 628 | # If consumerds are still present check their status. |
| 629 | # A zombie status qualifies the consumerd as *killed* |
| 630 | out=0 |
| 631 | for consumer_pid in $pid; do |
| 632 | state=$(ps -p $consumer_pid -o state= ) |
| 633 | if [[ -n "$state" && "$state" != "Z" ]]; then |
| 634 | out=1 |
| 635 | fi |
| 636 | done |
| 637 | sleep 0.5 |
| 638 | done |
| 639 | if [ $withtap -eq "1" ]; then |
| 640 | pass "Kill consumer daemon" |
| 641 | fi |
| 642 | fi |
| 643 | return $retval |
| 644 | } |
| 645 | |
| 646 | function stop_lttng_consumerd() |
| 647 | { |
| 648 | stop_lttng_consumerd_opt 1 "$@" |
| 649 | } |
| 650 | |
| 651 | function stop_lttng_consumerd_notap() |
| 652 | { |
| 653 | stop_lttng_consumerd_opt 0 "$@" |
| 654 | } |
| 655 | |
| 656 | function sigstop_lttng_consumerd_opt() |
| 657 | { |
| 658 | local withtap=$1 |
| 659 | local signal=SIGSTOP |
| 660 | local kill_opt="" |
| 661 | |
| 662 | PID_CONSUMERD=$(pgrep $CONSUMERD_MATCH) |
| 663 | |
| 664 | kill_opt="$kill_opt -s $signal" |
| 665 | |
| 666 | if [ $withtap -eq "1" ]; then |
| 667 | diag "Sending SIGSTOP to $CONSUMERD_BIN pids: $(echo $PID_CONSUMERD | tr '\n' ' ')" |
| 668 | fi |
| 669 | kill $kill_opt $PID_CONSUMERD 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 670 | retval=$? |
| 671 | set +x |
| 672 | |
| 673 | if [ $? -eq 1 ]; then |
| 674 | if [ $withtap -eq "1" ]; then |
| 675 | fail "Sending SIGSTOP to consumer daemon" |
| 676 | fi |
| 677 | return 1 |
| 678 | else |
| 679 | out=1 |
| 680 | while [ $out -ne 0 ]; do |
| 681 | pid=$(pgrep $CONSUMERD_MATCH) |
| 682 | |
| 683 | # Wait until state becomes stopped for all |
| 684 | # consumers. |
| 685 | out=0 |
| 686 | for consumer_pid in $pid; do |
| 687 | state=$(ps -p $consumer_pid -o state= ) |
| 688 | if [[ -n "$state" && "$state" != "T" ]]; then |
| 689 | out=1 |
| 690 | fi |
| 691 | done |
| 692 | sleep 0.5 |
| 693 | done |
| 694 | if [ $withtap -eq "1" ]; then |
| 695 | pass "Sending SIGSTOP to consumer daemon" |
| 696 | fi |
| 697 | fi |
| 698 | return $retval |
| 699 | } |
| 700 | |
| 701 | function sigstop_lttng_consumerd() |
| 702 | { |
| 703 | sigstop_lttng_consumerd_opt 1 "$@" |
| 704 | } |
| 705 | |
| 706 | function sigstop_lttng_consumerd_notap() |
| 707 | { |
| 708 | sigstop_lttng_consumerd_opt 0 "$@" |
| 709 | } |
| 710 | |
| 711 | function list_lttng_with_opts () |
| 712 | { |
| 713 | local opts=$1 |
| 714 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 715 | ok $? "Lttng-tool list command with option $opts" |
| 716 | } |
| 717 | |
| 718 | function create_lttng_session_no_output () |
| 719 | { |
| 720 | local sess_name=$1 |
| 721 | |
| 722 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 723 | ok $? "Create session $sess_name in no-output mode" |
| 724 | } |
| 725 | |
| 726 | function create_lttng_session_uri () { |
| 727 | local sess_name=$1 |
| 728 | local uri=$2 |
| 729 | local opts="${@:3}" |
| 730 | |
| 731 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 732 | ok $? "Create session $sess_name with uri:$uri and opts: $opts" |
| 733 | } |
| 734 | |
| 735 | function create_lttng_session () |
| 736 | { |
| 737 | local withtap=$1 |
| 738 | local expected_to_fail=$2 |
| 739 | local sess_name=$3 |
| 740 | local trace_path=$4 |
| 741 | local opt=$5 |
| 742 | |
| 743 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path $opt > $OUTPUT_DEST |
| 744 | ret=$? |
| 745 | if [ $expected_to_fail -eq "1" ]; then |
| 746 | test "$ret" -ne "0" |
| 747 | ret=$? |
| 748 | if [ $withtap -eq "1" ]; then |
| 749 | ok $ret "Create session $sess_name in $trace_path failed as expected" |
| 750 | fi |
| 751 | else |
| 752 | if [ $withtap -eq "1" ]; then |
| 753 | ok $ret "Create session $sess_name in $trace_path" |
| 754 | fi |
| 755 | fi |
| 756 | return $ret |
| 757 | } |
| 758 | |
| 759 | function create_lttng_session_ok () |
| 760 | { |
| 761 | create_lttng_session 1 0 "$@" |
| 762 | } |
| 763 | |
| 764 | function create_lttng_session_fail () |
| 765 | { |
| 766 | create_lttng_session 1 1 "$@" |
| 767 | } |
| 768 | |
| 769 | function create_lttng_session_notap () |
| 770 | { |
| 771 | create_lttng_session 0 0 "$@" |
| 772 | } |
| 773 | |
| 774 | |
| 775 | function enable_ust_lttng_channel () |
| 776 | { |
| 777 | local withtap=$1 |
| 778 | local expected_to_fail=$2 |
| 779 | local sess_name=$3 |
| 780 | local channel_name=$4 |
| 781 | local opt=$5 |
| 782 | |
| 783 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 784 | ret=$? |
| 785 | if [[ $expected_to_fail -eq "1" ]]; then |
| 786 | test "$ret" -ne "0" |
| 787 | ret=$? |
| 788 | if [ $withtap -eq "1" ]; then |
| 789 | ok $ret "Enable channel $channel_name for session $sess_name failed as expected" |
| 790 | fi |
| 791 | else |
| 792 | if [ $withtap -eq "1" ]; then |
| 793 | ok $ret "Enable channel $channel_name for session $sess_name" |
| 794 | fi |
| 795 | fi |
| 796 | return $ret |
| 797 | } |
| 798 | |
| 799 | function enable_ust_lttng_channel_ok () |
| 800 | { |
| 801 | enable_ust_lttng_channel 1 0 "$@" |
| 802 | } |
| 803 | |
| 804 | function enable_ust_lttng_channel_fail () |
| 805 | { |
| 806 | enable_ust_lttng_channel 1 1 "$@" |
| 807 | } |
| 808 | |
| 809 | function enable_ust_lttng_channel_notap () |
| 810 | { |
| 811 | enable_ust_lttng_channel 0 0 "$@" |
| 812 | } |
| 813 | |
| 814 | function disable_ust_lttng_channel() |
| 815 | { |
| 816 | local sess_name=$1 |
| 817 | local channel_name=$2 |
| 818 | |
| 819 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 820 | ok $? "Disable channel $channel_name for session $sess_name" |
| 821 | } |
| 822 | |
| 823 | function enable_lttng_mmap_overwrite_kernel_channel() |
| 824 | { |
| 825 | local sess_name=$1 |
| 826 | local channel_name=$2 |
| 827 | |
| 828 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 829 | ok $? "Enable channel $channel_name for session $sess_name" |
| 830 | } |
| 831 | |
| 832 | function enable_lttng_mmap_discard_small_kernel_channel() |
| 833 | { |
| 834 | local sess_name=$1 |
| 835 | local channel_name=$2 |
| 836 | |
| 837 | $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 |
| 838 | ok $? "Enable small discard channel $channel_name for session $sess_name" |
| 839 | } |
| 840 | |
| 841 | function enable_lttng_mmap_overwrite_small_kernel_channel() |
| 842 | { |
| 843 | local sess_name=$1 |
| 844 | local channel_name=$2 |
| 845 | |
| 846 | $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 |
| 847 | ok $? "Enable small discard channel $channel_name for session $sess_name" |
| 848 | } |
| 849 | |
| 850 | function enable_lttng_mmap_overwrite_ust_channel() |
| 851 | { |
| 852 | local sess_name=$1 |
| 853 | local channel_name=$2 |
| 854 | |
| 855 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 856 | ok $? "Enable channel $channel_name for session $sess_name" |
| 857 | } |
| 858 | |
| 859 | function enable_ust_lttng_event () |
| 860 | { |
| 861 | local withtap=$1 |
| 862 | local expected_to_fail=$2 |
| 863 | local sess_name=$3 |
| 864 | local event_name="$4" |
| 865 | local channel_name=$5 |
| 866 | |
| 867 | if [ -z $channel_name ]; then |
| 868 | # default channel if none specified |
| 869 | chan="" |
| 870 | else |
| 871 | chan="-c $channel_name" |
| 872 | fi |
| 873 | |
| 874 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 875 | ret=$? |
| 876 | if [[ $expected_to_fail -eq "1" ]]; then |
| 877 | test $ret -ne "0" |
| 878 | ret=$? |
| 879 | if [[ $withtap -eq "1" ]]; then |
| 880 | ok $ret "Enable ust event $event_name for session $session_name failed as expected" |
| 881 | fi |
| 882 | else |
| 883 | if [[ $withtap -eq "1" ]]; then |
| 884 | ok $ret "Enable ust event $event_name for session $sess_name" |
| 885 | fi |
| 886 | fi |
| 887 | return $ret |
| 888 | } |
| 889 | |
| 890 | function enable_ust_lttng_event_ok () |
| 891 | { |
| 892 | enable_ust_lttng_event 1 0 "$@" |
| 893 | } |
| 894 | |
| 895 | function enable_ust_lttng_event_fail () |
| 896 | { |
| 897 | enable_ust_lttng_event 1 1 "$@" |
| 898 | } |
| 899 | |
| 900 | function enable_ust_lttng_event_notap () |
| 901 | { |
| 902 | enable_ust_lttng_event 0 0 "$@" |
| 903 | } |
| 904 | |
| 905 | function enable_jul_lttng_event() |
| 906 | { |
| 907 | sess_name=$1 |
| 908 | event_name="$2" |
| 909 | channel_name=$3 |
| 910 | |
| 911 | if [ -z $channel_name ]; then |
| 912 | # default channel if none specified |
| 913 | chan="" |
| 914 | else |
| 915 | chan="-c $channel_name" |
| 916 | fi |
| 917 | |
| 918 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 919 | ok $? "Enable JUL event $event_name for session $sess_name" |
| 920 | } |
| 921 | |
| 922 | function enable_jul_lttng_event_loglevel() |
| 923 | { |
| 924 | local sess_name=$1 |
| 925 | local event_name="$2" |
| 926 | local loglevel=$3 |
| 927 | local channel_name=$4 |
| 928 | |
| 929 | if [ -z $channel_name ]; then |
| 930 | # default channel if none specified |
| 931 | chan="" |
| 932 | else |
| 933 | chan="-c $channel_name" |
| 934 | fi |
| 935 | |
| 936 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 937 | ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel" |
| 938 | } |
| 939 | |
| 940 | function enable_log4j_lttng_event() |
| 941 | { |
| 942 | sess_name=$1 |
| 943 | event_name="$2" |
| 944 | channel_name=$3 |
| 945 | |
| 946 | if [ -z $channel_name ]; then |
| 947 | # default channel if none specified |
| 948 | chan="" |
| 949 | else |
| 950 | chan="-c $channel_name" |
| 951 | fi |
| 952 | |
| 953 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 954 | ok $? "Enable LOG4J event $event_name for session $sess_name" |
| 955 | } |
| 956 | |
| 957 | function enable_log4j_lttng_event_loglevel() |
| 958 | { |
| 959 | local sess_name=$1 |
| 960 | local event_name="$2" |
| 961 | local loglevel=$3 |
| 962 | local channel_name=$4 |
| 963 | |
| 964 | if [ -z $channel_name ]; then |
| 965 | # default channel if none specified |
| 966 | chan="" |
| 967 | else |
| 968 | chan="-c $channel_name" |
| 969 | fi |
| 970 | |
| 971 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 972 | ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel" |
| 973 | } |
| 974 | |
| 975 | function enable_python_lttng_event() |
| 976 | { |
| 977 | sess_name=$1 |
| 978 | event_name="$2" |
| 979 | channel_name=$3 |
| 980 | |
| 981 | if [ -z $channel_name ]; then |
| 982 | # default channel if none specified |
| 983 | chan="" |
| 984 | else |
| 985 | chan="-c $channel_name" |
| 986 | fi |
| 987 | |
| 988 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 989 | ok $? "Enable Python event $event_name for session $sess_name" |
| 990 | } |
| 991 | |
| 992 | function enable_python_lttng_event_loglevel() |
| 993 | { |
| 994 | local sess_name=$1 |
| 995 | local event_name="$2" |
| 996 | local loglevel=$3 |
| 997 | local channel_name=$4 |
| 998 | |
| 999 | if [ -z $channel_name ]; then |
| 1000 | # default channel if none specified |
| 1001 | chan="" |
| 1002 | else |
| 1003 | chan="-c $channel_name" |
| 1004 | fi |
| 1005 | |
| 1006 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1007 | ok $? "Enable Python event $event_name for session $sess_name with loglevel $loglevel" |
| 1008 | } |
| 1009 | |
| 1010 | function enable_ust_lttng_event_filter() |
| 1011 | { |
| 1012 | local sess_name="$1" |
| 1013 | local event_name="$2" |
| 1014 | local filter="$3" |
| 1015 | |
| 1016 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1017 | ok $? "Enable event $event_name with filtering for session $sess_name" |
| 1018 | } |
| 1019 | |
| 1020 | function enable_ust_lttng_event_loglevel() |
| 1021 | { |
| 1022 | local sess_name="$1" |
| 1023 | local event_name="$2" |
| 1024 | local loglevel="$3" |
| 1025 | |
| 1026 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1027 | ok $? "Enable event $event_name with loglevel $loglevel" |
| 1028 | } |
| 1029 | |
| 1030 | function enable_ust_lttng_event_loglevel_only() |
| 1031 | { |
| 1032 | local sess_name="$1" |
| 1033 | local event_name="$2" |
| 1034 | local loglevel="$3" |
| 1035 | |
| 1036 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1037 | ok $? "Enable event $event_name with loglevel-only $loglevel" |
| 1038 | } |
| 1039 | |
| 1040 | function disable_ust_lttng_event () |
| 1041 | { |
| 1042 | local sess_name="$1" |
| 1043 | local event_name="$2" |
| 1044 | local channel_name="$3" |
| 1045 | |
| 1046 | if [ -z $channel_name ]; then |
| 1047 | # default channel if none specified |
| 1048 | chan="" |
| 1049 | else |
| 1050 | chan="-c $channel_name" |
| 1051 | fi |
| 1052 | |
| 1053 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1054 | ok $? "Disable event $event_name for session $sess_name" |
| 1055 | } |
| 1056 | |
| 1057 | function disable_jul_lttng_event () |
| 1058 | { |
| 1059 | local sess_name="$1" |
| 1060 | local event_name="$2" |
| 1061 | |
| 1062 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1 |
| 1063 | ok $? "Disable JUL event $event_name for session $sess_name" |
| 1064 | } |
| 1065 | |
| 1066 | function disable_log4j_lttng_event () |
| 1067 | { |
| 1068 | local sess_name="$1" |
| 1069 | local event_name="$2" |
| 1070 | |
| 1071 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1 |
| 1072 | ok $? "Disable LOG4J event $event_name for session $sess_name" |
| 1073 | } |
| 1074 | |
| 1075 | function disable_python_lttng_event () |
| 1076 | { |
| 1077 | local sess_name="$1" |
| 1078 | local event_name="$2" |
| 1079 | |
| 1080 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -p 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1081 | ok $? "Disable Python event $event_name for session $sess_name" |
| 1082 | } |
| 1083 | |
| 1084 | function start_lttng_tracing () |
| 1085 | { |
| 1086 | local expected_to_fail=$1 |
| 1087 | local sess_name=$2 |
| 1088 | |
| 1089 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1090 | ret=$? |
| 1091 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1092 | test "$ret" -ne "0" |
| 1093 | ok $? "Start tracing for session $sess_name failed as expected" |
| 1094 | else |
| 1095 | ok $ret "Start tracing for session $sess_name" |
| 1096 | fi |
| 1097 | } |
| 1098 | |
| 1099 | function start_lttng_tracing_ok () |
| 1100 | { |
| 1101 | start_lttng_tracing 0 "$@" |
| 1102 | } |
| 1103 | |
| 1104 | function start_lttng_tracing_fail () |
| 1105 | { |
| 1106 | start_lttng_tracing 1 "$@" |
| 1107 | } |
| 1108 | |
| 1109 | function stop_lttng_tracing () |
| 1110 | { |
| 1111 | local expected_to_fail=$1 |
| 1112 | local sess_name=$2 |
| 1113 | |
| 1114 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1115 | ret=$? |
| 1116 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1117 | test "$ret" -ne "0" |
| 1118 | ok $? "Stop lttng tracing for session $sess_name failed as expected" |
| 1119 | else |
| 1120 | ok $ret "Stop lttng tracing for session $sess_name" |
| 1121 | fi |
| 1122 | } |
| 1123 | |
| 1124 | function stop_lttng_tracing_ok () |
| 1125 | { |
| 1126 | stop_lttng_tracing 0 "$@" |
| 1127 | } |
| 1128 | |
| 1129 | function stop_lttng_tracing_fail () |
| 1130 | { |
| 1131 | stop_lttng_tracing 1 "$@" |
| 1132 | } |
| 1133 | |
| 1134 | function destroy_lttng_session () |
| 1135 | { |
| 1136 | local withtap=$1 |
| 1137 | local expected_to_fail=$2 |
| 1138 | local sess_name=$3 |
| 1139 | |
| 1140 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1141 | ret=$? |
| 1142 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1143 | test "$ret" -ne "0" |
| 1144 | ret=$? |
| 1145 | if [ $withtap -eq "1" ]; then |
| 1146 | ok $ret "Destroy session $sess_name failed as expected" |
| 1147 | fi |
| 1148 | else |
| 1149 | if [ $withtap -eq "1" ]; then |
| 1150 | ok $ret "Destroy session $sess_name" |
| 1151 | fi |
| 1152 | fi |
| 1153 | } |
| 1154 | |
| 1155 | function destroy_lttng_session_ok () |
| 1156 | { |
| 1157 | destroy_lttng_session 1 0 "$@" |
| 1158 | |
| 1159 | } |
| 1160 | |
| 1161 | function destroy_lttng_session_fail () |
| 1162 | { |
| 1163 | destroy_lttng_session 1 1 "$@" |
| 1164 | } |
| 1165 | |
| 1166 | function destroy_lttng_session_notap () |
| 1167 | { |
| 1168 | destroy_lttng_session 0 0 "$@" |
| 1169 | } |
| 1170 | |
| 1171 | function destroy_lttng_sessions () |
| 1172 | { |
| 1173 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1174 | ok $? "Destroy all lttng sessions" |
| 1175 | } |
| 1176 | |
| 1177 | function lttng_snapshot_add_output () |
| 1178 | { |
| 1179 | local expected_to_fail=$1 |
| 1180 | local sess_name=$2 |
| 1181 | local trace_path=$3 |
| 1182 | |
| 1183 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1184 | ret=$? |
| 1185 | if [[ $expected_to_fail -eq 1 ]]; then |
| 1186 | test "$ret" -ne "0" |
| 1187 | ok $? "Added snapshot output file://$trace_path failed as expected" |
| 1188 | else |
| 1189 | ok $ret "Added snapshot output file://$trace_path" |
| 1190 | fi |
| 1191 | } |
| 1192 | |
| 1193 | function lttng_snapshot_add_output_ok () |
| 1194 | { |
| 1195 | lttng_snapshot_add_output 0 "$@" |
| 1196 | } |
| 1197 | |
| 1198 | function lttng_snapshot_add_output_fail () |
| 1199 | { |
| 1200 | lttng_snapshot_add_output 1 "$@" |
| 1201 | } |
| 1202 | |
| 1203 | function lttng_snapshot_del_output () |
| 1204 | { |
| 1205 | local expected_to_fail=$1 |
| 1206 | local sess_name=$2 |
| 1207 | local id=$3 |
| 1208 | |
| 1209 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1210 | ret=$? |
| 1211 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1212 | test "$ret" -ne "0" |
| 1213 | ok $? "Deleted snapshot output id $id failed as expected" |
| 1214 | else |
| 1215 | ok $ret "Deleted snapshot output id $id" |
| 1216 | fi |
| 1217 | } |
| 1218 | |
| 1219 | function lttng_snapshot_del_output_ok () |
| 1220 | { |
| 1221 | lttng_snapshot_del_output 0 "$@" |
| 1222 | } |
| 1223 | |
| 1224 | function lttng_snapshot_del_output_fail () |
| 1225 | { |
| 1226 | lttng_snapshot_del_output 1 "$@" |
| 1227 | } |
| 1228 | |
| 1229 | function lttng_snapshot_record () |
| 1230 | { |
| 1231 | local sess_name=$1 |
| 1232 | local trace_path=$2 |
| 1233 | |
| 1234 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1235 | ok $? "Snapshot recorded" |
| 1236 | } |
| 1237 | |
| 1238 | function lttng_snapshot_list () |
| 1239 | { |
| 1240 | local sess_name=$1 |
| 1241 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1242 | ok $? "Snapshot list" |
| 1243 | } |
| 1244 | |
| 1245 | function lttng_save() |
| 1246 | { |
| 1247 | local sess_name=$1 |
| 1248 | local opts=$2 |
| 1249 | |
| 1250 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1251 | ok $? "Session saved" |
| 1252 | } |
| 1253 | |
| 1254 | function lttng_load() |
| 1255 | { |
| 1256 | local expected_to_fail=$1 |
| 1257 | local opts=$2 |
| 1258 | |
| 1259 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1260 | ret=$? |
| 1261 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1262 | test $ret -ne "0" |
| 1263 | ok $? "Load command failed as expected with opts: $opts" |
| 1264 | else |
| 1265 | ok $ret "Load command with opts: $opts" |
| 1266 | fi |
| 1267 | } |
| 1268 | |
| 1269 | function lttng_load_ok() |
| 1270 | { |
| 1271 | lttng_load 0 "$@" |
| 1272 | } |
| 1273 | |
| 1274 | function lttng_load_fail() |
| 1275 | { |
| 1276 | lttng_load 1 "$@" |
| 1277 | } |
| 1278 | |
| 1279 | function lttng_track() |
| 1280 | { |
| 1281 | local expected_to_fail=$1 |
| 1282 | local opts=$2 |
| 1283 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST |
| 1284 | ret=$? |
| 1285 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1286 | test $ret -ne "0" |
| 1287 | ok $? "Track command failed as expected with opts: $opts" |
| 1288 | else |
| 1289 | ok $ret "Track command with opts: $opts" |
| 1290 | fi |
| 1291 | } |
| 1292 | |
| 1293 | function lttng_track_ok() |
| 1294 | { |
| 1295 | lttng_track 0 "$@" |
| 1296 | } |
| 1297 | |
| 1298 | function lttng_track_fail() |
| 1299 | { |
| 1300 | lttng_track 1 "$@" |
| 1301 | } |
| 1302 | |
| 1303 | function lttng_untrack() |
| 1304 | { |
| 1305 | local expected_to_fail=$1 |
| 1306 | local opts=$2 |
| 1307 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST |
| 1308 | ret=$? |
| 1309 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1310 | test $ret -ne "0" |
| 1311 | ok $? "Untrack command failed as expected with opts: $opts" |
| 1312 | else |
| 1313 | ok $ret "Untrack command with opts: $opts" |
| 1314 | fi |
| 1315 | } |
| 1316 | |
| 1317 | function lttng_untrack_ok() |
| 1318 | { |
| 1319 | lttng_untrack 0 "$@" |
| 1320 | } |
| 1321 | |
| 1322 | function lttng_untrack_fail() |
| 1323 | { |
| 1324 | lttng_untrack 1 "$@" |
| 1325 | } |
| 1326 | |
| 1327 | function lttng_track_pid_ok() |
| 1328 | { |
| 1329 | PID=$1 |
| 1330 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" track --kernel --pid=$PID 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1331 | ok $? "Lttng track pid on the kernel domain" |
| 1332 | } |
| 1333 | |
| 1334 | function lttng_untrack_kernel_all_ok() |
| 1335 | { |
| 1336 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" untrack --kernel --pid --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1337 | ok $? "Lttng untrack all pid on the kernel domain" |
| 1338 | } |
| 1339 | |
| 1340 | function lttng_add_context_list() |
| 1341 | { |
| 1342 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context --list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1343 | ret=$? |
| 1344 | ok $ret "Context listing" |
| 1345 | } |
| 1346 | |
| 1347 | function add_context_lttng() |
| 1348 | { |
| 1349 | local expected_to_fail="$1" |
| 1350 | local domain="$2" |
| 1351 | local session_name="$3" |
| 1352 | local channel_name="$4" |
| 1353 | local type="$5" |
| 1354 | |
| 1355 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1356 | ret=$? |
| 1357 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1358 | test $ret -ne "0" |
| 1359 | ok $? "Add context command failed as expected for type: $type" |
| 1360 | else |
| 1361 | ok $ret "Add context command for type: $type" |
| 1362 | fi |
| 1363 | } |
| 1364 | |
| 1365 | function add_context_ust_ok() |
| 1366 | { |
| 1367 | add_context_lttng 0 -u "$@" |
| 1368 | } |
| 1369 | |
| 1370 | function add_context_ust_fail() |
| 1371 | { |
| 1372 | add_context_lttng 1 -u "$@" |
| 1373 | } |
| 1374 | |
| 1375 | function add_context_kernel_ok() |
| 1376 | { |
| 1377 | add_context_lttng 0 -k "$@" |
| 1378 | } |
| 1379 | |
| 1380 | function add_context_kernel_fail() |
| 1381 | { |
| 1382 | add_context_lttng 1 -k "$@" |
| 1383 | } |
| 1384 | |
| 1385 | function validate_metadata_event () |
| 1386 | { |
| 1387 | local event_name=$1 |
| 1388 | local nr_event_id=$2 |
| 1389 | local trace_path=$3 |
| 1390 | |
| 1391 | local metadata_file=$(find $trace_path | grep metadata) |
| 1392 | local metadata_path=$(dirname $metadata_file) |
| 1393 | |
| 1394 | which $BABELTRACE_BIN >/dev/null |
| 1395 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1396 | |
| 1397 | local count=$($BABELTRACE_BIN --output-format=ctf-metadata $metadata_path | grep $event_name | wc -l) |
| 1398 | |
| 1399 | if [ "$count" -ne "$nr_event_id" ]; then |
| 1400 | fail "Metadata match with the metadata of $count event(s) named $event_name" |
| 1401 | diag "$count matching event id found in metadata" |
| 1402 | else |
| 1403 | pass "Metadata match with the metadata of $count event(s) named $event_name" |
| 1404 | fi |
| 1405 | |
| 1406 | } |
| 1407 | |
| 1408 | function trace_matches () |
| 1409 | { |
| 1410 | local event_name=$1 |
| 1411 | local nr_iter=$2 |
| 1412 | local trace_path=$3 |
| 1413 | |
| 1414 | which $BABELTRACE_BIN >/dev/null |
| 1415 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1416 | |
| 1417 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
| 1418 | |
| 1419 | if [ "$count" -ne "$nr_iter" ]; then |
| 1420 | fail "Trace match" |
| 1421 | diag "$count matching events found in trace" |
| 1422 | else |
| 1423 | pass "Trace match" |
| 1424 | fi |
| 1425 | } |
| 1426 | |
| 1427 | function trace_match_only() |
| 1428 | { |
| 1429 | local event_name=$1 |
| 1430 | local nr_iter=$2 |
| 1431 | local trace_path=$3 |
| 1432 | |
| 1433 | which $BABELTRACE_BIN >/dev/null |
| 1434 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1435 | |
| 1436 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
| 1437 | local total=$($BABELTRACE_BIN $trace_path | wc -l) |
| 1438 | |
| 1439 | if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then |
| 1440 | pass "Trace match with $total event $event_name" |
| 1441 | else |
| 1442 | fail "Trace match" |
| 1443 | diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count" |
| 1444 | fi |
| 1445 | } |
| 1446 | |
| 1447 | function validate_trace |
| 1448 | { |
| 1449 | local event_name=$1 |
| 1450 | local trace_path=$2 |
| 1451 | |
| 1452 | which $BABELTRACE_BIN >/dev/null |
| 1453 | if [ $? -ne 0 ]; then |
| 1454 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1455 | fi |
| 1456 | |
| 1457 | OLDIFS=$IFS |
| 1458 | IFS="," |
| 1459 | for i in $event_name; do |
| 1460 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) |
| 1461 | if [ "$traced" -ne 0 ]; then |
| 1462 | pass "Validate trace for event $i, $traced events" |
| 1463 | else |
| 1464 | fail "Validate trace for event $i" |
| 1465 | diag "Found $traced occurences of $i" |
| 1466 | fi |
| 1467 | done |
| 1468 | ret=$? |
| 1469 | IFS=$OLDIFS |
| 1470 | return $ret |
| 1471 | } |
| 1472 | |
| 1473 | function validate_trace_count |
| 1474 | { |
| 1475 | local event_name=$1 |
| 1476 | local trace_path=$2 |
| 1477 | local expected_count=$3 |
| 1478 | |
| 1479 | which $BABELTRACE_BIN >/dev/null |
| 1480 | if [ $? -ne 0 ]; then |
| 1481 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1482 | fi |
| 1483 | |
| 1484 | cnt=0 |
| 1485 | OLDIFS=$IFS |
| 1486 | IFS="," |
| 1487 | for i in $event_name; do |
| 1488 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) |
| 1489 | if [ "$traced" -ne 0 ]; then |
| 1490 | pass "Validate trace for event $i, $traced events" |
| 1491 | else |
| 1492 | fail "Validate trace for event $i" |
| 1493 | diag "Found $traced occurences of $i" |
| 1494 | fi |
| 1495 | cnt=$(($cnt + $traced)) |
| 1496 | done |
| 1497 | IFS=$OLDIFS |
| 1498 | test $cnt -eq $expected_count |
| 1499 | ok $? "Read a total of $cnt events, expected $expected_count" |
| 1500 | } |
| 1501 | |
| 1502 | function trace_first_line |
| 1503 | { |
| 1504 | local trace_path=$1 |
| 1505 | |
| 1506 | which $BABELTRACE_BIN >/dev/null |
| 1507 | if [ $? -ne 0 ]; then |
| 1508 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1509 | fi |
| 1510 | |
| 1511 | $BABELTRACE_BIN $trace_path 2>/dev/null | head -n 1 |
| 1512 | } |
| 1513 | |
| 1514 | function validate_trace_exp() |
| 1515 | { |
| 1516 | local event_exp=$1 |
| 1517 | local trace_path=$2 |
| 1518 | |
| 1519 | which $BABELTRACE_BIN >/dev/null |
| 1520 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation" |
| 1521 | |
| 1522 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep --extended-regexp ${event_exp} | wc -l) |
| 1523 | if [ "$traced" -ne 0 ]; then |
| 1524 | pass "Validate trace for expression '${event_exp}', $traced events" |
| 1525 | else |
| 1526 | fail "Validate trace for expression '${event_exp}'" |
| 1527 | diag "Found $traced occurences of '${event_exp}'" |
| 1528 | fi |
| 1529 | ret=$? |
| 1530 | return $ret |
| 1531 | } |
| 1532 | |
| 1533 | function validate_trace_only_exp() |
| 1534 | { |
| 1535 | local event_exp=$1 |
| 1536 | local trace_path=$2 |
| 1537 | |
| 1538 | which $BABELTRACE_BIN >/dev/null |
| 1539 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
| 1540 | |
| 1541 | local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp ${event_exp} | wc -l) |
| 1542 | local total=$($BABELTRACE_BIN $trace_path | wc -l) |
| 1543 | |
| 1544 | if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then |
| 1545 | pass "Trace match with $total for expression '${event_exp}'" |
| 1546 | else |
| 1547 | fail "Trace match" |
| 1548 | diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected" |
| 1549 | fi |
| 1550 | ret=$? |
| 1551 | return $ret |
| 1552 | } |
| 1553 | |
| 1554 | function validate_trace_empty() |
| 1555 | { |
| 1556 | local trace_path=$1 |
| 1557 | |
| 1558 | which $BABELTRACE_BIN >/dev/null |
| 1559 | if [ $? -ne 0 ]; then |
| 1560 | skip 0 "Babeltrace binary not found. Skipping trace validation" |
| 1561 | fi |
| 1562 | |
| 1563 | events=$($BABELTRACE_BIN $trace_path 2>/dev/null) |
| 1564 | ret=$? |
| 1565 | if [ $ret -ne 0 ]; then |
| 1566 | fail "Failed to parse trace" |
| 1567 | return $ret |
| 1568 | fi |
| 1569 | |
| 1570 | traced=$(echo -n "$events" | wc -l) |
| 1571 | if [ "$traced" -eq 0 ]; then |
| 1572 | pass "Validate empty trace" |
| 1573 | else |
| 1574 | fail "Validate empty trace" |
| 1575 | diag "Found $traced events in trace" |
| 1576 | fi |
| 1577 | ret=$? |
| 1578 | return $ret |
| 1579 | } |
| 1580 | |
| 1581 | function regenerate_metadata () |
| 1582 | { |
| 1583 | local expected_to_fail=$1 |
| 1584 | local sess_name=$2 |
| 1585 | |
| 1586 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate metadata -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1587 | ret=$? |
| 1588 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1589 | test "$ret" -ne "0" |
| 1590 | ok $? "Expected fail on regenerate metadata $sess_name" |
| 1591 | else |
| 1592 | ok $ret "Metadata regenerate $sess_name" |
| 1593 | fi |
| 1594 | } |
| 1595 | |
| 1596 | function regenerate_metadata_ok () |
| 1597 | { |
| 1598 | regenerate_metadata 0 "$@" |
| 1599 | } |
| 1600 | |
| 1601 | function regenerate_metadata_fail () |
| 1602 | { |
| 1603 | regenerate_metadata 1 "$@" |
| 1604 | } |
| 1605 | |
| 1606 | function regenerate_statedump () |
| 1607 | { |
| 1608 | local expected_to_fail=$1 |
| 1609 | local sess_name=$2 |
| 1610 | |
| 1611 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate statedump -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1612 | ret=$? |
| 1613 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1614 | test "$ret" -ne "0" |
| 1615 | ok $? "Expected fail on regenerate statedump $sess_name" |
| 1616 | else |
| 1617 | ok $ret "Metadata regenerate $sess_name" |
| 1618 | fi |
| 1619 | } |
| 1620 | |
| 1621 | function regenerate_statedump_ok () |
| 1622 | { |
| 1623 | regenerate_statedump 0 "$@" |
| 1624 | } |
| 1625 | |
| 1626 | function regenerate_statedump_fail () |
| 1627 | { |
| 1628 | regenerate_statedump 1 "$@" |
| 1629 | } |
| 1630 | |
| 1631 | function rotate_session () |
| 1632 | { |
| 1633 | local expected_to_fail=$1 |
| 1634 | local sess_name=$2 |
| 1635 | |
| 1636 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN rotate $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1637 | ret=$? |
| 1638 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1639 | test "$ret" -ne "0" |
| 1640 | ok $? "Expected fail on rotate session $sess_name" |
| 1641 | else |
| 1642 | ok $ret "Rotate session $sess_name" |
| 1643 | fi |
| 1644 | } |
| 1645 | |
| 1646 | function rotate_session_ok () |
| 1647 | { |
| 1648 | rotate_session 0 "$@" |
| 1649 | } |
| 1650 | |
| 1651 | function rotate_session_fail () |
| 1652 | { |
| 1653 | rotate_session 1 "$@" |
| 1654 | } |
| 1655 | |
| 1656 | function destructive_tests_enabled () |
| 1657 | { |
| 1658 | if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then |
| 1659 | return 0 |
| 1660 | else |
| 1661 | return 1 |
| 1662 | fi |
| 1663 | } |
| 1664 | |
| 1665 | function lttng_enable_rotation_timer () |
| 1666 | { |
| 1667 | local expected_to_fail=$1 |
| 1668 | local sess_name=$2 |
| 1669 | local period=$3 |
| 1670 | |
| 1671 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1672 | ret=$? |
| 1673 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1674 | test "$ret" -ne "0" |
| 1675 | ok $? "Expected fail on rotate session $sess_name" |
| 1676 | else |
| 1677 | ok $ret "Rotate session $sess_name" |
| 1678 | fi |
| 1679 | } |
| 1680 | |
| 1681 | function lttng_enable_rotation_timer_ok () |
| 1682 | { |
| 1683 | lttng_enable_rotation_timer 0 $@ |
| 1684 | } |
| 1685 | |
| 1686 | function lttng_enable_rotation_timer_fail () |
| 1687 | { |
| 1688 | lttng_enable_rotation_timer 1 $@ |
| 1689 | } |
| 1690 | |
| 1691 | function lttng_enable_rotation_size () |
| 1692 | { |
| 1693 | local expected_to_fail=$1 |
| 1694 | local sess_name=$2 |
| 1695 | local size=$3 |
| 1696 | |
| 1697 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST |
| 1698 | ret=$? |
| 1699 | if [[ $expected_to_fail -eq "1" ]]; then |
| 1700 | test "$ret" -ne "0" |
| 1701 | ok $? "Expected fail on rotate session $sess_name" |
| 1702 | else |
| 1703 | ok $ret "Rotate session $sess_name" |
| 1704 | fi |
| 1705 | } |
| 1706 | |
| 1707 | function lttng_enable_rotation_size_ok () |
| 1708 | { |
| 1709 | lttng_enable_rotation_size 0 $@ |
| 1710 | } |
| 1711 | |
| 1712 | function lttng_enable_rotation_size_fail () |
| 1713 | { |
| 1714 | lttng_enable_rotation_size 1 $@ |
| 1715 | } |