xref: /aosp_15_r20/external/elfutils/tests/run-addr2line-test.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1*7304104dSAndroid Build Coastguard Worker#! /bin/sh
2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2013 Red Hat, Inc.
3*7304104dSAndroid Build Coastguard Worker# This file is part of elfutils.
4*7304104dSAndroid Build Coastguard Worker#
5*7304104dSAndroid Build Coastguard Worker# This file is free software; you can redistribute it and/or modify
6*7304104dSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by
7*7304104dSAndroid Build Coastguard Worker# the Free Software Foundation; either version 3 of the License, or
8*7304104dSAndroid Build Coastguard Worker# (at your option) any later version.
9*7304104dSAndroid Build Coastguard Worker#
10*7304104dSAndroid Build Coastguard Worker# elfutils is distributed in the hope that it will be useful, but
11*7304104dSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of
12*7304104dSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*7304104dSAndroid Build Coastguard Worker# GNU General Public License for more details.
14*7304104dSAndroid Build Coastguard Worker#
15*7304104dSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License
16*7304104dSAndroid Build Coastguard Worker# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17*7304104dSAndroid Build Coastguard Worker
18*7304104dSAndroid Build Coastguard Worker. $srcdir/test-subr.sh
19*7304104dSAndroid Build Coastguard Worker
20*7304104dSAndroid Build Coastguard Workertestfiles testfile
21*7304104dSAndroid Build Coastguard Workertempfiles good.out stdin.nl stdin.nl.out stdin.nonl stdin.nonl.out foo.out
22*7304104dSAndroid Build Coastguard Workertempfiles addr2line.out
23*7304104dSAndroid Build Coastguard Worker
24*7304104dSAndroid Build Coastguard Workercat > good.out <<\EOF
25*7304104dSAndroid Build Coastguard Workerfoo
26*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
27*7304104dSAndroid Build Coastguard Workerbar
28*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
29*7304104dSAndroid Build Coastguard Workerfoo
30*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
31*7304104dSAndroid Build Coastguard Workerbar
32*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
33*7304104dSAndroid Build Coastguard Workerfoo
34*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
35*7304104dSAndroid Build Coastguard Workerbar
36*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
37*7304104dSAndroid Build Coastguard Workerfoo
38*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
39*7304104dSAndroid Build Coastguard Workerbar
40*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
41*7304104dSAndroid Build Coastguard WorkerEOF
42*7304104dSAndroid Build Coastguard Worker
43*7304104dSAndroid Build Coastguard Workerecho "# Everything on the command line"
44*7304104dSAndroid Build Coastguard Workercat good.out | testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0
45*7304104dSAndroid Build Coastguard Worker
46*7304104dSAndroid Build Coastguard Workercat > stdin.nl <<\EOF
47*7304104dSAndroid Build Coastguard Worker0x08048468
48*7304104dSAndroid Build Coastguard Worker0x0804845c
49*7304104dSAndroid Build Coastguard Workerfoo
50*7304104dSAndroid Build Coastguard Workerbar
51*7304104dSAndroid Build Coastguard Workerfoo+0x0
52*7304104dSAndroid Build Coastguard Workerbar+0x0
53*7304104dSAndroid Build Coastguard Workerfoo-0x0
54*7304104dSAndroid Build Coastguard Workerbar-0x0
55*7304104dSAndroid Build Coastguard WorkerEOF
56*7304104dSAndroid Build Coastguard Worker
57*7304104dSAndroid Build Coastguard Workerecho "# Everything from stdin (with newlines)."
58*7304104dSAndroid Build Coastguard Workercat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
59*7304104dSAndroid Build Coastguard Workercmp good.out stdin.nl.out || exit 1
60*7304104dSAndroid Build Coastguard Worker
61*7304104dSAndroid Build Coastguard Workercat > foo.out <<\EOF
62*7304104dSAndroid Build Coastguard Workerfoo
63*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
64*7304104dSAndroid Build Coastguard WorkerEOF
65*7304104dSAndroid Build Coastguard Worker
66*7304104dSAndroid Build Coastguard Workerecho "# stdin without newline address, just EOF."
67*7304104dSAndroid Build Coastguard Workerecho -n "0x08048468" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nonl.out || exit 1
68*7304104dSAndroid Build Coastguard Workercmp foo.out stdin.nonl.out || exit 1
69*7304104dSAndroid Build Coastguard Worker
70*7304104dSAndroid Build Coastguard Workerecho "# stdin without newline symbol, just EOF."
71*7304104dSAndroid Build Coastguard Workerecho -n "foo" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
72*7304104dSAndroid Build Coastguard Workercmp foo.out stdin.nonl.out || exit 1
73*7304104dSAndroid Build Coastguard Worker
74*7304104dSAndroid Build Coastguard Workertempfiles good.addr.out
75*7304104dSAndroid Build Coastguard Worker
76*7304104dSAndroid Build Coastguard Workercat > good.addr.out <<\EOF
77*7304104dSAndroid Build Coastguard Worker0x08048468
78*7304104dSAndroid Build Coastguard Workerfoo
79*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
80*7304104dSAndroid Build Coastguard Worker0x0804845c
81*7304104dSAndroid Build Coastguard Workerbar
82*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
83*7304104dSAndroid Build Coastguard Worker0x08048468
84*7304104dSAndroid Build Coastguard Workerfoo
85*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
86*7304104dSAndroid Build Coastguard Worker0x0804845c
87*7304104dSAndroid Build Coastguard Workerbar
88*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
89*7304104dSAndroid Build Coastguard Worker0x08048468
90*7304104dSAndroid Build Coastguard Workerfoo
91*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
92*7304104dSAndroid Build Coastguard Worker0x0804845c
93*7304104dSAndroid Build Coastguard Workerbar
94*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
95*7304104dSAndroid Build Coastguard Worker0x08048468
96*7304104dSAndroid Build Coastguard Workerfoo
97*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/f.c:3
98*7304104dSAndroid Build Coastguard Worker0x0804845c
99*7304104dSAndroid Build Coastguard Workerbar
100*7304104dSAndroid Build Coastguard Worker/home/drepper/gnu/new-bu/build/ttt/b.c:4
101*7304104dSAndroid Build Coastguard WorkerEOF
102*7304104dSAndroid Build Coastguard Worker
103*7304104dSAndroid Build Coastguard Workerecho "# Everything on the command line with addresses"
104*7304104dSAndroid Build Coastguard Workercat good.addr.out | testrun_compare ${abs_top_builddir}/src/addr2line -a -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0
105*7304104dSAndroid Build Coastguard Worker
106*7304104dSAndroid Build Coastguard Workerecho "# Everything from stdin (with newlines) with addresses."
107*7304104dSAndroid Build Coastguard Workercat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -a -f -e testfile > stdin.nl.out || exit 1
108*7304104dSAndroid Build Coastguard Workercmp good.addr.out stdin.nl.out || exit 1
109*7304104dSAndroid Build Coastguard Worker
110*7304104dSAndroid Build Coastguard Workerecho "# Pretty with functions and addresses."
111*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/addr2line --pretty -a -f -e testfile 0x08048468 0x0804845c << EOF
112*7304104dSAndroid Build Coastguard Worker0x08048468: foo at /home/drepper/gnu/new-bu/build/ttt/f.c:3
113*7304104dSAndroid Build Coastguard Worker0x0804845c: bar at /home/drepper/gnu/new-bu/build/ttt/b.c:4
114*7304104dSAndroid Build Coastguard WorkerEOF
115*7304104dSAndroid Build Coastguard Worker
116*7304104dSAndroid Build Coastguard Workerexit 0
117