1#!/bin/sh -
2#
3# $Id: chk.bdb,v 1.2 2007/05/17 18:17:21 bostic Exp $
4#
5# Run the DB Java API test suite.
6# Alternatively supply the class name for an individual test
7# case and have that run.
8
9# NOTES:
10# This test requires one JAR not included with the Berkeley DB
11# distribution:  JUnit (junit.jar) I've been using the 8/31/2002 version
12# of JUnit.  You can download this JAR from http://jakarta.apache.org/
13#
14# JUNIT_JAR=/Users/gburd/Unix/opt/junit/junit.jar
15
16[ "x$JUNIT_JAR" = "x" ] && {
17	echo 'FAIL: unset environment variable JUNIT_JAR for junit.jar.'
18	exit 1
19}
20
21[ -f $JUNIT_JAR ] || {
22	echo 'FAIL: JUNIT_JAR not a valid path to the junit.jar.'
23	exit 1
24}
25
26case `uname` in
27*CYGWIN*)
28  CP_SEP=";"
29  d="../../build_windows/Debug"
30  DB_LIB_DIR="$d"
31  PATH="../../build_windows/Debug:$PATH"
32  export PATH;;
33*)
34  CP_SEP=":"
35  d="../../build_unix/"
36  DB_LIB_DIR="$d/.libs"
37esac
38
39REQUIRED_JARS=$JUNIT_JAR
40DB_JAR=$d/db.jar
41export DB_JAR
42export REQUIRED_JARS
43export CP_SEP
44export DB_LIB_DIR
45
46# Build the tests.
47
48make clean
49
50[ -f ./dbtest.jar ] || (make dbtest.jar) || {
51	echo 'FAIL: unable to find or build dbtest.jar'
52	exit 1
53}
54
55# Run the tests.
56
57
58if [ -n "$1" ]
59then
60    echo "Running: $1"
61    java -Xcheck:jni -Djava.library.path=$DB_LIB_DIR -cp "$REQUIRED_JARS$CP_SEP$DB_JAR$CP_SEP./dbtest.jar" org.junit.runner.JUnitCore $1
62
63else
64
65    for f in `find classes -name "*Test.class"`; do
66        c=`echo "$f" | sed -e 's/classes\///' -e 's/\.class//' -e 's/\//./g'`
67        echo "Running: $c"
68        if java -Xcheck:jni -Djava.library.path=$DB_LIB_DIR -cp "$REQUIRED_JARS$CP_SEP$DB_JAR$CP_SEP./dbtest.jar" org.junit.runner.JUnitCore $c ; then
69                :
70        else
71            echo "FAIL: test program failed"
72    #        exit 1
73        fi
74    done
75fi
76exit 0
77