From 4f3658be12a882a0e09bba96a01010c50b20ff5c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 29 Sep 2005 14:21:40 +0000 Subject: * Added some real tests. --- tests/Makefile.am | 9 ++++++--- tests/set-interpreter.sh | 22 ++++++++++++++++++++++ tests/shrink.sh | 21 +++++++++++++++++++++ tests/simple.c | 9 +++++++++ 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100755 tests/set-interpreter.sh create mode 100755 tests/shrink.sh create mode 100644 tests/simple.c diff --git a/tests/Makefile.am b/tests/Makefile.am index bbffa02..e8c176a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,10 +1,13 @@ -check_PROGRAMS = main +check_PROGRAMS = main simple -TESTS = plain-run.sh $(XFAIL_TESTS) +TESTS = plain-run.sh shrink.sh set-interpreter.sh $(XFAIL_TESTS) XFAIL_TESTS = plain-fail.sh +simple_SOURCES = simple.c + + main: main.o libfoo.so LD_LIBRARY_PATH=. $(CC) -o main main.o -L . -lfoo @@ -12,7 +15,7 @@ main.o: main.c $(CC) -fpic -o main.o -c main.c libfoo.so: foo.o libbar.so - $(CC) -shared -o libfoo.so foo.o -L . -lbar + $(CC) -shared -o libfoo.so foo.o -L . -lbar -Wl,-rpath,/no-such-path foo.o: foo.c $(CC) -fpic -o foo.o -c foo.c diff --git a/tests/set-interpreter.sh b/tests/set-interpreter.sh new file mode 100755 index 0000000..5d8a4e9 --- /dev/null +++ b/tests/set-interpreter.sh @@ -0,0 +1,22 @@ +#! /bin/sh -e + +./simple + +oldInterpreter=$(../src/patchelf --print-interpreter ./simple) +echo "current interpreter is $oldInterpreter" + +rm -rf scratch +mkdir -p scratch + +cp simple scratch/ +../src/patchelf --interpreter $(pwd)/scratch/interpreter scratch/simple + +echo "running with missing interpreter..." +if scratch/simple; then + echo "simple works, but it shouldn't" + exit 1 +fi + +echo "running with new interpreter..." +ln -s "$oldInterpreter" scratch/interpreter +scratch/simple diff --git a/tests/shrink.sh b/tests/shrink.sh new file mode 100755 index 0000000..fe50346 --- /dev/null +++ b/tests/shrink.sh @@ -0,0 +1,21 @@ +#! /bin/sh -e + +echo -n "RPATH before: " +readelf -a ./libfoo.so | grep RPATH +if ! readelf -a ./libfoo.so | grep RPATH | grep -q /no-such-path; then + echo "incomplete RPATH" + exit 1 +fi + +rm -rf scratch +mkdir -p scratch +cp libfoo.so scratch/ +../src/patchelf --shrink-rpath scratch/libfoo.so + +echo -n "RPATH after: " +readelf -a scratch/libfoo.so | grep RPATH +if readelf -a scratch/libfoo.so | grep RPATH | grep -q /no-such-path; then + echo "incomplete RPATH" + exit 1 +fi + diff --git a/tests/simple.c b/tests/simple.c new file mode 100644 index 0000000..62e6d62 --- /dev/null +++ b/tests/simple.c @@ -0,0 +1,9 @@ +#include + +char buf[16 * 1024 * 1024]; + +int main(int argc, char * * argv) +{ + printf("Hello World\n"); + return 0; +} -- cgit v1.2.1