lttng {add,list}-triggers: use `name` instead of `id`
[lttng-tools.git] / tests / regression / tools / trigger / test_list_triggers_cli
index 60221a2b57fbab0d3bb6f09f3c625df27502923c..42893f5d6c45c8e41c388c31c3db08fb0be9d4ad 100755 (executable)
@@ -24,7 +24,7 @@ TESTDIR="$CURDIR/../../.."
 source "$TESTDIR/utils/utils.sh"
 
 
-NUM_TESTS=67
+NUM_TESTS=72
 
 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
 
@@ -32,14 +32,22 @@ tmp_stdout=$(mktemp -t test_list_triggers_cli_stdout.XXXXXX)
 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")
 
 uid=$(id --user)
 gid=$(id --group)
 
 if [ "$uid" == "0" ]; then
        ist_root=1
+       ls "$uprobe_sdt_binary" >/dev/null 2>&1
+       if test $? == 0; then
+               hast_sdt_binary=1
+       else
+               hast_sdt_binary=0
+       fi
 else
        ist_root=0
+       hast_sdt_binary=0
 fi
 
 
@@ -65,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)
@@ -96,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)
@@ -104,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)
@@ -112,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)
@@ -120,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)
@@ -128,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)
@@ -136,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)
@@ -146,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)
@@ -157,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)
@@ -167,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)
@@ -220,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)
@@ -228,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})
@@ -236,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})
@@ -253,7 +261,7 @@ test_on_event_probe ()
        lttng_remove_trigger_ok "T2"
 }
 
-test_on_event_userspace_probe ()
+test_on_event_userspace_probe_elf ()
 {
        local elf_function_name="test_function"
 
@@ -262,10 +270,10 @@ test_on_event_userspace_probe ()
        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: ${uprobe_elf_binary}:${elf_function_name})
+           rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name})
          actions:
            notify
              errors: none
@@ -277,6 +285,32 @@ test_on_event_userspace_probe ()
        lttng_remove_trigger_ok "T0"
 }
 
+test_on_event_userspace_probe_sdt ()
+{
+
+       local sdt_provider_name="foobar"
+       local sdt_probe_name="tp1"
+
+       diag "on-event 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
+
+       cat > "${tmp_expected_stdout}" <<- EOF
+       - id: T0
+         user id: 0
+         condition: event rule hit
+           rule: ma-probe-sdt (type: userspace probe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name})
+         actions:
+           notify
+             errors: none
+         errors: none
+       EOF
+
+       list_triggers_matches_ok "on-event, userspace-probe event rule SDT" "${tmp_expected_stdout}"
+
+       lttng_remove_trigger_ok "T0"
+}
+
 test_on_event_syscall ()
 {
        diag "Listing on-event syscall"
@@ -285,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)
@@ -293,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)
@@ -326,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)
@@ -334,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)
@@ -342,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)
@@ -350,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)
@@ -358,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)
@@ -366,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)
@@ -374,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)
@@ -382,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)
@@ -390,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)
@@ -398,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)
@@ -422,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)
@@ -430,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)
@@ -454,7 +488,8 @@ 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
+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_snapshot_action
 test_notify_action
This page took 0.029142 seconds and 4 git commands to generate.