Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Copyright (C) 1999, 2000, 2002, 2003, 2005, 2007, 2008 Red Hat, Inc. |
| 3 | # This file is part of elfutils. |
| 4 | # Written by Ulrich Drepper <drepper@redhat.com>, 1999. |
| 5 | # |
| 6 | # This file is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 3 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # elfutils is distributed in the hope that it will be useful, but |
| 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | . $srcdir/test-subr.sh |
| 20 | |
| 21 | original=${original:-testfile11} |
| 22 | stripped=${stripped:-testfile7} |
| 23 | debugout=${debugfile:+-f testfile.debug.temp -F $debugfile} |
| 24 | |
| 25 | testfiles $original |
| 26 | test x$stripped = xtestfile.temp || testfiles $stripped $debugfile |
| 27 | |
| 28 | tempfiles testfile.temp testfile.debug.temp testfile.unstrip |
| 29 | |
| 30 | testrun ${abs_top_builddir}/src/strip -o testfile.temp $debugout $original |
| 31 | |
| 32 | status=0 |
| 33 | |
| 34 | cmp $stripped testfile.temp || status=$? |
| 35 | |
| 36 | # Check elflint and the expected result. |
| 37 | testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.temp || status=$? |
| 38 | |
| 39 | test -z "$debugfile" || { |
| 40 | cmp $debugfile testfile.debug.temp || status=$? |
| 41 | |
| 42 | # Check elflint and the expected result. |
| 43 | testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug.temp || status=$? |
| 44 | |
| 45 | # Now test unstrip recombining those files. |
| 46 | testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.temp testfile.debug.temp |
| 47 | |
| 48 | # Check that it came back whole. |
| 49 | testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip |
| 50 | } |
| 51 | |
| 52 | # test strip -g |
| 53 | testrun ${abs_top_builddir}/src/strip -g -o testfile.temp $original |
| 54 | |
| 55 | # Buggy eu-strip created multiple .shstrtab sections |
| 56 | shstrtab_SECS=$(testrun ${abs_top_builddir}/src/readelf -S testfile.temp | grep '.shstrtab' | wc --lines) |
| 57 | test $shstrtab_SECS -eq 1 || |
| 58 | { echo "*** failure not just one '.shstrtab' testfile.temp ($shstrtab_SECS)"; status=1; } |
| 59 | |
| 60 | # Now strip in-place and make sure it is smaller. |
| 61 | SIZE_original=$(stat -c%s $original) |
| 62 | testrun ${abs_top_builddir}/src/strip $original |
| 63 | SIZE_stripped=$(stat -c%s $original) |
| 64 | test $SIZE_stripped -lt $SIZE_original || |
| 65 | { echo "*** failure in-place strip file not smaller $original"; status=1; } |
| 66 | |
| 67 | tempfiles testfile.sections |
| 68 | testrun ${abs_top_builddir}/src/readelf -S testfile.temp > testfile.sections || status=$? |
| 69 | fgrep ' .debug_' testfile.sections && status=1 |
| 70 | |
| 71 | exit $status |