• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
20status=0
21
22# Use the original file from run-strip-test.sh but with many sections
23testfiles testfile
24tempfiles testfile1.strip testfile2.strip testfile1.debug testfile2.debug testfile.unstrip
25
26echo "Adding sections to testfile"
27testrun ${abs_builddir}/addsections 65535 testfile ||
28{ echo "*** failure addsections testfile"; status=1; }
29
30echo "Testing strip -o"
31testrun ${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?
35echo "elflint testfile1.strip"
36testrun ${abs_top_builddir}/src/elflint --gnu -q testfile1.strip ||
37{ echo "*** failure elflint testfile1.strip"; status=1; }
38
39echo "elflint testfile1.debug"
40testrun ${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.
44echo "unstrip"
45testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile1.strip testfile1.debug ||
46{ echo "*** failure unstrip"; status=1; }
47
48echo "elfcmp"
49testrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip ||
50{ echo "*** failure elfcmp"; status=1; }
51
52# test strip -g
53echo "Testing strip -g"
54testrun ${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?
58echo "elflint testfile2.strip"
59testrun ${abs_top_builddir}/src/elflint --gnu -q testfile2.strip ||
60{ echo "*** failure elflint testfile2.strip"; status=1; }
61
62echo "elflint testfile2.debug"
63testrun ${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.
67echo "Testing strip in-place"
68SIZE_original=$(stat -c%s testfile)
69echo "original size $SIZE_original"
70
71testrun ${abs_top_builddir}/src/strip testfile ||
72{ echo "*** failure strip in-place"; status=1; }
73
74SIZE_stripped=$(stat -c%s testfile)
75echo "stripped size $SIZE_stripped"
76test $SIZE_stripped -lt $SIZE_original ||
77  { echo "*** failure in-place strip file not smaller $original"; exit 1; }
78
79echo "elflint in-place"
80testrun ${abs_top_builddir}/src/elflint --gnu -q testfile ||
81{ echo "*** failure elflint in-place"; status=1; }
82
83exit $status
84