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