Debian Codegraph @

test/cxx/chk.cxxtests

raw
1 #!/bin/sh -
2 #
3 # $Id$
4 #
5 # Check to make sure that regression tests for C++ run.
6
7 TEST_CXX_SRCDIR=../test/cxx # must be a relative directory
8
9 # All paths must be relative to a subdirectory of the build directory
10 LIBS="-L.. -ldb_cxx"
11 CXXFLAGS="-I.. -I../../src/dbinc"
12
13 [ `uname` = "Linux" ] && LIBS="$LIBS -lpthread"
14
15 # Test must be run from a local build directory, not from a test
16 # directory.
17 [ -f db_config.h ] || {
18 echo 'FAIL: chk.cxxtests must be run from a local build directory.'
19 exit 1
20 }
21 [ -d ../src ] || {
22 echo 'FAIL: chk.cxxtests must be run from a local build directory.'
23 exit 1
24 }
25 [ -f libdb.a ] || make libdb.a || {
26 echo 'FAIL: unable to build libdb.a'
27 exit 1
28 }
29 [ -f libdb_cxx.a ] || make libdb_cxx.a || {
30 echo 'FAIL: unable to build libdb_cxx.a'
31 exit 1
32 }
33 CXX=`sed -e '/^CXX=/!d' -e 's/^CXX=//' -e 's/.*mode=compile *//' Makefile`
34 echo " ====== cxx tests using $CXX"
35 testnames=`cd $TEST_CXX_SRCDIR; ls *.cpp | sed -e 's/\.cpp$//'`
36
37 for testname in $testnames; do
38 if grep -x $testname $TEST_CXX_SRCDIR/ignore > /dev/null; then
39 echo " **** cxx test $testname ignored"
40 continue
41 fi
42
43 echo " ==== cxx test $testname"
44 rm -rf TESTCXX; mkdir TESTCXX
45 cd ./TESTCXX
46 testprefix=../$TEST_CXX_SRCDIR/$testname
47
48 ${CXX} ${CXXFLAGS} -o $testname $testprefix.cpp ${LIBS} > $testname.compileout 2>&1 || {
49 echo "FAIL: compilation of $testname failed, see TESTCXX/$testname.compileout"
50 exit 1
51 }
52 rm -f $testname.compileout
53 infile=$testprefix.testin
54 [ -f $infile ] || infile=/dev/null
55 goodoutfile=$testprefix.testout
56 [ -f $goodoutfile ] || goodoutfile=/dev/null
57 gooderrfile=$testprefix.testerr
58 [ -f $gooderrfile ] || gooderrfile=/dev/null
59 ./$testname <$infile > $testname.out 2> $testname.err
60 cmp $testname.out $goodoutfile > /dev/null || {
61 echo "FAIL: $testname output differs: see $testname.out, $goodoutfile"
62 exit 1
63 }
64 cmp $testname.err $gooderrfile > /dev/null || {
65 echo "FAIL: $testname error differs: see $testname.err, $gooderrfile"
66 exit 1
67 }
68 cd ..
69 done
70 rm -rf TESTCXX
71 exit 0