From c4220eaf0f552cfd68148ddefd6455ff2ce0e08c Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Wed, 11 Jul 2012 10:09:24 +0200 Subject: rewrite no-rpath test * compile locally this test in the no-rpath test * add tests for prebuilt no-rpath binaries on various ELF platforms => ia64 does not work, probably a bug in patchelf. Marking it as XFAIL for now --- tests/Makefile.am | 40 ++++++++++++++++++++--- tests/no-rpath | Bin 2848 -> 0 bytes tests/no-rpath-prebuild.sh | 41 ++++++++++++++++++++++++ tests/no-rpath-prebuild/no-rpath-amd64 | Bin 0 -> 9514 bytes tests/no-rpath-prebuild/no-rpath-armel | Bin 0 -> 7516 bytes tests/no-rpath-prebuild/no-rpath-armhf | Bin 0 -> 7451 bytes tests/no-rpath-prebuild/no-rpath-hurd-i386 | Bin 0 -> 7508 bytes tests/no-rpath-prebuild/no-rpath-i386 | Bin 0 -> 7328 bytes tests/no-rpath-prebuild/no-rpath-ia64 | Bin 0 -> 10745 bytes tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 | Bin 0 -> 9526 bytes tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 | Bin 0 -> 7296 bytes tests/no-rpath-prebuild/no-rpath-mips | Bin 0 -> 8198 bytes tests/no-rpath-prebuild/no-rpath-mipsel | Bin 0 -> 8202 bytes tests/no-rpath-prebuild/no-rpath-powerpc | Bin 0 -> 7746 bytes tests/no-rpath-prebuild/no-rpath-s390 | Bin 0 -> 7308 bytes tests/no-rpath-prebuild/no-rpath-sh4 | Bin 0 -> 7223 bytes tests/no-rpath-prebuild/no-rpath-sparc | Bin 0 -> 7197 bytes tests/no-rpath.c | 6 ++++ tests/no-rpath.sh | 6 ++-- 19 files changed, 85 insertions(+), 8 deletions(-) delete mode 100755 tests/no-rpath create mode 100755 tests/no-rpath-prebuild.sh create mode 100755 tests/no-rpath-prebuild/no-rpath-amd64 create mode 100755 tests/no-rpath-prebuild/no-rpath-armel create mode 100755 tests/no-rpath-prebuild/no-rpath-armhf create mode 100755 tests/no-rpath-prebuild/no-rpath-hurd-i386 create mode 100755 tests/no-rpath-prebuild/no-rpath-i386 create mode 100755 tests/no-rpath-prebuild/no-rpath-ia64 create mode 100755 tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 create mode 100755 tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 create mode 100755 tests/no-rpath-prebuild/no-rpath-mips create mode 100755 tests/no-rpath-prebuild/no-rpath-mipsel create mode 100755 tests/no-rpath-prebuild/no-rpath-powerpc create mode 100755 tests/no-rpath-prebuild/no-rpath-s390 create mode 100755 tests/no-rpath-prebuild/no-rpath-sh4 create mode 100755 tests/no-rpath-prebuild/no-rpath-sparc create mode 100644 tests/no-rpath.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 9a38df6..fb98023 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,15 +1,43 @@ -check_PROGRAMS = simple main main-scoped big-dynstr +check_PROGRAMS = simple main main-scoped big-dynstr no-rpath -TESTS = plain-fail.sh plain-run.sh shrink-rpath.sh set-interpreter-short.sh \ +no_rpath_arch_TESTS = \ + no-rpath-amd64.sh \ + no-rpath-armel.sh \ + no-rpath-armhf.sh \ + no-rpath-hurd-i386.sh \ + no-rpath-i386.sh \ + no-rpath-ia64.sh \ + no-rpath-kfreebsd-amd64.sh \ + no-rpath-kfreebsd-i386.sh \ + no-rpath-mips.sh \ + no-rpath-mipsel.sh \ + no-rpath-powerpc.sh \ + no-rpath-s390.sh \ + no-rpath-sh4.sh \ + no-rpath-sparc.sh + +XFAIL_TESTS = no-rpath-ia64.sh + +src_TESTS = \ + plain-fail.sh plain-run.sh shrink-rpath.sh set-interpreter-short.sh \ set-interpreter-long.sh set-rpath.sh no-rpath.sh big-dynstr.sh \ set-rpath-library.sh -EXTRA_DIST = no-rpath $(TESTS) + +build_TESTS = \ + $(no_rpath_arch_TESTS) + +TESTS= $(src_TESTS) $(build_TESTS) + +EXTRA_DIST = no-rpath-prebuild $(src_TESTS) no-rpath-prebuild.sh TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 +$(no_rpath_arch_TESTS): no-rpath-prebuild.sh + @ln -s $< $@ + CLEANFILES = big-dynstr.c clean-local: - $(RM) -r scratch + $(RM) -r scratch $(no_rpath_arch_TESTS) # by default, use -fpic to compile AM_CFLAGS = -fpic @@ -62,3 +90,7 @@ libbar_so_LDFLAGS = $(LDFLAGS_sharedlib) -Wl,-rpath,`pwd`/no-such-path libbar_scoped_so_SOURCES = bar.c libbar_scoped_so_LDFLAGS = $(LDFLAGS_sharedlib) +no_rpath_SOURCES = no-rpath.c +# no -fpic for no-rpath.o +no_rpath_CFLAGS = + diff --git a/tests/no-rpath b/tests/no-rpath deleted file mode 100755 index b454dfe..0000000 Binary files a/tests/no-rpath and /dev/null differ diff --git a/tests/no-rpath-prebuild.sh b/tests/no-rpath-prebuild.sh new file mode 100755 index 0000000..0fc96d2 --- /dev/null +++ b/tests/no-rpath-prebuild.sh @@ -0,0 +1,41 @@ +#! /bin/sh -e +ARCH="$1" +SCRATCH=scratch/no-rpath-$ARCH + +if [ -z "$ARCH" ]; then + ARCH=$(basename $0 .sh | sed -e 's/.*-//') +fi + +if [ -z "$ARCH" ] || [ $ARCH = prebuild ] ; then + echo "Architecture required" + exit 1 +fi + +no_rpath_bin="${srcdir}/no-rpath-prebuild/no-rpath-$ARCH" + +if [ ! -f $no_rpath_bin ]; then + echo "no 'no-rpath' binary for '$ARCH' in '${srcdir}/no-rpath-prebuild'" + exit 1 +fi + +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} + +cp $no_rpath_bin ${SCRATCH}/no-rpath + +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) +if test -n "$oldRPath"; then exit 1; fi +../src/patchelf \ + --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \ + --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath + +newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) +if ! echo "$newRPath" | grep -q '/foo:/bar'; then + echo "incomplete RPATH" + exit 1 +fi + +if [ "$(../src/patchelf --print-interpreter $no_rpath_bin)" \ + = "$(../src/patchelf --print-interpreter ../src/patchelf)" ]; then + cd ${SCRATCH} && ./no-rpath +fi diff --git a/tests/no-rpath-prebuild/no-rpath-amd64 b/tests/no-rpath-prebuild/no-rpath-amd64 new file mode 100755 index 0000000..f457704 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-amd64 differ diff --git a/tests/no-rpath-prebuild/no-rpath-armel b/tests/no-rpath-prebuild/no-rpath-armel new file mode 100755 index 0000000..8a9f879 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-armel differ diff --git a/tests/no-rpath-prebuild/no-rpath-armhf b/tests/no-rpath-prebuild/no-rpath-armhf new file mode 100755 index 0000000..aaaef60 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-armhf differ diff --git a/tests/no-rpath-prebuild/no-rpath-hurd-i386 b/tests/no-rpath-prebuild/no-rpath-hurd-i386 new file mode 100755 index 0000000..762c451 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-hurd-i386 differ diff --git a/tests/no-rpath-prebuild/no-rpath-i386 b/tests/no-rpath-prebuild/no-rpath-i386 new file mode 100755 index 0000000..07b3821 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-i386 differ diff --git a/tests/no-rpath-prebuild/no-rpath-ia64 b/tests/no-rpath-prebuild/no-rpath-ia64 new file mode 100755 index 0000000..4b65d7c Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-ia64 differ diff --git a/tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 b/tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 new file mode 100755 index 0000000..d7a2644 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 differ diff --git a/tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 b/tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 new file mode 100755 index 0000000..36c0ed3 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 differ diff --git a/tests/no-rpath-prebuild/no-rpath-mips b/tests/no-rpath-prebuild/no-rpath-mips new file mode 100755 index 0000000..2cc2d28 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-mips differ diff --git a/tests/no-rpath-prebuild/no-rpath-mipsel b/tests/no-rpath-prebuild/no-rpath-mipsel new file mode 100755 index 0000000..0a6ae88 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-mipsel differ diff --git a/tests/no-rpath-prebuild/no-rpath-powerpc b/tests/no-rpath-prebuild/no-rpath-powerpc new file mode 100755 index 0000000..9abb07e Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-powerpc differ diff --git a/tests/no-rpath-prebuild/no-rpath-s390 b/tests/no-rpath-prebuild/no-rpath-s390 new file mode 100755 index 0000000..1334eab Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-s390 differ diff --git a/tests/no-rpath-prebuild/no-rpath-sh4 b/tests/no-rpath-prebuild/no-rpath-sh4 new file mode 100755 index 0000000..6135f0a Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-sh4 differ diff --git a/tests/no-rpath-prebuild/no-rpath-sparc b/tests/no-rpath-prebuild/no-rpath-sparc new file mode 100755 index 0000000..a87bb59 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-sparc differ diff --git a/tests/no-rpath.c b/tests/no-rpath.c new file mode 100644 index 0000000..e6a5b85 --- /dev/null +++ b/tests/no-rpath.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello world\n"); + return 0; +} diff --git a/tests/no-rpath.sh b/tests/no-rpath.sh index 20c720c..3efa7f1 100755 --- a/tests/no-rpath.sh +++ b/tests/no-rpath.sh @@ -4,7 +4,7 @@ SCRATCH=scratch/$(basename $0 .sh) rm -rf ${SCRATCH} mkdir -p ${SCRATCH} -cp ${srcdir}/no-rpath ${SCRATCH}/ +cp no-rpath ${SCRATCH}/ oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) if test -n "$oldRPath"; then exit 1; fi @@ -18,6 +18,4 @@ if ! echo "$newRPath" | grep -q '/foo:/bar'; then exit 1 fi -if [ "$(uname -m)" = i686 -a "$(uname -s)" = Linux ]; then - cd ${SCRATCH} && ./no-rpath -fi +cd ${SCRATCH} && ./no-rpath -- cgit v0.12