Skip to content

Commit f60a5c2

Browse files
erthalionacmel
authored andcommitted
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>
1 parent 2e05bb5 commit f60a5c2

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
# perf data type profiling tests
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
set -e
6+
7+
# The logic below follows the same line as the annotate test, but looks for a
8+
# data type profiling manifestation
9+
testtype="# data-type: struct Buf"
10+
11+
err=0
12+
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
13+
perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX)
14+
testprog="perf test -w code_with_type"
15+
16+
cleanup() {
17+
rm -rf "${perfdata}" "${perfout}"
18+
rm -rf "${perfdata}".old
19+
20+
trap - EXIT TERM INT
21+
}
22+
23+
trap_cleanup() {
24+
echo "Unexpected signal in ${FUNCNAME[1]}"
25+
cleanup
26+
exit 1
27+
}
28+
trap trap_cleanup EXIT TERM INT
29+
30+
test_basic_annotate() {
31+
mode=$1
32+
echo "${mode} perf annotate test"
33+
if [ "x${mode}" == "xBasic" ]
34+
then
35+
perf mem record -o "${perfdata}" ${testprog} 2> /dev/null
36+
else
37+
perf mem record -o - ${testprog} 2> /dev/null > "${perfdata}"
38+
fi
39+
if [ "x$?" != "x0" ]
40+
then
41+
echo "${mode} annotate [Failed: perf record]"
42+
err=1
43+
return
44+
fi
45+
46+
# Generate the annotated output file
47+
if [ "x${mode}" == "xBasic" ]
48+
then
49+
perf annotate --code-with-type -i "${perfdata}" --stdio --percent-limit 1 2> /dev/null > "${perfout}"
50+
else
51+
perf annotate --code-with-type -i - --stdio 2> /dev/null --percent-limit 1 < "${perfdata}" > "${perfout}"
52+
fi
53+
54+
# check if it has the target data type
55+
if ! grep -q "${testtype}" "${perfout}"
56+
then
57+
echo "${mode} annotate [Failed: missing target data type]"
58+
cat "${perfout}"
59+
err=1
60+
return
61+
fi
62+
echo "${mode} annotate test [Success]"
63+
}
64+
65+
test_basic_annotate Basic
66+
test_basic_annotate Pipe
67+
68+
cleanup
69+
exit $err

0 commit comments

Comments
 (0)