From: Simon Marchi Date: Mon, 12 Apr 2021 16:25:50 +0000 (-0400) Subject: lttng add-trigger: some updates to event rule to new syntax X-Git-Tag: v2.13.0-rc1~44 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=50ad08620ff49e3c27e6eb3fea5151e744ae13ec;p=lttng-tools.git lttng add-trigger: some updates to event rule to new syntax Implement a few of the proposals for the event rule syntax related to event names that we want to adopt for the add-trigger command. - Remove the positional argument (tracepoint name). - Add --name option for tracepoints, syscalls and loggers. - Add --event-name option for probes. - Rename --exclude to --exclude-names. - Remove the --all/-a option. The equivalent now is to omit --name, which is the equivalent of --name=*. Change-Id: I7161570a47716c458a60d679bc229a8c8843b04f Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index af58d7b31..a885aea61 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -43,9 +43,10 @@ enum { OPT_USER_ID, OPT_RATE_POLICY, - OPT_ALL, + OPT_NAME, OPT_FILTER, - OPT_EXCLUDE, + OPT_EXCLUDE_NAMES, + OPT_EVENT_NAME, OPT_LOGLEVEL, OPT_LOGLEVEL_ONLY, @@ -61,7 +62,6 @@ enum { OPT_SYSCALL, OPT_TRACEPOINT, - OPT_NAME, OPT_MAX_SIZE, OPT_DATA_URL, OPT_CTRL_URL, @@ -72,11 +72,12 @@ enum { }; static const struct argpar_opt_descr event_rule_opt_descrs[] = { - { OPT_ALL, 'a', "all", false }, { OPT_FILTER, 'f', "filter", true }, - { OPT_EXCLUDE, 'x', "exclude", true }, + { OPT_NAME, 'n', "name", true }, + { OPT_EXCLUDE_NAMES, 'x', "exclude-names", true }, { OPT_LOGLEVEL, '\0', "loglevel", true }, { OPT_LOGLEVEL_ONLY, '\0', "loglevel-only", true }, + { OPT_EVENT_NAME, 'E', "event-name", true }, /* Domains */ { OPT_USERSPACE, 'u', "userspace", false }, @@ -542,22 +543,18 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) struct filter_parser_ctx *parser_ctx = NULL; struct lttng_log_level_rule *log_level_rule = NULL; - /* Was the -a/--all flag provided? */ - bool all_events = false; - - /* Tracepoint name (non-option argument). */ - const char *tracepoint_name = NULL; + /* Tracepoint and syscall options. */ + char *name = NULL; + char *exclude_names = NULL; + char **exclusion_list = NULL; /* Holds the argument of --probe / --userspace-probe. */ - char *source = NULL; + char *probe_source = NULL; + char *probe_event_name = NULL; /* Filter. */ char *filter = NULL; - /* Exclude. */ - char *exclude = NULL; - char **exclusion_list = NULL; - /* Log level. */ char *loglevel_str = NULL; bool loglevel_only = false; @@ -638,7 +635,8 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) goto error; } - if (!assign_string(&source, item_opt->arg, "source")) { + if (!assign_string(&probe_source, item_opt->arg, + "--probe")) { goto error; } @@ -649,8 +647,17 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) goto error; } - if (!assign_string(&source, item_opt->arg, "source")) { - goto error; + if (!assign_string(&probe_source, item_opt->arg, + "--userspace-probe")) { + goto error; + } + + break; + case OPT_EVENT_NAME: + if (!assign_string(&probe_event_name, + item_opt->arg, + "--event-name/-E")) { + goto error; } break; @@ -667,9 +674,6 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) goto error; } - break; - case OPT_ALL: - all_events = true; break; case OPT_FILTER: if (!assign_string(&filter, item_opt->arg, @@ -678,9 +682,17 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) } break; - case OPT_EXCLUDE: - if (!assign_string(&exclude, item_opt->arg, - "--exclude/-x")) { + case OPT_NAME: + if (!assign_string(&name, item_opt->arg, + "--name/-n")) { + goto error; + } + + break; + case OPT_EXCLUDE_NAMES: + if (!assign_string(&exclude_names, + item_opt->arg, + "--exclude-names/-x")) { goto error; } @@ -742,17 +754,9 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) (const struct argpar_item_non_opt *) item; - /* - * Don't accept two non-option arguments/tracepoint - * names. - */ - if (tracepoint_name) { - ERR("Unexpected argument '%s'", - item_non_opt->arg); - goto error; - } - - tracepoint_name = item_non_opt->arg; + /* Don't accept non-option arguments. */ + ERR("Unexpected argument '%s'", item_non_opt->arg); + goto error; } } @@ -761,44 +765,54 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) } /* - * Option -a is applicable to event rules of type tracepoint and - * syscall, and it is equivalent to using "*" as the tracepoint name. + * Option --name is applicable to event rules of type tracepoint + * and syscall. For tracepoint and syscall rules, if --name is + * omitted, it is implicitly "*". */ - if (all_events) { - switch (event_rule_type) { - case LTTNG_EVENT_RULE_TYPE_TRACEPOINT: - case LTTNG_EVENT_RULE_TYPE_SYSCALL: - break; - default: - ERR("Can't use -a/--all with %s event rules.", - lttng_event_rule_type_str(event_rule_type)); - goto error; + switch (event_rule_type) { + case LTTNG_EVENT_RULE_TYPE_TRACEPOINT: + case LTTNG_EVENT_RULE_TYPE_SYSCALL: + if (!name) { + name = strdup("*"); } + break; - if (tracepoint_name) { - ERR("Can't provide a tracepoint name with -a/--all."); + default: + if (name) { + ERR("Can't use --name with %s event rules.", + lttng_event_rule_type_str( + event_rule_type)); goto error; } - /* In which case, it's equivalent to tracepoint name "*". */ - tracepoint_name = "*"; + if (exclude_names) { + ERR("Can't use --exclude-names/-x with %s event rules.", + lttng_event_rule_type_str( + event_rule_type)); + goto error; + } } /* - * A tracepoint name (or -a, for the event rule types that accept it) - * is required. + * Option --event-name is only applicable to event rules of type probe. + * If omitted, it defaults to the probe location. */ - if (!tracepoint_name) { - ERR("Need to provide either a tracepoint name or -a/--all."); - goto error; - } + switch (event_rule_type) { + case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE: + case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE: + if (!probe_event_name) { + probe_event_name = strdup(probe_source); + } - /* - * We don't support multiple tracepoint names for now. - */ - if (strchr(tracepoint_name, ',')) { - ERR("Comma separated tracepoint names are not supported."); - goto error; + break; + + default: + if (probe_event_name) { + ERR("Can't use --event-name with %s event rules.", + lttng_event_rule_type_str( + event_rule_type)); + goto error; + } } /* @@ -852,16 +866,15 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) } /* If --exclude/-x was passed, split it into an exclusion list. */ - if (exclude) { + if (exclude_names) { if (domain_type != LTTNG_DOMAIN_UST) { ERR("Event name exclusions are not yet implemented for %s event rules.", get_domain_str(domain_type)); goto error; } - - if (create_exclusion_list_and_validate(tracepoint_name, exclude, - &exclusion_list) != 0) { + if (create_exclusion_list_and_validate(name, + exclude_names, &exclusion_list) != 0) { ERR("Failed to create exclusion list."); goto error; } @@ -886,10 +899,10 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) /* Set pattern. */ event_rule_status = lttng_event_rule_tracepoint_set_pattern( - res.er, tracepoint_name); + res.er, name); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to set tracepoint event rule's pattern to '%s'.", - tracepoint_name); + name); goto error; } @@ -965,8 +978,8 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) int ret; enum lttng_event_rule_status event_rule_status; - - ret = parse_kernel_probe_opts(source, &kernel_probe_location); + ret = parse_kernel_probe_opts( + probe_source, &kernel_probe_location); if (ret) { ERR("Failed to parse kernel probe location."); goto error; @@ -979,9 +992,12 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) goto error; } - event_rule_status = lttng_event_rule_kernel_probe_set_event_name(res.er, tracepoint_name); + event_rule_status = + lttng_event_rule_kernel_probe_set_event_name( + res.er, probe_event_name); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { - ERR("Failed to set kprobe event rule's name to '%s'.", tracepoint_name); + ERR("Failed to set kprobe event rule's name to '%s'.", + probe_event_name); goto error; } @@ -993,7 +1009,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) enum lttng_event_rule_status event_rule_status; ret = parse_userspace_probe_opts( - source, &userspace_probe_location); + probe_source, &userspace_probe_location); if (ret) { ERR("Failed to parse user space probe location."); goto error; @@ -1005,11 +1021,12 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) goto error; } - event_rule_status = lttng_event_rule_userspace_probe_set_event_name( - res.er, tracepoint_name); + event_rule_status = + lttng_event_rule_userspace_probe_set_event_name( + res.er, probe_event_name); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to set user space probe event rule's name to '%s'.", - tracepoint_name); + probe_event_name); goto error; } @@ -1026,10 +1043,10 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv) } event_rule_status = lttng_event_rule_syscall_set_pattern( - res.er, tracepoint_name); + res.er, name); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to set syscall event rule's pattern to '%s'.", - tracepoint_name); + name); goto error; } @@ -1067,9 +1084,12 @@ end: free(error); argpar_state_destroy(state); free(filter); - free(exclude); + free(name); + free(exclude_names); free(loglevel_str); - free(source); + free(probe_source); + free(probe_event_name); + strutils_free_null_terminated_array_of_strings(exclusion_list); lttng_kernel_probe_location_destroy(kernel_probe_location); lttng_userspace_probe_location_destroy(userspace_probe_location); diff --git a/tests/regression/tools/notification/test_notification_notifier_discarded_count b/tests/regression/tools/notification/test_notification_notifier_discarded_count index 51b6e04eb..dc75f8543 100755 --- a/tests/regression/tools/notification/test_notification_notifier_discarded_count +++ b/tests/regression/tools/notification/test_notification_notifier_discarded_count @@ -78,7 +78,7 @@ function test_kernel_notifier_discarded_count done lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --kernel lttng_test_filter_event \ + --condition event-rule-matches --kernel --name=lttng_test_filter_event \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -107,7 +107,7 @@ function test_kernel_notifier_discarded_count # Enable another notifier and list it to confirm the counter was cleared. lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --kernel lttng_test_filter_event \ + --condition event-rule-matches --kernel --name=lttng_test_filter_event \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -129,13 +129,13 @@ function test_kernel_notifier_discarded_count_max_bucket diag "Kernel event notifer error counter bucket limit" for i in $(seq 3); do lttng_add_trigger_ok "$i" \ - --condition event-rule-matches --kernel my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --kernel --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done for i in $(seq 4 5); do lttng_add_trigger_fail "$i" \ - --condition event-rule-matches --kernel my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --kernel --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done @@ -180,7 +180,7 @@ function test_ust_notifier_discarded_count done lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --userspace tp:tptest \ + --condition event-rule-matches --userspace --name=tp:tptest \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -206,7 +206,7 @@ function test_ust_notifier_discarded_count # Enable another notifier and list it to confirm the counter was cleared. lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --userspace tp:tptest \ + --condition event-rule-matches --userspace --name=tp:tptest \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -226,13 +226,13 @@ function test_ust_notifier_discarded_count_max_bucket diag "UST event notifer error counter bucket limit" for i in $(seq 3); do lttng_add_trigger_ok "$i" \ - --condition event-rule-matches --userspace my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --userspace --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done for i in $(seq 4 5); do lttng_add_trigger_fail "$i" \ - --condition event-rule-matches --userspace my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --userspace --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done diff --git a/tests/regression/tools/trigger/rate-policy/test_ust_rate_policy b/tests/regression/tools/trigger/rate-policy/test_ust_rate_policy index d7ec3891c..8a392a0f9 100755 --- a/tests/regression/tools/trigger/rate-policy/test_ust_rate_policy +++ b/tests/regression/tools/trigger/rate-policy/test_ust_rate_policy @@ -36,7 +36,7 @@ function test_rate_policy_every_n() # time the condition is met. lttng_add_trigger_ok \ $TRIGGER_NAME \ - --condition event-rule-matches -u "tp:tptest" \ + --condition event-rule-matches -u --name="tp:tptest" \ --action notify \ --rate-policy=every:5 @@ -46,7 +46,7 @@ function test_rate_policy_every_n() # the notification subsystem. lttng_add_trigger_ok \ $END_TRIGGER_NAME \ - --condition event-rule-matches -u "tp:end" \ + --condition event-rule-matches -u --name="tp:end" \ --action notify for i in $(seq 1 4); do @@ -122,7 +122,7 @@ function test_rate_policy_once_after_n() # time the condition is met. lttng_add_trigger_ok \ $TRIGGER_NAME \ - --condition event-rule-matches -u "tp:tptest" \ + --condition event-rule-matches -u --name="tp:tptest" \ --action notify \ --rate-policy=once-after:5 @@ -132,7 +132,7 @@ function test_rate_policy_once_after_n() # the notification subsystem. lttng_add_trigger_ok \ $END_TRIGGER_NAME \ - --condition event-rule-matches -u "tp:end" \ + --condition event-rule-matches -u --name="tp:end" \ --action notify ## Phase 1 diff --git a/tests/regression/tools/trigger/start-stop/test_start_stop b/tests/regression/tools/trigger/start-stop/test_start_stop index d04869397..b5937797d 100755 --- a/tests/regression/tools/trigger/start-stop/test_start_stop +++ b/tests/regression/tools/trigger/start-stop/test_start_stop @@ -57,7 +57,7 @@ function test_start_session_action() # a `notify` action. lttng_add_trigger_ok \ $TRIGGER_NAME \ - --condition event-rule-matches -u "tp:tptest" \ + --condition event-rule-matches -u --name=tp:tptest \ --action start-session $SESSION_NAME \ --action notify @@ -111,7 +111,7 @@ function test_stop_session_action() # a `notify` action. lttng_add_trigger_ok \ $TRIGGER_NAME \ - --condition event-rule-matches -u "tp:tptest" \ + --condition event-rule-matches -u --name=tp:tptest \ --action stop-session $SESSION_NAME \ --action notify diff --git a/tests/regression/tools/trigger/test_add_trigger_cli b/tests/regression/tools/trigger/test_add_trigger_cli index ba46a64ab..b712bdd3c 100755 --- a/tests/regression/tools/trigger/test_add_trigger_cli +++ b/tests/regression/tools/trigger/test_add_trigger_cli @@ -23,7 +23,7 @@ TESTDIR="$CURDIR/../../.." # shellcheck source=../../../utils/utils.sh source "$TESTDIR/utils/utils.sh" -plan_tests 234 +plan_tests 222 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" @@ -79,48 +79,48 @@ function test_failure () # top-level options test_success "explicit name" \ --name hohoho \ - --condition event-rule-matches some-event-id -u \ + --condition event-rule-matches --name=some-event-id -u \ --action notify # `--condition event-rule-matches` successes test_success "--condition event-rule-matches some-event -u" \ - --condition event-rule-matches some-event -u \ + --condition event-rule-matches --name=some-event -u \ --action notify -test_success "--condition event-rule-matches -a -u" \ - --condition event-rule-matches -a -u \ +test_success "--condition event-rule-matches -u" \ + --condition event-rule-matches -u \ --action notify test_success "notify action polices" \ - --condition event-rule-matches -u test-rate-policy \ + --condition event-rule-matches -u --name=test-rate-policy \ --action notify \ --rate-policy=every:55 \ --action notify \ --rate-policy=once-after:55 test_success "start session action polices" \ - --condition event-rule-matches -u test-rate-policy \ + --condition event-rule-matches -u --name=test-rate-policy \ --action start-session my_session \ --rate-policy=every:55 \ --action start-session my_session \ --rate-policy=once-after:55 test_success "stop session action polices" \ - --condition event-rule-matches -u test-rate-policy \ + --condition event-rule-matches -u --name=test-rate-policy \ --action stop-session my_session \ --rate-policy=every:55 \ --action stop-session my_session \ --rate-policy=once-after:55 test_success "snapshot session action polices" \ - --condition event-rule-matches -u test-rate-policy \ + --condition event-rule-matches -u --name=test-rate-policy \ --action snapshot-session my_session \ --rate-policy=every:55 \ --action snapshot-session my_session \ --rate-policy=once-after:55 test_success "rotate session action polices" \ - --condition event-rule-matches -u test-rate-policy \ + --condition event-rule-matches -u --name=test-rate-policy \ --action rotate-session my_session \ --rate-policy=every:55 \ --action rotate-session my_session \ @@ -128,7 +128,7 @@ test_success "rotate session action polices" \ skip $ist_root "non-root user: skipping kprobe tests" 9 || { test_success "--condition event-rule-matches probe by symbol" \ - --condition event-rule-matches -k --probe=lttng_channel_enable my_channel_enable \ + --condition event-rule-matches -k --probe=lttng_channel_enable --event-name=my_channel_enable \ --action notify channel_enable_addr=$(grep ' t lttng_channel_enable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ') @@ -148,101 +148,101 @@ skip $ist_root "non-root user: skipping kprobe tests" 9 || { offset_hex="0x$(printf '%x' $offset)" test_success "--condition event-rule-matches probe by symbol with offset" \ - --condition event-rule-matches -k --probe="${base_symbol}+${offset_hex}" my_$base_symbol \ + --condition event-rule-matches -k --probe="${base_symbol}+${offset_hex}" --event-name=my_$base_symbol \ --action notify test_success "--condition event-rule-matches probe by address" \ - --condition event-rule-matches -k "--probe=0x${channel_enable_addr}" my_channel_enable \ + --condition event-rule-matches -k "--probe=0x${channel_enable_addr}" --event-name=my_channel_enable \ --action notify } skip $ist_root "non-root user: skipping uprobe tests" 6 || { test_success "--condition event-rule-matches uprobe" \ - --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_function ma-probe \ + --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_function --event-name=ma-probe \ --action notify test_success "--condition event-rule-matches uprobe with elf prefix" \ - --condition event-rule-matches -k --userspace-probe=elf:${uprobe_elf_binary}:test_function ma-probe-2 \ + --condition event-rule-matches -k --userspace-probe=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \ --action notify } skip $ist_root "non-root user: skipping syscall tests" 9 || { - test_success "--condition event-rule-matches syscall" \ - --condition event-rule-matches -k --syscall open \ + test_success "--condition event-rule-matches one syscall" \ + --condition event-rule-matches -k --syscall --name=open \ --action notify - test_success "--condition event-rule-matches syscall -a" \ - --condition event-rule-matches -k --syscall -a \ + test_success "--condition event-rule-matches all syscalls" \ + --condition event-rule-matches -k --syscall \ --action notify - test_success "--condition event-rule-matches syscall with filter" \ - --condition event-rule-matches -k --syscall --filter 'a > 2' open \ + test_success "--condition event-rule-matches one syscall with filter" \ + --condition event-rule-matches -k --syscall --filter 'a > 2' --name=open \ --action notify } # `--action notify` successes test_success "--action notify" \ - --condition event-rule-matches some-event-notify -u \ + --condition event-rule-matches -u \ --action notify test_success "--action notify --capture foo" \ - --condition event-rule-matches some-event-notify-foo -u \ + --condition event-rule-matches -u \ --capture foo --action notify test_success "--action notify --capture foo[2]" \ - --condition event-rule-matches some-event-notify-foo2 -u \ + --condition event-rule-matches -u \ --capture 'foo[2]' --action notify test_success '--action notify --capture $ctx.foo' \ - --condition event-rule-matches some-event-notify-ctx-foo -u \ + --condition event-rule-matches -u \ --capture '$ctx.foo' --action notify test_success '--action notify --capture $ctx.foo[2]' \ - --condition event-rule-matches some-event-notify-ctx-foo2 -u \ + --condition event-rule-matches -u \ --capture '$ctx.foo[2]' --action notify test_success '--action notify --capture $app.prov:type' \ - --condition event-rule-matches some-event-notify-app-prov-type -u \ + --condition event-rule-matches -u \ --capture '$app.prov:type' --action notify test_success '--action notify --capture $app.prov:type[2]' \ - --condition event-rule-matches some-event-notify-app-prov-type-2 -u \ + --condition event-rule-matches -u \ --capture '$app.prov:type[2]' --action notify test_success '--action notify multiple captures' \ - --condition event-rule-matches some-event-notify-multiple-captures -u \ + --condition event-rule-matches -u \ --capture foo --capture '$app.hello:world' --action notify # `--action start-session` successes test_success "--action start-session" \ - --condition event-rule-matches some-event-start-session -u \ + --condition event-rule-matches -u \ --action start-session ze-session # `--action stop-session` successes test_success "--action stop-session foo" \ - --condition event-rule-matches some-event-stop-session -u \ + --condition event-rule-matches -u \ --action stop-session ze-session # `--action rotate-session` successes test_success "--action rotate-session foo" \ - --condition event-rule-matches some-event-rotate-session -u \ + --condition event-rule-matches -u \ --action rotate-session ze-session # `--action snapshot-session` successes test_success "--action snapshot-session foo" \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session test_success "--action snapshot-session with file URI" \ - --condition event-rule-matches some-event-snapshot-session2 -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --path /hello test_success "--action snapshot-session with net URI" \ - --condition event-rule-matches some-event-snapshot-session3 -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --url net://1.2.3.4 test_success "--action snapshot-session with ctrl/data URIs" \ - --condition event-rule-matches some-event-snapshot-session4 -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1234 --data-url=tcp://1.2.3.4:1235 # top-level failures @@ -254,12 +254,12 @@ test_failure "unknown option" \ test_failure "missing --action" \ "Error: Need at least one --action." \ - --condition event-rule-matches hello -u + --condition event-rule-matches -u test_failure "two --condition" \ "Error: A --condition was already given." \ - --condition event-rule-matches aaa -u \ - --condition event-rule-matches bbb -u \ + --condition event-rule-matches --name=aaa -u \ + --condition event-rule-matches --name=bbb -u \ --action notify test_failure "missing argument to --name" \ @@ -269,23 +269,23 @@ test_failure "missing argument to --name" \ for cmd in rate-policy=once-after rate-policy=every; do test_failure "missing argument to --${cmd}" \ "Error: Rate policy format is invalid." \ - --condition event-rule-matches -u -a --action notify \ + --condition event-rule-matches -u --action notify \ --${cmd} test_failure "invalid argument to --${cmd}: non-digit character" \ "Error: Failed to parse rate policy value \`123bob\` as an integer." \ - --condition event-rule-matches -u -a --action notify \ + --condition event-rule-matches -u --action notify \ --${cmd}:123bob test_failure "invalid argument to --${cmd}: empty string" \ "Error: Failed to parse rate policy value \`\` as an integer." \ - --condition event-rule-matches -u -a --action notify \ + --condition event-rule-matches -u --action notify \ --${cmd}":" done test_failure "invalid argument to --rate-policy: unknown policy type" \ "Error: Rate policy type \`bob\` unknown." \ - --condition event-rule-matches -u -a --action notify \ + --condition event-rule-matches -u --action notify \ --rate-policy=bob:123 # `--condition` failures @@ -298,152 +298,140 @@ test_failure "unknown --condition" \ # `--condition event-rule-matches` failures test_failure "missing args after --condition event-rule-matches" \ - "Error: Need to provide either a tracepoint name or -a/--all." \ - --condition event-rule-matches -test_failure "missing domain in --condition event-rule-matches" \ "Error: Please specify a domain (--kernel/--userspace/--jul/--log4j/--python)." \ - --condition event-rule-matches -a + --condition event-rule-matches + test_failure "extra args after --condition event-rule-matches" \ "Error: Unexpected argument 'bozo'" \ - --condition event-rule-matches foo -u bozo -test_failure "--condition event-rule-matches: --all with --probe" \ - "Error: Can't use -a/--all with probe event rules." \ - --condition event-rule-matches --probe=do_sys_open --all -test_failure "--condition event-rule-matches: missing tracepoint name with --probe" \ - "Error: Need to provide either a tracepoint name or -a/--all." \ - --condition event-rule-matches -k --probe do_sys_open - -test_failure "--condition event-rule-matches: missing tracepoint name with --userspace-probe" \ - "Error: Need to provide either a tracepoint name or -a/--all." \ - --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_function + --condition event-rule-matches -u bozo -test_failure "--condition event-rule-matches: extra argument with --userspace-probe" \ - "Error: Unexpected argument 'world'" \ - --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_failure hello world +test_failure "--condition event-rule-matches: --name with --probe" \ + "Error: Can't use --name with probe event rules." \ + --condition event-rule-matches --probe=do_sys_open --name='hello' -test_failure "--condition event-rule-matches: missing tracepoint name with --syscall" \ - "Error: Need to provide either a tracepoint name or -a/--all." \ - --condition event-rule-matches -k --syscall +test_failure "--condition event-rule-matches: --event-name with tracepoint" \ + "Error: Can't use --event-name with tracepoint event rules." \ + --condition event-rule-matches -u --event-name='hello' + +test_failure "--condition event-rule-matches: extra argument with --userspace-probe" \ + "Error: Unexpected argument 'hello'" \ + --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_failure hello test_failure "--condition event-rule-matches: extra argument with --syscall" \ "Error: Unexpected argument 'open'" \ - --condition event-rule-matches -k --syscall open open - -test_failure "--condition event-rule-matches: both -a and a tracepoint name with --syscall" \ - "Error: Can't provide a tracepoint name with -a/--all." \ - --condition event-rule-matches -k --syscall -a open + --condition event-rule-matches -k --syscall open test_failure "--condition event-rule-matches --capture: missing argument (end of arg list)" \ - 'Error: While parsing argument #3 (`--capture`): Missing required argument for option `--capture`' \ + 'Error: While parsing argument #2 (`--capture`): Missing required argument for option `--capture`' \ --action notify \ - --condition event-rule-matches -u -a --capture + --condition event-rule-matches -u --capture test_failure "--condition event-rule-matches --capture: missing argument (before another option)" \ 'Error: While parsing expression `--action`: Unary operators are not allowed in capture expressions.' \ - --condition event-rule-matches -u -a --capture \ + --condition event-rule-matches -u --capture \ --action notify \ test_failure "--condition event-rule-matches --capture: binary operator" \ 'Error: While parsing expression `foo == 2`: Binary operators are not allowed in capture expressions.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture 'foo == 2' --action notify test_failure "--condition event-rule-matches --capture: unary operator" \ 'Error: While parsing expression `!foo`: Unary operators are not allowed in capture expressions.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture '!foo' --action notify test_failure "--condition event-rule-matches --capture: logical operator" \ 'Error: While parsing expression `foo || bar`: Logical operators are not allowed in capture expressions.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture 'foo || bar' --action notify test_failure "--condition event-rule-matches --capture: accessing a sub-field" \ 'Error: While parsing expression `foo.bar`: Capturing subfields is not supported.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture 'foo.bar' --action notify test_failure "--condition event-rule-matches --capture: accessing the sub-field of an array element" \ 'Error: While parsing expression `foo[3].bar`: Capturing subfields is not supported.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture 'foo[3].bar' --action notify test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \ 'Error: Invalid app-specific context field name: missing colon in `foo`.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture '$app.foo' --action notify test_failure "--condition event-rule-matches --capture: missing colon in app-specific context field" \ 'Error: Invalid app-specific context field name: missing type name after colon in `foo:`.' \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --capture '$app.foo:' --action notify # `--action` failures test_failure "missing args after --action" \ "Error: While parsing argument #1 (\`--action\`): Missing required argument for option \`--action\`" \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --action # `--action notify` failures test_failure "extra arg after --action notify" \ "Error: Unexpected argument \`bob\`." \ - --condition event-rule-matches -u -a \ + --condition event-rule-matches -u \ --action notify bob # `--action start-session` failures test_failure "missing arg after --action start-session" \ "Error: Missing session name." \ - --condition event-rule-matches some-event-start-session -u \ + --condition event-rule-matches -u \ --action start-session test_failure "extra arg after --action start-session" \ "Error: Unexpected argument \`bob\`." \ - --condition event-rule-matches some-event-start-session -u \ + --condition event-rule-matches -u \ --action start-session ze-session bob # `--action stop-session` failures test_failure "missing arg after --action stop-session" \ "Error: Missing session name." \ - --condition event-rule-matches some-event-stop-session -u \ + --condition event-rule-matches -u \ --action stop-session test_failure "extra arg after --action stop-session" \ "Error: Unexpected argument \`bob\`." \ - --condition event-rule-matches some-event-stop-session -u \ + --condition event-rule-matches -u \ --action stop-session ze-session bob # `--action rotate-session` failures test_failure "missing arg after --action rotate-session" \ "Error: Missing session name." \ - --condition event-rule-matches some-event-rotate-session -u \ + --condition event-rule-matches -u \ --action rotate-session test_failure "extra arg after --action rotate-session" \ "Error: Unexpected argument \`bob\`." \ - --condition event-rule-matches some-event-rotate-session -u \ + --condition event-rule-matches -u \ --action rotate-session ze-session bob # `--action snapshot-session` failures test_failure "missing arg after --action snapshot-session" \ "Error: Missing session name." \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session test_failure "extra arg after --action snapshot-session" \ "Error: Unexpected argument \`bob\`." \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session bob test_failure "snapshot-session action, --max-size without destination" \ "Error: Can't provide a snapshot output max size without a snapshot output destination." \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --max-size 10M test_failure "snapshot-session action, --name without destination" \ "Error: Can't provide a snapshot output name without a snapshot output destination." \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --name hallo test_failure "snapshot-session action, --name with-local-path-instead-of-url" \ "Error: Failed to parse '/something/that/looks/like/a/path' as an URL." \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --name hallo --url /something/that/looks/like/a/path test_failure "snapshot-session action, --name with-net-url-instead-of-path" \ "Error: Failed to parse 'net://8.8.8.8/' as a local path." \ - --condition event-rule-matches some-event-snapshot-session -u \ + --condition event-rule-matches -u \ --action snapshot-session ze-session --name hallo --path net://8.8.8.8/ # Cleanup diff --git a/tests/regression/tools/trigger/test_list_triggers_cli b/tests/regression/tools/trigger/test_list_triggers_cli index 82a5d5a91..e023f3fd9 100755 --- a/tests/regression/tools/trigger/test_list_triggers_cli +++ b/tests/regression/tools/trigger/test_list_triggers_cli @@ -70,13 +70,13 @@ test_top_level_options () { diag "Listing top level options" - lttng_add_trigger_ok "hello" --condition event-rule-matches -u test-id --action notify + lttng_add_trigger_ok "hello" --condition event-rule-matches -u --name=test-name --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: hello user id: ${uid} condition: event rule hit - rule: test-id (type: tracepoint, domain: ust) + rule: test-name (type: tracepoint, domain: ust) actions: notify errors: none @@ -92,15 +92,15 @@ test_on_event_tracepoint () { diag "Listing on-event tracepoint" - lttng_add_trigger_ok "C" --condition event-rule-matches -u -a --action notify - lttng_add_trigger_ok "A" --condition event-rule-matches aaa -u --filter 'p == 2' --action notify - lttng_add_trigger_ok "D" --condition event-rule-matches 'hello*' -u -x 'hello2,hello3,hello4' --action notify - lttng_add_trigger_ok "B" --condition event-rule-matches -u gerboise --loglevel INFO --action notify - lttng_add_trigger_ok "E" --condition event-rule-matches -u lemming --loglevel-only WARNING --action notify - lttng_add_trigger_ok "F" --condition event-rule-matches -u capture-payload-field --capture a --action notify - lttng_add_trigger_ok "G" --condition event-rule-matches -u capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify - lttng_add_trigger_ok "H" --condition event-rule-matches -u capture-chan-ctx --capture '$ctx.vpid' --action notify - lttng_add_trigger_ok "I" --condition event-rule-matches -u capture-app-ctx --capture '$app.iga:active_clients' --action notify + lttng_add_trigger_ok "C" --condition event-rule-matches -u --action notify + lttng_add_trigger_ok "A" --condition event-rule-matches --name=aaa -u --filter 'p == 2' --action notify + lttng_add_trigger_ok "D" --condition event-rule-matches --name='hello*' -u -x 'hello2,hello3,hello4' --action notify + lttng_add_trigger_ok "B" --condition event-rule-matches -u --name=gerboise --loglevel INFO --action notify + lttng_add_trigger_ok "E" --condition event-rule-matches -u --name=lemming --loglevel-only WARNING --action notify + lttng_add_trigger_ok "F" --condition event-rule-matches -u --name=capture-payload-field --capture a --action notify + lttng_add_trigger_ok "G" --condition event-rule-matches -u --name=capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify + lttng_add_trigger_ok "H" --condition event-rule-matches -u --name=capture-chan-ctx --capture '$ctx.vpid' --action notify + lttng_add_trigger_ok "I" --condition event-rule-matches -u --name=capture-app-ctx --capture '$app.iga:active_clients' --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: A @@ -222,9 +222,9 @@ test_on_event_probe () offset_hex="0x$(printf '%x' $offset)" - lttng_add_trigger_ok "T0" --condition event-rule-matches -k --probe=lttng_channel_enable my_channel_enable --action notify - lttng_add_trigger_ok "T1" --condition event-rule-matches -k --probe="${base_symbol}+${offset_hex}" my_channel_enable --action notify - lttng_add_trigger_ok "T2" --condition event-rule-matches -k --probe="0x${channel_enable_addr}" my_channel_enable --action notify + lttng_add_trigger_ok "T0" --condition event-rule-matches -k --probe=lttng_channel_enable --event-name=my_channel_enable --action notify + lttng_add_trigger_ok "T1" --condition event-rule-matches -k --probe="${base_symbol}+${offset_hex}" --event-name=my_channel_enable --action notify + lttng_add_trigger_ok "T2" --condition event-rule-matches -k --probe="0x${channel_enable_addr}" --event-name=my_channel_enable --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: T0 @@ -266,7 +266,7 @@ test_on_event_userspace_probe_elf () diag "Listing on-event userspace-probe elf" - lttng_add_trigger_ok "T0" --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_function ma-probe-elf --action notify + lttng_add_trigger_ok "T0" --condition event-rule-matches -k --userspace-probe=${uprobe_elf_binary}:test_function --event-name=ma-probe-elf --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: T0 @@ -313,8 +313,8 @@ test_on_event_syscall () { diag "Listing on-event syscall" - lttng_add_trigger_ok "T0" --condition event-rule-matches -k --syscall open --action notify - lttng_add_trigger_ok "T1" --condition event-rule-matches -k --syscall ptrace --filter 'a > 2' --action notify + lttng_add_trigger_ok "T0" --condition event-rule-matches -k --syscall --name=open --action notify + lttng_add_trigger_ok "T1" --condition event-rule-matches -k --syscall --name=ptrace --filter 'a > 2' --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: T0 @@ -345,16 +345,16 @@ test_snapshot_action () { diag "Listing snapshot actions" - lttng_add_trigger_ok "T0" --condition event-rule-matches -u some-event --action snapshot-session ze-session - lttng_add_trigger_ok "T1" --condition event-rule-matches -u some-event --action snapshot-session ze-session --path /some/path - lttng_add_trigger_ok "T2" --condition event-rule-matches -u some-event --action snapshot-session ze-session --url file:///some/other/path - lttng_add_trigger_ok "T3" --condition event-rule-matches -u some-event --action snapshot-session ze-session --url net://1.2.3.4 - lttng_add_trigger_ok "T4" --condition event-rule-matches -u some-event --action snapshot-session ze-session --url net://1.2.3.4:1234:1235 - lttng_add_trigger_ok "T5" --condition event-rule-matches -u some-event --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1111 --data-url=tcp://1.2.3.4:1112 - lttng_add_trigger_ok "T6" --condition event-rule-matches -u some-event --action snapshot-session ze-session --path /some/path --max-size=1234 - lttng_add_trigger_ok "T7" --condition event-rule-matches -u some-event --action snapshot-session ze-session --path /some/path --name=meh - lttng_add_trigger_ok "T8" --condition event-rule-matches -u some-event --action snapshot-session ze-session --rate-policy=every:10 - lttng_add_trigger_ok "T9" --condition event-rule-matches -u some-event --action snapshot-session ze-session --rate-policy=once-after:10 + lttng_add_trigger_ok "T0" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session + lttng_add_trigger_ok "T1" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --path /some/path + lttng_add_trigger_ok "T2" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --url file:///some/other/path + lttng_add_trigger_ok "T3" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --url net://1.2.3.4 + lttng_add_trigger_ok "T4" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --url net://1.2.3.4:1234:1235 + lttng_add_trigger_ok "T5" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1111 --data-url=tcp://1.2.3.4:1112 + lttng_add_trigger_ok "T6" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --path /some/path --max-size=1234 + lttng_add_trigger_ok "T7" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --path /some/path --name=meh + lttng_add_trigger_ok "T8" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --rate-policy=every:10 + lttng_add_trigger_ok "T9" --condition event-rule-matches -u --name=some-event --action snapshot-session ze-session --rate-policy=once-after:10 cat > "${tmp_expected_stdout}" <<- EOF - name: T0 @@ -455,8 +455,8 @@ test_snapshot_action () test_notify_action () { - lttng_add_trigger_ok "T0" --condition event-rule-matches -u some-event --action notify --rate-policy=once-after:5 - lttng_add_trigger_ok "T1" --condition event-rule-matches -u some-event --action notify --rate-policy=every:10 + lttng_add_trigger_ok "T0" --condition event-rule-matches -u --name=some-event --action notify --rate-policy=once-after:5 + lttng_add_trigger_ok "T1" --condition event-rule-matches -u --name=some-event --action notify --rate-policy=every:10 cat > "${tmp_expected_stdout}" <<- EOF - name: T0 diff --git a/tests/regression/tools/trigger/test_remove_trigger_cli b/tests/regression/tools/trigger/test_remove_trigger_cli index 9a0468761..5f3dffc4e 100755 --- a/tests/regression/tools/trigger/test_remove_trigger_cli +++ b/tests/regression/tools/trigger/test_remove_trigger_cli @@ -68,8 +68,8 @@ function remove_trigger () start_lttng_sessiond_notap # Add a few triggers -lttng_add_trigger_ok "ABC" --condition event-rule-matches aaa -u --filter 'p == 2' --action notify -lttng_add_trigger_ok "DEF" --condition event-rule-matches -u -a --action notify +lttng_add_trigger_ok "ABC" --condition event-rule-matches --name=aaa -u --filter 'p == 2' --action notify +lttng_add_trigger_ok "DEF" --condition event-rule-matches -u --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: ABC diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 4f4cfc951..6a9e1891d 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -2197,8 +2197,10 @@ function lttng_add_trigger() local expected_to_fail="$1" local trigger_name="$2" shift 2 + local args=("$@") - $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name "$trigger_name" "$@" 1> /dev/null 2> /dev/null + diag "$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name $trigger_name ${args[*]}" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name "$trigger_name" "${args[@]}" 1> /dev/null 2> /dev/null ret=$? if [[ $expected_to_fail -eq "1" ]]; then test "$ret" -ne "0" @@ -2214,7 +2216,8 @@ function lttng_remove_trigger() local trigger_name="$2" shift 2 - $TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger "$trigger_name" "$@" 1> /dev/null 2> /dev/null + diag "$TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger $trigger_name" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN remove-trigger "$trigger_name" 1> /dev/null 2> /dev/null ret=$? if [[ $expected_to_fail -eq "1" ]]; then test "$ret" -ne "0"