summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-09-29 14:21:40 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-09-29 14:21:40 +0000
commit4f3658be12a882a0e09bba96a01010c50b20ff5c (patch)
tree6e395ffa3a34ef8da2da76e6e0896ae45970292d /tests
parent111c97cf888df0ebf9d30125fe2456b9e638cd12 (diff)
downloadpatchelf-4f3658be12a882a0e09bba96a01010c50b20ff5c.tar.gz
* Added some real tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am9
-rwxr-xr-xtests/set-interpreter.sh22
-rwxr-xr-xtests/shrink.sh21
-rw-r--r--tests/simple.c9
4 files changed, 58 insertions, 3 deletions
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 <stdio.h>
+
+char buf[16 * 1024 * 1024];
+
+int main(int argc, char * * argv)
+{
+ printf("Hello World\n");
+ return 0;
+}