Home | History | Annotate | Download | only in tests
      1 #! /bin/sh
      2 # Copyright (C) 2018 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 status=0
     21 
     22 # Use the original file from run-strip-test.sh but with many sections
     23 testfiles testfile
     24 tempfiles testfile1.strip testfile2.strip testfile1.debug testfile2.debug testfile.unstrip
     25 
     26 echo "Adding sections to testfile"
     27 testrun ${abs_builddir}/addsections 65535 testfile ||
     28 { echo "*** failure addsections testfile"; status=1; }
     29 
     30 echo "Testing strip -o"
     31 testrun ${abs_top_builddir}/src/strip -o testfile1.strip -f testfile1.debug testfile ||
     32 { echo "*** failure strip -o"; status=1; }
     33 
     34 # Do the parts check out?
     35 echo "elflint testfile1.strip"
     36 testrun ${abs_top_builddir}/src/elflint --gnu -q testfile1.strip ||
     37 { echo "*** failure elflint testfile1.strip"; status=1; }
     38 
     39 echo "elflint testfile1.debug"
     40 testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile1.debug ||
     41 { echo "*** failure elflint testfile1.debug"; status=1; }
     42 
     43 # Now test unstrip recombining those files.
     44 echo "unstrip"
     45 testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile1.strip testfile1.debug ||
     46 { echo "*** failure unstrip"; status=1; }
     47 
     48 echo "elfcmp"
     49 testrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip ||
     50 { echo "*** failure elfcmp"; status=1; }
     51 
     52 # test strip -g
     53 echo "Testing strip -g"
     54 testrun ${abs_top_builddir}/src/strip -g -o testfile2.strip -f testfile2.debug testfile ||
     55 { echo "*** failure strip -g"; status=1; }
     56 
     57 # Do the parts check out?
     58 echo "elflint testfile2.strip"
     59 testrun ${abs_top_builddir}/src/elflint --gnu -q testfile2.strip ||
     60 { echo "*** failure elflint testfile2.strip"; status=1; }
     61 
     62 echo "elflint testfile2.debug"
     63 testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile2.debug ||
     64 { echo "*** failure elflint testfile2.debug"; status=1; }
     65 
     66 # Now strip "in-place" and make sure it is smaller.
     67 echo "Testing strip in-place"
     68 SIZE_original=$(stat -c%s testfile)
     69 echo "original size $SIZE_original"
     70 
     71 testrun ${abs_top_builddir}/src/strip testfile ||
     72 { echo "*** failure strip in-place"; status=1; }
     73 
     74 SIZE_stripped=$(stat -c%s testfile)
     75 echo "stripped size $SIZE_stripped"
     76 test $SIZE_stripped -lt $SIZE_original ||
     77   { echo "*** failure in-place strip file not smaller $original"; exit 1; }
     78 
     79 echo "elflint in-place"
     80 testrun ${abs_top_builddir}/src/elflint --gnu -q testfile ||
     81 { echo "*** failure elflint in-place"; status=1; }
     82 
     83 exit $status
     84