diff options
| author | Dmitrii Dolgov <9erthalion6@gmail.com> | 2026-02-08 13:22:25 +0100 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-02-08 19:16:28 -0300 |
| commit | f60a5c22967b845d5319d4f447cb28190021795c (patch) | |
| tree | 06c853f91735dbc6ac1ec1acd3c621321469c7dd | |
| parent | 2e05bb52a12d3cdb81f3b6f5de5cb3905d383552 (diff) | |
perf tests: Test annotate with data type profiling and rust
Exercise the annotate command with data type profiling feature on the
rust runtime. For that add a new shell test, which will profile the
code_with_type workload, then annotate the result expecting to see some
data structures from the rust code.
Committer testing:
root@number:~# perf test 'perf data type profiling tests'
83: perf data type profiling tests : Ok
root@number:~# perf test -v 'perf data type profiling tests'
83: perf data type profiling tests : Ok
root@number:~# perf test -vv 'perf data type profiling tests'
83: perf data type profiling tests:
--- start ---
test child forked, pid 111044
Basic perf annotate test
Basic annotate test [Success]
Pipe perf annotate test
Pipe annotate test [Success]
---- end(0) ----
83: perf data type profiling tests : Ok
root@number:~#
Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rwxr-xr-x | tools/perf/tests/shell/data_type_profiling.sh | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/data_type_profiling.sh b/tools/perf/tests/shell/data_type_profiling.sh new file mode 100755 index 000000000000..cdc9adb7d708 --- /dev/null +++ b/tools/perf/tests/shell/data_type_profiling.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# perf data type profiling tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +# The logic below follows the same line as the annotate test, but looks for a +# data type profiling manifestation +testtype="# data-type: struct Buf" + +err=0 +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) +perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX) +testprog="perf test -w code_with_type" + +cleanup() { + rm -rf "${perfdata}" "${perfout}" + rm -rf "${perfdata}".old + + trap - EXIT TERM INT +} + +trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +test_basic_annotate() { + mode=$1 + echo "${mode} perf annotate test" + if [ "x${mode}" == "xBasic" ] + then + perf mem record -o "${perfdata}" ${testprog} 2> /dev/null + else + perf mem record -o - ${testprog} 2> /dev/null > "${perfdata}" + fi + if [ "x$?" != "x0" ] + then + echo "${mode} annotate [Failed: perf record]" + err=1 + return + fi + + # Generate the annotated output file + if [ "x${mode}" == "xBasic" ] + then + perf annotate --code-with-type -i "${perfdata}" --stdio --percent-limit 1 2> /dev/null > "${perfout}" + else + perf annotate --code-with-type -i - --stdio 2> /dev/null --percent-limit 1 < "${perfdata}" > "${perfout}" + fi + + # check if it has the target data type + if ! grep -q "${testtype}" "${perfout}" + then + echo "${mode} annotate [Failed: missing target data type]" + cat "${perfout}" + err=1 + return + fi + echo "${mode} annotate test [Success]" +} + +test_basic_annotate Basic +test_basic_annotate Pipe + +cleanup +exit $err |
