port: add support for BSD mktemp
[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 $*"
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
8d5a3312
MJ
89 tmp_stdout_raw=$(mktemp -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
90 tmp_expected_stdout=$(mktemp -t "tmp.${FUNCNAME[0]}_expected_stdout.XXXXXX")
dceffc9e
JR
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" \
ef9ff9cb
SM
453 "Error: While parsing argument #2 (\`--condition\`): Missing required argument for option \`--condition\`
454Error: Valid condition names are:
455Error: event-rule-matches" \
b4b7369f
JR
456 --condition
457test_failure "unknown --condition" \
ef9ff9cb
SM
458 "Error: While parsing argument #2 (\`--condition\`): Unknown condition name 'zoofest'
459Error: Valid condition names are:
460Error: event-rule-matches" \
b4b7369f 461 --condition zoofest
e776cf47 462test_failure "unknown --condition=" \
ef9ff9cb
SM
463 "Error: While parsing argument #2 (\`--condition=zoofest\`): Unknown condition name 'zoofest'
464Error: Valid condition names are:
465Error: event-rule-matches" \
e776cf47 466 --condition=zoofest
b4b7369f 467
665db063
SM
468# `--condition event-rule-matches` failures
469test_failure "missing args after --condition event-rule-matches" \
695f7044 470 "Error: Need at least one --action." \
0b621ec1 471 --condition event-rule-matches --type=user
50ad0862 472
665db063 473test_failure "extra args after --condition event-rule-matches" \
b4b7369f 474 "Error: Unexpected argument 'bozo'" \
695f7044 475 --condition event-rule-matches --type=user bozo
64c34630 476
949f049b
SM
477test_failure "--log-level unknown level" \
478 "Error: Failed to parse log level string \`FOO\`." \
695f7044 479 --condition event-rule-matches --type=user --log-level=FOO
b4b7369f 480
85522de5 481for type in kprobe kernel:kprobe; do
24de704e 482 test_failure "--condition event-rule-matches: --name with --type=$type" \
85522de5 483 "Error: Can't use --name with kernel kprobe event rules." \
24de704e
SM
484 --condition event-rule-matches --type=$type --location=do_sys_open --name='hello'
485done
486
695f7044
JR
487test_failure "--condition event-rule-matches: --location with user tracepoint event rule" \
488 "Error: Can't use --location with user tracepoint event rules." \
489 --condition event-rule-matches --type=user --location='hello'
b4b7369f 490
695f7044
JR
491test_failure "--condition event-rule-matches: --event-name with user tracepoint event rule" \
492 "Error: Can't use --event-name with user tracepoint event rules." \
493 --condition event-rule-matches --type=user --event-name='hello'
50ad0862 494
46fd07ac
JR
495test_failure "--condition event-rule-matches: extra argument with --type=kernel:uprobe" \
496 "Error: Unexpected argument 'hello'" \
695f7044 497 --condition event-rule-matches --type=$type --location=${uprobe_elf_binary}:test_failure hello
b4b7369f 498
24de704e 499test_failure "--condition event-rule-matches: extra argument with --type=syscall" \
b4b7369f 500 "Error: Unexpected argument 'open'" \
695f7044 501 --condition event-rule-matches --type=syscall open
b4b7369f 502
57739a6b
JR
503test_failure "--condition event-rule-matches: --type=syscall:nope" \
504 "Error: Failed to parse syscall type 'syscall:nope'." \
695f7044 505 --condition event-rule-matches --type=syscall:nope \
57739a6b
JR
506 --name=open
507
b03a81fb
SM
508test_failure "--exclude-name with non-glob name" \
509 "Error: Event jean: Exclusions can only be used with a globbing pattern" \
695f7044 510 --condition event-rule-matches --type=user --name='jean' --exclude-name jean-chretien \
b03a81fb
SM
511 --action notify
512
665db063 513test_failure "--condition event-rule-matches --capture: missing argument (end of arg list)" \
35c4b2b3 514 'Error: While parsing argument #7 (`--capture`): Missing required argument for option `--capture`' \
20a01d15 515 --action notify \
695f7044 516 --condition event-rule-matches --type=user --capture
20a01d15 517
665db063 518test_failure "--condition event-rule-matches --capture: missing argument (before another option)" \
20a01d15 519 'Error: While parsing expression `--action`: Unary operators are not allowed in capture expressions.' \
695f7044 520 --condition event-rule-matches --type=user --capture \
20a01d15
SM
521 --action notify \
522
665db063 523test_failure "--condition event-rule-matches --capture: binary operator" \
20a01d15 524 'Error: While parsing expression `foo == 2`: Binary operators are not allowed in capture expressions.' \
695f7044 525 --condition event-rule-matches --type=user \
20a01d15
SM
526 --capture 'foo == 2' --action notify
527
665db063 528test_failure "--condition event-rule-matches --capture: unary operator" \
20a01d15 529 'Error: While parsing expression `!foo`: Unary operators are not allowed in capture expressions.' \
695f7044 530 --condition event-rule-matches --type=user \
20a01d15
SM
531 --capture '!foo' --action notify
532
665db063 533test_failure "--condition event-rule-matches --capture: logical operator" \
20a01d15 534 'Error: While parsing expression `foo || bar`: Logical operators are not allowed in capture expressions.' \
695f7044 535 --condition event-rule-matches --type=user \
20a01d15
SM
536 --capture 'foo || bar' --action notify
537
665db063 538test_failure "--condition event-rule-matches --capture: accessing a sub-field" \
20a01d15 539 'Error: While parsing expression `foo.bar`: Capturing subfields is not supported.' \
695f7044 540 --condition event-rule-matches --type=user \
20a01d15
SM
541 --capture 'foo.bar' --action notify
542
665db063 543test_failure "--condition event-rule-matches --capture: accessing the sub-field of an array element" \
20a01d15 544 'Error: While parsing expression `foo[3].bar`: Capturing subfields is not supported.' \
695f7044 545 --condition event-rule-matches --type=user \
20a01d15
SM
546 --capture 'foo[3].bar' --action notify
547
665db063 548test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \
20a01d15 549 'Error: Invalid app-specific context field name: missing colon in `foo`.' \
695f7044 550 --condition event-rule-matches --type=user \
20a01d15
SM
551 --capture '$app.foo' --action notify
552
665db063 553test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \
20a01d15 554 'Error: Invalid app-specific context field name: missing type name after colon in `foo:`.' \
695f7044 555 --condition event-rule-matches --type=user \
20a01d15
SM
556 --capture '$app.foo:' --action notify
557
b4b7369f
JR
558# `--action` failures
559test_failure "missing args after --action" \
ef9ff9cb
SM
560 "Error: While parsing argument #5 (\`--action\`): Missing required argument for option \`--action\`
561Error: Valid action names are:
562Error: notify" \
695f7044 563 --condition event-rule-matches --type=user \
b4b7369f
JR
564 --action
565
ef9ff9cb
SM
566test_failure "unknown --action" \
567 "Error: While parsing argument #5 (\`--action\`): Unknown action name 'zoofest'
568Error: Valid action names are:
569Error: notify" \
570 --condition event-rule-matches --type=user \
571 --action zoofest
572
573test_failure "unknown --action=" \
574 "Error: While parsing argument #5 (\`--action=zoofest\`): Unknown action name 'zoofest'
575Error: Valid action names are:
576Error: notify" \
577 --condition event-rule-matches --type=user \
578 --action=zoofest
579
b4b7369f
JR
580# `--action notify` failures
581test_failure "extra arg after --action notify" \
582 "Error: Unexpected argument \`bob\`." \
695f7044 583 --condition event-rule-matches --type=user \
b4b7369f
JR
584 --action notify bob
585
586# `--action start-session` failures
587test_failure "missing arg after --action start-session" \
588 "Error: Missing session name." \
695f7044 589 --condition event-rule-matches --type=user \
b4b7369f
JR
590 --action start-session
591test_failure "extra arg after --action start-session" \
592 "Error: Unexpected argument \`bob\`." \
695f7044 593 --condition event-rule-matches --type=user \
b4b7369f
JR
594 --action start-session ze-session bob
595
596# `--action stop-session` failures
597test_failure "missing arg after --action stop-session" \
598 "Error: Missing session name." \
695f7044 599 --condition event-rule-matches --type=user \
b4b7369f
JR
600 --action stop-session
601test_failure "extra arg after --action stop-session" \
602 "Error: Unexpected argument \`bob\`." \
695f7044 603 --condition event-rule-matches --type=user \
b4b7369f
JR
604 --action stop-session ze-session bob
605
606# `--action rotate-session` failures
607test_failure "missing arg after --action rotate-session" \
608 "Error: Missing session name." \
695f7044 609 --condition event-rule-matches --type=user \
b4b7369f
JR
610 --action rotate-session
611test_failure "extra arg after --action rotate-session" \
612 "Error: Unexpected argument \`bob\`." \
695f7044 613 --condition event-rule-matches --type=user \
b4b7369f
JR
614 --action rotate-session ze-session bob
615
616# `--action snapshot-session` failures
617test_failure "missing arg after --action snapshot-session" \
618 "Error: Missing session name." \
695f7044 619 --condition event-rule-matches --type=user \
b4b7369f
JR
620 --action snapshot-session
621test_failure "extra arg after --action snapshot-session" \
622 "Error: Unexpected argument \`bob\`." \
695f7044 623 --condition event-rule-matches --type=user \
b4b7369f
JR
624 --action snapshot-session ze-session bob
625test_failure "snapshot-session action, --max-size without destination" \
626 "Error: Can't provide a snapshot output max size without a snapshot output destination." \
695f7044 627 --condition event-rule-matches --type=user \
b4b7369f
JR
628 --action snapshot-session ze-session --max-size 10M
629test_failure "snapshot-session action, --name without destination" \
630 "Error: Can't provide a snapshot output name without a snapshot output destination." \
695f7044 631 --condition event-rule-matches --type=user \
b4b7369f
JR
632 --action snapshot-session ze-session --name hallo
633test_failure "snapshot-session action, --name with-local-path-instead-of-url" \
634 "Error: Failed to parse '/something/that/looks/like/a/path' as an URL." \
695f7044 635 --condition event-rule-matches --type=user \
b4b7369f
JR
636 --action snapshot-session ze-session --name hallo --url /something/that/looks/like/a/path
637test_failure "snapshot-session action, --name with-net-url-instead-of-path" \
638 "Error: Failed to parse 'net://8.8.8.8/' as a local path." \
695f7044 639 --condition event-rule-matches --type=user \
b4b7369f
JR
640 --action snapshot-session ze-session --name hallo --path net://8.8.8.8/
641
dceffc9e
JR
642test_mi
643
b4b7369f
JR
644# Cleanup
645stop_lttng_sessiond_notap
646rm -f "${tmp_stdout}"
647rm -f "${tmp_stderr}"
This page took 0.066276 seconds and 4 git commands to generate.