#!/bin/sh set -e # 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 BUILDDIR=$PWD # 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 keydb/libkeydb_*.so; do backend=${t##keydb/libkeydb_} backend=${backend%%.so} if [ "`echo ${TESTSDIR}/$backend-*`" != "${TESTSDIR}/$backend-*" ]; then echo "* testing $backend backend" sed -e "s;BUILDDIR;${BUILDDIR};" -e "s;WORKDIR;${WORKDIR};" \ -e "s;DB;${backend};" \ ${TESTSDIR}/test-in.ini > ${WORKDIR}/test.ini touch ${WORKDIR}/blacklist for t in ${TESTSDIR}/$backend-*.t ${TESTSDIR}/all-*.t; do total=`expr $total + 1` mkdir ${WORKDIR}/db/ if ! $t ${WORKDIR}/test.ini $backend; then echo "test $t failed" >&2 fail=`expr $fail + 1` fi rm -rf ${WORKDIR}/db/ done rm ${WORKDIR}/test.ini fi done if [ "$fail" -gt 0 ]; then echo "** failed $fail/$total tests" >&2 exit 1 else echo "** all tests succeeded ($total)" fi