Change "event rule hit" to "event-rule matches" in user interface strings
[lttng-tools.git] / tests / regression / tools / trigger / test_list_triggers_cli
index 31ba7b366c114d4dd2c1febbf9da555233342302..cb7a3b4760d68f0c0da14c27ba2890a685228314 100755 (executable)
@@ -23,7 +23,7 @@ TESTDIR="$CURDIR/../../.."
 # shellcheck source=../../../utils/utils.sh
 source "$TESTDIR/utils/utils.sh"
 
-NUM_TESTS=84
+NUM_TESTS=106
 
 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
 
@@ -32,6 +32,7 @@ tmp_stderr=$(mktemp -t test_list_triggers_cli_stderr.XXXXXX)
 tmp_expected_stdout=$(mktemp -t test_list_triggers_cli_expected_stdout.XXXXXX)
 uprobe_elf_binary=$(realpath "${TESTDIR}/utils/testapp/userspace-probe-elf-binary/.libs/userspace-probe-elf-binary")
 uprobe_sdt_binary=$(realpath "${TESTDIR}/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-sdt-binary")
+register_some_triggers_bin=$(realpath "${CURDIR}/utils/register-some-triggers")
 
 uid=$(id --user)
 gid=$(id --group)
@@ -74,7 +75,7 @@ test_top_level_options ()
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: hello
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: test-name (type: tracepoint, domain: ust)
          actions:
            notify
@@ -87,13 +88,13 @@ test_top_level_options ()
        lttng_remove_trigger_ok "hello"
 }
 
-test_on_event_tracepoint ()
+test_event_rule_matches_tracepoint ()
 {
-       diag "Listing on-event tracepoint"
+       diag "Listing event-rule-matches tracepoint"
 
        lttng_add_trigger_ok "C" --condition event-rule-matches --domain=user --action notify
        lttng_add_trigger_ok "A" --condition event-rule-matches --name=aaa --domain=user --filter 'p == 2' --action notify
-       lttng_add_trigger_ok "D" --condition event-rule-matches --name='hello*' --domain=user -x 'hello2,hello3,hello4' --action notify
+       lttng_add_trigger_ok "D" --condition event-rule-matches --name='hello*' --domain=user -x hello2 --exclude-name  hello3 -x hello4 --action notify
        lttng_add_trigger_ok "B" --condition event-rule-matches --domain=user --name=gerboise --log-level INFO.. --action notify
        lttng_add_trigger_ok "E" --condition event-rule-matches --domain=user --name=lemming --log-level WARNING --action notify
        lttng_add_trigger_ok "J" --condition event-rule-matches --domain=user --name=lemming --log-level .. --action notify
@@ -105,7 +106,7 @@ test_on_event_tracepoint ()
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: A
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: aaa (type: tracepoint, domain: ust, filter: p == 2)
          actions:
            notify
@@ -113,7 +114,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: B
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: gerboise (type: tracepoint, domain: ust, log level at least INFO)
          actions:
            notify
@@ -121,7 +122,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: C
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: * (type: tracepoint, domain: ust)
          actions:
            notify
@@ -129,7 +130,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: D
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4)
          actions:
            notify
@@ -137,7 +138,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: E
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: lemming (type: tracepoint, domain: ust, log level is WARNING)
          actions:
            notify
@@ -145,7 +146,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: F
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: capture-payload-field (type: tracepoint, domain: ust)
            captures:
              - a
@@ -155,7 +156,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: G
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: capture-array (type: tracepoint, domain: ust)
            captures:
              - a[2]
@@ -166,7 +167,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: H
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: capture-chan-ctx (type: tracepoint, domain: ust)
            captures:
              - \$ctx.vpid
@@ -176,7 +177,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: I
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: capture-app-ctx (type: tracepoint, domain: ust)
            captures:
              - \$app.iga:active_clients
@@ -186,7 +187,7 @@ test_on_event_tracepoint ()
          errors: none
        - name: J
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: lemming (type: tracepoint, domain: ust)
          actions:
            notify
@@ -208,12 +209,12 @@ test_on_event_tracepoint ()
        lttng_remove_trigger_ok "J"
 }
 
-test_on_event_probe ()
+test_event_rule_matches_probe ()
 {
        local channel_enable_addr
        local channel_disable_addr
 
-       diag "Listing on-event kernel probe"
+       diag "Listing event-rule-matches kernel probe"
 
        channel_enable_addr=$(grep ' t lttng_channel_enable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ')
        channel_disable_addr=$(grep ' t lttng_channel_disable\s\[lttng_tracer\]$' /proc/kallsyms | cut -f 1 -d ' ')
@@ -238,7 +239,7 @@ test_on_event_probe ()
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: my_channel_enable (type: probe, location: lttng_channel_enable)
          actions:
            notify
@@ -246,7 +247,7 @@ test_on_event_probe ()
          errors: none
        - name: T1
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex})
          actions:
            notify
@@ -254,7 +255,7 @@ test_on_event_probe ()
          errors: none
        - name: T2
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr})
          actions:
            notify
@@ -269,18 +270,18 @@ test_on_event_probe ()
        lttng_remove_trigger_ok "T2"
 }
 
-test_on_event_userspace_probe_elf ()
+test_event_rule_matches_userspace_probe_elf ()
 {
        local elf_function_name="test_function"
 
-       diag "Listing on-event userspace-probe elf"
+       diag "Listing event-rule-matches userspace-probe elf"
 
        lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe-elf --action notify
 
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name})
          actions:
            notify
@@ -293,19 +294,19 @@ test_on_event_userspace_probe_elf ()
        lttng_remove_trigger_ok "T0"
 }
 
-test_on_event_userspace_probe_sdt ()
+test_event_rule_matches_userspace_probe_sdt ()
 {
        local sdt_provider_name="foobar"
        local sdt_probe_name="tp1"
 
-       diag "on-event userspace-probe sdt"
+       diag "Listing event-rule-matches userspace-probe sdt"
 
-       lttng_add_trigger_ok "T0" --condition on-event -k --userspace-probe=sdt:${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name} ma-probe-sdt --action notify
+       lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=uprobe --location=sdt:${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name} --event-name=ma-probe-sdt --action notify
 
        cat > "${tmp_expected_stdout}" <<- EOF
-       - id: T0
-         user id: 0
-         condition: event rule hit
+       - name: T0
+         owner uid: 0
+         condition: event rule matches
            rule: ma-probe-sdt (type: userspace probe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name})
          actions:
            notify
@@ -313,31 +314,58 @@ test_on_event_userspace_probe_sdt ()
          errors: none
        EOF
 
-       list_triggers_matches_ok "on-event, userspace-probe event rule SDT" "${tmp_expected_stdout}"
+       list_triggers_matches_ok "event-rule-matches, userspace-probe event rule SDT" "${tmp_expected_stdout}"
 
        lttng_remove_trigger_ok "T0"
 }
 
-test_on_event_syscall ()
+test_event_rule_matches_syscall ()
 {
-       diag "Listing on-event syscall"
+       diag "Listing event-rule-matches syscall"
 
        lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=syscall --name=open --action notify
-       lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=kernel --type=syscall --name=ptrace --filter 'a > 2' --action notify
+       lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=kernel --type=syscall:entry --name=open --action notify
+       lttng_add_trigger_ok "T2" --condition event-rule-matches --domain=kernel --type=syscall:exit --name=open --action notify
+       lttng_add_trigger_ok "T3" --condition event-rule-matches --domain=kernel --type=syscall:entry+exit --name=open --action notify
+       lttng_add_trigger_ok "T4" --condition event-rule-matches --domain=kernel --type=syscall --name=ptrace --filter 'a > 2' --action notify
 
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
-         condition: event rule hit
-           rule: open (type: syscall)
+         condition: event rule matches
+           rule: open (type: syscall:entry+exit)
          actions:
            notify
              errors: none
          errors: none
        - name: T1
          owner uid: ${uid}
-         condition: event rule hit
-           rule: ptrace (type: syscall, filter: a > 2)
+         condition: event rule matches
+           rule: open (type: syscall:entry)
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: T2
+         owner uid: ${uid}
+         condition: event rule matches
+           rule: open (type: syscall:exit)
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: T3
+         owner uid: ${uid}
+         condition: event rule matches
+           rule: open (type: syscall:entry+exit)
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: T4
+         owner uid: ${uid}
+         condition: event rule matches
+           rule: ptrace (type: syscall:entry+exit, filter: a > 2)
          actions:
            notify
              errors: none
@@ -348,6 +376,118 @@ test_on_event_syscall ()
 
        lttng_remove_trigger_ok "T0"
        lttng_remove_trigger_ok "T1"
+       lttng_remove_trigger_ok "T2"
+       lttng_remove_trigger_ok "T3"
+       lttng_remove_trigger_ok "T4"
+}
+
+test_session_consumed_size_condition ()
+{
+       ${register_some_triggers_bin} test_session_consumed_size_condition
+
+       cat > "${tmp_expected_stdout}" <<- EOF
+       - name: trigger-with-session-consumed-size-condition
+         owner uid: ${uid}
+         condition: session consumed size
+           session name: the-session-name
+           threshold: 1234 bytes
+         actions:
+           notify
+             errors: none
+         errors: none
+       EOF
+
+       list_triggers_matches_ok "session consumed size condition" "${tmp_expected_stdout}"
+
+       lttng_remove_trigger_ok "trigger-with-session-consumed-size-condition"
+}
+
+test_buffer_usage_conditions ()
+{
+       ${register_some_triggers_bin} test_buffer_usage_conditions
+
+       cat > "${tmp_expected_stdout}" <<- EOF
+       - name: trigger-with-buffer-usage-high-bytes-condition
+         owner uid: ${uid}
+         condition: buffer usage high
+           session name: the-session-name
+           channel name: the-channel-name
+           domain: ust
+           threshold (bytes): 1234
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: trigger-with-buffer-usage-high-ratio-condition
+         owner uid: ${uid}
+         condition: buffer usage high
+           session name: the-session-name
+           channel name: the-channel-name
+           domain: ust
+           threshold (ratio): 0.25
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: trigger-with-buffer-usage-low-bytes-condition
+         owner uid: ${uid}
+         condition: buffer usage low
+           session name: the-session-name
+           channel name: the-channel-name
+           domain: ust
+           threshold (bytes): 2345
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: trigger-with-buffer-usage-low-ratio-condition
+         owner uid: ${uid}
+         condition: buffer usage low
+           session name: the-session-name
+           channel name: the-channel-name
+           domain: ust
+           threshold (ratio): 0.40
+         actions:
+           notify
+             errors: none
+         errors: none
+       EOF
+
+       list_triggers_matches_ok "buffer usage condition" "${tmp_expected_stdout}"
+
+       lttng_remove_trigger_ok "trigger-with-buffer-usage-high-bytes-condition"
+       lttng_remove_trigger_ok "trigger-with-buffer-usage-high-ratio-condition"
+       lttng_remove_trigger_ok "trigger-with-buffer-usage-low-bytes-condition"
+       lttng_remove_trigger_ok "trigger-with-buffer-usage-low-ratio-condition"
+}
+
+test_session_rotation_conditions ()
+{
+       ${register_some_triggers_bin} test_session_rotation_conditions
+
+       cat > "${tmp_expected_stdout}" <<- EOF
+       - name: trigger-with-session-rotation-completed-condition
+         owner uid: ${uid}
+         condition: session rotation completed
+           session name: the-session-name
+         actions:
+           notify
+             errors: none
+         errors: none
+       - name: trigger-with-session-rotation-ongoing-condition
+         owner uid: ${uid}
+         condition: session rotation ongoing
+           session name: the-session-name
+         actions:
+           notify
+             errors: none
+         errors: none
+       EOF
+
+       list_triggers_matches_ok "session rotation conditions" "${tmp_expected_stdout}"
+
+       lttng_remove_trigger_ok "trigger-with-session-rotation-completed-condition"
+       lttng_remove_trigger_ok "trigger-with-session-rotation-ongoing-condition"
 }
 
 test_snapshot_action ()
@@ -368,7 +508,7 @@ test_snapshot_action ()
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`
@@ -376,7 +516,7 @@ test_snapshot_action ()
          errors: none
        - name: T1
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, path: /some/path
@@ -384,7 +524,7 @@ test_snapshot_action ()
          errors: none
        - name: T2
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, path: /some/other/path
@@ -392,7 +532,7 @@ test_snapshot_action ()
          errors: none
        - name: T3
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, url: net://1.2.3.4
@@ -400,7 +540,7 @@ test_snapshot_action ()
          errors: none
        - name: T4
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, url: net://1.2.3.4:1234:1235
@@ -408,7 +548,7 @@ test_snapshot_action ()
          errors: none
        - name: T5
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, control url: tcp://1.2.3.4:1111, data url: tcp://1.2.3.4:1112
@@ -416,7 +556,7 @@ test_snapshot_action ()
          errors: none
        - name: T6
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, path: /some/path, max size: 1234
@@ -424,7 +564,7 @@ test_snapshot_action ()
          errors: none
        - name: T7
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, path: /some/path, name: meh
@@ -432,7 +572,7 @@ test_snapshot_action ()
          errors: none
        - name: T8
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, rate policy: after every 10 occurrences
@@ -440,7 +580,7 @@ test_snapshot_action ()
          errors: none
        - name: T9
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            snapshot session \`ze-session\`, rate policy: once after 10 occurrences
@@ -470,7 +610,7 @@ test_notify_action ()
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            notify, rate policy: once after 5 occurrences
@@ -478,7 +618,7 @@ test_notify_action ()
          errors: none
        - name: T1
          owner uid: ${uid}
-         condition: event rule hit
+         condition: event rule matches
            rule: some-event (type: tracepoint, domain: ust)
          actions:
            notify, rate policy: after every 10 occurrences
@@ -486,7 +626,7 @@ test_notify_action ()
          errors: none
        EOF
 
-       list_triggers_matches_ok "snapshot action" "${tmp_expected_stdout}"
+       list_triggers_matches_ok "notify action" "${tmp_expected_stdout}"
 
        lttng_remove_trigger_ok "T0"
        lttng_remove_trigger_ok "T1"
@@ -498,11 +638,14 @@ plan_tests $NUM_TESTS
 start_lttng_sessiond_notap
 
 test_top_level_options
-test_on_event_tracepoint
-skip $ist_root "non-root user: skipping kprobe tests" 9 || test_on_event_probe
-skip $ist_root "non-root user: skipping userspace probe elf tests" 5 || test_on_event_userspace_probe_elf
-skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 5 || test_on_event_userspace_probe_sdt
-skip $ist_root "non-root user: skipping syscall tests" 7 || test_on_event_syscall
+test_event_rule_matches_tracepoint
+skip $ist_root "non-root user: skipping kprobe tests" 9 || test_event_rule_matches_probe
+skip $ist_root "non-root user: skipping uprobe tests" 5 || test_event_rule_matches_userspace_probe_elf
+skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 5 || test_event_rule_matches_userspace_probe_sdt
+skip $ist_root "non-root user: skipping syscall tests" 13 || test_event_rule_matches_syscall
+test_session_consumed_size_condition
+test_buffer_usage_conditions
+test_session_rotation_conditions
 test_snapshot_action
 test_notify_action
 
This page took 0.030696 seconds and 4 git commands to generate.