aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Scherer <Konrad.Scherer@windriver.com>2010-07-30 13:08:31 -0400
committerKonrad Scherer <Konrad.Scherer@windriver.com>2010-07-30 13:19:05 -0400
commit7c9033fc63bd40e9cf0562ad5322274c08d3b39f (patch)
tree9537370798b23a9ecd6aba445dd147918ce200f4
parent51591a9413959ca2dda5966f5402d431adc3fb50 (diff)
downloadpseudo-7c9033fc63bd40e9cf0562ad5322274c08d3b39f.tar.gz
pseudo-7c9033fc63bd40e9cf0562ad5322274c08d3b39f.tar.bz2
pseudo-7c9033fc63bd40e9cf0562ad5322274c08d3b39f.zip
Add basic test harness to test pseudo
CQ: WIND00225366 A simple test harness that runs all the scripts in the test directory. Each test script is run inside pseudo and uses exit status to report back whether the test was successful. The script uses the build executables, not the installed ones and each test run starts with an empty database.
-rw-r--r--Makefile.in29
-rwxr-xr-xrun_tests.sh49
-rwxr-xr-xtest/test-dir-move.sh14
3 files changed, 80 insertions, 12 deletions
diff --git a/Makefile.in b/Makefile.in
index 7945598..d152cda 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -47,35 +47,40 @@ SHOBJS=pseudo_table.o pseudo_util.o
DBOBJS=pseudo_db.o -ldl -lpthread
WRAPOBJS=pseudo_wrappers.o
-test: install
- @echo "No tests yet."
+PSEUDO=bin/pseudo
+PSEUDODB=bin/pseudodb
+PSEUDOLOG=bin/pseudolog
-all: libpseudo.so pseudo pseudodb pseudolog
+
+all: libpseudo.so $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG)
+
+test: all
+ @./run_tests.sh
install-lib: libpseudo.so
mkdir -p $(DESTDIR)$(LIBDIR)
cp libpseudo*.so $(DESTDIR)$(LIBDIR)
-install-bin: pseudo pseudodb pseudolog
+install-bin: $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG)
mkdir -p $(DESTDIR)$(BINDIR)
- cp pseudo pseudodb pseudolog $(DESTDIR)$(BINDIR)
+ cp $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG) $(DESTDIR)$(BINDIR)
install-data:
mkdir -p $(DESTDIR)$(DATADIR)
install: all install-lib install-bin install-data
-pseudo: pseudo.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_server.o pseudo_ipc.o
- $(CC) $(CFLAGS) -o pseudo \
+$(PSEUDO): pseudo.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_server.o pseudo_ipc.o
+ $(CC) $(CFLAGS) -o $(PSEUDO) \
pseudo.o pseudo_server.o pseudo_client.o pseudo_ipc.o \
$(DBOBJS) $(SHOBJS) $(DBLDFLAGS)
-pseudolog: pseudolog.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_ipc.o
- $(CC) $(CFLAGS) -o pseudolog pseudolog.o pseudo_client.o pseudo_ipc.o \
+$(PSEUDOLOG): pseudolog.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_ipc.o
+ $(CC) $(CFLAGS) -o $(PSEUDOLOG) pseudolog.o pseudo_client.o pseudo_ipc.o \
$(DBOBJS) $(SHOBJS) $(DBLDFLAGS)
-pseudodb: pseudodb.o $(SHOBJS) $(DBOBJS) pseudo_ipc.o
- $(CC) $(CFLAGS) -o pseudodb pseudodb.o \
+$(PSEUDODB): pseudodb.o $(SHOBJS) $(DBOBJS) pseudo_ipc.o
+ $(CC) $(CFLAGS) -o $(PSEUDODB) pseudodb.o \
$(DBOBJS) $(SHOBJS) $(DBLDFLAGS) pseudo_ipc.o
libpseudo.so: $(WRAPOBJS) pseudo_client.o pseudo_ipc.o $(SHOBJS)
@@ -110,7 +115,7 @@ offsets64:
$(CC) -m64 -o offsets64 offsets.c
clean:
- rm -f *.o *.so pseudo pseudodb pseudolog \
+ rm -f *.o *.so $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG) \
pseudo_wrapfuncs.h pseudo_wrapfuncs.c \
pseudo_wrapper_table.c \
pseudo_wrapfuncs.c.old pseudo_wrapfuncs.h.old \
diff --git a/run_tests.sh b/run_tests.sh
new file mode 100755
index 0000000..9915d3b
--- /dev/null
+++ b/run_tests.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+opt_verbose=
+
+usage()
+{
+ echo >&2 "usage:"
+ echo >&2 " run_tests [-v|--verbose]"
+ exit 1
+}
+
+for arg
+do
+ case $arg in
+ --) shift; break ;;
+ -v | --verbose)
+ opt_verbose=-v
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+#The tests will be run on the build dir, not the installed versions
+#This requires to following be set properly.
+export PSEUDO_PREFIX=${PWD}
+export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}"
+
+num_tests=0
+num_passed_tests=0
+
+for file in test/test*.sh
+do
+ filename=${file#test/}
+ let num_tests++
+ mkdir -p var/pseudo
+ ./bin/pseudo $file ${opt_verbose}
+ if [ "$?" -eq "0" ]; then
+ let num_passed_tests++
+ if [ "${opt_verbose}" == "-v" ]; then
+ echo "${filename%.sh}: Passed."
+ fi
+ else
+ echo "${filename/%.sh}: Failed."
+ fi
+ rm -rf var
+done
+echo "${num_passed_tests}/${num_tests} test(s) passed."
+
diff --git a/test/test-dir-move.sh b/test/test-dir-move.sh
new file mode 100755
index 0000000..37182f3
--- /dev/null
+++ b/test/test-dir-move.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+mkdir d1
+touch d1/f1
+mv d1 d2
+fileuid=`\ls -n1 d2/f1 | awk '{ print $3 }'`
+if [ "$fileuid" == "$UID" ]
+then
+ #echo "Passed."
+ rm -rf d2
+ exit 0
+fi
+rm -rf d2
+#echo "Failed"
+exit 1