Blame tests/run-lfs-symbols.sh

Packit 032894
#! /bin/bash
Packit 032894
# Copyright (C) 2015 Red Hat, Inc.
Packit 032894
# This file is part of elfutils.
Packit 032894
#
Packit 032894
# This file is free software; you can redistribute it and/or modify
Packit 032894
# it under the terms of the GNU General Public License as published by
Packit 032894
# the Free Software Foundation; either version 3 of the License, or
Packit 032894
# (at your option) any later version.
Packit 032894
#
Packit 032894
# elfutils is distributed in the hope that it will be useful, but
Packit 032894
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
# GNU General Public License for more details.
Packit 032894
#
Packit 032894
# You should have received a copy of the GNU General Public License
Packit 032894
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
if ! grep -q -F '#define _FILE_OFFSET_BITS' ${abs_top_builddir}/config.h; then
Packit 032894
  echo "LFS testing is irrelevent on this system"
Packit 032894
  exit 77
Packit 032894
fi
Packit 032894
Packit 032894
# #include <stdio.h>
Packit 032894
# int main () {
Packit 032894
#     FILE *f = fopen ("/dev/null", "r");
Packit 032894
#     return f == NULL;
Packit 032894
# }
Packit 032894
#
Packit 032894
# Built for Linux i686, without setting _FILE_OFFSET_BITS.
Packit 032894
# $ gcc -m32 -O2 nolfs.c -o testfile-nolfs
Packit 032894
testfiles testfile-nolfs
Packit 032894
Packit 032894
LFS_FORMAT='BEGIN {
Packit 032894
  while ((getline < "%s") > 0)
Packit 032894
    /^\w/ && bad[$0]
Packit 032894
  FS="@"
Packit 032894
}
Packit 032894
/@@GLIBC_/ && $1 in bad { print $1 }'
Packit 032894
Packit 032894
LFS=$(printf "$LFS_FORMAT" "${abs_srcdir}/lfs-symbols")
Packit 032894
Packit 032894
makeprint() {
Packit 032894
  make print-$1 -C $2 |& awk -F= "/^$1=/{ print \$2 }"
Packit 032894
}
Packit 032894
Packit 032894
testrun_lfs() {
Packit 032894
  bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS")
Packit 032894
  if [ -n "$bad" ]; then
Packit 032894
    echo "$1 contains non-lfs symbols:" $bad
Packit 032894
    exit_status=1
Packit 032894
  fi
Packit 032894
}
Packit 032894
Packit 032894
# First sanity-check that LFS detection works.
Packit 032894
exit_status=0
Packit 032894
testrun_lfs ./testfile-nolfs
Packit 032894
if [ $exit_status -eq 0 ]; then
Packit 032894
  echo "Didn't detect any problem with testfile-nolfs!"
Packit 032894
  exit 99
Packit 032894
fi
Packit 032894
Packit 032894
exit_status=0
Packit 032894
Packit 032894
# Check all normal build targets.
Packit 032894
for dir in libelf libdw libasm libcpu src; do
Packit 032894
  dir=${abs_top_builddir}/$dir
Packit 032894
  for program in $(makeprint PROGRAMS $dir); do
Packit 032894
    testrun_lfs $dir/$program
Packit 032894
  done
Packit 032894
done
Packit 032894
Packit 032894
# Check all libebl modules.
Packit 032894
dir=${abs_top_builddir}/backends
Packit 032894
for module in $(makeprint modules $dir); do
Packit 032894
  testrun_lfs $dir/libebl_$module.so
Packit 032894
done
Packit 032894
Packit 032894
# Check all test programs.
Packit 032894
dir=${abs_builddir}
Packit 032894
for program in $(makeprint check_PROGRAMS $dir); do
Packit 032894
  testrun_lfs $dir/$program
Packit 032894
done
Packit 032894
Packit 032894
exit $exit_status