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