768006bf150ef8e476e022a19ad94d089f84f9bc
[platform/upstream/elfutils.git] / tests / run-addr2line-test.sh
1 #! /bin/sh
2 # Copyright (C) 2013 Red Hat, Inc.
3 # This file is part of elfutils.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # elfutils is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 . $srcdir/test-subr.sh
19
20 testfiles testfile
21 tempfiles good.out stdin.nl stdin.nl.out stdin.nonl stdin.nonl.out foo.out
22 tempfiles addr2line.out
23
24 cat > good.out <<\EOF
25 foo
26 /home/drepper/gnu/new-bu/build/ttt/f.c:3
27 bar
28 /home/drepper/gnu/new-bu/build/ttt/b.c:4
29 foo
30 /home/drepper/gnu/new-bu/build/ttt/f.c:3
31 bar
32 /home/drepper/gnu/new-bu/build/ttt/b.c:4
33 foo
34 /home/drepper/gnu/new-bu/build/ttt/f.c:3
35 bar
36 /home/drepper/gnu/new-bu/build/ttt/b.c:4
37 foo
38 /home/drepper/gnu/new-bu/build/ttt/f.c:3
39 bar
40 /home/drepper/gnu/new-bu/build/ttt/b.c:4
41 EOF
42
43 echo "# Everything on the command line"
44 cat 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
46 cat > stdin.nl <<\EOF
47 0x08048468
48 0x0804845c
49 foo
50 bar
51 foo+0x0
52 bar+0x0
53 foo-0x0
54 bar-0x0
55 EOF
56
57 echo "# Everything from stdin (with newlines)."
58 cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
59 cmp good.out stdin.nl.out || exit 1
60
61 cat > foo.out <<\EOF
62 foo
63 /home/drepper/gnu/new-bu/build/ttt/f.c:3
64 EOF
65
66 echo "# stdin without newline address, just EOF."
67 echo -n "0x08048468" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nonl.out || exit 1
68 cmp foo.out stdin.nonl.out || exit 1
69
70 echo "# stdin without newline symbol, just EOF."
71 echo -n "foo" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
72 cmp foo.out stdin.nonl.out || exit 1
73
74 exit 0