Skip to content

Commit 3350471

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

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

tools/perf/tests/shell/data_type_profiling.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ set -e
66

77
# The logic below follows the same line as the annotate test, but looks for a
88
# data type profiling manifestation
9-
testtype="# data-type: struct Buf"
9+
10+
# Values in testtypes and testprogs should match
11+
testtypes=("# data-type: struct Buf" "# data-type: struct _buf")
12+
testprogs=("perf test -w code_with_type" "perf test -w datasym")
1013

1114
err=0
1215
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
1316
perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX)
14-
testprog="perf test -w code_with_type"
1517

1618
cleanup() {
1719
rm -rf "${perfdata}" "${perfout}"
@@ -29,12 +31,23 @@ trap trap_cleanup EXIT TERM INT
2931

3032
test_basic_annotate() {
3133
mode=$1
32-
echo "${mode} perf annotate test"
34+
runtime=$2
35+
36+
echo "${mode} ${runtime} perf annotate test"
37+
38+
case "x${runtime}" in
39+
"xRust")
40+
index=0 ;;
41+
42+
"xC")
43+
index=1 ;;
44+
esac
45+
3346
if [ "x${mode}" == "xBasic" ]
3447
then
35-
perf mem record -o "${perfdata}" ${testprog} 2> /dev/null
48+
perf mem record -o "${perfdata}" ${testprogs[$index]} 2> /dev/null
3649
else
37-
perf mem record -o - ${testprog} 2> /dev/null > "${perfdata}"
50+
perf mem record -o - ${testprogs[$index]} 2> /dev/null > "${perfdata}"
3851
fi
3952
if [ "x$?" != "x0" ]
4053
then
@@ -52,7 +65,7 @@ test_basic_annotate() {
5265
fi
5366

5467
# check if it has the target data type
55-
if ! grep -q "${testtype}" "${perfout}"
68+
if ! grep -q "${testtypes[$index]}" "${perfout}"
5669
then
5770
echo "${mode} annotate [Failed: missing target data type]"
5871
cat "${perfout}"
@@ -62,8 +75,10 @@ test_basic_annotate() {
6275
echo "${mode} annotate test [Success]"
6376
}
6477

65-
test_basic_annotate Basic
66-
test_basic_annotate Pipe
78+
test_basic_annotate Basic Rust
79+
test_basic_annotate Pipe Rust
80+
test_basic_annotate Basic C
81+
test_basic_annotate Pipe C
6782

6883
cleanup
6984
exit $err

0 commit comments

Comments
 (0)