Skip to content

Commit ac88100

Browse files
captain5050namhyung
authored andcommitted
perf tests c2c: Add a basic c2c
Add basic c2c record and report testing to gain some coverage. Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 3118d14 commit ac88100

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

tools/perf/tests/shell/c2c.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# perf c2c tests
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
set -e
6+
7+
err=0
8+
perfdata=$(mktemp /tmp/__perf_c2c_test.perf.data.XXXXX)
9+
10+
cleanup() {
11+
rm -f "${perfdata}"
12+
rm -f "${perfdata}".old
13+
trap - EXIT TERM INT
14+
}
15+
16+
trap_cleanup() {
17+
echo "Unexpected signal in ${FUNCNAME[1]}"
18+
cleanup
19+
exit 1
20+
}
21+
trap trap_cleanup EXIT TERM INT
22+
23+
check_c2c_support() {
24+
# Check if perf c2c record works.
25+
if ! perf c2c record -o "${perfdata}" -- true > /dev/null 2>&1 ; then
26+
return 1
27+
fi
28+
return 0
29+
}
30+
31+
test_c2c_record_report() {
32+
echo "c2c record and report test"
33+
if ! check_c2c_support ; then
34+
echo "c2c record and report test [Skipped: perf c2c record failed (possibly missing hardware support)]"
35+
err=2
36+
return
37+
fi
38+
39+
# Run a workload that does some memory operations.
40+
if ! perf c2c record -o "${perfdata}" -- perf test -w datasym 1 > /dev/null 2>&1 ; then
41+
echo "c2c record and report test [Skipped: perf c2c record failed during workload]"
42+
return
43+
fi
44+
45+
if ! perf c2c report -i "${perfdata}" --stdio > /dev/null 2>&1 ; then
46+
echo "c2c record and report test [Failed: report failed]"
47+
err=1
48+
return
49+
fi
50+
51+
if ! perf c2c report -i "${perfdata}" -N > /dev/null 2>&1 ; then
52+
echo "c2c record and report test [Failed: report -N failed]"
53+
err=1
54+
return
55+
fi
56+
57+
echo "c2c record and report test [Success]"
58+
}
59+
60+
test_c2c_record_report
61+
cleanup
62+
exit $err

0 commit comments

Comments
 (0)