Blame tests/run-compress-test.sh

Packit Service 97d2fb
#! /bin/sh
Packit Service 97d2fb
# Copyright (C) 2015 Red Hat, Inc.
Packit Service 97d2fb
# This file is part of elfutils.
Packit Service 97d2fb
#
Packit Service 97d2fb
# This file is free software; you can redistribute it and/or modify
Packit Service 97d2fb
# it under the terms of the GNU General Public License as published by
Packit Service 97d2fb
# the Free Software Foundation; either version 3 of the License, or
Packit Service 97d2fb
# (at your option) any later version.
Packit Service 97d2fb
#
Packit Service 97d2fb
# elfutils is distributed in the hope that it will be useful, but
Packit Service 97d2fb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 97d2fb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 97d2fb
# GNU General Public License for more details.
Packit Service 97d2fb
#
Packit Service 97d2fb
# You should have received a copy of the GNU General Public License
Packit Service 97d2fb
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 97d2fb
Packit Service 97d2fb
. $srcdir/test-subr.sh
Packit Service 97d2fb
Packit Service 97d2fb
# uncompress -> gnucompress -> uncompress -> elfcompress -> uncompress
Packit Service 97d2fb
testrun_elfcompress_file()
Packit Service 97d2fb
{
Packit Service 97d2fb
    infile="$1"
Packit Service 97d2fb
    uncompressedfile="${infile}.uncompressed"
Packit Service 97d2fb
    tempfiles "$uncompressedfile"
Packit Service 97d2fb
    
Packit Service 97d2fb
    echo "uncompress $infile -> $uncompressedfile"
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${uncompressedfile} ${infile}
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elflint --gnu-ld ${uncompressedfile}
Packit Service 97d2fb
Packit Service 97d2fb
    SIZE_uncompressed=$(stat -c%s $uncompressedfile)
Packit Service 97d2fb
Packit Service 97d2fb
    gnucompressedfile="${infile}.gnu"
Packit Service 97d2fb
    tempfiles "$gnucompressedfile"
Packit Service 97d2fb
    echo "compress gnu $uncompressedfile -> $gnucompressedfile"
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcompress -v -t gnu -o ${gnucompressedfile} ${uncompressedfile}
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elflint --gnu-ld ${gnucompressedfile}
Packit Service 97d2fb
Packit Service 97d2fb
    SIZE_gnucompressed=$(stat -c%s $gnucompressedfile)
Packit Service 97d2fb
    test $SIZE_gnucompressed -lt $SIZE_uncompressed ||
Packit Service 97d2fb
	{ echo "*** failure $gnucompressedfile not smaller"; exit -1; }
Packit Service 97d2fb
    
Packit Service 97d2fb
    gnuuncompressedfile="${infile}.gnu.uncompressed"
Packit Service 97d2fb
    tempfiles "$gnuuncompressedfile"
Packit Service 97d2fb
    echo "uncompress $gnucompressedfile -> $gnuuncompressedfile"
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${gnuuncompressedfile} ${gnucompressedfile}
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${gnuuncompressedfile}
Packit Service 97d2fb
Packit Service 97d2fb
    elfcompressedfile="${infile}.gabi"
Packit Service 97d2fb
    tempfiles "$elfcompressedfile"
Packit Service 97d2fb
    echo "compress gabi $uncompressedfile -> $elfcompressedfile"
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcompress -v -t zlib -o ${elfcompressedfile} ${uncompressedfile}
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elflint --gnu-ld ${elfcompressedfile}
Packit Service 97d2fb
Packit Service 97d2fb
    SIZE_elfcompressed=$(stat -c%s $elfcompressedfile)
Packit Service 97d2fb
    test $SIZE_elfcompressed -lt $SIZE_uncompressed ||
Packit Service 97d2fb
	{ echo "*** failure $elfcompressedfile not smaller"; exit -1; }
Packit Service 97d2fb
    
Packit Service 97d2fb
    elfuncompressedfile="${infile}.gabi.uncompressed"
Packit Service 97d2fb
    tempfiles "$elfuncompressedfile"
Packit Service 97d2fb
    echo "uncompress $elfcompressedfile -> $elfuncompressedfile"
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${elfuncompressedfile} ${elfcompressedfile}
Packit Service 97d2fb
    testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${elfuncompressedfile}
Packit Service 97d2fb
}
Packit Service 97d2fb
Packit Service 97d2fb
testrun_elfcompress()
Packit Service 97d2fb
{
Packit Service 97d2fb
    testfile="$1"
Packit Service 97d2fb
    testfiles ${testfile}
Packit Service 97d2fb
    testrun_elfcompress_file ${testfile}
Packit Service 97d2fb
Packit Service 97d2fb
    # Merge the string tables to make things a little more interesting.
Packit Service 97d2fb
    mergedfile="${testfile}.merged"
Packit Service 97d2fb
    tempfiles ${mergedfile}
Packit Service 97d2fb
    echo "merging string tables ${testfile} -> ${mergedfile}"
Packit Service 97d2fb
    testrun ${abs_top_builddir}/tests/elfstrmerge -o ${mergedfile} ${testfile}
Packit Service 97d2fb
    testrun_elfcompress_file ${mergedfile}
Packit Service 97d2fb
}
Packit Service 97d2fb
Packit Service 97d2fb
# Random ELF32 testfile
Packit Service 97d2fb
testrun_elfcompress testfile4
Packit Service 97d2fb
Packit Service 97d2fb
# Random ELF64 testfile
Packit Service 97d2fb
testrun_elfcompress testfile12
Packit Service 97d2fb
Packit Service 97d2fb
# Random ELF64BE testfile
Packit Service 97d2fb
testrun_elfcompress testfileppc64
Packit Service 97d2fb
Packit Service 97d2fb
# Random ELF32BE testfile
Packit Service 97d2fb
testrun_elfcompress testfileppc32
Packit Service 97d2fb
Packit Service 97d2fb
# Already compressed files
Packit Service 97d2fb
testrun_elfcompress testfile-zgnu64
Packit Service 97d2fb
testrun_elfcompress testfile-zgnu64be
Packit Service 97d2fb
testrun_elfcompress testfile-zgabi64
Packit Service 97d2fb
testrun_elfcompress testfile-zgabi64be
Packit Service 97d2fb
testrun_elfcompress testfile-zgnu32
Packit Service 97d2fb
testrun_elfcompress testfile-zgnu32be
Packit Service 97d2fb
testrun_elfcompress testfile-zgabi32
Packit Service 97d2fb
testrun_elfcompress testfile-zgabi32be
Packit Service 97d2fb
Packit Service 97d2fb
exit 0