diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChangeLog | 17 | ||||
-rw-r--r-- | tests/Makefile.am | 5 | ||||
-rw-r--r-- | tests/alldts.c | 2 | ||||
-rw-r--r-- | tests/arls.c | 4 | ||||
-rw-r--r-- | tests/dwarf-getstring.c | 2 | ||||
-rw-r--r-- | tests/ecp.c | 4 | ||||
-rw-r--r-- | tests/lfs-symbols | 73 | ||||
-rw-r--r-- | tests/rdwrmmap.c | 4 | ||||
-rwxr-xr-x | tests/run-lfs-symbols.sh | 86 | ||||
-rw-r--r-- | tests/test-elf_cntl_gelf_getshdr.c | 4 | ||||
-rw-r--r-- | tests/test-flag-nobits.c | 6 | ||||
-rw-r--r-- | tests/testfile-nolfs.bz2 | bin | 0 -> 2563 bytes |
12 files changed, 202 insertions, 5 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 523a3506..11515501 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,20 @@ +2015-10-09 Josh Stone <[email protected]> + + * lfs-symbols: New list of LFS-related symbols from lintian. + * testfile-nolfs.bz2: New test binary for sanity checking. + * run-lfs-symbols.sh: New test. + * Makefile.am (TESTS): Add run-lfs-symbols.sh. + (EXTRA_DIST): Add lfs-symbols, testfile-nolfs.bz2, and + run-lfs-symbols.sh. + * alldts.c (main): Replace open64 with open. + * dwarf-getstring.c (main): Likewise. + * arls.c: Include config.h. + * ecp.c: Likewise. + * rdwrmmap.c: Likewise. + * test-elf_cntl_gelf_getshdr.c: Likewise. + * test-flag-nobits.c: Include config.h. + (main): Replace open64 with open. + 2015-10-09 Mark Wielaard <[email protected]> * elfshphehdr.c (check): Rename argument from check to statement. diff --git a/tests/Makefile.am b/tests/Makefile.am index fc9b648d..5612fc7b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -120,7 +120,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \ run-linkmap-cut.sh run-aggregate-size.sh vdsosyms run-readelf-A.sh \ run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \ - elfshphehdr + elfshphehdr run-lfs-symbols.sh if !BIARCH export ELFUTILS_DISABLE_BIARCH = 1 @@ -303,7 +303,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-getsrc-die.sh run-strptr.sh \ testfile-x32-core.bz2 testfile-x32.bz2 \ backtrace.x32.core.bz2 backtrace.x32.exec.bz2 \ - testfile-x32-s.bz2 testfile-x32-d.bz2 testfile-x32-debug.bz2 + testfile-x32-s.bz2 testfile-x32-d.bz2 testfile-x32-debug.bz2 \ + run-lfs-symbols.sh lfs-symbols testfile-nolfs.bz2 if USE_VALGRIND valgrind_cmd='valgrind -q --error-exitcode=1 --run-libc-freeres=no' diff --git a/tests/alldts.c b/tests/alldts.c index 378aa412..c39b8fb6 100644 --- a/tests/alldts.c +++ b/tests/alldts.c @@ -68,7 +68,7 @@ main (void) (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER); /* Open the file. */ - int fd = open64 (fname, O_RDWR | O_CREAT | O_TRUNC, 0666); + int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd == -1) { printf ("cannot open `%s': %m\n", fname); diff --git a/tests/arls.c b/tests/arls.c index cd8e4b81..ca0d3e6e 100644 --- a/tests/arls.c +++ b/tests/arls.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <ar.h> #include <fcntl.h> #include <libelf.h> diff --git a/tests/dwarf-getstring.c b/tests/dwarf-getstring.c index b70c2a70..824edef8 100644 --- a/tests/dwarf-getstring.c +++ b/tests/dwarf-getstring.c @@ -37,7 +37,7 @@ main (int argc, char *argv[]) Dwarf_Off offset = 0; size_t len; - int fd = open64 (argv[cnt], O_RDONLY); + int fd = open (argv[cnt], O_RDONLY); if (fd == -1) { printf ("cannot open '%s': %m\n", argv[cnt]); diff --git a/tests/ecp.c b/tests/ecp.c index 39a48510..38a6859e 100644 --- a/tests/ecp.c +++ b/tests/ecp.c @@ -15,6 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <errno.h> #include <error.h> #include <fcntl.h> diff --git a/tests/lfs-symbols b/tests/lfs-symbols new file mode 100644 index 00000000..282a4ad4 --- /dev/null +++ b/tests/lfs-symbols @@ -0,0 +1,73 @@ +# Imported from lintian/data/binaries/lfs-symbols +# +# Exceptions: +# fts* - linux-kernel-modules.c is careful with FTS_NOSTAT + +# Manually maintained list of non-lfs symbols +# +# List was found by grepping around in /usr/include on an i386 system +# with build-essential installed +# +# Please keep this sorted by key. + +__fxstat +__fxstatat +__lxstat +__xstat +aio_cancel +aio_error +aio_fsync +aio_read +aio_return +aio_suspend +aio_write +alphasort +creat +fallocate +fgetpos +fopen +freopen +fseeko +fsetpos +fstatfs +fstatvfs +ftello +ftruncate +#fts_open +#fts_read +#fts_children +#fts_set +#fts_close +ftw +getdirentries +getrlimit +glob +globfree +lio_listio +lockf +lseek +mkostemp +mkostemps +mkstemp +mkstemps +mmap +nftw +open +openat +posix_fadvise +posix_fallocate +pread +preadv +prlimit +pwrite +pwritev +readdir +readdir_r +scandir +sendfile +setrlimit +statfs +statvfs +tmpfile +truncate +versionsort diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c index 95a4df35..6f027dfe 100644 --- a/tests/rdwrmmap.c +++ b/tests/rdwrmmap.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <errno.h> #include <error.h> #include <stdio.h> diff --git a/tests/run-lfs-symbols.sh b/tests/run-lfs-symbols.sh new file mode 100755 index 00000000..f0894405 --- /dev/null +++ b/tests/run-lfs-symbols.sh @@ -0,0 +1,86 @@ +#! /bin/bash +# Copyright (C) 2015 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +. $srcdir/test-subr.sh + +if ! grep -q -F '#define _FILE_OFFSET_BITS' ${abs_top_builddir}/config.h; then + echo "LFS testing is irrelevent on this system" + exit 77 +fi + +# #include <stdio.h> +# int main () { +# FILE *f = fopen ("/dev/null", "r"); +# return f == NULL; +# } +# +# Built for Linux i686, without setting _FILE_OFFSET_BITS. +# $ gcc -m32 -O2 nolfs.c -o testfile-nolfs +testfiles testfile-nolfs + +LFS_FORMAT='BEGIN { + while ((getline < "%s") > 0) + /^\w/ && bad[$0] + FS="@" +} +/@@GLIBC_/ && $1 in bad { print $1 }' + +LFS=$(printf "$LFS_FORMAT" "${abs_srcdir}/lfs-symbols") + +makeprint() { + make print-$1 -C $2 |& awk -F= "/^$1=/{ print \$2 }" +} + +testrun_lfs() { + bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS") + if [ -n "$bad" ]; then + echo "$1 contains non-lfs symbols:" $bad + exit_status=1 + fi +} + +# First sanity-check that LFS detection works. +exit_status=0 +testrun_lfs ./testfile-nolfs +if [ $exit_status -eq 0 ]; then + echo "Didn't detect any problem with testfile-nolfs!" + exit 99 +fi + +exit_status=0 + +# Check all normal build targets. +for dir in libelf libdw libasm libcpu src; do + dir=${abs_top_builddir}/$dir + for program in $(makeprint PROGRAMS $dir); do + testrun_lfs $dir/$program + done +done + +# Check all libebl modules. +dir=${abs_top_builddir}/backends +for module in $(makeprint modules $dir); do + testrun_lfs $dir/libebl_$module.so +done + +# Check all test programs. +dir=${abs_builddir} +for program in $(makeprint check_PROGRAMS $dir); do + testrun_lfs $dir/$program +done + +exit $exit_status diff --git a/tests/test-elf_cntl_gelf_getshdr.c b/tests/test-elf_cntl_gelf_getshdr.c index b561b53c..7371110c 100644 --- a/tests/test-elf_cntl_gelf_getshdr.c +++ b/tests/test-elf_cntl_gelf_getshdr.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> diff --git a/tests/test-flag-nobits.c b/tests/test-flag-nobits.c index e58d8c3d..ff19ce20 100644 --- a/tests/test-flag-nobits.c +++ b/tests/test-flag-nobits.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <fcntl.h> #include <stdlib.h> #include <gelf.h> @@ -26,7 +30,7 @@ main (int argc, char **argv) elf_version (EV_CURRENT); - int fd = open64 (argv[1], O_RDONLY); + int fd = open (argv[1], O_RDONLY); Elf *stripped = elf_begin (fd, ELF_C_READ, NULL); Elf_Scn *scn = NULL; diff --git a/tests/testfile-nolfs.bz2 b/tests/testfile-nolfs.bz2 Binary files differnew file mode 100644 index 00000000..ab8351e9 --- /dev/null +++ b/tests/testfile-nolfs.bz2 |