xref: /linux/tools/perf/tests/shell/inject-callchain.sh (revision bf4afc53b77aeaa48b5409da5c8da6bb4eff7f43)
1#!/bin/bash
2# perf inject to convert DWARF callchains to regular ones
3# SPDX-License-Identifier: GPL-2.0
4
5if ! perf check feature -q dwarf; then
6    echo "SKIP: DWARF support is not available"
7    exit 2
8fi
9
10TESTDATA=$(mktemp /tmp/perf-test.XXXXXX)
11
12err=0
13
14cleanup()
15{
16    trap - EXIT TERM INT
17    rm -f ${TESTDATA}*
18}
19
20trap_cleanup()
21{
22	cleanup
23	exit 1
24}
25
26trap trap_cleanup EXIT TERM INT
27
28echo "recording data with DWARF callchain"
29perf record -F 999 --call-graph dwarf -o "${TESTDATA}" -- perf test -w noploop
30
31echo "convert DWARF callchain using perf inject"
32perf inject -i "${TESTDATA}" --convert-callchain -o "${TESTDATA}.new"
33
34perf report -i "${TESTDATA}" --no-children -q --percent-limit=1 > ${TESTDATA}.out
35perf report -i "${TESTDATA}.new" --no-children -q --percent-limit=1 > ${TESTDATA}.new.out
36
37echo "compare the both result excluding inlined functions"
38if diff -u "${TESTDATA}.out" "${TESTDATA}.new.out" | grep "^- " | grep -qv "(inlined)"; then
39    echo "Found some differences"
40    diff -u "${TESTDATA}.out" "${TESTDATA}.new.out"
41    err=1
42fi
43
44cleanup
45exit $err
46