Skip to content

Commit

Permalink
rewrite no-rpath test
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
vdanjean committed Jul 11, 2012
1 parent e49720c commit c4220ea
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 8 deletions.
40 changes: 36 additions & 4 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 =

Binary file removed tests/no-rpath
Binary file not shown.
41 changes: 41 additions & 0 deletions tests/no-rpath-prebuild.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/no-rpath-prebuild/no-rpath-amd64
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-armel
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-armhf
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-hurd-i386
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-i386
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-ia64
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-kfreebsd-i386
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-mips
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-mipsel
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-powerpc
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-s390
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-sh4
Binary file not shown.
Binary file added tests/no-rpath-prebuild/no-rpath-sparc
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/no-rpath.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main() {
printf("Hello world\n");
return 0;
}
6 changes: 2 additions & 4 deletions tests/no-rpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit c4220ea

Please sign in to comment.