Home | History | Annotate | Download | only in tests
      1 #! /bin/bash
      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 if ! grep -q -F '#define _FILE_OFFSET_BITS' ${abs_top_builddir}/config.h; then
     21   echo "LFS testing is irrelevent on this system"
     22   exit 77
     23 fi
     24 
     25 # #include <stdio.h>
     26 # int main () {
     27 #     FILE *f = fopen ("/dev/null", "r");
     28 #     return f == NULL;
     29 # }
     30 #
     31 # Built for Linux i686, without setting _FILE_OFFSET_BITS.
     32 # $ gcc -m32 -O2 nolfs.c -o testfile-nolfs
     33 testfiles testfile-nolfs
     34 
     35 LFS_FORMAT='BEGIN {
     36   while ((getline < "%s") > 0)
     37     /^\w/ && bad[$0]
     38   FS="@"
     39 }
     40 /@@GLIBC_/ && $1 in bad { print $1 }'
     41 
     42 LFS=$(printf "$LFS_FORMAT" "${abs_srcdir}/lfs-symbols")
     43 
     44 makeprint() {
     45   make print-$1 -C $2 |& awk -F= "/^$1=/{ print \$2 }"
     46 }
     47 
     48 testrun_lfs() {
     49   bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS")
     50   if [ -n "$bad" ]; then
     51     echo "$1 contains non-lfs symbols:" $bad
     52     exit_status=1
     53   fi
     54 }
     55 
     56 # First sanity-check that LFS detection works.
     57 exit_status=0
     58 testrun_lfs ./testfile-nolfs
     59 if [ $exit_status -eq 0 ]; then
     60   echo "Didn't detect any problem with testfile-nolfs!"
     61   exit 99
     62 fi
     63 
     64 exit_status=0
     65 
     66 # Check all normal build targets.
     67 for dir in libelf libdw libasm libcpu src; do
     68   dir=${abs_top_builddir}/$dir
     69   for program in $(makeprint PROGRAMS $dir); do
     70     testrun_lfs $dir/$program
     71   done
     72 done
     73 
     74 # Check all libebl modules.
     75 dir=${abs_top_builddir}/backends
     76 for module in $(makeprint modules $dir); do
     77   testrun_lfs $dir/libebl_$module.so
     78 done
     79 
     80 # Check all test programs.
     81 dir=${abs_builddir}
     82 for program in $(makeprint check_PROGRAMS $dir); do
     83   testrun_lfs $dir/$program
     84 done
     85 
     86 exit $exit_status
     87