Commit | Line | Data |
---|---|---|
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 | ||
20 | CURDIR="$(dirname "$0")" | |
21 | TESTDIR="$CURDIR/../../.." | |
22 | ||
23 | # shellcheck source=../../../utils/utils.sh | |
24 | source "$TESTDIR/utils/utils.sh" | |
25 | ||
213efb0c | 26 | plan_tests 297 |
b4b7369f JR |
27 | |
28 | FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" | |
29 | ||
30 | # shellcheck disable=SC2119 | |
31 | start_lttng_sessiond_notap | |
32 | ||
7539dcec FD |
33 | tmp_stdout=$(mktemp --tmpdir -t test_parse_cli_trigger_stdout.XXXXXX) |
34 | tmp_stderr=$(mktemp --tmpdir -t test_parse_cli_trigger_stderr.XXXXXX) | |
b4b7369f JR |
35 | uprobe_elf_binary="${TESTDIR}/utils/testapp/userspace-probe-elf-binary/.libs/userspace-probe-elf-binary" |
36 | ||
37 | if [ "$(id -u)" == "0" ]; then | |
38 | ist_root=1 | |
39 | else | |
40 | ist_root=0 | |
41 | fi | |
42 | ||
43 | function test_success () | |
44 | { | |
45 | local test_name="$1" | |
46 | shift | |
47 | ||
48 | diag "${FULL_LTTNG_BIN} add-trigger $*" | |
e45dd625 | 49 | set -x |
b4b7369f | 50 | "${FULL_LTTNG_BIN}" add-trigger "$@" > "${tmp_stdout}" 2> "${tmp_stderr}" |
e45dd625 | 51 | set +x |
b4b7369f JR |
52 | ok $? "${test_name}: exit code is 0" |
53 | ||
54 | diff -u "${tmp_stdout}" <(echo "Trigger registered successfully.") | |
55 | ok $? "${test_name}: expected stdout" | |
56 | ||
57 | diff -u "${tmp_stderr}" /dev/null | |
58 | ok $? "${test_name}: expected stderr" | |
59 | } | |
60 | ||
61 | function test_failure () | |
62 | { | |
63 | local test_name="$1" | |
64 | local error_msg="$2" | |
65 | ||
66 | shift 2 | |
67 | ||
68 | diag "${FULL_LTTNG_BIN} add-trigger $*" | |
69 | "${FULL_LTTNG_BIN}" add-trigger "$@" > "${tmp_stdout}" 2> "${tmp_stderr}" | |
70 | isnt $? 0 "${test_name}: exit code is not 0" | |
71 | ||
72 | diff -u "${tmp_stdout}" /dev/null | |
73 | ok $? "${test_name}: expected stdout" | |
74 | ||
75 | diff -u "${tmp_stderr}" <(echo "${error_msg}") | |
76 | ok $? "${test_name}: expected stderr" | |
77 | } | |
78 | ||
79 | # top-level options | |
1d4b59f2 SM |
80 | test_success "explicit name" \ |
81 | --name hohoho \ | |
64c34630 | 82 | --condition event-rule-matches --name=some-event-id --domain=user \ |
b4b7369f JR |
83 | --action notify |
84 | ||
665db063 | 85 | # `--condition event-rule-matches` successes |
64c34630 SM |
86 | test_success "--condition event-rule-matches some-event --domain=user" \ |
87 | --condition event-rule-matches --name=some-event --domain=user \ | |
b4b7369f JR |
88 | --action notify |
89 | ||
64c34630 SM |
90 | test_success "--condition event-rule-matches --domain=user" \ |
91 | --condition event-rule-matches --domain=user \ | |
b4b7369f JR |
92 | --action notify |
93 | ||
e45dd625 | 94 | test_success "notify action polices" \ |
64c34630 | 95 | --condition event-rule-matches --domain=user --name=test-rate-policy \ |
b4b7369f | 96 | --action notify \ |
bbadb5e0 | 97 | --rate-policy=every:55 \ |
e45dd625 | 98 | --action notify \ |
bbadb5e0 | 99 | --rate-policy=once-after:55 |
b4b7369f | 100 | |
e45dd625 | 101 | test_success "start session action polices" \ |
64c34630 | 102 | --condition event-rule-matches --domain=user --name=test-rate-policy \ |
e45dd625 | 103 | --action start-session my_session \ |
bbadb5e0 | 104 | --rate-policy=every:55 \ |
e45dd625 | 105 | --action start-session my_session \ |
bbadb5e0 | 106 | --rate-policy=once-after:55 |
e45dd625 JR |
107 | |
108 | test_success "stop session action polices" \ | |
64c34630 | 109 | --condition event-rule-matches --domain=user --name=test-rate-policy \ |
e45dd625 | 110 | --action stop-session my_session \ |
bbadb5e0 | 111 | --rate-policy=every:55 \ |
e45dd625 | 112 | --action stop-session my_session \ |
bbadb5e0 | 113 | --rate-policy=once-after:55 |
e45dd625 JR |
114 | |
115 | test_success "snapshot session action polices" \ | |
64c34630 | 116 | --condition event-rule-matches --domain=user --name=test-rate-policy \ |
e45dd625 | 117 | --action snapshot-session my_session \ |
bbadb5e0 | 118 | --rate-policy=every:55 \ |
e45dd625 | 119 | --action snapshot-session my_session \ |
bbadb5e0 | 120 | --rate-policy=once-after:55 |
e45dd625 JR |
121 | |
122 | test_success "rotate session action polices" \ | |
64c34630 | 123 | --condition event-rule-matches --domain=user --name=test-rate-policy \ |
e45dd625 | 124 | --action rotate-session my_session \ |
bbadb5e0 | 125 | --rate-policy=every:55 \ |
e45dd625 | 126 | --action rotate-session my_session \ |
bbadb5e0 | 127 | --rate-policy=once-after:55 |
b4b7369f | 128 | |
949f049b SM |
129 | test_success "--log-level single level" \ |
130 | --condition event-rule-matches --domain=user --log-level=INFO \ | |
131 | --action notify | |
132 | ||
133 | test_success "--log-level range open max" \ | |
134 | --condition event-rule-matches --domain=user --log-level=INFO.. \ | |
135 | --action notify | |
136 | ||
137 | test_success "--log-level range any" \ | |
138 | --condition event-rule-matches --domain=user --log-level=.. \ | |
139 | --action notify | |
140 | ||
b03a81fb SM |
141 | test_success "--exclude-name one" \ |
142 | --condition event-rule-matches --domain=user --name='bernard*' --exclude-name=bernard-lermite \ | |
143 | --action notify | |
144 | ||
145 | test_success "--exclude-name two" \ | |
146 | --condition event-rule-matches --domain=user --name='jean-*' --exclude-name jean-chretien -x jean-charest \ | |
147 | --action notify | |
148 | ||
24de704e SM |
149 | skip $ist_root "non-root user: skipping kprobe tests" 18 || { |
150 | for type in kprobe kernel-probe; do | |
151 | test_success "--condition event-rule-matches probe by symbol" \ | |
152 | --condition event-rule-matches --domain=kernel --type=$type --location=lttng_channel_enable --event-name=my_channel_enable \ | |
153 | --action notify | |
154 | ||
155 | channel_enable_addr=$(grep ' t lttng_channel_enable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ') | |
156 | channel_disable_addr=$(grep ' t lttng_channel_disable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ') | |
157 | ||
158 | # We need to find a valid offset. | |
159 | base_symbol="" | |
160 | offset=0 | |
161 | if [[ 0x$channel_enable_addr -lt 0x$channel_disable_addr ]]; then | |
162 | base_symbol="lttng_channel_enable" | |
163 | offset=$(( 0x$channel_disable_addr - 0x$channel_enable_addr )) | |
164 | else | |
165 | base_symbol="lttng_channel_disable" | |
166 | offset=$(( 0x$channel_enable_addr - 0x$channel_disable_addr )) | |
167 | fi | |
168 | ||
169 | offset_hex="0x$(printf '%x' $offset)" | |
170 | ||
171 | test_success "--condition event-rule-matches probe by symbol with offset" \ | |
172 | --condition event-rule-matches --domain=kernel --type=$type --location="${base_symbol}+${offset_hex}" --event-name=my_$base_symbol \ | |
173 | --action notify | |
174 | ||
175 | test_success "--condition event-rule-matches probe by address" \ | |
176 | --condition event-rule-matches --domain=kernel --type=$type --location="0x${channel_enable_addr}" --event-name=my_channel_enable \ | |
177 | --action notify | |
178 | done | |
b4b7369f JR |
179 | } |
180 | ||
24de704e SM |
181 | skip $ist_root "non-root user: skipping uprobe tests" 12 || { |
182 | for type in uprobe userspace-probe; do | |
183 | test_success "--condition event-rule-matches uprobe" \ | |
184 | --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_function --event-name=ma-probe \ | |
185 | --action notify | |
b4b7369f | 186 | |
24de704e SM |
187 | test_success "--condition event-rule-matches uprobe with elf prefix" \ |
188 | --condition event-rule-matches --domain=kernel --type=$type --location=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \ | |
189 | --action notify | |
190 | done | |
b4b7369f JR |
191 | } |
192 | ||
213efb0c | 193 | skip $ist_root "non-root user: skipping syscall tests" 30 || { |
50ad0862 | 194 | test_success "--condition event-rule-matches one syscall" \ |
24de704e | 195 | --condition event-rule-matches --domain=kernel --type=syscall --name=open \ |
b4b7369f JR |
196 | --action notify |
197 | ||
50ad0862 | 198 | test_success "--condition event-rule-matches all syscalls" \ |
24de704e | 199 | --condition event-rule-matches --domain=kernel --type=syscall \ |
b4b7369f JR |
200 | --action notify |
201 | ||
50ad0862 | 202 | test_success "--condition event-rule-matches one syscall with filter" \ |
24de704e | 203 | --condition event-rule-matches --domain=kernel --type=syscall --filter 'a > 2' --name=open \ |
b4b7369f | 204 | --action notify |
57739a6b JR |
205 | test_success "--condition event-rule-matches one syscall:entry" \ |
206 | --condition event-rule-matches --domain=kernel --type=syscall:entry --name=open \ | |
207 | --action notify | |
208 | test_success "--condition event-rule-matches one syscall:exit" \ | |
209 | --condition event-rule-matches --domain=kernel --type=syscall:exit --name=open \ | |
210 | --action notify | |
211 | test_success "--condition event-rule-matches one syscall:entry-exit" \ | |
212 | --condition event-rule-matches --domain=kernel --type=syscall:entry+exit --name=open \ | |
213 | --action notify | |
213efb0c JR |
214 | |
215 | # Same thing but with "kernel:syscall" type instead: | |
216 | test_success "--condition event-rule-matches one syscall" \ | |
217 | --condition event-rule-matches --domain=kernel --type=kernel:syscall --name=open \ | |
218 | --action notify | |
219 | ||
220 | test_success "--condition event-rule-matches one kernel:syscall:entry" \ | |
221 | --condition event-rule-matches --domain=kernel --type=kernel:syscall:entry --name=open \ | |
222 | --action notify | |
223 | test_success "--condition event-rule-matches one kernel:syscall:exit" \ | |
224 | --condition event-rule-matches --domain=kernel --type=kernel:syscall:exit --name=open \ | |
225 | --action notify | |
226 | test_success "--condition event-rule-matches one kernel:syscall:entry-exit" \ | |
227 | --condition event-rule-matches --domain=kernel --type=kernel:syscall:entry+exit --name=open \ | |
228 | --action notify | |
229 | ||
b4b7369f JR |
230 | } |
231 | ||
232 | # `--action notify` successes | |
233 | test_success "--action notify" \ | |
64c34630 | 234 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
235 | --action notify |
236 | ||
20a01d15 | 237 | test_success "--action notify --capture foo" \ |
64c34630 | 238 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
239 | --capture foo --action notify |
240 | ||
241 | test_success "--action notify --capture foo[2]" \ | |
64c34630 | 242 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
243 | --capture 'foo[2]' --action notify |
244 | ||
245 | test_success '--action notify --capture $ctx.foo' \ | |
64c34630 | 246 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
247 | --capture '$ctx.foo' --action notify |
248 | ||
249 | test_success '--action notify --capture $ctx.foo[2]' \ | |
64c34630 | 250 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
251 | --capture '$ctx.foo[2]' --action notify |
252 | ||
253 | test_success '--action notify --capture $app.prov:type' \ | |
64c34630 | 254 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
255 | --capture '$app.prov:type' --action notify |
256 | ||
257 | test_success '--action notify --capture $app.prov:type[2]' \ | |
64c34630 | 258 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
259 | --capture '$app.prov:type[2]' --action notify |
260 | ||
261 | test_success '--action notify multiple captures' \ | |
64c34630 | 262 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
263 | --capture foo --capture '$app.hello:world' --action notify |
264 | ||
b4b7369f JR |
265 | # `--action start-session` successes |
266 | test_success "--action start-session" \ | |
64c34630 | 267 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
268 | --action start-session ze-session |
269 | ||
270 | # `--action stop-session` successes | |
271 | test_success "--action stop-session foo" \ | |
64c34630 | 272 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
273 | --action stop-session ze-session |
274 | ||
275 | # `--action rotate-session` successes | |
276 | test_success "--action rotate-session foo" \ | |
64c34630 | 277 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
278 | --action rotate-session ze-session |
279 | ||
280 | # `--action snapshot-session` successes | |
281 | test_success "--action snapshot-session foo" \ | |
64c34630 | 282 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
283 | --action snapshot-session ze-session |
284 | ||
285 | test_success "--action snapshot-session with file URI" \ | |
64c34630 | 286 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
287 | --action snapshot-session ze-session --path /hello |
288 | ||
289 | test_success "--action snapshot-session with net URI" \ | |
64c34630 | 290 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
291 | --action snapshot-session ze-session --url net://1.2.3.4 |
292 | ||
293 | test_success "--action snapshot-session with ctrl/data URIs" \ | |
64c34630 | 294 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
295 | --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1234 --data-url=tcp://1.2.3.4:1235 |
296 | ||
297 | # top-level failures | |
298 | test_failure "no args" "Error: Missing --condition." | |
299 | ||
300 | test_failure "unknown option" \ | |
301 | "Error: Unknown option \`--hello\`" \ | |
302 | --hello | |
303 | ||
304 | test_failure "missing --action" \ | |
305 | "Error: Need at least one --action." \ | |
64c34630 | 306 | --condition event-rule-matches --domain=user |
b4b7369f JR |
307 | |
308 | test_failure "two --condition" \ | |
309 | "Error: A --condition was already given." \ | |
64c34630 SM |
310 | --condition event-rule-matches --name=aaa --domain=user \ |
311 | --condition event-rule-matches --name=bbb --domain=user \ | |
b4b7369f JR |
312 | --action notify |
313 | ||
1d4b59f2 SM |
314 | test_failure "missing argument to --name" \ |
315 | "Error: While parsing argument #1 (\`--name\`): Missing required argument for option \`--name\`" \ | |
316 | --name | |
b4b7369f | 317 | |
bbadb5e0 | 318 | for cmd in rate-policy=once-after rate-policy=every; do |
b4b7369f | 319 | test_failure "missing argument to --${cmd}" \ |
bbadb5e0 | 320 | "Error: Rate policy format is invalid." \ |
64c34630 | 321 | --condition event-rule-matches --domain=user --action notify \ |
b4b7369f JR |
322 | --${cmd} |
323 | ||
324 | test_failure "invalid argument to --${cmd}: non-digit character" \ | |
bbadb5e0 | 325 | "Error: Failed to parse rate policy value \`123bob\` as an integer." \ |
64c34630 | 326 | --condition event-rule-matches --domain=user --action notify \ |
bbadb5e0 | 327 | --${cmd}:123bob |
b4b7369f JR |
328 | |
329 | test_failure "invalid argument to --${cmd}: empty string" \ | |
bbadb5e0 | 330 | "Error: Failed to parse rate policy value \`\` as an integer." \ |
64c34630 | 331 | --condition event-rule-matches --domain=user --action notify \ |
bbadb5e0 | 332 | --${cmd}":" |
b4b7369f JR |
333 | done |
334 | ||
bbadb5e0 JR |
335 | test_failure "invalid argument to --rate-policy: unknown policy type" \ |
336 | "Error: Rate policy type \`bob\` unknown." \ | |
64c34630 | 337 | --condition event-rule-matches --domain=user --action notify \ |
bbadb5e0 JR |
338 | --rate-policy=bob:123 |
339 | ||
b4b7369f JR |
340 | # `--condition` failures |
341 | test_failure "missing args after --condition" \ | |
29bcf415 | 342 | "Error: While parsing argument #1 (\`--condition\`): Missing required argument for option \`--condition\`" \ |
b4b7369f JR |
343 | --condition |
344 | test_failure "unknown --condition" \ | |
345 | "Error: Unknown condition name 'zoofest'" \ | |
346 | --condition zoofest | |
347 | ||
665db063 SM |
348 | # `--condition event-rule-matches` failures |
349 | test_failure "missing args after --condition event-rule-matches" \ | |
64c34630 | 350 | "Error: Please specify a domain (--domain=(kernel,user,jul,log4j,python))." \ |
50ad0862 SM |
351 | --condition event-rule-matches |
352 | ||
665db063 | 353 | test_failure "extra args after --condition event-rule-matches" \ |
b4b7369f | 354 | "Error: Unexpected argument 'bozo'" \ |
64c34630 SM |
355 | --condition event-rule-matches --domain=user bozo |
356 | ||
949f049b SM |
357 | test_failure "--log-level unknown level" \ |
358 | "Error: Failed to parse log level string \`FOO\`." \ | |
359 | --condition event-rule-matches --domain=user --log-level=FOO | |
360 | ||
64c34630 SM |
361 | test_failure "two same --domain" \ |
362 | "Error: More than one \`--domain\` was specified." \ | |
363 | --condition event-rule-matches --domain=user --domain=user | |
364 | ||
365 | test_failure "two different --domain" \ | |
366 | "Error: More than one \`--domain\` was specified." \ | |
367 | --condition event-rule-matches --domain=user --domain=kernel | |
b4b7369f | 368 | |
24de704e SM |
369 | for type in kprobe kernel-probe; do |
370 | test_failure "--condition event-rule-matches: --name with --type=$type" \ | |
371 | "Error: Can't use --name with probe event rules." \ | |
372 | --condition event-rule-matches --type=$type --location=do_sys_open --name='hello' | |
373 | done | |
374 | ||
375 | test_failure "--condition event-rule-matches: --location with tracepoint event rule" \ | |
376 | "Error: Can't use --location with tracepoint event rules." \ | |
377 | --condition event-rule-matches --domain=user --location='hello' | |
b4b7369f | 378 | |
24de704e | 379 | test_failure "--condition event-rule-matches: --event-name with tracepoint event rule" \ |
50ad0862 | 380 | "Error: Can't use --event-name with tracepoint event rules." \ |
64c34630 | 381 | --condition event-rule-matches --domain=user --event-name='hello' |
50ad0862 | 382 | |
24de704e SM |
383 | for type in uprobe userspace-probe; do |
384 | test_failure "--condition event-rule-matches: extra argument with --type=$type" \ | |
385 | "Error: Unexpected argument 'hello'" \ | |
386 | --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_failure hello | |
387 | done | |
b4b7369f | 388 | |
24de704e | 389 | test_failure "--condition event-rule-matches: extra argument with --type=syscall" \ |
b4b7369f | 390 | "Error: Unexpected argument 'open'" \ |
24de704e | 391 | --condition event-rule-matches --domain=kernel --type=syscall open |
b4b7369f | 392 | |
57739a6b JR |
393 | test_failure "--condition event-rule-matches: --type=syscall:nope" \ |
394 | "Error: Failed to parse syscall type 'syscall:nope'." \ | |
395 | --condition event-rule-matches --domain=kernel --type=syscall:nope \ | |
396 | --name=open | |
397 | ||
b03a81fb SM |
398 | test_failure "--exclude-name with non-glob name" \ |
399 | "Error: Event jean: Exclusions can only be used with a globbing pattern" \ | |
400 | --condition event-rule-matches --domain=user --name='jean' --exclude-name jean-chretien \ | |
401 | --action notify | |
402 | ||
665db063 | 403 | test_failure "--condition event-rule-matches --capture: missing argument (end of arg list)" \ |
50ad0862 | 404 | 'Error: While parsing argument #2 (`--capture`): Missing required argument for option `--capture`' \ |
20a01d15 | 405 | --action notify \ |
64c34630 | 406 | --condition event-rule-matches --domain=user --capture |
20a01d15 | 407 | |
665db063 | 408 | test_failure "--condition event-rule-matches --capture: missing argument (before another option)" \ |
20a01d15 | 409 | 'Error: While parsing expression `--action`: Unary operators are not allowed in capture expressions.' \ |
64c34630 | 410 | --condition event-rule-matches --domain=user --capture \ |
20a01d15 SM |
411 | --action notify \ |
412 | ||
665db063 | 413 | test_failure "--condition event-rule-matches --capture: binary operator" \ |
20a01d15 | 414 | 'Error: While parsing expression `foo == 2`: Binary operators are not allowed in capture expressions.' \ |
64c34630 | 415 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
416 | --capture 'foo == 2' --action notify |
417 | ||
665db063 | 418 | test_failure "--condition event-rule-matches --capture: unary operator" \ |
20a01d15 | 419 | 'Error: While parsing expression `!foo`: Unary operators are not allowed in capture expressions.' \ |
64c34630 | 420 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
421 | --capture '!foo' --action notify |
422 | ||
665db063 | 423 | test_failure "--condition event-rule-matches --capture: logical operator" \ |
20a01d15 | 424 | 'Error: While parsing expression `foo || bar`: Logical operators are not allowed in capture expressions.' \ |
64c34630 | 425 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
426 | --capture 'foo || bar' --action notify |
427 | ||
665db063 | 428 | test_failure "--condition event-rule-matches --capture: accessing a sub-field" \ |
20a01d15 | 429 | 'Error: While parsing expression `foo.bar`: Capturing subfields is not supported.' \ |
64c34630 | 430 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
431 | --capture 'foo.bar' --action notify |
432 | ||
665db063 | 433 | test_failure "--condition event-rule-matches --capture: accessing the sub-field of an array element" \ |
20a01d15 | 434 | 'Error: While parsing expression `foo[3].bar`: Capturing subfields is not supported.' \ |
64c34630 | 435 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
436 | --capture 'foo[3].bar' --action notify |
437 | ||
665db063 | 438 | test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \ |
20a01d15 | 439 | 'Error: Invalid app-specific context field name: missing colon in `foo`.' \ |
64c34630 | 440 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
441 | --capture '$app.foo' --action notify |
442 | ||
665db063 | 443 | test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \ |
20a01d15 | 444 | 'Error: Invalid app-specific context field name: missing type name after colon in `foo:`.' \ |
64c34630 | 445 | --condition event-rule-matches --domain=user \ |
20a01d15 SM |
446 | --capture '$app.foo:' --action notify |
447 | ||
b4b7369f JR |
448 | # `--action` failures |
449 | test_failure "missing args after --action" \ | |
29bcf415 | 450 | "Error: While parsing argument #1 (\`--action\`): Missing required argument for option \`--action\`" \ |
64c34630 | 451 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
452 | --action |
453 | ||
454 | # `--action notify` failures | |
455 | test_failure "extra arg after --action notify" \ | |
456 | "Error: Unexpected argument \`bob\`." \ | |
64c34630 | 457 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
458 | --action notify bob |
459 | ||
460 | # `--action start-session` failures | |
461 | test_failure "missing arg after --action start-session" \ | |
462 | "Error: Missing session name." \ | |
64c34630 | 463 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
464 | --action start-session |
465 | test_failure "extra arg after --action start-session" \ | |
466 | "Error: Unexpected argument \`bob\`." \ | |
64c34630 | 467 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
468 | --action start-session ze-session bob |
469 | ||
470 | # `--action stop-session` failures | |
471 | test_failure "missing arg after --action stop-session" \ | |
472 | "Error: Missing session name." \ | |
64c34630 | 473 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
474 | --action stop-session |
475 | test_failure "extra arg after --action stop-session" \ | |
476 | "Error: Unexpected argument \`bob\`." \ | |
64c34630 | 477 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
478 | --action stop-session ze-session bob |
479 | ||
480 | # `--action rotate-session` failures | |
481 | test_failure "missing arg after --action rotate-session" \ | |
482 | "Error: Missing session name." \ | |
64c34630 | 483 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
484 | --action rotate-session |
485 | test_failure "extra arg after --action rotate-session" \ | |
486 | "Error: Unexpected argument \`bob\`." \ | |
64c34630 | 487 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
488 | --action rotate-session ze-session bob |
489 | ||
490 | # `--action snapshot-session` failures | |
491 | test_failure "missing arg after --action snapshot-session" \ | |
492 | "Error: Missing session name." \ | |
64c34630 | 493 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
494 | --action snapshot-session |
495 | test_failure "extra arg after --action snapshot-session" \ | |
496 | "Error: Unexpected argument \`bob\`." \ | |
64c34630 | 497 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
498 | --action snapshot-session ze-session bob |
499 | test_failure "snapshot-session action, --max-size without destination" \ | |
500 | "Error: Can't provide a snapshot output max size without a snapshot output destination." \ | |
64c34630 | 501 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
502 | --action snapshot-session ze-session --max-size 10M |
503 | test_failure "snapshot-session action, --name without destination" \ | |
504 | "Error: Can't provide a snapshot output name without a snapshot output destination." \ | |
64c34630 | 505 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
506 | --action snapshot-session ze-session --name hallo |
507 | test_failure "snapshot-session action, --name with-local-path-instead-of-url" \ | |
508 | "Error: Failed to parse '/something/that/looks/like/a/path' as an URL." \ | |
64c34630 | 509 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
510 | --action snapshot-session ze-session --name hallo --url /something/that/looks/like/a/path |
511 | test_failure "snapshot-session action, --name with-net-url-instead-of-path" \ | |
512 | "Error: Failed to parse 'net://8.8.8.8/' as a local path." \ | |
64c34630 | 513 | --condition event-rule-matches --domain=user \ |
b4b7369f JR |
514 | --action snapshot-session ze-session --name hallo --path net://8.8.8.8/ |
515 | ||
516 | # Cleanup | |
517 | stop_lttng_sessiond_notap | |
518 | rm -f "${tmp_stdout}" | |
519 | rm -f "${tmp_stderr}" |