diff options
| author | Mark Wielaard <[email protected]> | 2017-06-07 20:32:38 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2017-06-14 14:51:33 +0200 |
| commit | b58aebe71e0b4863db1b7fd3e942e36303257f3a (patch) | |
| tree | b35449ab65eef87b6645130e5a86c5f8be4725c6 /tests | |
| parent | e0b3232e9a0bc8215ca1be29b1ec6df43811eb87 (diff) | |
strip: Don't generate empty output file when nothing to do.
If there was nothing to do strip would skip generating a separate
debug file if one was requested, but it would also not finish the
creation of a new output file (with the non-stripped sections).
Also if there was an error any partially created output would be kept.
Make sure that when the -o output file option is given we always generate
a complete output file (except on error). Also make sure that when the -f
debug file option is given it is only generated when it is not empty.
Add testcase run-strip-nothing.sh that tests the various combinations.
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 6 | ||||
| -rw-r--r-- | tests/Makefile.am | 2 | ||||
| -rwxr-xr-x | tests/run-strip-nothing.sh | 62 |
3 files changed, 70 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index a7b20224..ecf62630 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2017-06-07 Mark Wielaard <[email protected]> + + * run-strip-nothing.sh: New test. + * Makefile.am (TESTS): Add run-strip-nothing.sh. + (EXTRA_DIST): Likewise. + 2017-06-06 Mark Wielaard <[email protected]> * run-strip-test.sh: Test strip -g doesn't introduce extra .shstrtab. diff --git a/tests/Makefile.am b/tests/Makefile.am index 50648db8..0aa16da1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -81,6 +81,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \ run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \ run-strip-test9.sh run-strip-test10.sh run-strip-test11.sh \ + run-strip-nothing.sh \ run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \ run-strip-nobitsalign.sh \ run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \ @@ -175,6 +176,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \ run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \ run-strip-test9.sh run-strip-test10.sh run-strip-test11.sh \ + run-strip-nothing.sh \ run-strip-strmerge.sh run-strip-nobitsalign.sh \ testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \ run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \ diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh new file mode 100755 index 00000000..e80bd906 --- /dev/null +++ b/tests/run-strip-nothing.sh @@ -0,0 +1,62 @@ +#! /bin/sh +# Copyright (C) 2017 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +. $srcdir/test-subr.sh + +# If there is nothing to strip then -o output should be identical to input. +# And there should not be an (empty) -f debug file. + +tempfiles a.out strip.out debug.out + +# Create no-debug a.out. +echo "int main() { return 1; }" | gcc -xc - + +# strip to file +testrun ${abs_top_builddir}/src/strip -g -o strip.out || + { echo "*** failed to strip -g -o strip.out a.out"; exit -1; } + +testrun ${abs_top_builddir}/src/elfcmp a.out strip.out || + { echo "*** failed strip.out different from a.out"; exit -1; } + +# strip original +testrun ${abs_top_builddir}/src/strip -g || + { echo "*** failed to strip -g a.out"; exit -1; } + +testrun ${abs_top_builddir}/src/elfcmp strip.out a.out || + { echo "*** failed a.out different from strip.out"; exit -1; } + +# strip to file with debug file +testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out || + { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } + +testrun ${abs_top_builddir}/src/elfcmp a.out strip.out || + { echo "*** failed strip.out different from a.out (with debug)"; exit -1; } + +test ! -f debug.out || + { echo "*** failed strip.out and debug.out exist"; exit -1; } + +# strip original with debug file +testrun ${abs_top_builddir}/src/strip -g -f debug.out || + { echo "*** failed to strip -g -f debug.out a.out"; exit -1; } + +testrun ${abs_top_builddir}/src/elfcmp strip.out a.out || + { echo "*** failed a.out different from strip.out (with debug)"; exit -1; } + +test ! -f debug.out || + { echo "*** failed a.out and debug.out exist"; exit -1; } + +exit 0 |
