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