From: Namhyung Kim <namhyung@kernel.org>
To: Howard Chu <howardchu95@gmail.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
kan.liang@linux.intel.com, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] perf trace: Add tests for BTF general augmentation
Date: Tue, 10 Dec 2024 14:30:36 -0800 [thread overview]
Message-ID: <Z1jBDHeEnPrsL7DQ@google.com> (raw)
In-Reply-To: <20241126223257.22465-2-howardchu95@gmail.com>
Hello,
On Tue, Nov 26, 2024 at 02:32:56PM -0800, Howard Chu wrote:
> Currently, we only have perf trace augmentation tests for enum
> arguments. This patch adds tests for more general syscall arguments,
> such as struct pointers, strings, and buffers.
>
> These tests utilize the perf config system to configure the perf trace
> output, as suggested by Arnaldo Carvalho de Melo <acme@kernel.org>
>
> Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> Suggested-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Howard Chu <howardchu95@gmail.com>
> ---
> tools/perf/tests/shell/trace_btf_general.sh | 81 +++++++++++++++++++++
> 1 file changed, 81 insertions(+)
> create mode 100755 tools/perf/tests/shell/trace_btf_general.sh
>
> diff --git a/tools/perf/tests/shell/trace_btf_general.sh b/tools/perf/tests/shell/trace_btf_general.sh
> new file mode 100755
> index 000000000000..903310b355c4
> --- /dev/null
> +++ b/tools/perf/tests/shell/trace_btf_general.sh
> @@ -0,0 +1,81 @@
> +#!/bin/bash
> +# perf trace BTF general tests
> +# SPDX-License-Identifier: GPL-2.0
> +
> +err=0
> +set -e
> +
> +. "$(dirname $0)"/lib/probe.sh
> +skip_if_no_perf_trace || exit 2
The kernel might not have BPF/BTF support. I think you can check if
/sys/kernel/btf/vmlinux is there and skip the test if not.
Thanks,
Namhyung
> +
> +file1=$(mktemp /tmp/file1_XXXXX)
> +file2=$(echo $file1 | sed 's/file1/file2/g')
> +
> +buffer="buffer content"
> +perf_config_tmp=$(mktemp /tmp/.perfconfig_XXXXX)
> +
> +trap cleanup EXIT TERM INT HUP
> +
> +trace_test_string() {
> + echo "Testing perf trace's string augmentation"
> + if ! perf trace -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1 | \
> + grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$"
> + then
> + echo "String augmentation test failed"
> + err=1
> + fi
> +}
> +
> +trace_test_buffer() {
> + echo "Testing perf trace's buffer augmentation"
> + # echo will insert a newline (\10) at the end of the buffer
> + if ! perf trace -e write --max-events=1 -- echo "${buffer}" 2>&1 | \
> + grep -q -E "^echo/[0-9]+ write\([0-9]+, ${buffer}.*, [0-9]+\) += +[0-9]+$"
> + then
> + echo "Buffer augmentation test failed"
> + err=1
> + fi
> +}
> +
> +trace_test_struct_btf() {
> + echo "Testing perf trace's struct augmentation"
> + if ! perf trace -e clock_nanosleep --force-btf --max-events=1 -- sleep 1 2>&1 | \
> + grep -q -E "^sleep/[0-9]+ clock_nanosleep\(0, 0, \{1,\}, 0x[0-9a-f]+\) += +[0-9]+$"
> + then
> + echo "BTF struct augmentation test failed"
> + err=1
> + fi
> +}
> +
> +cleanup() {
> + rm -rf ${file1} ${file2} ${perf_config_tmp}
> +}
> +
> +trap_cleanup() {
> + echo "Unexpected signal in ${FUNCNAME[1]}"
> + cleanup
> + exit 1
> +}
> +
> +# don't overwrite user's perf config
> +trace_config() {
> + export PERF_CONFIG=${perf_config_tmp}
> + perf config trace.show_arg_names=false trace.show_duration=false \
> + trace.show_timestamp=false trace.args_alignment=0
> +}
> +
> +trace_config
> +
> +trace_test_string
> +
> +if [ $err = 0 ]; then
> + trace_test_buffer
> +fi
> +
> +if [ $err = 0 ]; then
> + trace_test_struct_btf
> +fi
> +
> +cleanup
> +
> +exit $err
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-12-10 22:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 22:32 [PATCH v2 0/2] perf trace: Add tests for BTF general augmentation Howard Chu
2024-11-26 22:32 ` [PATCH v2 1/2] " Howard Chu
2024-12-10 22:30 ` Namhyung Kim [this message]
2024-12-11 22:11 ` Howard Chu
2024-11-26 22:32 ` [PATCH v2 2/2] perf docs: Add documentation for --force-btf option Howard Chu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z1jBDHeEnPrsL7DQ@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.