X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Ftrigger%2Ftest_add_trigger_cli;h=de50c9f0fe25ed5277c71e4ee4e8018d0b865a61;hb=57739a6b3247c7ded74522906e214eff0d6dc14c;hp=7b56fcfa603263ff1f6746572094fc81d7b65112;hpb=64c34630769271a77e5eb8254452e466809ce4d9;p=lttng-tools.git diff --git a/tests/regression/tools/trigger/test_add_trigger_cli b/tests/regression/tools/trigger/test_add_trigger_cli index 7b56fcfa6..de50c9f0f 100755 --- a/tests/regression/tools/trigger/test_add_trigger_cli +++ b/tests/regression/tools/trigger/test_add_trigger_cli @@ -23,7 +23,7 @@ TESTDIR="$CURDIR/../../.." # shellcheck source=../../../utils/utils.sh source "$TESTDIR/utils/utils.sh" -plan_tests 228 +plan_tests 276 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" @@ -126,57 +126,82 @@ test_success "rotate session action polices" \ --action rotate-session my_session \ --rate-policy=once-after:55 -skip $ist_root "non-root user: skipping kprobe tests" 9 || { - test_success "--condition event-rule-matches probe by symbol" \ - --condition event-rule-matches --domain=kernel --probe=lttng_channel_enable --event-name=my_channel_enable \ - --action notify - - 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 ' ') - - # We need to find a valid offset. - base_symbol="" - offset=0 - if [[ 0x$channel_enable_addr -lt 0x$channel_disable_addr ]]; then - base_symbol="lttng_channel_enable" - offset=$(( 0x$channel_disable_addr - 0x$channel_enable_addr )) - else - base_symbol="lttng_channel_disable" - offset=$(( 0x$channel_enable_addr - 0x$channel_disable_addr )) - fi +test_success "--log-level single level" \ + --condition event-rule-matches --domain=user --log-level=INFO \ + --action notify - offset_hex="0x$(printf '%x' $offset)" +test_success "--log-level range open max" \ + --condition event-rule-matches --domain=user --log-level=INFO.. \ + --action notify - test_success "--condition event-rule-matches probe by symbol with offset" \ - --condition event-rule-matches --domain=kernel --probe="${base_symbol}+${offset_hex}" --event-name=my_$base_symbol \ - --action notify +test_success "--log-level range any" \ + --condition event-rule-matches --domain=user --log-level=.. \ + --action notify - test_success "--condition event-rule-matches probe by address" \ - --condition event-rule-matches --domain=kernel "--probe=0x${channel_enable_addr}" --event-name=my_channel_enable \ - --action notify +skip $ist_root "non-root user: skipping kprobe tests" 18 || { + for type in kprobe kernel-probe; do + test_success "--condition event-rule-matches probe by symbol" \ + --condition event-rule-matches --domain=kernel --type=$type --location=lttng_channel_enable --event-name=my_channel_enable \ + --action notify + + 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 ' ') + + # We need to find a valid offset. + base_symbol="" + offset=0 + if [[ 0x$channel_enable_addr -lt 0x$channel_disable_addr ]]; then + base_symbol="lttng_channel_enable" + offset=$(( 0x$channel_disable_addr - 0x$channel_enable_addr )) + else + base_symbol="lttng_channel_disable" + offset=$(( 0x$channel_enable_addr - 0x$channel_disable_addr )) + fi + + offset_hex="0x$(printf '%x' $offset)" + + test_success "--condition event-rule-matches probe by symbol with offset" \ + --condition event-rule-matches --domain=kernel --type=$type --location="${base_symbol}+${offset_hex}" --event-name=my_$base_symbol \ + --action notify + + test_success "--condition event-rule-matches probe by address" \ + --condition event-rule-matches --domain=kernel --type=$type --location="0x${channel_enable_addr}" --event-name=my_channel_enable \ + --action notify + done } -skip $ist_root "non-root user: skipping uprobe tests" 6 || { - test_success "--condition event-rule-matches uprobe" \ - --condition event-rule-matches --domain=kernel --userspace-probe=${uprobe_elf_binary}:test_function --event-name=ma-probe \ - --action notify +skip $ist_root "non-root user: skipping uprobe tests" 12 || { + for type in uprobe userspace-probe; do + test_success "--condition event-rule-matches uprobe" \ + --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_function --event-name=ma-probe \ + --action notify - test_success "--condition event-rule-matches uprobe with elf prefix" \ - --condition event-rule-matches --domain=kernel --userspace-probe=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \ - --action notify + test_success "--condition event-rule-matches uprobe with elf prefix" \ + --condition event-rule-matches --domain=kernel --type=$type --location=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \ + --action notify + done } -skip $ist_root "non-root user: skipping syscall tests" 9 || { +skip $ist_root "non-root user: skipping syscall tests" 18 || { test_success "--condition event-rule-matches one syscall" \ - --condition event-rule-matches --domain=kernel --syscall --name=open \ + --condition event-rule-matches --domain=kernel --type=syscall --name=open \ --action notify test_success "--condition event-rule-matches all syscalls" \ - --condition event-rule-matches --domain=kernel --syscall \ + --condition event-rule-matches --domain=kernel --type=syscall \ --action notify test_success "--condition event-rule-matches one syscall with filter" \ - --condition event-rule-matches --domain=kernel --syscall --filter 'a > 2' --name=open \ + --condition event-rule-matches --domain=kernel --type=syscall --filter 'a > 2' --name=open \ + --action notify + test_success "--condition event-rule-matches one syscall:entry" \ + --condition event-rule-matches --domain=kernel --type=syscall:entry --name=open \ + --action notify + test_success "--condition event-rule-matches one syscall:exit" \ + --condition event-rule-matches --domain=kernel --type=syscall:exit --name=open \ + --action notify + test_success "--condition event-rule-matches one syscall:entry-exit" \ + --condition event-rule-matches --domain=kernel --type=syscall:entry+exit --name=open \ --action notify } @@ -305,6 +330,10 @@ test_failure "extra args after --condition event-rule-matches" \ "Error: Unexpected argument 'bozo'" \ --condition event-rule-matches --domain=user bozo +test_failure "--log-level unknown level" \ + "Error: Failed to parse log level string \`FOO\`." \ + --condition event-rule-matches --domain=user --log-level=FOO + test_failure "two same --domain" \ "Error: More than one \`--domain\` was specified." \ --condition event-rule-matches --domain=user --domain=user @@ -313,21 +342,34 @@ test_failure "two different --domain" \ "Error: More than one \`--domain\` was specified." \ --condition event-rule-matches --domain=user --domain=kernel -test_failure "--condition event-rule-matches: --name with --probe" \ - "Error: Can't use --name with probe event rules." \ - --condition event-rule-matches --probe=do_sys_open --name='hello' +for type in kprobe kernel-probe; do + test_failure "--condition event-rule-matches: --name with --type=$type" \ + "Error: Can't use --name with probe event rules." \ + --condition event-rule-matches --type=$type --location=do_sys_open --name='hello' +done + +test_failure "--condition event-rule-matches: --location with tracepoint event rule" \ + "Error: Can't use --location with tracepoint event rules." \ + --condition event-rule-matches --domain=user --location='hello' -test_failure "--condition event-rule-matches: --event-name with tracepoint" \ +test_failure "--condition event-rule-matches: --event-name with tracepoint event rule" \ "Error: Can't use --event-name with tracepoint event rules." \ --condition event-rule-matches --domain=user --event-name='hello' -test_failure "--condition event-rule-matches: extra argument with --userspace-probe" \ - "Error: Unexpected argument 'hello'" \ - --condition event-rule-matches --domain=kernel --userspace-probe=${uprobe_elf_binary}:test_failure hello +for type in uprobe userspace-probe; do + test_failure "--condition event-rule-matches: extra argument with --type=$type" \ + "Error: Unexpected argument 'hello'" \ + --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_failure hello +done -test_failure "--condition event-rule-matches: extra argument with --syscall" \ +test_failure "--condition event-rule-matches: extra argument with --type=syscall" \ "Error: Unexpected argument 'open'" \ - --condition event-rule-matches --domain=kernel --syscall open + --condition event-rule-matches --domain=kernel --type=syscall open + +test_failure "--condition event-rule-matches: --type=syscall:nope" \ + "Error: Failed to parse syscall type 'syscall:nope'." \ + --condition event-rule-matches --domain=kernel --type=syscall:nope \ + --name=open test_failure "--condition event-rule-matches --capture: missing argument (end of arg list)" \ 'Error: While parsing argument #2 (`--capture`): Missing required argument for option `--capture`' \