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