X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Ftrigger%2Ftest_list_triggers_cli;h=fa1af958d7d98346ea78bb723e4a7b2106507745;hp=1257ec881cca6ea047ba6ebee10f4ffb6aa2e5b1;hb=7f4d5b07cf7be895b38b69073389a4fcc318ec29;hpb=b203b4b06b6d895d6745f3c45b83b2a36ae6a989 diff --git a/tests/regression/tools/trigger/test_list_triggers_cli b/tests/regression/tools/trigger/test_list_triggers_cli index 1257ec881..fa1af958d 100755 --- a/tests/regression/tools/trigger/test_list_triggers_cli +++ b/tests/regression/tools/trigger/test_list_triggers_cli @@ -23,7 +23,7 @@ TESTDIR="$CURDIR/../../.." # shellcheck source=../../../utils/utils.sh source "$TESTDIR/utils/utils.sh" -plan_tests 44 +plan_tests 49 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" @@ -41,12 +41,6 @@ else ist_root=0 fi -function add_trigger () -{ - "${FULL_LTTNG_BIN}" add-trigger "$@" - ok $? "add trigger \`$*\`: exit code is 0" -} - function list_triggers () { local test_name="$1" @@ -68,29 +62,14 @@ test_top_level_options () start_lttng_sessiond_notap - add_trigger --id hello --condition on-event -u test-id --action notify - add_trigger --fire-once-after 123 --condition on-event -u test-fire-once-after --action notify - add_trigger --fire-every 124 --condition on-event -u test-fire-every --action notify + lttng_add_trigger_ok "hello" --condition on-event -u test-id --action notify cat > "${tmp_expected_stdout}" <<- EOF - - id: T0 - user id: ${uid} - firing policy: once after 123 occurences - condition: event rule hit - rule: test-fire-once-after (type: tracepoint, domain: ust) - actions: - notify - - id: T1 - user id: ${uid} - firing policy: after every 124 occurences - condition: event rule hit - rule: test-fire-every (type: tracepoint, domain: ust) - actions: - notify - id: hello user id: ${uid} condition: event rule hit rule: test-id (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: notify EOF @@ -105,77 +84,86 @@ test_on_event_tracepoint () # shellcheck disable=SC2119 start_lttng_sessiond_notap - add_trigger --condition on-event -u -a --action notify - add_trigger --id ABC --condition on-event aaa -u --filter 'p == 2' --action notify - add_trigger --condition on-event 'hello*' -u -x 'hello2,hello3,hello4' --action notify - add_trigger --id BCD --condition on-event -u gerboise --loglevel INFO --action notify - add_trigger --condition on-event -u lemming --loglevel-only WARNING --action notify - add_trigger --condition on-event -u capture-payload-field --capture a --action notify - add_trigger --condition on-event -u capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify - add_trigger --condition on-event -u capture-chan-ctx --capture '$ctx.vpid' --action notify - add_trigger --condition on-event -u capture-app-ctx --capture '$app.iga:active_clients' --action notify + lttng_add_trigger_ok "C" --condition on-event -u -a --action notify + lttng_add_trigger_ok "A" --condition on-event aaa -u --filter 'p == 2' --action notify + lttng_add_trigger_ok "D" --condition on-event 'hello*' -u -x 'hello2,hello3,hello4' --action notify + lttng_add_trigger_ok "B" --condition on-event -u gerboise --loglevel INFO --action notify + lttng_add_trigger_ok "E" --condition on-event -u lemming --loglevel-only WARNING --action notify + lttng_add_trigger_ok "F" --condition on-event -u capture-payload-field --capture a --action notify + lttng_add_trigger_ok "G" --condition on-event -u capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify + lttng_add_trigger_ok "H" --condition on-event -u capture-chan-ctx --capture '$ctx.vpid' --action notify + lttng_add_trigger_ok "I" --condition on-event -u capture-app-ctx --capture '$app.iga:active_clients' --action notify cat > "${tmp_expected_stdout}" <<- EOF - - id: ABC + - id: A user id: ${uid} condition: event rule hit rule: aaa (type: tracepoint, domain: ust, filter: p == 2) + tracer notifications discarded: 0 actions: notify - - id: BCD + - id: B user id: ${uid} condition: event rule hit - rule: gerboise (type: tracepoint, domain: ust, log level <= TRACE_INFO) + rule: gerboise (type: tracepoint, domain: ust, log level at least INFO) + tracer notifications discarded: 0 actions: notify - - id: T0 + - id: C user id: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: notify - - id: T1 + - id: D user id: ${uid} condition: event rule hit rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4) + tracer notifications discarded: 0 actions: notify - - id: T2 + - id: E user id: ${uid} condition: event rule hit - rule: lemming (type: tracepoint, domain: ust, log level == TRACE_WARNING) + rule: lemming (type: tracepoint, domain: ust, log level is WARNING) + tracer notifications discarded: 0 actions: notify - - id: T3 + - id: F user id: ${uid} condition: event rule hit rule: capture-payload-field (type: tracepoint, domain: ust) + tracer notifications discarded: 0 captures: - a actions: notify - - id: T4 + - id: G user id: ${uid} condition: event rule hit rule: capture-array (type: tracepoint, domain: ust) + tracer notifications discarded: 0 captures: - a[2] - \$ctx.tourlou[18] actions: notify - - id: T5 + - id: H user id: ${uid} condition: event rule hit rule: capture-chan-ctx (type: tracepoint, domain: ust) + tracer notifications discarded: 0 captures: - \$ctx.vpid actions: notify - - id: T6 + - id: I user id: ${uid} condition: event rule hit rule: capture-app-ctx (type: tracepoint, domain: ust) + tracer notifications discarded: 0 captures: - \$app.iga:active_clients actions: @@ -211,27 +199,30 @@ test_on_event_probe () offset_hex="0x$(printf '%x' $offset)" - add_trigger --condition on-event -k --probe=lttng_channel_enable my_channel_enable --action notify - add_trigger --condition on-event -k --probe="${base_symbol}+${offset_hex}" my_channel_enable --action notify - add_trigger --condition on-event -k --probe="0x${channel_enable_addr}" my_channel_enable --action notify + lttng_add_trigger_ok "T0" --condition on-event -k --probe=lttng_channel_enable my_channel_enable --action notify + lttng_add_trigger_ok "T1" --condition on-event -k --probe="${base_symbol}+${offset_hex}" my_channel_enable --action notify + 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 user id: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: lttng_channel_enable) + tracer notifications discarded: 0 actions: notify - id: T1 user id: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex}) + tracer notifications discarded: 0 actions: notify - id: T2 user id: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr}) + tracer notifications discarded: 0 actions: notify EOF @@ -246,13 +237,14 @@ test_on_event_userspace_probe () # shellcheck disable=SC2119 start_lttng_sessiond_notap - add_trigger --condition on-event -k --userspace-probe=${uprobe_elf_binary}:test_function ma-probe --action notify + lttng_add_trigger_ok "T0" --condition on-event -k --userspace-probe=${uprobe_elf_binary}:test_function ma-probe --action notify cat > "${tmp_expected_stdout}" <<- EOF - id: T0 user id: ${uid} condition: event rule hit rule: ma-probe (type: userspace probe, location: ${uprobe_elf_binary}:test_function) + tracer notifications discarded: 0 actions: notify EOF @@ -267,20 +259,22 @@ test_on_event_syscall () # shellcheck disable=SC2119 start_lttng_sessiond_notap - add_trigger --condition on-event -k --syscall open --action notify - add_trigger --condition on-event -k --syscall ptrace --filter 'a > 2' --action notify + lttng_add_trigger_ok "T0" --condition on-event -k --syscall open --action notify + lttng_add_trigger_ok "T1" --condition on-event -k --syscall ptrace --filter 'a > 2' --action notify cat > "${tmp_expected_stdout}" <<- EOF - id: T0 user id: ${uid} condition: event rule hit rule: open (type: syscall) + tracer notifications discarded: 0 actions: notify - id: T1 user id: ${uid} condition: event rule hit rule: ptrace (type: syscall, filter: a > 2) + tracer notifications discarded: 0 actions: notify EOF @@ -294,14 +288,16 @@ test_snapshot_action () { start_lttng_sessiond_notap - add_trigger --condition on-event -u some-event --action snapshot-session ze-session - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --path /some/path - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --url file:///some/other/path - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --url net://1.2.3.4 - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --url net://1.2.3.4:1234:1235 - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --ctrl-url=tcp://1.2.3.4:1111 --data-url=tcp://1.2.3.4:1112 - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --path /some/path --max-size=1234 - add_trigger --condition on-event -u some-event --action snapshot-session ze-session --path /some/path --name=meh + lttng_add_trigger_ok "T0" --condition on-event -u some-event --action snapshot-session ze-session + lttng_add_trigger_ok "T1" --condition on-event -u some-event --action snapshot-session ze-session --path /some/path + lttng_add_trigger_ok "T2" --condition on-event -u some-event --action snapshot-session ze-session --url file:///some/other/path + lttng_add_trigger_ok "T3" --condition on-event -u some-event --action snapshot-session ze-session --url net://1.2.3.4 + lttng_add_trigger_ok "T4" --condition on-event -u some-event --action snapshot-session ze-session --url net://1.2.3.4:1234:1235 + lttng_add_trigger_ok "T5" --condition on-event -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 on-event -u some-event --action snapshot-session ze-session --path /some/path --max-size=1234 + lttng_add_trigger_ok "T7" --condition on-event -u some-event --action snapshot-session ze-session --path /some/path --name=meh + lttng_add_trigger_ok "T8" --condition on-event -u some-event --action snapshot-session ze-session --fire-every 10 + lttng_add_trigger_ok "T9" --condition on-event -u some-event --action snapshot-session ze-session --fire-once-after 10 cat > "${tmp_expected_stdout}" <<- EOF @@ -309,50 +305,102 @@ test_snapshot_action () user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\` - id: T1 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, path: /some/path - id: T2 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, path: /some/other/path - id: T3 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, url: net://1.2.3.4 - id: T4 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, url: net://1.2.3.4:1234:1235 - id: T5 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, control url: tcp://1.2.3.4:1111, data url: tcp://1.2.3.4:1112 - id: T6 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, path: /some/path, max size: 1234 - id: T7 user id: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 actions: snapshot session \`ze-session\`, path: /some/path, name: meh + - id: T8 + user id: ${uid} + condition: event rule hit + rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 + actions: + snapshot session \`ze-session\`, rate policy: after every 10 occurrences + - id: T9 + user id: ${uid} + condition: event rule hit + rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 + actions: + snapshot session \`ze-session\`, rate policy: once after 10 occurrences + EOF + + list_triggers "snapshot action" "${tmp_expected_stdout}" + + stop_lttng_sessiond_notap +} + +test_notify_action () +{ + start_lttng_sessiond_notap + + lttng_add_trigger_ok "T0" --condition on-event -u some-event --action notify --fire-once-after 5 + lttng_add_trigger_ok "T1" --condition on-event -u some-event --action notify --fire-every 10 + + + cat > "${tmp_expected_stdout}" <<- EOF + - id: T0 + user id: ${uid} + condition: event rule hit + rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 + actions: + notify, rate policy: once after 5 occurrences + - id: T1 + user id: ${uid} + condition: event rule hit + rule: some-event (type: tracepoint, domain: ust) + tracer notifications discarded: 0 + actions: + notify, rate policy: after every 10 occurrences EOF list_triggers "snapshot action" "${tmp_expected_stdout}" @@ -366,6 +414,7 @@ skip $ist_root "non-root user: skipping kprobe tests" 6 || test_on_event_probe skip $ist_root "non-root user: skipping uprobe tests" 4 || test_on_event_userspace_probe skip $ist_root "non-root user: skipping syscall tests" 5 || test_on_event_syscall test_snapshot_action +test_notify_action # Cleanup rm -f "${tmp_stdout}"