• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2# Copyright (C) 2017 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# If there is nothing to strip then -o output should be identical to input.
21# And there should not be an (empty) -f debug file.
22
23tempfiles a.out strip.out debug.out
24
25# Create no-debug a.out.
26echo "int main() { return 1; }" | ${CC} -s -xc -
27
28# strip to file
29testrun ${abs_top_builddir}/src/strip -g -o strip.out ||
30  { echo "*** failed to strip -g -o strip.out a.out"; exit -1; }
31
32testrun ${abs_top_builddir}/src/elfcmp a.out strip.out ||
33  { echo "*** failed strip.out different from a.out"; exit -1; }
34
35# strip original
36testrun ${abs_top_builddir}/src/strip -g ||
37  { echo "*** failed to strip -g a.out"; exit -1; }
38
39testrun ${abs_top_builddir}/src/elfcmp strip.out a.out ||
40  { echo "*** failed a.out different from strip.out"; exit -1; }
41
42# strip to file with debug file
43testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
44  { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
45
46testrun ${abs_top_builddir}/src/elfcmp a.out strip.out ||
47  { echo "*** failed strip.out different from a.out (with debug)"; exit -1; }
48
49test ! -f debug.out ||
50  { echo "*** failed strip.out and debug.out exist"; exit -1; }
51
52# strip original with debug file
53testrun ${abs_top_builddir}/src/strip -g -f debug.out ||
54  { echo "*** failed to strip -g -f debug.out a.out"; exit -1; }
55
56testrun ${abs_top_builddir}/src/elfcmp strip.out a.out ||
57  { echo "*** failed a.out different from strip.out (with debug)"; exit -1; }
58
59test ! -f debug.out ||
60  { echo "*** failed a.out and debug.out exist"; exit -1; }
61
62exit 0
63