blob: 5f5d2e0017d1b22a493859fc84c5effba52cfd56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!/bin/sh -
# $Id: testone,v 1.5 2002/08/16 19:35:56 dda Exp $
#
# Run just one Java regression test, the single argument
# is the classname within this package.
error()
{
echo '' >&2
echo "Java regression error: $@" >&2
echo '' >&2
ecode=1
}
# compares the result against the good version,
# reports differences, and removes the result file
# if there are no differences.
#
compare_result()
{
good="$1"
latest="$2"
if [ ! -e "$good" ]; then
echo "Note: $good does not exist"
return
fi
tmpout=/tmp/blddb$$.tmp
diff "$good" "$latest" > $tmpout
if [ -s $tmpout ]; then
nbad=`grep '^[0-9]' $tmpout | wc -l`
error "$good and $latest differ in $nbad places."
else
rm $latest
fi
rm -f $tmpout
}
ecode=0
stdinflag=n
JAVA=${JAVA:-java}
JAVAC=${JAVAC:-javac}
# classdir is relative to TESTDIR subdirectory
classdir=./classes
# CLASSPATH is used by javac and java.
# We use CLASSPATH rather than the -classpath command line option
# because the latter behaves differently from JDK1.1 and JDK1.2
export CLASSPATH="$classdir:$CLASSPATH"
# determine the prefix of the install tree
prefix=""
while :
do
case "$1" in
--prefix=* )
prefix="`echo $1 | sed -e 's/--prefix=//'`"; shift
export LD_LIBRARY_PATH="$prefix/lib:$LD_LIBRARY_PATH"
export CLASSPATH="$prefix/lib/db.jar:$CLASSPATH"
;;
--stdin )
stdinflag=y; shift
;;
* )
break
;;
esac
done
if [ "$#" = 0 ]; then
echo 'Usage: testone [ --prefix=<dir> | --stdin ] TestName'
exit 1
fi
name="$1"
# class must be public
if ! grep "public.*class.*$name" $name.java > /dev/null; then
error "public class $name is not declared in file $name.java"
exit 1
fi
# compile
rm -rf TESTDIR; mkdir TESTDIR
cd ./TESTDIR
mkdir -p $classdir
${JAVAC} -d $classdir ../$name.java ../TestUtil.java > ../$name.compileout 2>&1
if [ $? != 0 -o -s ../$name.compileout ]; then
error "compilation of $name failed, see $name.compileout"
exit 1
fi
rm -f ../$name.compileout
# find input and error file
infile=../$name.testin
if [ ! -f $infile ]; then
infile=/dev/null
fi
# run and diff results
rm -rf TESTDIR
if [ "$stdinflag" = y ]
then
${JAVA} com.sleepycat.test.$name $TEST_ARGS >../$name.out 2>../$name.err
else
${JAVA} com.sleepycat.test.$name $TEST_ARGS <$infile >../$name.out 2>../$name.err
fi
cd ..
testerr=$name.testerr
if [ ! -f $testerr ]; then
testerr=/dev/null
fi
testout=$name.testout
if [ ! -f $testout ]; then
testout=/dev/null
fi
compare_result $testout $name.out
compare_result $testerr $name.err
rm -rf TESTDIR
exit $ecode
|