Home | History | Annotate | Download | only in tests
      1 #! /bin/sh
      2 # Copyright (C) 2015 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 # uncompress -> gnucompress -> uncompress -> elfcompress -> uncompress
     21 testrun_elfcompress_file()
     22 {
     23     infile="$1"
     24     uncompressedfile="${infile}.uncompressed"
     25     tempfiles "$uncompressedfile"
     26     
     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}
     30 
     31     SIZE_uncompressed=$(stat -c%s $uncompressedfile)
     32 
     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}
     38 
     39     SIZE_gnucompressed=$(stat -c%s $gnucompressedfile)
     40     test $SIZE_gnucompressed -lt $SIZE_uncompressed ||
     41 	{ echo "*** failure $gnucompressedfile not smaller"; exit -1; }
     42     
     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}
     48 
     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}
     54 
     55     SIZE_elfcompressed=$(stat -c%s $elfcompressedfile)
     56     test $SIZE_elfcompressed -lt $SIZE_uncompressed ||
     57 	{ echo "*** failure $elfcompressedfile not smaller"; exit -1; }
     58     
     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}
     64 }
     65 
     66 testrun_elfcompress()
     67 {
     68     testfile="$1"
     69     testfiles ${testfile}
     70     testrun_elfcompress_file ${testfile}
     71 
     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}
     78 }
     79 
     80 # Random ELF32 testfile
     81 testrun_elfcompress testfile4
     82 
     83 # Random ELF64 testfile
     84 testrun_elfcompress testfile12
     85 
     86 # Random ELF64BE testfile
     87 testrun_elfcompress testfileppc64
     88 
     89 # Random ELF32BE testfile
     90 testrun_elfcompress testfileppc32
     91 
     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
    101 
    102 exit 0
    103