diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 5 | ||||
-rwxr-xr-x | tests/force-rpath.sh | 39 | ||||
-rwxr-xr-x | tests/output-flag.sh | 38 | ||||
-rwxr-xr-x | tests/plain-needed.sh | 4 | ||||
-rwxr-xr-x | tests/set-rpath-library.sh | 1 |
5 files changed, 85 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 32218e8..d2d58b0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,7 +21,10 @@ no_rpath_arch_TESTS = \ 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 soname.sh shrink-rpath-with-allowed-prefixes.sh + set-rpath-library.sh soname.sh shrink-rpath-with-allowed-prefixes.sh \ + force-rpath.sh \ + plain-needed.sh \ + output-flag.sh build_TESTS = \ $(no_rpath_arch_TESTS) diff --git a/tests/force-rpath.sh b/tests/force-rpath.sh new file mode 100755 index 0000000..9256905 --- /dev/null +++ b/tests/force-rpath.sh @@ -0,0 +1,39 @@ +#! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) + +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} + +SCRATCHFILE=${SCRATCH}/libfoo.so +cp libfoo.so $SCRATCHFILE + +doit() { + echo patchelf $* + ../src/patchelf $* $SCRATCHFILE +} + +expect() { + out=$(echo $(objdump -x $SCRATCHFILE | grep PATH)) + + if [ "$out" != "$*" ]; then + echo "Expected '$*' but got '$out'" + exit 1 + fi +} + +doit --remove-rpath +expect +doit --set-rpath foo +expect RUNPATH foo +doit --force-rpath --set-rpath foo +expect RPATH foo +doit --force-rpath --set-rpath bar +expect RPATH bar +doit --remove-rpath +expect +doit --force-rpath --set-rpath foo +expect RPATH foo +doit --set-rpath foo +expect RUNPATH foo +doit --set-rpath bar +expect RUNPATH bar diff --git a/tests/output-flag.sh b/tests/output-flag.sh new file mode 100755 index 0000000..5da26b5 --- /dev/null +++ b/tests/output-flag.sh @@ -0,0 +1,38 @@ +#! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) + +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} +mkdir -p ${SCRATCH}/libsA +mkdir -p ${SCRATCH}/libsB + +cp main ${SCRATCH}/ +cp libfoo.so ${SCRATCH}/libsA/ +cp libbar.so ${SCRATCH}/libsB/ + +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/main) +if test -z "$oldRPath"; then oldRPath="/oops"; fi + +../src/patchelf --force-rpath --set-rpath $oldRPath:$(pwd)/${SCRATCH}/libsA:$(pwd)/${SCRATCH}/libsB ${SCRATCH}/main --output ${SCRATCH}/main2 +# make sure it copies even when there is nothing to do (because rpath is already set) +../src/patchelf --force-rpath --set-rpath $oldRPath:$(pwd)/${SCRATCH}/libsA:$(pwd)/${SCRATCH}/libsB ${SCRATCH}/main2 --output ${SCRATCH}/main3 + +if test "$(uname)" = FreeBSD; then + export LD_LIBRARY_PATH=$(pwd)/${SCRATCH}/libsB +fi + +exitCode=0 +(cd ${SCRATCH} && ./main2) || exitCode=$? + +if test "$exitCode" != 46; then + echo "bad exit code!" + exit 1 +fi + +exitCode=0 +(cd ${SCRATCH} && ./main3) || exitCode=$? + +if test "$exitCode" != 46; then + echo "bad exit code!" + exit 1 +fi diff --git a/tests/plain-needed.sh b/tests/plain-needed.sh new file mode 100755 index 0000000..36267fb --- /dev/null +++ b/tests/plain-needed.sh @@ -0,0 +1,4 @@ +#! /bin/sh +set -e +echo "Confirming main requires libfoo" +../src/patchelf --print-needed main | grep -q libfoo.so diff --git a/tests/set-rpath-library.sh b/tests/set-rpath-library.sh index dd1381f..a5c8ca7 100755 --- a/tests/set-rpath-library.sh +++ b/tests/set-rpath-library.sh @@ -26,7 +26,6 @@ exitCode=0 if test "$exitCode" = 46; then echo "expected failure" - exit 1 fi # So set an RUNPATH on libfoo as well. |