X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Ftrigger%2Ftest_list_triggers_cli;h=a040180138bac02f356bcdae687dc1b826250722;hp=31ba7b366c114d4dd2c1febbf9da555233342302;hb=HEAD;hpb=481c5310f698d32187c0f20bd0d1da3b8b696b06 diff --git a/tests/regression/tools/trigger/test_list_triggers_cli b/tests/regression/tools/trigger/test_list_triggers_cli index 31ba7b366..b99288471 100755 --- a/tests/regression/tools/trigger/test_list_triggers_cli +++ b/tests/regression/tools/trigger/test_list_triggers_cli @@ -23,178 +23,752 @@ TESTDIR="$CURDIR/../../.." # shellcheck source=../../../utils/utils.sh source "$TESTDIR/utils/utils.sh" -NUM_TESTS=84 +NUM_TESTS=150 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" 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) +tmp_expected_stdout_mi=$(mktemp -t test_list_triggers_cli_expected_stdout.mi.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) -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 +sdt_binary_present=0 +if [ -f "$uprobe_sdt_binary" ]; then + sdt_binary_present=1 fi - -function list_triggers_matches_ok () -{ - local test_name="$1" - local expected_stdout_file="$2" - - "${FULL_LTTNG_BIN}" list-triggers > "${tmp_stdout}" 2> "${tmp_stderr}" - ok $? "${test_name}: exit code is 0" - - diff -u "${expected_stdout_file}" "${tmp_stdout}" - ok $? "${test_name}: expected stdout" - - diff -u /dev/null "${tmp_stderr}" - ok $? "${test_name}: expected stderr" -} - test_top_level_options () { diag "Listing top level options" - lttng_add_trigger_ok "hello" --condition event-rule-matches --domain=user --name=test-name --action notify + lttng_add_trigger_ok "hello" --condition event-rule-matches --type=user --name=test-name --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: hello owner uid: ${uid} - condition: event rule hit - rule: test-name (type: tracepoint, domain: ust) + condition: event rule matches + rule: test-name (type: user tracepoint) + errors: none actions: notify errors: none errors: none EOF + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + hello + ${uid} + + + + + test-name + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + list_triggers_matches_ok "top level options" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI top level options" "${tmp_expected_stdout_mi}" lttng_remove_trigger_ok "hello" } -test_on_event_tracepoint () +test_event_rule_matches_tracepoint () { - diag "Listing on-event 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 "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 - lttng_add_trigger_ok "F" --condition event-rule-matches --domain=user --name=capture-payload-field --capture a --action notify - lttng_add_trigger_ok "G" --condition event-rule-matches --domain=user --name=capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify - lttng_add_trigger_ok "H" --condition event-rule-matches --domain=user --name=capture-chan-ctx --capture '$ctx.vpid' --action notify - lttng_add_trigger_ok "I" --condition event-rule-matches --domain=user --name=capture-app-ctx --capture '$app.iga:active_clients' --action notify + diag "Listing event-rule-matches tracepoint" + + lttng_add_trigger_ok "C" --condition event-rule-matches --type=user --action notify + lttng_add_trigger_ok "A" --condition event-rule-matches --name=aaa --type=user --filter 'p == 2' --action notify + lttng_add_trigger_ok "D" --condition event-rule-matches --name='hello*' --type=user -x hello2 --exclude-name hello3 -x hello4 --action notify + lttng_add_trigger_ok "B" --condition event-rule-matches --type=user --name=gerboise --log-level INFO.. --action notify + lttng_add_trigger_ok "E" --condition event-rule-matches --type=user --name=lemming --log-level WARNING --action notify + lttng_add_trigger_ok "J" --condition event-rule-matches --type=user --name=lemming --log-level .. --action notify + lttng_add_trigger_ok "F" --condition event-rule-matches --type=user --name=capture-payload-field --capture a --action notify + lttng_add_trigger_ok "G" --condition event-rule-matches --type=user --name=capture-array --capture 'a[2]' --capture '$ctx.tourlou[18]' --action notify + lttng_add_trigger_ok "H" --condition event-rule-matches --type=user --name=capture-chan-ctx --capture '$ctx.vpid' --action notify + lttng_add_trigger_ok "I" --condition event-rule-matches --type=user --name=capture-app-ctx --capture '$app.iga:active_clients' --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: A owner uid: ${uid} - condition: event rule hit - rule: aaa (type: tracepoint, domain: ust, filter: p == 2) + condition: event rule matches + rule: aaa (type: user tracepoint, filter: p == 2) + errors: none actions: notify errors: none errors: none - name: B owner uid: ${uid} - condition: event rule hit - rule: gerboise (type: tracepoint, domain: ust, log level at least INFO) + condition: event rule matches + rule: gerboise (type: user tracepoint, log level at least INFO) + errors: none actions: notify errors: none errors: none - name: C owner uid: ${uid} - condition: event rule hit - rule: * (type: tracepoint, domain: ust) + condition: event rule matches + rule: * (type: user tracepoint) + errors: none actions: notify errors: none errors: none - name: D owner uid: ${uid} - condition: event rule hit - rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4) + condition: event rule matches + rule: hello* (type: user tracepoint, exclusions: hello2,hello3,hello4) + errors: none actions: notify errors: none errors: none - name: E owner uid: ${uid} - condition: event rule hit - rule: lemming (type: tracepoint, domain: ust, log level is WARNING) + condition: event rule matches + rule: lemming (type: user tracepoint, log level is WARNING) + errors: none actions: notify errors: none errors: none - name: F owner uid: ${uid} - condition: event rule hit - rule: capture-payload-field (type: tracepoint, domain: ust) + condition: event rule matches + rule: capture-payload-field (type: user tracepoint) captures: - a + errors: none actions: notify errors: none errors: none - name: G owner uid: ${uid} - condition: event rule hit - rule: capture-array (type: tracepoint, domain: ust) + condition: event rule matches + rule: capture-array (type: user tracepoint) captures: - a[2] - \$ctx.tourlou[18] + errors: none actions: notify errors: none errors: none - name: H owner uid: ${uid} - condition: event rule hit - rule: capture-chan-ctx (type: tracepoint, domain: ust) + condition: event rule matches + rule: capture-chan-ctx (type: user tracepoint) captures: - \$ctx.vpid + errors: none actions: notify errors: none errors: none - name: I owner uid: ${uid} - condition: event rule hit - rule: capture-app-ctx (type: tracepoint, domain: ust) + condition: event rule matches + rule: capture-app-ctx (type: user tracepoint) captures: - \$app.iga:active_clients + errors: none actions: notify errors: none errors: none - name: J owner uid: ${uid} - condition: event rule hit - rule: lemming (type: tracepoint, domain: ust) + condition: event rule matches + rule: lemming (type: user tracepoint) + errors: none actions: notify errors: none errors: none EOF + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + A + ${uid} + + + + + aaa + p == 2 + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + B + ${uid} + + + + + gerboise + + + 6 + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + C + ${uid} + + + + + * + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + D + ${uid} + + + + + hello* + + hello2 + hello3 + hello4 + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + E + ${uid} + + + + + lemming + + + 4 + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + F + ${uid} + + + + + capture-payload-field + + + + + + a + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + G + ${uid} + + + + + capture-array + + + + + + 2 + + + a + + + + + + + 18 + + + tourlou + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + H + ${uid} + + + + + capture-chan-ctx + + + + + + vpid + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + I + ${uid} + + + + + capture-app-ctx + + + + + + iga + active_clients + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + J + ${uid} + + + + + lemming + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + list_triggers_matches_ok "event-rule-matches, tracepoint event rule" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI event-rule-matches, tracepoint event rule" "${tmp_expected_stdout_mi}" lttng_remove_trigger_ok "A" lttng_remove_trigger_ok "B" @@ -208,15 +782,15 @@ 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 ' ') + channel_enable_addr=$(grep '\' /proc/kallsyms | cut -f 1 -d ' ') + channel_disable_addr=$(grep '\' /proc/kallsyms | cut -f 1 -d ' ') # We need to find a valid offset. base_symbol="" @@ -230,225 +804,1731 @@ test_on_event_probe () fi offset_hex="0x$(printf '%x' $offset)" + channel_enable_addr_decimal=$(printf '%u' 0x"${channel_enable_addr}") - lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=kprobe --location=lttng_channel_enable --event-name=my_channel_enable --action notify - lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=kernel --type=kprobe --location="${base_symbol}+${offset_hex}" --event-name=my_channel_enable --action notify - lttng_add_trigger_ok "T2" --condition event-rule-matches --domain=kernel --type=kprobe --location="0x${channel_enable_addr}" --event-name=my_channel_enable --action notify + lttng_add_trigger_ok "T0" --condition event-rule-matches --type=kprobe --location=lttng_channel_enable --event-name=my_channel_enable --action notify + lttng_add_trigger_ok "T1" --condition event-rule-matches --type=kprobe --location="${base_symbol}+${offset_hex}" --event-name=my_channel_enable --action notify + lttng_add_trigger_ok "T2" --condition event-rule-matches --type=kprobe --location="0x${channel_enable_addr}" --event-name=my_channel_enable --action notify cat > "${tmp_expected_stdout}" <<- EOF - name: T0 owner uid: ${uid} - condition: event rule hit - rule: my_channel_enable (type: probe, location: lttng_channel_enable) + condition: event rule matches + rule: my_channel_enable (type: kernel:kprobe, location: lttng_channel_enable) + errors: none actions: notify errors: none errors: none - name: T1 owner uid: ${uid} - condition: event rule hit - rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex}) + condition: event rule matches + rule: my_channel_enable (type: kernel:kprobe, location: ${base_symbol}+${offset_hex}) + errors: none actions: notify errors: none errors: none - name: T2 owner uid: ${uid} - condition: event rule hit - rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr}) + condition: event rule matches + rule: my_channel_enable (type: kernel:kprobe, location: 0x${channel_enable_addr}) + errors: none actions: notify errors: none errors: none EOF + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + T0 + ${uid} + + + + + my_channel_enable + + + lttng_channel_enable + 0 + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T1 + ${uid} + + + + + my_channel_enable + + + ${base_symbol} + ${offset} + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T2 + ${uid} + + + + + my_channel_enable + + +
${channel_enable_addr_decimal}
+
+
+
+
+ +
+ + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + +
+ + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + +
+
+
+
+ EOF + list_triggers_matches_ok "event-rule-matches, probe event rule" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI event-rule-matches, probe event rule" "${tmp_expected_stdout_mi}" lttng_remove_trigger_ok "T0" lttng_remove_trigger_ok "T1" 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 + lttng_add_trigger_ok "T0" --condition event-rule-matches --type=kernel: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 - rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name}) + condition: event rule matches + rule: ma-probe-elf (type: kernel:uprobe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name}) + errors: none actions: notify errors: none errors: none EOF + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + T0 + ${uid} + + + + + ma-probe-elf + + + ${elf_function_name} + ${uprobe_elf_binary} + ENTRY + + + + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + list_triggers_matches_ok "event-rule-matches, userspace-probe event rule" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI event-rule-matches, userspace-probe event rule" "${tmp_expected_stdout_mi}" 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 --type=kernel: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 - rule: ma-probe-sdt (type: userspace probe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name}) + - name: T0 + owner uid: 0 + condition: event rule matches + rule: ma-probe-sdt (type: kernel:uprobe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name}) + errors: none actions: notify errors: none errors: none EOF - list_triggers_matches_ok "on-event, userspace-probe event rule SDT" "${tmp_expected_stdout}" + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + T0 + ${uid} + + + + + ma-probe-sdt + + + ${sdt_probe_name} + ${sdt_provider_name} + ${uprobe_sdt_binary} + + + + + + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + + list_triggers_matches_ok "event-rule-matches, userspace-probe event rule SDT" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI event-rule-matches, userspace-probe event rule SDT" "${tmp_expected_stdout_mi}" 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 "T0" --condition event-rule-matches --type=syscall --name=open --action notify + lttng_add_trigger_ok "T1" --condition event-rule-matches --type=syscall:entry --name=open --action notify + lttng_add_trigger_ok "T2" --condition event-rule-matches --type=syscall:exit --name=open --action notify + lttng_add_trigger_ok "T3" --condition event-rule-matches --type=syscall:entry+exit --name=open --action notify + lttng_add_trigger_ok "T4" --condition event-rule-matches --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: kernel:syscall:entry+exit) + errors: none 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: kernel:syscall:entry) + errors: none actions: notify errors: none errors: none + - name: T2 + owner uid: ${uid} + condition: event rule matches + rule: open (type: kernel:syscall:exit) + errors: none + actions: + notify + errors: none + errors: none + - name: T3 + owner uid: ${uid} + condition: event rule matches + rule: open (type: kernel:syscall:entry+exit) + errors: none + actions: + notify + errors: none + errors: none + - name: T4 + owner uid: ${uid} + condition: event rule matches + rule: ptrace (type: kernel:syscall:entry+exit, filter: a > 2) + errors: none + actions: + notify + errors: none + errors: none + EOF + + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + T0 + ${uid} + + + + + entry+exit + open + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T1 + ${uid} + + + + + entry + open + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T2 + ${uid} + + + + + exit + open + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T3 + ${uid} + + + + + entry+exit + open + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T4 + ${uid} + + + + + entry+exit + ptrace + a > 2 + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + EOF + list_triggers_matches_ok "event-rule-matches, syscall event rule" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI event-rule-matches, syscall event rule" "${tmp_expected_stdout_mi}" 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 + errors: none + actions: + notify + errors: none + errors: none + EOF + + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + trigger-with-session-consumed-size-condition + ${uid} + + + the-session-name + 1234 + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + + + list_triggers_matches_ok "session consumed size condition" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI session consumed size condition" "${tmp_expected_stdout_mi}" + + 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: user space + threshold (bytes): 1234 + errors: none + 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: user space + threshold (ratio): 0.25 + errors: none + 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: user space + threshold (bytes): 2345 + errors: none + 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: user space + threshold (ratio): 0.40 + errors: none + actions: + notify + errors: none + errors: none + EOF + + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + trigger-with-buffer-usage-high-bytes-condition + ${uid} + + + the-session-name + the-channel-name + UST + 1234 + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + trigger-with-buffer-usage-high-ratio-condition + ${uid} + + + the-session-name + the-channel-name + UST + 0.250000 + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + trigger-with-buffer-usage-low-bytes-condition + ${uid} + + + the-session-name + the-channel-name + UST + 2345 + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + trigger-with-buffer-usage-low-ratio-condition + ${uid} + + + the-session-name + the-channel-name + UST + 0.400000 + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + + list_triggers_matches_ok "buffer usage condition" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI buffer usage condition" "${tmp_expected_stdout_mi}" + + 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 + errors: none + 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 + errors: none + actions: + notify + errors: none + errors: none + EOF + + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + trigger-with-session-rotation-completed-condition + ${uid} + + + the-session-name + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + trigger-with-session-rotation-ongoing-condition + ${uid} + + + the-session-name + + + + + + + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + + list_triggers_matches_ok "session rotation conditions" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI session rotation conditions" "${tmp_expected_stdout_mi}" + + lttng_remove_trigger_ok "trigger-with-session-rotation-completed-condition" + lttng_remove_trigger_ok "trigger-with-session-rotation-ongoing-condition" } test_snapshot_action () { diag "Listing snapshot actions" - lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session - lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --path /some/path - lttng_add_trigger_ok "T2" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --url file:///some/other/path - lttng_add_trigger_ok "T3" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --url net://1.2.3.4 - lttng_add_trigger_ok "T4" --condition event-rule-matches --domain=user --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 --domain=user --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 --domain=user --name=some-event --action snapshot-session ze-session --path /some/path --max-size=1234 - lttng_add_trigger_ok "T7" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --path /some/path --name=meh - lttng_add_trigger_ok "T8" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --rate-policy=every:10 - lttng_add_trigger_ok "T9" --condition event-rule-matches --domain=user --name=some-event --action snapshot-session ze-session --rate-policy=once-after:10 + lttng_add_trigger_ok "T0" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session + lttng_add_trigger_ok "T1" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session --path /some/path + lttng_add_trigger_ok "T2" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session --url file:///some/other/path + lttng_add_trigger_ok "T3" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session --url net://1.2.3.4 + lttng_add_trigger_ok "T4" --condition event-rule-matches --type=user --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 --type=user --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 --type=user --name=some-event --action snapshot-session ze-session --path /some/path --max-size=1234 + lttng_add_trigger_ok "T7" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session --path /some/path --name=meh + lttng_add_trigger_ok "T8" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session --rate-policy=every:10 + lttng_add_trigger_ok "T9" --condition event-rule-matches --type=user --name=some-event --action snapshot-session ze-session --rate-policy=once-after:10 cat > "${tmp_expected_stdout}" <<- EOF - name: T0 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\` errors: none errors: none - name: T1 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, path: /some/path errors: none errors: none - name: T2 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, path: /some/other/path errors: none errors: none - name: T3 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, url: net://1.2.3.4 errors: none errors: none - name: T4 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, url: net://1.2.3.4:1234:1235 errors: none errors: none - name: T5 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, control url: tcp://1.2.3.4:1111, data url: tcp://1.2.3.4:1112 errors: none errors: none - name: T6 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, path: /some/path, max size: 1234 errors: none errors: none - name: T7 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, path: /some/path, name: meh errors: none errors: none - name: T8 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: - snapshot session \`ze-session\`, rate policy: after every 10 occurrences + snapshot session \`ze-session\`, rate policy: every 10 occurrences errors: none errors: none - name: T9 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: snapshot session \`ze-session\`, rate policy: once after 10 occurrences errors: none errors: none EOF + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + T0 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T1 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + /some/path + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T2 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + /some/other/path + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T3 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + net://1.2.3.4 + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T4 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + net://1.2.3.4:1234:1235 + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T5 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + tcp://1.2.3.4:1111 + tcp://1.2.3.4:1112 + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T6 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + /some/path + 1234 + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T7 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + meh + /some/path + + + + 1 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T8 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + + 10 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T9 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + ze-session + + + 10 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + list_triggers_matches_ok "snapshot action" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI snapshot action" "${tmp_expected_stdout_mi}" lttng_remove_trigger_ok "T0" lttng_remove_trigger_ok "T1" @@ -464,29 +2544,135 @@ test_snapshot_action () test_notify_action () { - lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=user --name=some-event --action notify --rate-policy=once-after:5 - lttng_add_trigger_ok "T1" --condition event-rule-matches --domain=user --name=some-event --action notify --rate-policy=every:10 + lttng_add_trigger_ok "T0" --condition event-rule-matches --type=user --name=some-event --action notify --rate-policy=once-after:5 + lttng_add_trigger_ok "T1" --condition event-rule-matches --type=user --name=some-event --action notify --rate-policy=every:10 cat > "${tmp_expected_stdout}" <<- EOF - name: T0 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: notify, rate policy: once after 5 occurrences errors: none errors: none - name: T1 owner uid: ${uid} - condition: event rule hit - rule: some-event (type: tracepoint, domain: ust) + condition: event rule matches + rule: some-event (type: user tracepoint) + errors: none actions: - notify, rate policy: after every 10 occurrences + notify, rate policy: every 10 occurrences errors: none errors: none EOF - list_triggers_matches_ok "snapshot action" "${tmp_expected_stdout}" + cat > "${tmp_expected_stdout_mi}" <<- EOF + + + list-trigger + + + + T0 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 5 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + T1 + ${uid} + + + + + some-event + + + + + + + discarded tracer messages + Count of messages discarded by the tracer due to a communication error with the session daemon + + 0 + + + + + + + + + + + 10 + + + + + + total execution failures + Aggregated count of errors encountered when executing the action + + 0 + + + + + + + + + + + + EOF + + list_triggers_matches_ok "notify action" "${tmp_expected_stdout}" + list_triggers_matches_mi_ok "MI notify action" "${tmp_expected_stdout_mi}" lttng_remove_trigger_ok "T0" lttng_remove_trigger_ok "T1" @@ -498,11 +2684,16 @@ 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 +check_skip_kernel_test 48 "Skipping kprobe, uprobe, SDT and syscall tests." || { + test_event_rule_matches_probe + test_event_rule_matches_userspace_probe_elf + skip $sdt_binary_present "No SDT binary. Skipping userspace probe SDT tests" 9 || test_event_rule_matches_userspace_probe_sdt + test_event_rule_matches_syscall +} +test_session_consumed_size_condition +test_buffer_usage_conditions +test_session_rotation_conditions test_snapshot_action test_notify_action