summaryrefslogtreecommitdiff
path: root/test/c/chk.ctests
blob: 1c76e495b3d3c1aeac8197c19f9deda5f4567826 (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
#!/bin/sh -
#
# $Id$
#
# Check to make sure we can run DB 1.85 code.
d=../../
b=./tmp_build/
s=$d/src

mkdir -p $b

[ -f $d/LICENSE ] || {
	echo 'FAIL: Test must be run from scr directory.'
	exit 1
}

nocleanup=0
while [ $# -gt 0 ]
do 
	case "$1" in
	-nocleanup)
		nocleanup=1; shift;;
	*)
		echo "Unrecognized option: $1, ignoring"
		shift;;
	esac
done

opts="--enable-compat185 --disable-shared"
echo "Building DB library, this can take a while."
(cd $b && ../../../dist/configure $opts > /dev/null && make libdb.a > /dev/null) || {
	echo 'FAIL: unable to build libdb.a'
	exit 1
}

# if compiling on linux blade server, add -pthread on cc
CINC="-I$b -I$s -I$s/dbinc"
[ `uname` = "Linux" ] && CINC="$CINC -pthread"

for i in `ls test_*.c`; do

	echo "=== Running $i ===" | tee -a compile.out
	if cc -g -Wall $CINC $i $b/libdb.a -o t >> compile.out 2>&1; then
		:
	else
		echo "FAIL: unable to compile test program $i"
		exit 1
	fi

	if ./t; then
		:
	else
		echo "FAIL: test program failed"
		exit 1
	fi
	rm -f ./t
done

# Cleanup.
# TODO: The test should be consistent, so this cleanup isn't so haphazard.
#       Alternatively we could build each test in a sub-dir and cleanup after
#       individual runs.
rm a.db __db.* output
rm -rf ./TESTDIR

if [ nocleanup = 0 ]; then
	rm -rf compile.out $b
fi

exit 0