xref: /aosp_15_r20/external/elfutils/tests/run-strip-test-many.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1*7304104dSAndroid Build Coastguard Worker#! /bin/sh
2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2018 Red Hat, Inc.
3*7304104dSAndroid Build Coastguard Worker# This file is part of elfutils.
4*7304104dSAndroid Build Coastguard Worker#
5*7304104dSAndroid Build Coastguard Worker# This file is free software; you can redistribute it and/or modify
6*7304104dSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by
7*7304104dSAndroid Build Coastguard Worker# the Free Software Foundation; either version 3 of the License, or
8*7304104dSAndroid Build Coastguard Worker# (at your option) any later version.
9*7304104dSAndroid Build Coastguard Worker#
10*7304104dSAndroid Build Coastguard Worker# elfutils is distributed in the hope that it will be useful, but
11*7304104dSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of
12*7304104dSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*7304104dSAndroid Build Coastguard Worker# GNU General Public License for more details.
14*7304104dSAndroid Build Coastguard Worker#
15*7304104dSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License
16*7304104dSAndroid Build Coastguard Worker# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17*7304104dSAndroid Build Coastguard Worker
18*7304104dSAndroid Build Coastguard Worker. $srcdir/test-subr.sh
19*7304104dSAndroid Build Coastguard Worker
20*7304104dSAndroid Build Coastguard Workerstatus=0
21*7304104dSAndroid Build Coastguard Worker
22*7304104dSAndroid Build Coastguard Worker# Use the original file from run-strip-test.sh but with many sections
23*7304104dSAndroid Build Coastguard Workertestfiles testfile
24*7304104dSAndroid Build Coastguard Workertempfiles testfile1.strip testfile2.strip testfile1.debug testfile2.debug testfile.unstrip
25*7304104dSAndroid Build Coastguard Worker
26*7304104dSAndroid Build Coastguard Workerecho "Adding sections to testfile"
27*7304104dSAndroid Build Coastguard Workertestrun ${abs_builddir}/addsections 65535 testfile ||
28*7304104dSAndroid Build Coastguard Worker{ echo "*** failure addsections testfile"; status=1; }
29*7304104dSAndroid Build Coastguard Worker
30*7304104dSAndroid Build Coastguard Workerecho "Testing strip -o"
31*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/strip -o testfile1.strip -f testfile1.debug testfile ||
32*7304104dSAndroid Build Coastguard Worker{ echo "*** failure strip -o"; status=1; }
33*7304104dSAndroid Build Coastguard Worker
34*7304104dSAndroid Build Coastguard Worker# Do the parts check out?
35*7304104dSAndroid Build Coastguard Workerecho "elflint testfile1.strip"
36*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/elflint --gnu -q testfile1.strip ||
37*7304104dSAndroid Build Coastguard Worker{ echo "*** failure elflint testfile1.strip"; status=1; }
38*7304104dSAndroid Build Coastguard Worker
39*7304104dSAndroid Build Coastguard Workerecho "elflint testfile1.debug"
40*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile1.debug ||
41*7304104dSAndroid Build Coastguard Worker{ echo "*** failure elflint testfile1.debug"; status=1; }
42*7304104dSAndroid Build Coastguard Worker
43*7304104dSAndroid Build Coastguard Worker# Now test unstrip recombining those files.
44*7304104dSAndroid Build Coastguard Workerecho "unstrip"
45*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile1.strip testfile1.debug ||
46*7304104dSAndroid Build Coastguard Worker{ echo "*** failure unstrip"; status=1; }
47*7304104dSAndroid Build Coastguard Worker
48*7304104dSAndroid Build Coastguard Workerecho "elfcmp"
49*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip ||
50*7304104dSAndroid Build Coastguard Worker{ echo "*** failure elfcmp"; status=1; }
51*7304104dSAndroid Build Coastguard Worker
52*7304104dSAndroid Build Coastguard Worker# test strip -g
53*7304104dSAndroid Build Coastguard Workerecho "Testing strip -g"
54*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/strip -g -o testfile2.strip -f testfile2.debug testfile ||
55*7304104dSAndroid Build Coastguard Worker{ echo "*** failure strip -g"; status=1; }
56*7304104dSAndroid Build Coastguard Worker
57*7304104dSAndroid Build Coastguard Worker# Do the parts check out?
58*7304104dSAndroid Build Coastguard Workerecho "elflint testfile2.strip"
59*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/elflint --gnu -q testfile2.strip ||
60*7304104dSAndroid Build Coastguard Worker{ echo "*** failure elflint testfile2.strip"; status=1; }
61*7304104dSAndroid Build Coastguard Worker
62*7304104dSAndroid Build Coastguard Workerecho "elflint testfile2.debug"
63*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile2.debug ||
64*7304104dSAndroid Build Coastguard Worker{ echo "*** failure elflint testfile2.debug"; status=1; }
65*7304104dSAndroid Build Coastguard Worker
66*7304104dSAndroid Build Coastguard Worker# Now strip "in-place" and make sure it is smaller.
67*7304104dSAndroid Build Coastguard Workerecho "Testing strip in-place"
68*7304104dSAndroid Build Coastguard WorkerSIZE_original=$(stat -c%s testfile)
69*7304104dSAndroid Build Coastguard Workerecho "original size $SIZE_original"
70*7304104dSAndroid Build Coastguard Worker
71*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/strip testfile ||
72*7304104dSAndroid Build Coastguard Worker{ echo "*** failure strip in-place"; status=1; }
73*7304104dSAndroid Build Coastguard Worker
74*7304104dSAndroid Build Coastguard WorkerSIZE_stripped=$(stat -c%s testfile)
75*7304104dSAndroid Build Coastguard Workerecho "stripped size $SIZE_stripped"
76*7304104dSAndroid Build Coastguard Workertest $SIZE_stripped -lt $SIZE_original ||
77*7304104dSAndroid Build Coastguard Worker  { echo "*** failure in-place strip file not smaller $original"; exit 1; }
78*7304104dSAndroid Build Coastguard Worker
79*7304104dSAndroid Build Coastguard Workerecho "elflint in-place"
80*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/elflint --gnu -q testfile ||
81*7304104dSAndroid Build Coastguard Worker{ echo "*** failure elflint in-place"; status=1; }
82*7304104dSAndroid Build Coastguard Worker
83*7304104dSAndroid Build Coastguard Workerexit $status
84