summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-09-29 12:03:56 (GMT)
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-09-29 12:03:56 (GMT)
commit0da4ea8b6510e0d00ccf1eb0c52599532d8c4bb3 (patch)
treedf46cf02ddc181cc75db90055bf9d4ed1aa96e79
parent0177cc4483979b5b216240e0b1340ce97dd84113 (diff)
downloadpatchelf-0da4ea8b6510e0d00ccf1eb0c52599532d8c4bb3.zip
patchelf-0da4ea8b6510e0d00ccf1eb0c52599532d8c4bb3.tar.gz
patchelf-0da4ea8b6510e0d00ccf1eb0c52599532d8c4bb3.tar.bz2
* Add tests.
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac4
-rw-r--r--src/Makefile.am3
-rw-r--r--src/patchelf.c (renamed from patchelf.c)0
-rw-r--r--tests/Makefile.am27
-rw-r--r--tests/bar.c7
-rw-r--r--tests/foo.c9
-rw-r--r--tests/main.c (renamed from test.c)6
-rwxr-xr-xtests/plain-fail.sh2
-rwxr-xr-xtests/plain-run.sh7
10 files changed, 63 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index 5a7c726..a459377 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1 @@
-bin_PROGRAMS = patchelf
-
-patchelf_SOURCES = patchelf.c
-
+SUBDIRS = src tests
diff --git a/configure.ac b/configure.ac
index 13a9b83..6619003 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_INIT(patchelf, "0.1")
-AC_CONFIG_SRCDIR(patchelf.c)
+AC_CONFIG_SRCDIR(Makefile.am)
AM_INIT_AUTOMAKE
# Change to `1' to produce a `stable' release (i.e., the `preREVISION'
@@ -16,5 +16,5 @@ if test "$STABLE" != "1"; then
fi
AC_PROG_CC
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..d61eee2
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,3 @@
+bin_PROGRAMS = patchelf
+
+patchelf_SOURCES = patchelf.c
diff --git a/patchelf.c b/src/patchelf.c
index ae6e7b2..ae6e7b2 100644
--- a/patchelf.c
+++ b/src/patchelf.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..fc92ab3
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,27 @@
+check_PROGRAMS = main
+
+TESTS = plain-run.sh $(XFAIL_TESTS)
+
+XFAIL_TESTS = plain-fail.sh
+
+
+main: main.o libfoo.so
+ LD_LIBRARY_PATH=. $(CC) -o main main.o -L . -lfoo
+
+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
+
+foo.o: foo.c
+ $(CC) -fpic -o foo.o -c foo.c
+
+libbar.so: bar.o
+ $(CC) -shared -o libbar.so bar.o -L .
+
+bar.o: bar.c
+ $(CC) -fpic -o bar.o -c bar.c
+
+clean-local:
+ $(RM) *.o libfoo.so libbar.so main
diff --git a/tests/bar.c b/tests/bar.c
new file mode 100644
index 0000000..5012310
--- /dev/null
+++ b/tests/bar.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int bar()
+{
+ printf("This is bar()!\n");
+ return 34;
+}
diff --git a/tests/foo.c b/tests/foo.c
new file mode 100644
index 0000000..be71954
--- /dev/null
+++ b/tests/foo.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+int bar();
+
+int foo()
+{
+ printf("This is foo()!\n");
+ return 12 + bar();
+}
diff --git a/test.c b/tests/main.c
index 62e6d62..8d71605 100644
--- a/test.c
+++ b/tests/main.c
@@ -2,8 +2,12 @@
char buf[16 * 1024 * 1024];
+int foo();
+
int main(int argc, char * * argv)
{
printf("Hello World\n");
- return 0;
+ int x = foo();
+ printf("Result is %d\n", x);
+ return x;
}
diff --git a/tests/plain-fail.sh b/tests/plain-fail.sh
new file mode 100755
index 0000000..b8021bc
--- /dev/null
+++ b/tests/plain-fail.sh
@@ -0,0 +1,2 @@
+#! /bin/sh
+./main
diff --git a/tests/plain-run.sh b/tests/plain-run.sh
new file mode 100755
index 0000000..e092956
--- /dev/null
+++ b/tests/plain-run.sh
@@ -0,0 +1,7 @@
+#! /bin/sh
+LD_LIBRARY_PATH=. ./main
+exitCode=$?
+if test "$exitCode" != 46; then
+ echo "bad exit code!"
+ exit 1
+fi