Tests: remove leftover debug printing in test_add_trigger_cli
[lttng-tools.git] / tests / regression / tools / trigger / test_add_trigger_cli
CommitLineData
b4b7369f
JR
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 add-trigger` command line interface.
19
20CURDIR="$(dirname "$0")"
21TESTDIR="$CURDIR/../../.."
22
23# shellcheck source=../../../utils/utils.sh
24source "$TESTDIR/utils/utils.sh"
25
ef9ff9cb 26plan_tests 295
b4b7369f
JR
27
28FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
29
30# shellcheck disable=SC2119
31start_lttng_sessiond_notap
32
8d5a3312
MJ
33tmp_stdout=$(mktemp -t test_parse_cli_trigger_stdout.XXXXXX)
34tmp_stderr=$(mktemp -t test_parse_cli_trigger_stderr.XXXXXX)
b4b7369f
JR
35uprobe_elf_binary="${TESTDIR}/utils/testapp/userspace-probe-elf-binary/.libs/userspace-probe-elf-binary"
36
37if [ "$(id -u)" == "0" ]; then
38 ist_root=1
39else
40 ist_root=0
41fi
42
43function test_success ()
44{
45 local test_name="$1"
f674361c
JG
46 local trigger_name="$2"
47 shift 2
b4b7369f
JR
48
49 diag "${FULL_LTTNG_BIN} add-trigger $*"
50 "${FULL_LTTNG_BIN}" add-trigger "$@" > "${tmp_stdout}" 2> "${tmp_stderr}"
51 ok $? "${test_name}: exit code is 0"
52
f674361c 53 diff -u "${tmp_stdout}" <(echo "Added trigger \`$trigger_name\`.")
b4b7369f
JR
54 ok $? "${test_name}: expected stdout"
55
56 diff -u "${tmp_stderr}" /dev/null
57 ok $? "${test_name}: expected stderr"
58}
59
60function test_failure ()
61{
62 local test_name="$1"
63 local error_msg="$2"
64
65 shift 2
66
67 diag "${FULL_LTTNG_BIN} add-trigger $*"
68 "${FULL_LTTNG_BIN}" add-trigger "$@" > "${tmp_stdout}" 2> "${tmp_stderr}"
69 isnt $? 0 "${test_name}: exit code is not 0"
70
71 diff -u "${tmp_stdout}" /dev/null
72 ok $? "${test_name}: expected stdout"
73
74 diff -u "${tmp_stderr}" <(echo "${error_msg}")
75 ok $? "${test_name}: expected stderr"
76}
77
dceffc9e
JR
78function test_mi ()
79{
80 local tmp_stdout_raw
81 local tmp_expected_stdout
82
83 # Concretely the code used to serialize a trigger object is the same as
84 # the one used by the list command. Here we simply validate that a
85 # simple trigger is correctly generated.
86
8d5a3312
MJ
87 tmp_stdout_raw=$(mktemp -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
88 tmp_expected_stdout=$(mktemp -t "tmp.${FUNCNAME[0]}_expected_stdout.XXXXXX")
dceffc9e
JR
89
90 diag "${FULL_LTTNG_BIN} --mi=xml add-trigger"
91
92 cat > "${tmp_expected_stdout}" <<- EOF
93 <?xml version="1.0" encoding="UTF-8"?>
dcd975d1 94 <command xmlns="https://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://lttng.org/xml/ns/lttng-mi https://lttng.org/xml/schemas/lttng-mi/${MI_XSD_MAJOR_VERSION}/lttng-mi-${MI_XSD_MAJOR_VERSION}.${MI_XSD_MINOR_VERSION}.xsd" schemaVersion="${MI_XSD_MAJOR_VERSION}.${MI_XSD_MINOR_VERSION}">
dceffc9e
JR
95 <name>add-trigger</name>
96 <output>
97 <trigger>
98 <name>mi_hohoho</name>
99 <owner_uid>${UID}</owner_uid>
100 <condition>
101 <condition_event_rule_matches>
102 <event_rule>
103 <event_rule_user_tracepoint>
104 <name_pattern>some-event-id</name_pattern>
105 </event_rule_user_tracepoint>
106 </event_rule>
107 <capture_descriptors/>
108 </condition_event_rule_matches>
109 </condition>
110 <action>
111 <action_list>
112 <action>
113 <action_notify>
114 <rate_policy>
115 <rate_policy_every_n>
116 <interval>1</interval>
117 </rate_policy_every_n>
118 </rate_policy>
119 </action_notify>
120 </action>
121 </action_list>
122 </action>
123 </trigger>
124 </output>
125 <success>true</success>
126 </command>
127 EOF
128
129 "${FULL_LTTNG_BIN}" --mi xml add-trigger --name mi_hohoho \
130 --condition event-rule-matches --name=some-event-id --type=user \
131 --action notify > "${tmp_stdout_raw}" 2> "${tmp_stderr}"
132
133 ok $? "add-trigger mi: exit code is 0"
134
135 # Pretty-fy xml before further test.
fa182fe0 136 $XML_PRETTY < "${tmp_stdout_raw}" > "${tmp_stdout}"
dceffc9e 137
fa182fe0 138 $MI_VALIDATE "${tmp_stdout}"
dceffc9e
JR
139 ok $? "add-trigger mi is valid"
140
141 diff -u "${tmp_expected_stdout}" "${tmp_stdout}"
142 ok $? "mi: expected stdout"
143
144 diff -u "${tmp_stderr}" /dev/null
145 ok $? "mi: expected stderr"
146
147 rm -f "${tmp_stdout_raw}"
148}
149
b4b7369f 150# top-level options
f674361c 151test_success "explicit name" "hohoho" \
1d4b59f2 152 --name hohoho \
f674361c 153 --condition event-rule-matches --type=user \
b4b7369f
JR
154 --action notify
155
665db063 156# `--condition event-rule-matches` successes
695f7044 157test_success "--condition event-rule-matches some-event --type=user" \
f674361c
JG
158 "some-event" \
159 --name=some-event --condition event-rule-matches --type=user \
b4b7369f
JR
160 --action notify
161
f674361c 162test_success "--condition event-rule-matches --type=user" "trigger0" \
695f7044 163 --condition event-rule-matches --type=user \
b4b7369f
JR
164 --action notify
165
f674361c
JG
166test_success "notify action policies" "test-rate-policy-1" \
167 --name=test-rate-policy-1 \
168 --condition event-rule-matches --type=user \
b4b7369f 169 --action notify \
bbadb5e0 170 --rate-policy=every:55 \
e45dd625 171 --action notify \
bbadb5e0 172 --rate-policy=once-after:55
b4b7369f 173
f674361c
JG
174test_success "start session action policies" "test-rate-policy-2" \
175 --name=test-rate-policy-2 \
176 --condition event-rule-matches --type=user \
e45dd625 177 --action start-session my_session \
bbadb5e0 178 --rate-policy=every:55 \
e45dd625 179 --action start-session my_session \
bbadb5e0 180 --rate-policy=once-after:55
e45dd625 181
f674361c
JG
182test_success "stop session action policies" "test-rate-policy-3" \
183 --name=test-rate-policy-3 \
184 --condition event-rule-matches --type=user \
e45dd625 185 --action stop-session my_session \
bbadb5e0 186 --rate-policy=every:55 \
e45dd625 187 --action stop-session my_session \
bbadb5e0 188 --rate-policy=once-after:55
e45dd625 189
f674361c
JG
190test_success "snapshot session action policies" "test-rate-policy-4" \
191 --name=test-rate-policy-4 \
192 --condition event-rule-matches --type=user \
e45dd625 193 --action snapshot-session my_session \
bbadb5e0 194 --rate-policy=every:55 \
e45dd625 195 --action snapshot-session my_session \
bbadb5e0 196 --rate-policy=once-after:55
e45dd625 197
f674361c
JG
198test_success "rotate session action policies" "test-rate-policy-5" \
199 --name=test-rate-policy-5 \
200 --condition event-rule-matches --type=user \
e45dd625 201 --action rotate-session my_session \
bbadb5e0 202 --rate-policy=every:55 \
e45dd625 203 --action rotate-session my_session \
bbadb5e0 204 --rate-policy=once-after:55
b4b7369f 205
f674361c 206test_success "--log-level single level" "trigger1" \
695f7044 207 --condition event-rule-matches --type=user --log-level=INFO \
949f049b
SM
208 --action notify
209
f674361c 210test_success "--log-level range open max" "trigger2" \
695f7044 211 --condition event-rule-matches --type=user --log-level=INFO.. \
949f049b
SM
212 --action notify
213
f674361c 214test_success "--log-level range any" "trigger3" \
695f7044 215 --condition event-rule-matches --type=user --log-level=.. \
949f049b
SM
216 --action notify
217
f674361c 218test_success "--exclude-name one" "trigger4" \
695f7044 219 --condition event-rule-matches --type=user --name='bernard*' --exclude-name=bernard-lermite \
b03a81fb
SM
220 --action notify
221
f674361c 222test_success "--exclude-name two" "trigger5" \
695f7044 223 --condition event-rule-matches --type=user --name='jean-*' --exclude-name jean-chretien -x jean-charest \
b03a81fb
SM
224 --action notify
225
24de704e 226skip $ist_root "non-root user: skipping kprobe tests" 18 || {
f674361c
JG
227 i=0
228
85522de5 229 for type in kprobe kernel:kprobe; do
f674361c
JG
230 test_success "--condition event-rule-matches probe by symbol" "kprobe-trigger-$i" \
231 --name="kprobe-trigger-$i" \
695f7044 232 --condition event-rule-matches --type=$type --location=lttng_channel_enable --event-name=my_channel_enable \
24de704e
SM
233 --action notify
234
235 channel_enable_addr=$(grep ' t lttng_channel_enable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ')
236 channel_disable_addr=$(grep ' t lttng_channel_disable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ')
237
238 # We need to find a valid offset.
239 base_symbol=""
240 offset=0
241 if [[ 0x$channel_enable_addr -lt 0x$channel_disable_addr ]]; then
242 base_symbol="lttng_channel_enable"
243 offset=$(( 0x$channel_disable_addr - 0x$channel_enable_addr ))
244 else
245 base_symbol="lttng_channel_disable"
246 offset=$(( 0x$channel_enable_addr - 0x$channel_disable_addr ))
247 fi
248
249 offset_hex="0x$(printf '%x' $offset)"
250
f674361c
JG
251
252 test_success "--condition event-rule-matches probe by symbol with offset" "kprobe-trigger-$((i+1))" \
253 --name="kprobe-trigger-$((i+1))" \
695f7044 254 --condition event-rule-matches --type=$type --location="${base_symbol}+${offset_hex}" --event-name=my_$base_symbol \
24de704e
SM
255 --action notify
256
f674361c
JG
257 test_success "--condition event-rule-matches probe by address" "kprobe-trigger-$((i+2))" \
258 --name="kprobe-trigger-$((i+2))" \
695f7044 259 --condition event-rule-matches --type=$type --location="0x${channel_enable_addr}" --event-name=my_channel_enable \
24de704e 260 --action notify
f674361c 261 i=$((i+3))
24de704e 262 done
b4b7369f
JR
263}
264
46fd07ac 265skip $ist_root "non-root user: skipping uprobe tests" 6 || {
f674361c
JG
266 test_success "--condition event-rule-matches uprobe" "uprobe-trigger-0" \
267 --name="uprobe-trigger-0" \
695f7044 268 --condition event-rule-matches --type=kernel:uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe \
46fd07ac 269 --action notify
b4b7369f 270
f674361c
JG
271 test_success "--condition event-rule-matches uprobe with elf prefix" "uprobe-trigger-1" \
272 --name="uprobe-trigger-1" \
695f7044 273 --condition event-rule-matches --type=kernel:uprobe --location=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \
46fd07ac 274 --action notify
b4b7369f
JR
275}
276
4f7da553 277skip $ist_root "non-root user: skipping syscall tests" 30 || {
f674361c
JG
278 test_success "--condition event-rule-matches one syscall" "syscall-trigger-0" \
279 --name="syscall-trigger-0" \
695f7044 280 --condition event-rule-matches --type=syscall --name=open \
b4b7369f
JR
281 --action notify
282
f674361c
JG
283 test_success "--condition event-rule-matches all syscalls" "syscall-trigger-1" \
284 --name="syscall-trigger-1" \
695f7044 285 --condition event-rule-matches --type=syscall \
b4b7369f
JR
286 --action notify
287
f674361c
JG
288 test_success "--condition event-rule-matches one syscall with filter" "syscall-trigger-2" \
289 --name="syscall-trigger-2" \
695f7044 290 --condition event-rule-matches --type=syscall --filter 'a > 2' --name=open \
b4b7369f 291 --action notify
f674361c
JG
292 test_success "--condition event-rule-matches one syscall:entry" "syscall-trigger-3" \
293 --name="syscall-trigger-3" \
695f7044 294 --condition event-rule-matches --type=syscall:entry --name=open \
57739a6b 295 --action notify
f674361c
JG
296 test_success "--condition event-rule-matches one syscall:exit" "syscall-trigger-4" \
297 --name="syscall-trigger-4" \
695f7044 298 --condition event-rule-matches --type=syscall:exit --name=open \
57739a6b 299 --action notify
f674361c
JG
300 test_success "--condition event-rule-matches one syscall:entry-exit" "syscall-trigger-5" \
301 --name="syscall-trigger-5" \
695f7044 302 --condition event-rule-matches --type=syscall:entry+exit --name=open \
57739a6b 303 --action notify
4f7da553
JR
304
305 # Same thing but with "kernel:syscall" type instead:
f674361c
JG
306 test_success "--condition event-rule-matches one syscall" "syscall-trigger-6" \
307 --name="syscall-trigger-6" \
695f7044 308 --condition event-rule-matches --type=kernel:syscall --name=open \
4f7da553
JR
309 --action notify
310
f674361c
JG
311 test_success "--condition event-rule-matches one kernel:syscall:entry" "syscall-trigger-7" \
312 --name="syscall-trigger-7" \
695f7044 313 --condition event-rule-matches --type=kernel:syscall:entry --name=open \
4f7da553 314 --action notify
f674361c
JG
315 test_success "--condition event-rule-matches one kernel:syscall:exit" "syscall-trigger-8" \
316 --name="syscall-trigger-8" \
695f7044 317 --condition event-rule-matches --type=kernel:syscall:exit --name=open \
4f7da553 318 --action notify
f674361c
JG
319 test_success "--condition event-rule-matches one kernel:syscall:entry-exit" "syscall-trigger-9" \
320 --name="syscall-trigger-9" \
695f7044 321 --condition event-rule-matches --type=kernel:syscall:entry+exit --name=open \
4f7da553
JR
322 --action notify
323
b4b7369f
JR
324}
325
326# `--action notify` successes
f674361c
JG
327test_success "--action notify" "notify-1" \
328 --name=notify-1 \
695f7044 329 --condition event-rule-matches --type=user \
b4b7369f
JR
330 --action notify
331
f674361c
JG
332test_success "--action notify --capture foo" "notify-2" \
333 --name=notify-2 \
695f7044 334 --condition event-rule-matches --type=user \
20a01d15
SM
335 --capture foo --action notify
336
f674361c
JG
337test_success "--action notify --capture foo[2]" "notify-3" \
338 --name=notify-3 \
695f7044 339 --condition event-rule-matches --type=user \
20a01d15
SM
340 --capture 'foo[2]' --action notify
341
f674361c
JG
342test_success '--action notify --capture $ctx.foo' "notify-4" \
343 --name=notify-4 \
695f7044 344 --condition event-rule-matches --type=user \
20a01d15
SM
345 --capture '$ctx.foo' --action notify
346
f674361c
JG
347test_success '--action notify --capture $ctx.foo[2]' "notify-5" \
348 --name=notify-5 \
695f7044 349 --condition event-rule-matches --type=user \
20a01d15
SM
350 --capture '$ctx.foo[2]' --action notify
351
f674361c
JG
352test_success '--action notify --capture $app.prov:type' "notify-6" \
353 --name=notify-6 \
695f7044 354 --condition event-rule-matches --type=user \
20a01d15
SM
355 --capture '$app.prov:type' --action notify
356
f674361c
JG
357test_success '--action notify --capture $app.prov:type[2]' "notify-7" \
358 --name=notify-7 \
695f7044 359 --condition event-rule-matches --type=user \
20a01d15
SM
360 --capture '$app.prov:type[2]' --action notify
361
f674361c
JG
362test_success '--action notify multiple captures' "notify-8" \
363 --name=notify-8 \
695f7044 364 --condition event-rule-matches --type=user \
20a01d15
SM
365 --capture foo --capture '$app.hello:world' --action notify
366
b4b7369f 367# `--action start-session` successes
f674361c
JG
368test_success "--action start-session" "notify-9" \
369 --name=notify-9 \
695f7044 370 --condition event-rule-matches --type=user \
b4b7369f
JR
371 --action start-session ze-session
372
373# `--action stop-session` successes
f674361c
JG
374test_success "--action stop-session foo" "notify-10"\
375 --name=notify-10 \
695f7044 376 --condition event-rule-matches --type=user \
b4b7369f
JR
377 --action stop-session ze-session
378
379# `--action rotate-session` successes
f674361c
JG
380test_success "--action rotate-session foo" "notify-11"\
381 --name=notify-11 \
695f7044 382 --condition event-rule-matches --type=user \
b4b7369f
JR
383 --action rotate-session ze-session
384
385# `--action snapshot-session` successes
f674361c
JG
386test_success "--action snapshot-session foo" "notify-12"\
387 --name=notify-12 \
695f7044 388 --condition event-rule-matches --type=user \
b4b7369f
JR
389 --action snapshot-session ze-session
390
f674361c
JG
391test_success "--action snapshot-session with file URI" "notify-13"\
392 --name=notify-13 \
695f7044 393 --condition event-rule-matches --type=user \
b4b7369f
JR
394 --action snapshot-session ze-session --path /hello
395
f674361c
JG
396test_success "--action snapshot-session with net URI" "notify-14"\
397 --name=notify-14 \
695f7044 398 --condition event-rule-matches --type=user \
b4b7369f
JR
399 --action snapshot-session ze-session --url net://1.2.3.4
400
f674361c
JG
401test_success "--action snapshot-session with ctrl/data URIs" "notify-15"\
402 --name=notify-15 \
695f7044 403 --condition event-rule-matches --type=user \
b4b7369f
JR
404 --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1234 --data-url=tcp://1.2.3.4:1235
405
406# top-level failures
407test_failure "no args" "Error: Missing --condition."
408
409test_failure "unknown option" \
35c4b2b3 410 "Error: While parsing argument #2 (\`--hello\`): Unknown option \`--hello\`" \
b4b7369f
JR
411 --hello
412
413test_failure "missing --action" \
414 "Error: Need at least one --action." \
695f7044 415 --condition event-rule-matches --type=user
b4b7369f
JR
416
417test_failure "two --condition" \
418 "Error: A --condition was already given." \
695f7044
JR
419 --condition event-rule-matches --name=aaa --type=user \
420 --condition event-rule-matches --name=bbb --type=user \
b4b7369f
JR
421 --action notify
422
1d4b59f2 423test_failure "missing argument to --name" \
35c4b2b3 424 "Error: While parsing argument #2 (\`--name\`): Missing required argument for option \`--name\`" \
1d4b59f2 425 --name
b4b7369f 426
bbadb5e0 427for cmd in rate-policy=once-after rate-policy=every; do
b4b7369f 428 test_failure "missing argument to --${cmd}" \
bbadb5e0 429 "Error: Rate policy format is invalid." \
695f7044 430 --condition event-rule-matches --type=user --action notify \
b4b7369f
JR
431 --${cmd}
432
433 test_failure "invalid argument to --${cmd}: non-digit character" \
bbadb5e0 434 "Error: Failed to parse rate policy value \`123bob\` as an integer." \
695f7044 435 --condition event-rule-matches --type=user --action notify \
bbadb5e0 436 --${cmd}:123bob
b4b7369f
JR
437
438 test_failure "invalid argument to --${cmd}: empty string" \
bbadb5e0 439 "Error: Failed to parse rate policy value \`\` as an integer." \
695f7044 440 --condition event-rule-matches --type=user --action notify \
bbadb5e0 441 --${cmd}":"
b4b7369f
JR
442done
443
bbadb5e0
JR
444test_failure "invalid argument to --rate-policy: unknown policy type" \
445 "Error: Rate policy type \`bob\` unknown." \
695f7044 446 --condition event-rule-matches --type=user --action notify \
bbadb5e0
JR
447 --rate-policy=bob:123
448
b4b7369f
JR
449# `--condition` failures
450test_failure "missing args after --condition" \
ef9ff9cb
SM
451 "Error: While parsing argument #2 (\`--condition\`): Missing required argument for option \`--condition\`
452Error: Valid condition names are:
453Error: event-rule-matches" \
b4b7369f
JR
454 --condition
455test_failure "unknown --condition" \
ef9ff9cb
SM
456 "Error: While parsing argument #2 (\`--condition\`): Unknown condition name 'zoofest'
457Error: Valid condition names are:
458Error: event-rule-matches" \
b4b7369f 459 --condition zoofest
e776cf47 460test_failure "unknown --condition=" \
ef9ff9cb
SM
461 "Error: While parsing argument #2 (\`--condition=zoofest\`): Unknown condition name 'zoofest'
462Error: Valid condition names are:
463Error: event-rule-matches" \
e776cf47 464 --condition=zoofest
b4b7369f 465
665db063
SM
466# `--condition event-rule-matches` failures
467test_failure "missing args after --condition event-rule-matches" \
695f7044 468 "Error: Need at least one --action." \
0b621ec1 469 --condition event-rule-matches --type=user
50ad0862 470
665db063 471test_failure "extra args after --condition event-rule-matches" \
b4b7369f 472 "Error: Unexpected argument 'bozo'" \
695f7044 473 --condition event-rule-matches --type=user bozo
64c34630 474
949f049b
SM
475test_failure "--log-level unknown level" \
476 "Error: Failed to parse log level string \`FOO\`." \
695f7044 477 --condition event-rule-matches --type=user --log-level=FOO
b4b7369f 478
85522de5 479for type in kprobe kernel:kprobe; do
24de704e 480 test_failure "--condition event-rule-matches: --name with --type=$type" \
85522de5 481 "Error: Can't use --name with kernel kprobe event rules." \
24de704e
SM
482 --condition event-rule-matches --type=$type --location=do_sys_open --name='hello'
483done
484
695f7044
JR
485test_failure "--condition event-rule-matches: --location with user tracepoint event rule" \
486 "Error: Can't use --location with user tracepoint event rules." \
487 --condition event-rule-matches --type=user --location='hello'
b4b7369f 488
695f7044
JR
489test_failure "--condition event-rule-matches: --event-name with user tracepoint event rule" \
490 "Error: Can't use --event-name with user tracepoint event rules." \
491 --condition event-rule-matches --type=user --event-name='hello'
50ad0862 492
46fd07ac
JR
493test_failure "--condition event-rule-matches: extra argument with --type=kernel:uprobe" \
494 "Error: Unexpected argument 'hello'" \
695f7044 495 --condition event-rule-matches --type=$type --location=${uprobe_elf_binary}:test_failure hello
b4b7369f 496
24de704e 497test_failure "--condition event-rule-matches: extra argument with --type=syscall" \
b4b7369f 498 "Error: Unexpected argument 'open'" \
695f7044 499 --condition event-rule-matches --type=syscall open
b4b7369f 500
57739a6b
JR
501test_failure "--condition event-rule-matches: --type=syscall:nope" \
502 "Error: Failed to parse syscall type 'syscall:nope'." \
695f7044 503 --condition event-rule-matches --type=syscall:nope \
57739a6b
JR
504 --name=open
505
b03a81fb
SM
506test_failure "--exclude-name with non-glob name" \
507 "Error: Event jean: Exclusions can only be used with a globbing pattern" \
695f7044 508 --condition event-rule-matches --type=user --name='jean' --exclude-name jean-chretien \
b03a81fb
SM
509 --action notify
510
665db063 511test_failure "--condition event-rule-matches --capture: missing argument (end of arg list)" \
35c4b2b3 512 'Error: While parsing argument #7 (`--capture`): Missing required argument for option `--capture`' \
20a01d15 513 --action notify \
695f7044 514 --condition event-rule-matches --type=user --capture
20a01d15 515
665db063 516test_failure "--condition event-rule-matches --capture: missing argument (before another option)" \
20a01d15 517 'Error: While parsing expression `--action`: Unary operators are not allowed in capture expressions.' \
695f7044 518 --condition event-rule-matches --type=user --capture \
20a01d15
SM
519 --action notify \
520
665db063 521test_failure "--condition event-rule-matches --capture: binary operator" \
20a01d15 522 'Error: While parsing expression `foo == 2`: Binary operators are not allowed in capture expressions.' \
695f7044 523 --condition event-rule-matches --type=user \
20a01d15
SM
524 --capture 'foo == 2' --action notify
525
665db063 526test_failure "--condition event-rule-matches --capture: unary operator" \
20a01d15 527 'Error: While parsing expression `!foo`: Unary operators are not allowed in capture expressions.' \
695f7044 528 --condition event-rule-matches --type=user \
20a01d15
SM
529 --capture '!foo' --action notify
530
665db063 531test_failure "--condition event-rule-matches --capture: logical operator" \
20a01d15 532 'Error: While parsing expression `foo || bar`: Logical operators are not allowed in capture expressions.' \
695f7044 533 --condition event-rule-matches --type=user \
20a01d15
SM
534 --capture 'foo || bar' --action notify
535
665db063 536test_failure "--condition event-rule-matches --capture: accessing a sub-field" \
20a01d15 537 'Error: While parsing expression `foo.bar`: Capturing subfields is not supported.' \
695f7044 538 --condition event-rule-matches --type=user \
20a01d15
SM
539 --capture 'foo.bar' --action notify
540
665db063 541test_failure "--condition event-rule-matches --capture: accessing the sub-field of an array element" \
20a01d15 542 'Error: While parsing expression `foo[3].bar`: Capturing subfields is not supported.' \
695f7044 543 --condition event-rule-matches --type=user \
20a01d15
SM
544 --capture 'foo[3].bar' --action notify
545
665db063 546test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \
20a01d15 547 'Error: Invalid app-specific context field name: missing colon in `foo`.' \
695f7044 548 --condition event-rule-matches --type=user \
20a01d15
SM
549 --capture '$app.foo' --action notify
550
665db063 551test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \
20a01d15 552 'Error: Invalid app-specific context field name: missing type name after colon in `foo:`.' \
695f7044 553 --condition event-rule-matches --type=user \
20a01d15
SM
554 --capture '$app.foo:' --action notify
555
b4b7369f
JR
556# `--action` failures
557test_failure "missing args after --action" \
ef9ff9cb
SM
558 "Error: While parsing argument #5 (\`--action\`): Missing required argument for option \`--action\`
559Error: Valid action names are:
560Error: notify" \
695f7044 561 --condition event-rule-matches --type=user \
b4b7369f
JR
562 --action
563
ef9ff9cb
SM
564test_failure "unknown --action" \
565 "Error: While parsing argument #5 (\`--action\`): Unknown action name 'zoofest'
566Error: Valid action names are:
567Error: notify" \
568 --condition event-rule-matches --type=user \
569 --action zoofest
570
571test_failure "unknown --action=" \
572 "Error: While parsing argument #5 (\`--action=zoofest\`): Unknown action name 'zoofest'
573Error: Valid action names are:
574Error: notify" \
575 --condition event-rule-matches --type=user \
576 --action=zoofest
577
b4b7369f
JR
578# `--action notify` failures
579test_failure "extra arg after --action notify" \
580 "Error: Unexpected argument \`bob\`." \
695f7044 581 --condition event-rule-matches --type=user \
b4b7369f
JR
582 --action notify bob
583
584# `--action start-session` failures
585test_failure "missing arg after --action start-session" \
586 "Error: Missing session name." \
695f7044 587 --condition event-rule-matches --type=user \
b4b7369f
JR
588 --action start-session
589test_failure "extra arg after --action start-session" \
590 "Error: Unexpected argument \`bob\`." \
695f7044 591 --condition event-rule-matches --type=user \
b4b7369f
JR
592 --action start-session ze-session bob
593
594# `--action stop-session` failures
595test_failure "missing arg after --action stop-session" \
596 "Error: Missing session name." \
695f7044 597 --condition event-rule-matches --type=user \
b4b7369f
JR
598 --action stop-session
599test_failure "extra arg after --action stop-session" \
600 "Error: Unexpected argument \`bob\`." \
695f7044 601 --condition event-rule-matches --type=user \
b4b7369f
JR
602 --action stop-session ze-session bob
603
604# `--action rotate-session` failures
605test_failure "missing arg after --action rotate-session" \
606 "Error: Missing session name." \
695f7044 607 --condition event-rule-matches --type=user \
b4b7369f
JR
608 --action rotate-session
609test_failure "extra arg after --action rotate-session" \
610 "Error: Unexpected argument \`bob\`." \
695f7044 611 --condition event-rule-matches --type=user \
b4b7369f
JR
612 --action rotate-session ze-session bob
613
614# `--action snapshot-session` failures
615test_failure "missing arg after --action snapshot-session" \
616 "Error: Missing session name." \
695f7044 617 --condition event-rule-matches --type=user \
b4b7369f
JR
618 --action snapshot-session
619test_failure "extra arg after --action snapshot-session" \
620 "Error: Unexpected argument \`bob\`." \
695f7044 621 --condition event-rule-matches --type=user \
b4b7369f
JR
622 --action snapshot-session ze-session bob
623test_failure "snapshot-session action, --max-size without destination" \
624 "Error: Can't provide a snapshot output max size without a snapshot output destination." \
695f7044 625 --condition event-rule-matches --type=user \
b4b7369f
JR
626 --action snapshot-session ze-session --max-size 10M
627test_failure "snapshot-session action, --name without destination" \
628 "Error: Can't provide a snapshot output name without a snapshot output destination." \
695f7044 629 --condition event-rule-matches --type=user \
b4b7369f
JR
630 --action snapshot-session ze-session --name hallo
631test_failure "snapshot-session action, --name with-local-path-instead-of-url" \
632 "Error: Failed to parse '/something/that/looks/like/a/path' as an URL." \
695f7044 633 --condition event-rule-matches --type=user \
b4b7369f
JR
634 --action snapshot-session ze-session --name hallo --url /something/that/looks/like/a/path
635test_failure "snapshot-session action, --name with-net-url-instead-of-path" \
636 "Error: Failed to parse 'net://8.8.8.8/' as a local path." \
695f7044 637 --condition event-rule-matches --type=user \
b4b7369f
JR
638 --action snapshot-session ze-session --name hallo --path net://8.8.8.8/
639
dceffc9e
JR
640test_mi
641
b4b7369f
JR
642# Cleanup
643stop_lttng_sessiond_notap
644rm -f "${tmp_stdout}"
645rm -f "${tmp_stderr}"
This page took 0.069403 seconds and 4 git commands to generate.