xref: /linux/tools/perf/tests/shell/test_arm_callgraph_fp.sh (revision 0526b56cbc3c489642bd6a5fe4b718dea7ef0ee8)
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
18perf record -o $PERF_DATA --call-graph fp -e cycles//u -D 1000 --user-callchains -- $TEST_PROGRAM 2> /dev/null &
19PID=$!
20
21echo " + Recording (PID=$PID)..."
22sleep 2
23echo " + Stopping perf-record..."
24
25kill $PID
26wait $PID
27
28# expected perf-script output:
29#
30# program
31# 	728 leaf
32# 	753 parent
33# 	76c leafloop
34# ...
35
36perf script -i $PERF_DATA -F comm,ip,sym | head -n4
37perf script -i $PERF_DATA -F comm,ip,sym | head -n4 | \
38	awk '{ if ($2 != "") sym[i++] = $2 } END { if (sym[0] != "leaf" ||
39						       sym[1] != "parent" ||
40						       sym[2] != "leafloop") exit 1 }'
41