From 1d4b59f247e2692bf1e9c3c0aac93a47389d20dd Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 9 Apr 2021 14:46:42 -0400 Subject: [PATCH] lttng {add,list}-triggers: use `name` instead of `id` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The right term is "trigger name", not "trigger id". Change the option to add-trigger accordingly, as well as the output of list-trigger. Change-Id: I5c304aea2c37f983de001cb11c5ba8859f564617 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/add_trigger.c | 16 +++--- src/bin/lttng/commands/list_triggers.c | 2 +- .../tools/trigger/test_add_trigger_cli | 10 ++-- .../tools/trigger/test_list_triggers_cli | 56 +++++++++---------- .../tools/trigger/test_remove_trigger_cli | 14 ++--- tests/utils/utils.sh | 2 +- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index fdfbecfaa..af5c420e1 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -2026,7 +2026,7 @@ struct argpar_opt_descr add_trigger_options[] = { { OPT_LIST_OPTIONS, '\0', "list-options", false }, { OPT_CONDITION, '\0', "condition", true }, { OPT_ACTION, '\0', "action", true }, - { OPT_ID, '\0', "id", true }, + { OPT_NAME, '\0', "name", true }, { OPT_USER_ID, '\0', "user-id", true }, ARGPAR_OPT_DESCR_SENTINEL, }; @@ -2052,7 +2052,7 @@ int cmd_add_trigger(int argc, const char **argv) struct lttng_action *action = NULL; struct lttng_trigger *trigger = NULL; char *error = NULL; - char *id = NULL; + char *name = NULL; int i; char *user_id = NULL; @@ -2152,9 +2152,9 @@ int cmd_add_trigger(int argc, const char **argv) break; } - case OPT_ID: + case OPT_NAME: { - if (!assign_string(&id, item_opt->arg, "--id")) { + if (!assign_string(&name, item_opt->arg, "--name")) { goto error; } @@ -2212,12 +2212,12 @@ int cmd_add_trigger(int argc, const char **argv) goto error; } - if (id) { + if (name) { enum lttng_trigger_status trigger_status = - lttng_trigger_set_name(trigger, id); + lttng_trigger_set_name(trigger, name); if (trigger_status != LTTNG_TRIGGER_STATUS_OK) { - ERR("Failed to set trigger id."); + ERR("Failed to set trigger name."); goto error; } } @@ -2262,7 +2262,7 @@ end: lttng_action_destroy(action); lttng_trigger_destroy(trigger); free(error); - free(id); + free(name); free(user_id); return ret; } diff --git a/src/bin/lttng/commands/list_triggers.c b/src/bin/lttng/commands/list_triggers.c index 1590bbc79..3b806e7ea 100644 --- a/src/bin/lttng/commands/list_triggers.c +++ b/src/bin/lttng/commands/list_triggers.c @@ -816,7 +816,7 @@ void print_one_trigger(const struct lttng_trigger *trigger) trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid); assert(trigger_status == LTTNG_TRIGGER_STATUS_OK); - MSG("- id: %s", name); + MSG("- name: %s", name); MSG(" user id: %d", trigger_uid); condition = lttng_trigger_get_const_condition(trigger); diff --git a/tests/regression/tools/trigger/test_add_trigger_cli b/tests/regression/tools/trigger/test_add_trigger_cli index fd962c04b..a8d03c4dd 100755 --- a/tests/regression/tools/trigger/test_add_trigger_cli +++ b/tests/regression/tools/trigger/test_add_trigger_cli @@ -77,8 +77,8 @@ function test_failure () } # top-level options -test_success "explicit id" \ - --id hohoho \ +test_success "explicit name" \ + --name hohoho \ --condition on-event some-event-id -u \ --action notify @@ -262,9 +262,9 @@ test_failure "two --condition" \ --condition on-event bbb -u \ --action notify -test_failure "missing argument to --id" \ - "Error: While parsing argument #1 (\`--id\`): Missing required argument for option \`--id\`" \ - --id +test_failure "missing argument to --name" \ + "Error: While parsing argument #1 (\`--name\`): Missing required argument for option \`--name\`" \ + --name for cmd in rate-policy=once-after rate-policy=every; do test_failure "missing argument to --${cmd}" \ diff --git a/tests/regression/tools/trigger/test_list_triggers_cli b/tests/regression/tools/trigger/test_list_triggers_cli index 9c85838b3..42893f5d6 100755 --- a/tests/regression/tools/trigger/test_list_triggers_cli +++ b/tests/regression/tools/trigger/test_list_triggers_cli @@ -73,7 +73,7 @@ test_top_level_options () lttng_add_trigger_ok "hello" --condition on-event -u test-id --action notify cat > "${tmp_expected_stdout}" <<- EOF - - id: hello + - name: hello user id: ${uid} condition: event rule hit rule: test-id (type: tracepoint, domain: ust) @@ -104,7 +104,7 @@ test_on_event_tracepoint () cat > "${tmp_expected_stdout}" <<- EOF - - id: A + - name: A user id: ${uid} condition: event rule hit rule: aaa (type: tracepoint, domain: ust, filter: p == 2) @@ -112,7 +112,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: B + - name: B user id: ${uid} condition: event rule hit rule: gerboise (type: tracepoint, domain: ust, log level at least INFO) @@ -120,7 +120,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: C + - name: C user id: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) @@ -128,7 +128,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: D + - name: D user id: ${uid} condition: event rule hit rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4) @@ -136,7 +136,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: E + - name: E user id: ${uid} condition: event rule hit rule: lemming (type: tracepoint, domain: ust, log level is WARNING) @@ -144,7 +144,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: F + - name: F user id: ${uid} condition: event rule hit rule: capture-payload-field (type: tracepoint, domain: ust) @@ -154,7 +154,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: G + - name: G user id: ${uid} condition: event rule hit rule: capture-array (type: tracepoint, domain: ust) @@ -165,7 +165,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: H + - name: H user id: ${uid} condition: event rule hit rule: capture-chan-ctx (type: tracepoint, domain: ust) @@ -175,7 +175,7 @@ test_on_event_tracepoint () notify errors: none errors: none - - id: I + - name: I user id: ${uid} condition: event rule hit rule: capture-app-ctx (type: tracepoint, domain: ust) @@ -228,7 +228,7 @@ test_on_event_probe () lttng_add_trigger_ok "T2" --condition on-event -k --probe="0x${channel_enable_addr}" my_channel_enable --action notify cat > "${tmp_expected_stdout}" <<- EOF - - id: T0 + - name: T0 user id: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: lttng_channel_enable) @@ -236,7 +236,7 @@ test_on_event_probe () notify errors: none errors: none - - id: T1 + - name: T1 user id: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex}) @@ -244,7 +244,7 @@ test_on_event_probe () notify errors: none errors: none - - id: T2 + - name: T2 user id: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr}) @@ -270,7 +270,7 @@ test_on_event_userspace_probe_elf () lttng_add_trigger_ok "T0" --condition on-event -k --userspace-probe=${uprobe_elf_binary}:${elf_function_name} ma-probe-elf --action notify cat > "${tmp_expected_stdout}" <<- EOF - - id: T0 + - name: T0 user id: ${uid} condition: event rule hit rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name}) @@ -319,7 +319,7 @@ test_on_event_syscall () lttng_add_trigger_ok "T1" --condition on-event -k --syscall ptrace --filter 'a > 2' --action notify cat > "${tmp_expected_stdout}" <<- EOF - - id: T0 + - name: T0 user id: ${uid} condition: event rule hit rule: open (type: syscall) @@ -327,7 +327,7 @@ test_on_event_syscall () notify errors: none errors: none - - id: T1 + - name: T1 user id: ${uid} condition: event rule hit rule: ptrace (type: syscall, filter: a > 2) @@ -360,7 +360,7 @@ test_snapshot_action () cat > "${tmp_expected_stdout}" <<- EOF - - id: T0 + - name: T0 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -368,7 +368,7 @@ test_snapshot_action () snapshot session \`ze-session\` errors: none errors: none - - id: T1 + - name: T1 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -376,7 +376,7 @@ test_snapshot_action () snapshot session \`ze-session\`, path: /some/path errors: none errors: none - - id: T2 + - name: T2 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -384,7 +384,7 @@ test_snapshot_action () snapshot session \`ze-session\`, path: /some/other/path errors: none errors: none - - id: T3 + - name: T3 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -392,7 +392,7 @@ test_snapshot_action () snapshot session \`ze-session\`, url: net://1.2.3.4 errors: none errors: none - - id: T4 + - name: T4 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -400,7 +400,7 @@ test_snapshot_action () snapshot session \`ze-session\`, url: net://1.2.3.4:1234:1235 errors: none errors: none - - id: T5 + - name: T5 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -408,7 +408,7 @@ test_snapshot_action () snapshot session \`ze-session\`, control url: tcp://1.2.3.4:1111, data url: tcp://1.2.3.4:1112 errors: none errors: none - - id: T6 + - name: T6 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -416,7 +416,7 @@ test_snapshot_action () snapshot session \`ze-session\`, path: /some/path, max size: 1234 errors: none errors: none - - id: T7 + - name: T7 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -424,7 +424,7 @@ test_snapshot_action () snapshot session \`ze-session\`, path: /some/path, name: meh errors: none errors: none - - id: T8 + - name: T8 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -432,7 +432,7 @@ test_snapshot_action () snapshot session \`ze-session\`, rate policy: after every 10 occurrences errors: none errors: none - - id: T9 + - name: T9 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -456,7 +456,7 @@ test_notify_action () cat > "${tmp_expected_stdout}" <<- EOF - - id: T0 + - name: T0 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) @@ -464,7 +464,7 @@ test_notify_action () notify, rate policy: once after 5 occurrences errors: none errors: none - - id: T1 + - name: T1 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) diff --git a/tests/regression/tools/trigger/test_remove_trigger_cli b/tests/regression/tools/trigger/test_remove_trigger_cli index 8a0f90a9e..5ec36bccf 100755 --- a/tests/regression/tools/trigger/test_remove_trigger_cli +++ b/tests/regression/tools/trigger/test_remove_trigger_cli @@ -51,13 +51,13 @@ function list_triggers () function remove_trigger () { - local id="$1" - local test_name="remove trigger ${id}" + local name="$1" + local test_name="remove trigger ${name}" - "${FULL_LTTNG_BIN}" remove-trigger "${id}" > "${tmp_stdout}" 2> "${tmp_stderr}" + "${FULL_LTTNG_BIN}" remove-trigger "${name}" > "${tmp_stdout}" 2> "${tmp_stderr}" ok $? "${test_name}: exit code is 0" - diff -u <(echo "Removed trigger \`${id}\`.") "${tmp_stdout}" + diff -u <(echo "Removed trigger \`${name}\`.") "${tmp_stdout}" ok $? "${test_name}: expected stdout" diff -u /dev/null "${tmp_stderr}" @@ -72,7 +72,7 @@ lttng_add_trigger_ok "ABC" --condition on-event aaa -u --filter 'p == 2' --actio lttng_add_trigger_ok "DEF" --condition on-event -u -a --action notify cat > "${tmp_expected_stdout}" <<- EOF -- id: ABC +- name: ABC user id: ${uid} condition: event rule hit rule: aaa (type: tracepoint, domain: ust, filter: p == 2) @@ -80,7 +80,7 @@ cat > "${tmp_expected_stdout}" <<- EOF notify errors: none errors: none -- id: DEF +- name: DEF user id: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) @@ -94,7 +94,7 @@ list_triggers "two triggers left" "${tmp_expected_stdout}" remove_trigger "ABC" cat > "${tmp_expected_stdout}" <<- EOF -- id: DEF +- name: DEF user id: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index c81cc2d1a..4f4cfc951 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -2198,7 +2198,7 @@ function lttng_add_trigger() local trigger_name="$2" shift 2 - $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --id "$trigger_name" "$@" 1> /dev/null 2> /dev/null + $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-trigger --name "$trigger_name" "$@" 1> /dev/null 2> /dev/null ret=$? if [[ $expected_to_fail -eq "1" ]]; then test "$ret" -ne "0" -- 2.34.1