runtests assumes its run from the directory it lives in, and that this
is the build directory. Improve it to be able to cope with a build in a
different directory to the source and work out the correct paths.
16 files changed:
+# Work out where everything is
+# Binary should be in current directory
if [ ! -e onak ]; then
echo "** onak binary doesn't exist, cannot run test suite" >&2
exit 1
fi
if [ ! -e onak ]; then
echo "** onak binary doesn't exist, cannot run test suite" >&2
exit 1
fi
-if [ -e t/db/ ]; then
- rm -rf t/db/
-fi
+# Tests live in the t/ dir underneath where this script is
+TESTSDIR=$(dirname $(readlink -f "$0"))/t
+
+# We create a temporary directory to work in
+WORKDIR=$(mktemp -d -t onak-test.XXXXXXXX)
+trap cleanup exit
+cleanup () {
+ rm -rf "$WORKDIR"
+}
+
+export BUILDDIR TESTSDIR WORKDIR
+
+echo "BUILDDIR: ${BUILDDIR}"
+echo "TESTSDIR: ${TESTSDIR}"
+echo "WORKDIR : ${WORKDIR}"
+
+fail=0
+total=0
for t in libkeydb_*.so; do
backend=${t##libkeydb_}
backend=${backend%%.so}
for t in libkeydb_*.so; do
backend=${t##libkeydb_}
backend=${backend%%.so}
- if [ "`echo t/$backend-*`" != "t/$backend-*" ]; then
+ if [ "`echo ${TESTSDIR}/$backend-*`" != "${TESTSDIR}/$backend-*" ]; then
echo "* testing $backend backend [conf]"
echo "* testing $backend backend [conf]"
- (sed -e "s;DIR;`pwd`;" t/test-in.conf ; \
- echo db_backend $backend) > t/test.conf
- for t in t/$backend-*.t t/all-*.t; do
+ (sed -e "s;BUILDDIR;${BUILDDIR};" -e "s;WORKDIR;${WORKDIR};" \
+ ${TESTSDIR}/test-in.conf ; \
+ echo db_backend $backend) > ${WORKDIR}/test.conf
+ for t in ${TESTSDIR}/$backend-*.t ${TESTSDIR}/all-*.t; do
- mkdir t/db/
- if ! $t test.conf $backend; then
+ mkdir ${WORKDIR}/db/
+ if ! $t ${WORKDIR}/test.conf $backend; then
echo "test $t failed" >&2
fail=`expr $fail + 1`
fi
echo "test $t failed" >&2
fail=`expr $fail + 1`
fi
+ rm ${WORKDIR}/test.conf
- if [ "`echo t/$backend-*`" != "t/$backend-*" ]; then
+ if [ "`echo ${TESTSDIR}/$backend-*`" != "${TESTSDIR}/$backend-*" ]; then
echo "* testing $backend backend [ini]"
echo "* testing $backend backend [ini]"
- sed -e "s;DIR;`pwd`;" -e "s;DB;${backend};" t/test-in.ini \
- > t/test.ini
- for t in t/$backend-*.t t/all-*.t; do
+ sed -e "s;BUILDDIR;${BUILDDIR};" -e "s;WORKDIR;${WORKDIR};" \
+ -e "s;DB;${backend};" \
+ ${TESTSDIR}/test-in.ini > ${WORKDIR}/test.ini
+ for t in ${TESTSDIR}/$backend-*.t ${TESTSDIR}/all-*.t; do
- mkdir t/db/
- if ! $t test.ini $backend; then
+ mkdir ${WORKDIR}/db/
+ if ! $t ${WORKDIR}/test.ini $backend; then
echo "test $t failed" >&2
fail=`expr $fail + 1`
fi
echo "test $t failed" >&2
fail=`expr $fail + 1`
fi
echo "** failed $fail/$total tests" >&2
exit 1
else
echo "** failed $fail/$total tests" >&2
exit 1
else
- echo "** all tests succeeded"
+ echo "** all tests succeeded ($total)"
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 get 0x94FA372B2DA8B985 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 get 0x94FA372B2DA8B985 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by keyid."
exit 1
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by keyid."
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 get 0x12345678 2>&1 | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 get 0x12345678 2>&1 | \
grep -q 'Key not found'; then
echo "* Did not correctly error on non-existent key"
exit 1
grep -q 'Key not found'; then
echo "* Did not correctly error on non-existent key"
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 index noodles 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 index noodles 2> /dev/null | \
grep -q -- 'pub 4096R/2DA8B985 2008/06/03 Jonathan McDowell'; then
echo "* Did not correctly retrieve key by text"
exit 1
grep -q -- 'pub 4096R/2DA8B985 2008/06/03 Jonathan McDowell'; then
echo "* Did not correctly retrieve key by text"
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 hget 81929DAE08B8F80888DA524923B93067 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 hget 81929DAE08B8F80888DA524923B93067 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by text"
exit 1
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by text"
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 get 0x0E3A94C3E83002DAB88CCA1694FA372B2DA8B985 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 get 0x0E3A94C3E83002DAB88CCA1694FA372B2DA8B985 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by keyid."
exit 1
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by keyid."
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 get 0x2DA8B985 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 get 0x2DA8B985 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by keyid."
exit 1
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by keyid."
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 get 0x045281F1B9A66E35 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 get 0x045281F1B9A66E35 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
fi
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
fi
-if ! ../onak -c $1 get 0xFF162FC5CF3FBAD1 2> /dev/null | \
+if ! ${BUILDDIR}/onak -c $1 get 0xFF162FC5CF3FBAD1 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-if ! ../onak -c $1 get 0xB9A66E35 2> /dev/null | \
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+if ! ${BUILDDIR}/onak -c $1 get 0xB9A66E35 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
fi
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
fi
-if ! ../onak -c $1 get 0xCF3FBAD1 2> /dev/null | \
+if ! ${BUILDDIR}/onak -c $1 get 0xCF3FBAD1 2> /dev/null | \
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
echo "* Did not correctly retrieve key by subkey id."
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
if [ ! -e db/worddb -o ! -e db/id32db -o ! -e db/keydb.0.db ]; then
echo Did not correctly add key using db4 backend.
exit 1
if [ ! -e db/worddb -o ! -e db/id32db -o ! -e db/keydb.0.db ]; then
echo Did not correctly add key using db4 backend.
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
if [ ! -e db/0x2DA8B985 ]; then
echo Did not correctly add key using file backend.
exit 1
if [ ! -e db/0x2DA8B985 ]; then
echo Did not correctly add key using file backend.
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-../onak -b -c $1 delete 0x2DA8B985
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+${BUILDDIR}/onak -b -c $1 delete 0x2DA8B985
if [ -e db/0x2DA8B985 ]; then
echo "* Did not correctly delete key using file backend"
exit 1
if [ -e db/0x2DA8B985 ]; then
echo "* Did not correctly delete key using file backend"
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
if [ ! -e db/key/2D/A8/2DA8B985/94FA372B2DA8B985 ]; then
echo Did not correctly add key using fs backend.
exit 1
if [ ! -e db/key/2D/A8/2DA8B985/94FA372B2DA8B985 ]; then
echo Did not correctly add key using fs backend.
exit 1
-cd t
-../onak -b -c $1 add < ../keys/noodles.key
-../onak -b -c $1 delete 0x2DA8B985
+cd ${WORKDIR}
+${BUILDDIR}/onak -b -c $1 add < ${TESTSDIR}/../keys/noodles.key
+${BUILDDIR}/onak -b -c $1 delete 0x2DA8B985
if [ -e db/key/2D/A8/2DA8B985/94FA372B2DA8B985 ]; then
echo "* Did not correctly delete key using fs backend"
exit 1
if [ -e db/key/2D/A8/2DA8B985/94FA372B2DA8B985 ]; then
echo "* Did not correctly delete key using fs backend"
exit 1
-pks_bin_dir DIR
-backends_dir DIR
-db_dir DIR/t/db/
+pks_bin_dir BUILDDIR
+backends_dir BUILDDIR
+db_dir WORKDIR/db/
logfile onak.log
loglevel 7
use_keyd false
logfile onak.log
loglevel 7
use_keyd false
logfile=onak.log
loglevel=7
use_keyd=false
logfile=onak.log
loglevel=7
use_keyd=false
[backend:test-DB]
type=DB
[backend:test-DB]
type=DB
this_site=pgp-public-keys@localhost
this_site=pgp-public-keys@localhost