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