| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) - 2020 EfficiOS, inc |
| 4 | # |
| 5 | # This library is free software; you can redistribute it and/or modify it under |
| 6 | # the terms of the GNU Lesser General Public License as published by the Free |
| 7 | # Software Foundation; version 2.1 of the License. |
| 8 | # |
| 9 | # This library is distributed in the hope that it will be useful, but WITHOUT |
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 12 | # details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU Lesser General Public License |
| 15 | # along with this library; if not, write to the Free Software Foundation, Inc., |
| 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | |
| 18 | # Test the `lttng list-trigger` command line interface. |
| 19 | |
| 20 | CURDIR="$(dirname "$0")" |
| 21 | TESTDIR="$CURDIR/../../.." |
| 22 | |
| 23 | # shellcheck source=../../../utils/utils.sh |
| 24 | source "$TESTDIR/utils/utils.sh" |
| 25 | |
| 26 | NUM_TESTS=106 |
| 27 | |
| 28 | FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" |
| 29 | |
| 30 | tmp_stdout=$(mktemp -t test_list_triggers_cli_stdout.XXXXXX) |
| 31 | tmp_stderr=$(mktemp -t test_list_triggers_cli_stderr.XXXXXX) |
| 32 | tmp_expected_stdout=$(mktemp -t test_list_triggers_cli_expected_stdout.XXXXXX) |
| 33 | uprobe_elf_binary=$(realpath "${TESTDIR}/utils/testapp/userspace-probe-elf-binary/.libs/userspace-probe-elf-binary") |
| 34 | uprobe_sdt_binary=$(realpath "${TESTDIR}/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-sdt-binary") |
| 35 | register_some_triggers_bin=$(realpath "${CURDIR}/utils/register-some-triggers") |
| 36 | |
| 37 | uid=$(id --user) |
| 38 | gid=$(id --group) |
| 39 | |
| 40 | if [ "$uid" == "0" ]; then |
| 41 | ist_root=1 |
| 42 | ls "$uprobe_sdt_binary" >/dev/null 2>&1 |
| 43 | if test $? == 0; then |
| 44 | hast_sdt_binary=1 |
| 45 | else |
| 46 | hast_sdt_binary=0 |
| 47 | fi |
| 48 | else |
| 49 | ist_root=0 |
| 50 | hast_sdt_binary=0 |
| 51 | fi |
| 52 | |
| 53 | |
| 54 | test_top_level_options () |
| 55 | { |
| 56 | diag "Listing top level options" |
| 57 | |
| 58 | lttng_add_trigger_ok "hello" --condition event-rule-matches --domain=user --name=test-name --action notify |
| 59 | |
| 60 | cat > "${tmp_expected_stdout}" <<- EOF |
| 61 | - name: hello |
| 62 | owner uid: ${uid} |
| 63 | condition: event rule matches |
| 64 | rule: test-name (type: tracepoint, domain: ust) |
| 65 | actions: |
| 66 | notify |
| 67 | errors: none |
| 68 | errors: none |
| 69 | EOF |
| 70 | |
| 71 | list_triggers_matches_ok "top level options" "${tmp_expected_stdout}" |
| 72 | |
| 73 | lttng_remove_trigger_ok "hello" |
| 74 | } |
| 75 | |
| 76 | test_event_rule_matches_tracepoint () |
| 77 | { |
| 78 | diag "Listing event-rule-matches tracepoint" |
| 79 | |
| 80 | lttng_add_trigger_ok "C" --condition event-rule-matches --domain=user --action notify |
| 81 | lttng_add_trigger_ok "A" --condition event-rule-matches --name=aaa --domain=user --filter 'p == 2' --action notify |
| 82 | lttng_add_trigger_ok "D" --condition event-rule-matches --name='hello*' --domain=user -x hello2 --exclude-name hello3 -x hello4 --action notify |
| 83 | lttng_add_trigger_ok "B" --condition event-rule-matches --domain=user --name=gerboise --log-level INFO.. --action notify |
| 84 | lttng_add_trigger_ok "E" --condition event-rule-matches --domain=user --name=lemming --log-level WARNING --action notify |
| 85 | lttng_add_trigger_ok "J" --condition event-rule-matches --domain=user --name=lemming --log-level .. --action notify |
| 86 | lttng_add_trigger_ok "F" --condition event-rule-matches --domain=user --name=capture-payload-field --capture a --action notify |
| 87 | lttng_add_trigger_ok "G" --condition event-rule-matches --domain=user --name=capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify |
| 88 | lttng_add_trigger_ok "H" --condition event-rule-matches --domain=user --name=capture-chan-ctx --capture '$ctx.vpid' --action notify |
| 89 | lttng_add_trigger_ok "I" --condition event-rule-matches --domain=user --name=capture-app-ctx --capture '$app.iga:active_clients' --action notify |
| 90 | |
| 91 | cat > "${tmp_expected_stdout}" <<- EOF |
| 92 | - name: A |
| 93 | owner uid: ${uid} |
| 94 | condition: event rule matches |
| 95 | rule: aaa (type: tracepoint, domain: ust, filter: p == 2) |
| 96 | actions: |
| 97 | notify |
| 98 | errors: none |
| 99 | errors: none |
| 100 | - name: B |
| 101 | owner uid: ${uid} |
| 102 | condition: event rule matches |
| 103 | rule: gerboise (type: tracepoint, domain: ust, log level at least INFO) |
| 104 | actions: |
| 105 | notify |
| 106 | errors: none |
| 107 | errors: none |
| 108 | - name: C |
| 109 | owner uid: ${uid} |
| 110 | condition: event rule matches |
| 111 | rule: * (type: tracepoint, domain: ust) |
| 112 | actions: |
| 113 | notify |
| 114 | errors: none |
| 115 | errors: none |
| 116 | - name: D |
| 117 | owner uid: ${uid} |
| 118 | condition: event rule matches |
| 119 | rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4) |
| 120 | actions: |
| 121 | notify |
| 122 | errors: none |
| 123 | errors: none |
| 124 | - name: E |
| 125 | owner uid: ${uid} |
| 126 | condition: event rule matches |
| 127 | rule: lemming (type: tracepoint, domain: ust, log level is WARNING) |
| 128 | actions: |
| 129 | notify |
| 130 | errors: none |
| 131 | errors: none |
| 132 | - name: F |
| 133 | owner uid: ${uid} |
| 134 | condition: event rule matches |
| 135 | rule: capture-payload-field (type: tracepoint, domain: ust) |
| 136 | captures: |
| 137 | - a |
| 138 | actions: |
| 139 | notify |
| 140 | errors: none |
| 141 | errors: none |
| 142 | - name: G |
| 143 | owner uid: ${uid} |
| 144 | condition: event rule matches |
| 145 | rule: capture-array (type: tracepoint, domain: ust) |
| 146 | captures: |
| 147 | - a[2] |
| 148 | - \$ctx.tourlou[18] |
| 149 | actions: |
| 150 | notify |
| 151 | errors: none |
| 152 | errors: none |
| 153 | - name: H |
| 154 | owner uid: ${uid} |
| 155 | condition: event rule matches |
| 156 | rule: capture-chan-ctx (type: tracepoint, domain: ust) |
| 157 | captures: |
| 158 | - \$ctx.vpid |
| 159 | actions: |
| 160 | notify |
| 161 | errors: none |
| 162 | errors: none |
| 163 | - name: I |
| 164 | owner uid: ${uid} |
| 165 | condition: event rule matches |
| 166 | rule: capture-app-ctx (type: tracepoint, domain: ust) |
| 167 | captures: |
| 168 | - \$app.iga:active_clients |
| 169 | actions: |
| 170 | notify |
| 171 | errors: none |
| 172 | errors: none |
| 173 | - name: J |
| 174 | owner uid: ${uid} |
| 175 | condition: event rule matches |
| 176 | rule: lemming (type: tracepoint, domain: ust) |
| 177 | actions: |
| 178 | notify |
| 179 | errors: none |
| 180 | errors: none |
| 181 | EOF |
| 182 | |
| 183 | list_triggers_matches_ok "event-rule-matches, tracepoint event rule" "${tmp_expected_stdout}" |
| 184 | |
| 185 | lttng_remove_trigger_ok "A" |
| 186 | lttng_remove_trigger_ok "B" |
| 187 | lttng_remove_trigger_ok "C" |
| 188 | lttng_remove_trigger_ok "D" |
| 189 | lttng_remove_trigger_ok "E" |
| 190 | lttng_remove_trigger_ok "F" |
| 191 | lttng_remove_trigger_ok "G" |
| 192 | lttng_remove_trigger_ok "H" |
| 193 | lttng_remove_trigger_ok "I" |
| 194 | lttng_remove_trigger_ok "J" |
| 195 | } |
| 196 | |
| 197 | test_event_rule_matches_probe () |
| 198 | { |
| 199 | local channel_enable_addr |
| 200 | local channel_disable_addr |
| 201 | |
| 202 | diag "Listing event-rule-matches kernel probe" |
| 203 | |
| 204 | channel_enable_addr=$(grep ' t lttng_channel_enable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ') |
| 205 | channel_disable_addr=$(grep ' t lttng_channel_disable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ') |
| 206 | |
| 207 | # We need to find a valid offset. |
| 208 | base_symbol="" |
| 209 | offset=0 |
| 210 | if [[ 0x$channel_enable_addr -lt 0x$channel_disable_addr ]]; then |
| 211 | base_symbol="lttng_channel_enable" |
| 212 | offset=$(( 0x$channel_disable_addr - 0x$channel_enable_addr )) |
| 213 | else |
| 214 | base_symbol="lttng_channel_disable" |
| 215 | offset=$(( 0x$channel_enable_addr - 0x$channel_disable_addr )) |
| 216 | fi |
| 217 | |
| 218 | offset_hex="0x$(printf '%x' $offset)" |
| 219 | |
| 220 | lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=kprobe --location=lttng_channel_enable --event-name=my_channel_enable --action notify |
| 221 | lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=kernel --type=kprobe --location="${base_symbol}+${offset_hex}" --event-name=my_channel_enable --action notify |
| 222 | lttng_add_trigger_ok "T2" --condition event-rule-matches --domain=kernel --type=kprobe --location="0x${channel_enable_addr}" --event-name=my_channel_enable --action notify |
| 223 | |
| 224 | cat > "${tmp_expected_stdout}" <<- EOF |
| 225 | - name: T0 |
| 226 | owner uid: ${uid} |
| 227 | condition: event rule matches |
| 228 | rule: my_channel_enable (type: probe, location: lttng_channel_enable) |
| 229 | actions: |
| 230 | notify |
| 231 | errors: none |
| 232 | errors: none |
| 233 | - name: T1 |
| 234 | owner uid: ${uid} |
| 235 | condition: event rule matches |
| 236 | rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex}) |
| 237 | actions: |
| 238 | notify |
| 239 | errors: none |
| 240 | errors: none |
| 241 | - name: T2 |
| 242 | owner uid: ${uid} |
| 243 | condition: event rule matches |
| 244 | rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr}) |
| 245 | actions: |
| 246 | notify |
| 247 | errors: none |
| 248 | errors: none |
| 249 | EOF |
| 250 | |
| 251 | list_triggers_matches_ok "event-rule-matches, probe event rule" "${tmp_expected_stdout}" |
| 252 | |
| 253 | lttng_remove_trigger_ok "T0" |
| 254 | lttng_remove_trigger_ok "T1" |
| 255 | lttng_remove_trigger_ok "T2" |
| 256 | } |
| 257 | |
| 258 | test_event_rule_matches_userspace_probe_elf () |
| 259 | { |
| 260 | local elf_function_name="test_function" |
| 261 | |
| 262 | diag "Listing event-rule-matches userspace-probe elf" |
| 263 | |
| 264 | lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe-elf --action notify |
| 265 | |
| 266 | cat > "${tmp_expected_stdout}" <<- EOF |
| 267 | - name: T0 |
| 268 | owner uid: ${uid} |
| 269 | condition: event rule matches |
| 270 | rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name}) |
| 271 | actions: |
| 272 | notify |
| 273 | errors: none |
| 274 | errors: none |
| 275 | EOF |
| 276 | |
| 277 | list_triggers_matches_ok "event-rule-matches, userspace-probe event rule" "${tmp_expected_stdout}" |
| 278 | |
| 279 | lttng_remove_trigger_ok "T0" |
| 280 | } |
| 281 | |
| 282 | test_event_rule_matches_userspace_probe_sdt () |
| 283 | { |
| 284 | local sdt_provider_name="foobar" |
| 285 | local sdt_probe_name="tp1" |
| 286 | |
| 287 | diag "Listing event-rule-matches userspace-probe sdt" |
| 288 | |
| 289 | lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=uprobe --location=sdt:${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name} --event-name=ma-probe-sdt --action notify |
| 290 | |
| 291 | cat > "${tmp_expected_stdout}" <<- EOF |
| 292 | - name: T0 |
| 293 | owner uid: 0 |
| 294 | condition: event rule matches |
| 295 | rule: ma-probe-sdt (type: userspace probe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name}) |
| 296 | actions: |
| 297 | notify |
| 298 | errors: none |
| 299 | errors: none |
| 300 | EOF |
| 301 | |
| 302 | list_triggers_matches_ok "event-rule-matches, userspace-probe event rule SDT" "${tmp_expected_stdout}" |
| 303 | |
| 304 | lttng_remove_trigger_ok "T0" |
| 305 | } |
| 306 | |
| 307 | test_event_rule_matches_syscall () |
| 308 | { |
| 309 | diag "Listing event-rule-matches syscall" |
| 310 | |
| 311 | lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=syscall --name=open --action notify |
| 312 | lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=kernel --type=syscall:entry --name=open --action notify |
| 313 | lttng_add_trigger_ok "T2" --condition event-rule-matches --domain=kernel --type=syscall:exit --name=open --action notify |
| 314 | lttng_add_trigger_ok "T3" --condition event-rule-matches --domain=kernel --type=syscall:entry+exit --name=open --action notify |
| 315 | lttng_add_trigger_ok "T4" --condition event-rule-matches --domain=kernel --type=syscall --name=ptrace --filter 'a > 2' --action notify |
| 316 | |
| 317 | cat > "${tmp_expected_stdout}" <<- EOF |
| 318 | - name: T0 |
| 319 | owner uid: ${uid} |
| 320 | condition: event rule matches |
| 321 | rule: open (type: syscall:entry+exit) |
| 322 | actions: |
| 323 | notify |
| 324 | errors: none |
| 325 | errors: none |
| 326 | - name: T1 |
| 327 | owner uid: ${uid} |
| 328 | condition: event rule matches |
| 329 | rule: open (type: syscall:entry) |
| 330 | actions: |
| 331 | notify |
| 332 | errors: none |
| 333 | errors: none |
| 334 | - name: T2 |
| 335 | owner uid: ${uid} |
| 336 | condition: event rule matches |
| 337 | rule: open (type: syscall:exit) |
| 338 | actions: |
| 339 | notify |
| 340 | errors: none |
| 341 | errors: none |
| 342 | - name: T3 |
| 343 | owner uid: ${uid} |
| 344 | condition: event rule matches |
| 345 | rule: open (type: syscall:entry+exit) |
| 346 | actions: |
| 347 | notify |
| 348 | errors: none |
| 349 | errors: none |
| 350 | - name: T4 |
| 351 | owner uid: ${uid} |
| 352 | condition: event rule matches |
| 353 | rule: ptrace (type: syscall:entry+exit, filter: a > 2) |
| 354 | actions: |
| 355 | notify |
| 356 | errors: none |
| 357 | errors: none |
| 358 | EOF |
| 359 | |
| 360 | list_triggers_matches_ok "event-rule-matches, syscall event rule" "${tmp_expected_stdout}" |
| 361 | |
| 362 | lttng_remove_trigger_ok "T0" |
| 363 | lttng_remove_trigger_ok "T1" |
| 364 | lttng_remove_trigger_ok "T2" |
| 365 | lttng_remove_trigger_ok "T3" |
| 366 | lttng_remove_trigger_ok "T4" |
| 367 | } |
| 368 | |
| 369 | test_session_consumed_size_condition () |
| 370 | { |
| 371 | ${register_some_triggers_bin} test_session_consumed_size_condition |
| 372 | |
| 373 | cat > "${tmp_expected_stdout}" <<- EOF |
| 374 | - name: trigger-with-session-consumed-size-condition |
| 375 | owner uid: ${uid} |
| 376 | condition: session consumed size |
| 377 | session name: the-session-name |
| 378 | threshold: 1234 bytes |
| 379 | actions: |
| 380 | notify |
| 381 | errors: none |
| 382 | errors: none |
| 383 | EOF |
| 384 | |
| 385 | list_triggers_matches_ok "session consumed size condition" "${tmp_expected_stdout}" |
| 386 | |
| 387 | lttng_remove_trigger_ok "trigger-with-session-consumed-size-condition" |
| 388 | } |
| 389 | |
| 390 | test_buffer_usage_conditions () |
| 391 | { |
| 392 | ${register_some_triggers_bin} test_buffer_usage_conditions |
| 393 | |
| 394 | cat > "${tmp_expected_stdout}" <<- EOF |
| 395 | - name: trigger-with-buffer-usage-high-bytes-condition |
| 396 | owner uid: ${uid} |
| 397 | condition: buffer usage high |
| 398 | session name: the-session-name |
| 399 | channel name: the-channel-name |
| 400 | domain: ust |
| 401 | threshold (bytes): 1234 |
| 402 | actions: |
| 403 | notify |
| 404 | errors: none |
| 405 | errors: none |
| 406 | - name: trigger-with-buffer-usage-high-ratio-condition |
| 407 | owner uid: ${uid} |
| 408 | condition: buffer usage high |
| 409 | session name: the-session-name |
| 410 | channel name: the-channel-name |
| 411 | domain: ust |
| 412 | threshold (ratio): 0.25 |
| 413 | actions: |
| 414 | notify |
| 415 | errors: none |
| 416 | errors: none |
| 417 | - name: trigger-with-buffer-usage-low-bytes-condition |
| 418 | owner uid: ${uid} |
| 419 | condition: buffer usage low |
| 420 | session name: the-session-name |
| 421 | channel name: the-channel-name |
| 422 | domain: ust |
| 423 | threshold (bytes): 2345 |
| 424 | actions: |
| 425 | notify |
| 426 | errors: none |
| 427 | errors: none |
| 428 | - name: trigger-with-buffer-usage-low-ratio-condition |
| 429 | owner uid: ${uid} |
| 430 | condition: buffer usage low |
| 431 | session name: the-session-name |
| 432 | channel name: the-channel-name |
| 433 | domain: ust |
| 434 | threshold (ratio): 0.40 |
| 435 | actions: |
| 436 | notify |
| 437 | errors: none |
| 438 | errors: none |
| 439 | EOF |
| 440 | |
| 441 | list_triggers_matches_ok "buffer usage condition" "${tmp_expected_stdout}" |
| 442 | |
| 443 | lttng_remove_trigger_ok "trigger-with-buffer-usage-high-bytes-condition" |
| 444 | lttng_remove_trigger_ok "trigger-with-buffer-usage-high-ratio-condition" |
| 445 | lttng_remove_trigger_ok "trigger-with-buffer-usage-low-bytes-condition" |
| 446 | lttng_remove_trigger_ok "trigger-with-buffer-usage-low-ratio-condition" |
| 447 | } |
| 448 | |
| 449 | test_session_rotation_conditions () |
| 450 | { |
| 451 | ${register_some_triggers_bin} test_session_rotation_conditions |
| 452 | |
| 453 | cat > "${tmp_expected_stdout}" <<- EOF |
| 454 | - name: trigger-with-session-rotation-completed-condition |
| 455 | owner uid: ${uid} |
| 456 | condition: session rotation completed |
| 457 | session name: the-session-name |
| 458 | actions: |
| 459 | notify |
| 460 | errors: none |
| 461 | errors: none |
| 462 | - name: trigger-with-session-rotation-ongoing-condition |
| 463 | owner uid: ${uid} |
| 464 | condition: session rotation ongoing |
| 465 | session name: the-session-name |
| 466 | actions: |
| 467 | notify |
| 468 | errors: none |
| 469 | errors: none |
| 470 | EOF |
| 471 | |
| 472 | list_triggers_matches_ok "session rotation conditions" "${tmp_expected_stdout}" |
| 473 | |
| 474 | lttng_remove_trigger_ok "trigger-with-session-rotation-completed-condition" |
| 475 | lttng_remove_trigger_ok "trigger-with-session-rotation-ongoing-condition" |
| 476 | } |
| 477 | |
| 478 | test_snapshot_action () |
| 479 | { |
| 480 | diag "Listing snapshot actions" |
| 481 | |
| 482 | lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session |
| 483 | lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --path /some/path |
| 484 | lttng_add_trigger_ok "T2" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --url file:///some/other/path |
| 485 | lttng_add_trigger_ok "T3" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --url net://1.2.3.4 |
| 486 | lttng_add_trigger_ok "T4" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --url net://1.2.3.4:1234:1235 |
| 487 | lttng_add_trigger_ok "T5" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1111 --data-url=tcp://1.2.3.4:1112 |
| 488 | lttng_add_trigger_ok "T6" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --path /some/path --max-size=1234 |
| 489 | lttng_add_trigger_ok "T7" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --path /some/path --name=meh |
| 490 | lttng_add_trigger_ok "T8" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --rate-policy=every:10 |
| 491 | lttng_add_trigger_ok "T9" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --rate-policy=once-after:10 |
| 492 | |
| 493 | cat > "${tmp_expected_stdout}" <<- EOF |
| 494 | - name: T0 |
| 495 | owner uid: ${uid} |
| 496 | condition: event rule matches |
| 497 | rule: some-event (type: tracepoint, domain: ust) |
| 498 | actions: |
| 499 | snapshot session \`ze-session\` |
| 500 | errors: none |
| 501 | errors: none |
| 502 | - name: T1 |
| 503 | owner uid: ${uid} |
| 504 | condition: event rule matches |
| 505 | rule: some-event (type: tracepoint, domain: ust) |
| 506 | actions: |
| 507 | snapshot session \`ze-session\`, path: /some/path |
| 508 | errors: none |
| 509 | errors: none |
| 510 | - name: T2 |
| 511 | owner uid: ${uid} |
| 512 | condition: event rule matches |
| 513 | rule: some-event (type: tracepoint, domain: ust) |
| 514 | actions: |
| 515 | snapshot session \`ze-session\`, path: /some/other/path |
| 516 | errors: none |
| 517 | errors: none |
| 518 | - name: T3 |
| 519 | owner uid: ${uid} |
| 520 | condition: event rule matches |
| 521 | rule: some-event (type: tracepoint, domain: ust) |
| 522 | actions: |
| 523 | snapshot session \`ze-session\`, url: net://1.2.3.4 |
| 524 | errors: none |
| 525 | errors: none |
| 526 | - name: T4 |
| 527 | owner uid: ${uid} |
| 528 | condition: event rule matches |
| 529 | rule: some-event (type: tracepoint, domain: ust) |
| 530 | actions: |
| 531 | snapshot session \`ze-session\`, url: net://1.2.3.4:1234:1235 |
| 532 | errors: none |
| 533 | errors: none |
| 534 | - name: T5 |
| 535 | owner uid: ${uid} |
| 536 | condition: event rule matches |
| 537 | rule: some-event (type: tracepoint, domain: ust) |
| 538 | actions: |
| 539 | snapshot session \`ze-session\`, control url: tcp://1.2.3.4:1111, data url: tcp://1.2.3.4:1112 |
| 540 | errors: none |
| 541 | errors: none |
| 542 | - name: T6 |
| 543 | owner uid: ${uid} |
| 544 | condition: event rule matches |
| 545 | rule: some-event (type: tracepoint, domain: ust) |
| 546 | actions: |
| 547 | snapshot session \`ze-session\`, path: /some/path, max size: 1234 |
| 548 | errors: none |
| 549 | errors: none |
| 550 | - name: T7 |
| 551 | owner uid: ${uid} |
| 552 | condition: event rule matches |
| 553 | rule: some-event (type: tracepoint, domain: ust) |
| 554 | actions: |
| 555 | snapshot session \`ze-session\`, path: /some/path, name: meh |
| 556 | errors: none |
| 557 | errors: none |
| 558 | - name: T8 |
| 559 | owner uid: ${uid} |
| 560 | condition: event rule matches |
| 561 | rule: some-event (type: tracepoint, domain: ust) |
| 562 | actions: |
| 563 | snapshot session \`ze-session\`, rate policy: every 10 occurrences |
| 564 | errors: none |
| 565 | errors: none |
| 566 | - name: T9 |
| 567 | owner uid: ${uid} |
| 568 | condition: event rule matches |
| 569 | rule: some-event (type: tracepoint, domain: ust) |
| 570 | actions: |
| 571 | snapshot session \`ze-session\`, rate policy: once after 10 occurrences |
| 572 | errors: none |
| 573 | errors: none |
| 574 | EOF |
| 575 | |
| 576 | list_triggers_matches_ok "snapshot action" "${tmp_expected_stdout}" |
| 577 | |
| 578 | lttng_remove_trigger_ok "T0" |
| 579 | lttng_remove_trigger_ok "T1" |
| 580 | lttng_remove_trigger_ok "T2" |
| 581 | lttng_remove_trigger_ok "T3" |
| 582 | lttng_remove_trigger_ok "T4" |
| 583 | lttng_remove_trigger_ok "T5" |
| 584 | lttng_remove_trigger_ok "T6" |
| 585 | lttng_remove_trigger_ok "T7" |
| 586 | lttng_remove_trigger_ok "T8" |
| 587 | lttng_remove_trigger_ok "T9" |
| 588 | } |
| 589 | |
| 590 | test_notify_action () |
| 591 | { |
| 592 | lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=user --name=some-event --action notify --rate-policy=once-after:5 |
| 593 | lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=user --name=some-event --action notify --rate-policy=every:10 |
| 594 | |
| 595 | cat > "${tmp_expected_stdout}" <<- EOF |
| 596 | - name: T0 |
| 597 | owner uid: ${uid} |
| 598 | condition: event rule matches |
| 599 | rule: some-event (type: tracepoint, domain: ust) |
| 600 | actions: |
| 601 | notify, rate policy: once after 5 occurrences |
| 602 | errors: none |
| 603 | errors: none |
| 604 | - name: T1 |
| 605 | owner uid: ${uid} |
| 606 | condition: event rule matches |
| 607 | rule: some-event (type: tracepoint, domain: ust) |
| 608 | actions: |
| 609 | notify, rate policy: every 10 occurrences |
| 610 | errors: none |
| 611 | errors: none |
| 612 | EOF |
| 613 | |
| 614 | list_triggers_matches_ok "notify action" "${tmp_expected_stdout}" |
| 615 | |
| 616 | lttng_remove_trigger_ok "T0" |
| 617 | lttng_remove_trigger_ok "T1" |
| 618 | } |
| 619 | |
| 620 | plan_tests $NUM_TESTS |
| 621 | |
| 622 | # shellcheck disable=SC2119 |
| 623 | start_lttng_sessiond_notap |
| 624 | |
| 625 | test_top_level_options |
| 626 | test_event_rule_matches_tracepoint |
| 627 | skip $ist_root "non-root user: skipping kprobe tests" 9 || test_event_rule_matches_probe |
| 628 | skip $ist_root "non-root user: skipping uprobe tests" 5 || test_event_rule_matches_userspace_probe_elf |
| 629 | skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 5 || test_event_rule_matches_userspace_probe_sdt |
| 630 | skip $ist_root "non-root user: skipping syscall tests" 13 || test_event_rule_matches_syscall |
| 631 | test_session_consumed_size_condition |
| 632 | test_buffer_usage_conditions |
| 633 | test_session_rotation_conditions |
| 634 | test_snapshot_action |
| 635 | test_notify_action |
| 636 | |
| 637 | stop_lttng_sessiond_notap |
| 638 | |
| 639 | # Cleanup |
| 640 | rm -f "${tmp_stdout}" |
| 641 | rm -f "${tmp_stderr}" |
| 642 | rm -f "${tmp_expected_stdout}" |