xref: /linux/tools/perf/tests/shell/test_arm_callgraph_fp.sh (revision 490cc3c5e724502667a104a4e818dc071faf5e77)
1#!/bin/sh
2# Check Arm64 callgraphs are complete in fp mode
3# SPDX-License-Identifier: GPL-2.0
4
5shelldir=$(dirname "$0")
6# shellcheck source=lib/perf_has_symbol.sh
7. "${shelldir}"/lib/perf_has_symbol.sh
8
9lscpu | grep -q "aarch64" || exit 2
10
11skip_test_missing_symbol leafloop
12
13PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
14TEST_PROGRAM="perf test -w leafloop"
15
16cleanup_files()
17{
18	rm -f "$PERF_DATA"
19}
20
21trap cleanup_files EXIT TERM INT
22
23# Add a 1 second delay to skip samples that are not in the leaf() function
24# shellcheck disable=SC2086
25perf record -o "$PERF_DATA" --call-graph fp -e cycles//u -D 1000 --user-callchains -- $TEST_PROGRAM 2> /dev/null &
26PID=$!
27
28echo " + Recording (PID=$PID)..."
29sleep 2
30echo " + Stopping perf-record..."
31
32kill $PID
33wait $PID
34
35# expected perf-script output:
36#
37# program
38# 	728 leaf
39# 	753 parent
40# 	76c leafloop
41# ...
42
43perf script -i "$PERF_DATA" -F comm,ip,sym | head -n4
44perf script -i "$PERF_DATA" -F comm,ip,sym | head -n4 | \
45	awk '{ if ($2 != "") sym[i++] = $2 } END { if (sym[0] != "leaf" ||
46						       sym[1] != "parent" ||
47						       sym[2] != "leafloop") exit 1 }'
48