2 # Copyright (C) 2015 Red Hat, Inc.
3 # This file is part of elfutils.
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.
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.
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/>.
18 . $srcdir/test-subr.sh
20 # uncompress -> gnucompress -> uncompress -> elfcompress -> uncompress
21 testrun_elfcompress_file()
24 uncompressedfile="${infile}.uncompressed"
25 tempfiles "$uncompressedfile"
27 echo "uncompress $infile -> $uncompressedfile"
28 testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${uncompressedfile} ${infile}
29 testrun ${abs_top_builddir}/src/elflint --gnu-ld ${uncompressedfile}
31 SIZE_uncompressed=$(stat -c%s $uncompressedfile)
33 gnucompressedfile="${infile}.gnu"
34 tempfiles "$gnucompressedfile"
35 echo "compress gnu $uncompressedfile -> $gnucompressedfile"
36 testrun ${abs_top_builddir}/src/elfcompress -v -t gnu -o ${gnucompressedfile} ${uncompressedfile}
37 testrun ${abs_top_builddir}/src/elflint --gnu-ld ${gnucompressedfile}
39 SIZE_gnucompressed=$(stat -c%s $gnucompressedfile)
40 test $SIZE_gnucompressed -lt $SIZE_uncompressed ||
41 { echo "*** failure $gnucompressedfile not smaller"; exit -1; }
43 gnuuncompressedfile="${infile}.gnu.uncompressed"
44 tempfiles "$gnuuncompressedfile"
45 echo "uncompress $gnucompressedfile -> $gnuuncompressedfile"
46 testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${gnuuncompressedfile} ${gnucompressedfile}
47 testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${gnuuncompressedfile}
49 elfcompressedfile="${infile}.gabi"
50 tempfiles "$elfcompressedfile"
51 echo "compress gabi $uncompressedfile -> $elfcompressedfile"
52 testrun ${abs_top_builddir}/src/elfcompress -v -t zlib -o ${elfcompressedfile} ${uncompressedfile}
53 testrun ${abs_top_builddir}/src/elflint --gnu-ld ${elfcompressedfile}
55 SIZE_elfcompressed=$(stat -c%s $elfcompressedfile)
56 test $SIZE_elfcompressed -lt $SIZE_uncompressed ||
57 { echo "*** failure $elfcompressedfile not smaller"; exit -1; }
59 elfuncompressedfile="${infile}.gabi.uncompressed"
60 tempfiles "$elfuncompressedfile"
61 echo "uncompress $elfcompressedfile -> $elfuncompressedfile"
62 testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${elfuncompressedfile} ${elfcompressedfile}
63 testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${elfuncompressedfile}
70 testrun_elfcompress_file ${testfile}
72 # Merge the string tables to make things a little more interesting.
73 mergedfile="${testfile}.merged"
74 tempfiles ${mergedfile}
75 echo "merging string tables ${testfile} -> ${mergedfile}"
76 testrun ${abs_top_builddir}/tests/elfstrmerge -o ${mergedfile} ${testfile}
77 testrun_elfcompress_file ${mergedfile}
80 # Random ELF32 testfile
81 testrun_elfcompress testfile4
83 # Random ELF64 testfile
84 testrun_elfcompress testfile12
86 # Random ELF64BE testfile
87 testrun_elfcompress testfileppc64
89 # Random ELF32BE testfile
90 testrun_elfcompress testfileppc32
92 # Already compressed files
93 testrun_elfcompress testfile-zgnu64
94 testrun_elfcompress testfile-zgnu64be
95 testrun_elfcompress testfile-zgabi64
96 testrun_elfcompress testfile-zgabi64be
97 testrun_elfcompress testfile-zgnu32
98 testrun_elfcompress testfile-zgnu32be
99 testrun_elfcompress testfile-zgabi32
100 testrun_elfcompress testfile-zgabi32be