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