Home | History | Annotate | Download | only in tests
      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 tempfiles good.addr.out
     75 
     76 cat > good.addr.out <<\EOF
     77 0x08048468
     78 foo
     79 /home/drepper/gnu/new-bu/build/ttt/f.c:3
     80 0x0804845c
     81 bar
     82 /home/drepper/gnu/new-bu/build/ttt/b.c:4
     83 0x08048468
     84 foo
     85 /home/drepper/gnu/new-bu/build/ttt/f.c:3
     86 0x0804845c
     87 bar
     88 /home/drepper/gnu/new-bu/build/ttt/b.c:4
     89 0x08048468
     90 foo
     91 /home/drepper/gnu/new-bu/build/ttt/f.c:3
     92 0x0804845c
     93 bar
     94 /home/drepper/gnu/new-bu/build/ttt/b.c:4
     95 0x08048468
     96 foo
     97 /home/drepper/gnu/new-bu/build/ttt/f.c:3
     98 0x0804845c
     99 bar
    100 /home/drepper/gnu/new-bu/build/ttt/b.c:4
    101 EOF
    102 
    103 echo "# Everything on the command line with addresses"
    104 cat 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 
    106 echo "# Everything from stdin (with newlines) with addresses."
    107 cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -a -f -e testfile > stdin.nl.out || exit 1
    108 cmp good.addr.out stdin.nl.out || exit 1
    109 
    110 echo "# Pretty with functions and addresses."
    111 testrun_compare ${abs_top_builddir}/src/addr2line --pretty -a -f -e testfile 0x08048468 0x0804845c << EOF
    112 0x08048468: foo at /home/drepper/gnu/new-bu/build/ttt/f.c:3
    113 0x0804845c: bar at /home/drepper/gnu/new-bu/build/ttt/b.c:4
    114 EOF
    115 
    116 exit 0
    117