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