perf tests: Test annotate with data type profiling and C

Exercise the annotate command with data type profiling feature with C.

For that extend the existing data type profiling shell test to profile
the datasym workload, then annotate the result expecting to see some
data structures from the C code.

Committer testing:

  root@number:~# perf test '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 125028
  Basic Rust perf annotate test
  Basic annotate test [Success]
  Pipe Rust perf annotate test
  Pipe annotate test [Success]
  Basic C perf annotate test
  Basic annotate test [Success]
  Pipe C 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>
This commit is contained in:
Dmitrii Dolgov 2026-02-08 13:22:26 +01:00 committed by Arnaldo Carvalho de Melo
parent f60a5c2296
commit 335047109d

View file

@ -6,12 +6,14 @@ 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"
# Values in testtypes and testprogs should match
testtypes=("# data-type: struct Buf" "# data-type: struct _buf")
testprogs=("perf test -w code_with_type" "perf test -w datasym")
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}"
@ -29,12 +31,23 @@ trap trap_cleanup EXIT TERM INT
test_basic_annotate() {
mode=$1
echo "${mode} perf annotate test"
runtime=$2
echo "${mode} ${runtime} perf annotate test"
case "x${runtime}" in
"xRust")
index=0 ;;
"xC")
index=1 ;;
esac
if [ "x${mode}" == "xBasic" ]
then
perf mem record -o "${perfdata}" ${testprog} 2> /dev/null
perf mem record -o "${perfdata}" ${testprogs[$index]} 2> /dev/null
else
perf mem record -o - ${testprog} 2> /dev/null > "${perfdata}"
perf mem record -o - ${testprogs[$index]} 2> /dev/null > "${perfdata}"
fi
if [ "x$?" != "x0" ]
then
@ -52,7 +65,7 @@ test_basic_annotate() {
fi
# check if it has the target data type
if ! grep -q "${testtype}" "${perfout}"
if ! grep -q "${testtypes[$index]}" "${perfout}"
then
echo "${mode} annotate [Failed: missing target data type]"
cat "${perfout}"
@ -62,8 +75,10 @@ test_basic_annotate() {
echo "${mode} annotate test [Success]"
}
test_basic_annotate Basic
test_basic_annotate Pipe
test_basic_annotate Basic Rust
test_basic_annotate Pipe Rust
test_basic_annotate Basic C
test_basic_annotate Pipe C
cleanup
exit $err