#!/bin/sh # # db_test_suite # Copyright (C) 1997-1998 by John Heidemann # $Id: db_test_suite,v 1.17 2004/02/04 17:22:07 johnh Exp $ # usage () { cat 1>&2 <&2 exit 1 } # # Convert a distributed program into one suitable for # running in the source tree. # build_testprog () { p="$1" test "x$p" = x && die "build_testprog: bogus argument" tp=$TEST_DIR/$p sed -e "s@$MYPERL@$PERL@" -e 's@dblibdir *= *".*"@dblibdir = "."@' -e 's@dbbindir *= *".*"@dbbindir = "'$TEST_DIR'"@' <$p >$tp || die "sed failed" chmod +x $tp echo $tp } failed='' pwd=`pwd` for i in $TESTS do ( TEST_DIR=`dirname $i` if `echo $TEST_DIR | grep -v '^/' >/dev/null` then TEST_DIR=`pwd`/$TEST_DIR fi P=$TEST_DIR/`basename $i .cmd` # portable=true subprogs='' . $P.cmd || die "db_test_suite: no $P.cmd" # # skip unportable tests # $portable || { # $are_we_me || { # echo "$P skipped (unportable)" # continue # } # } # need to run command in place # => take source and fix stuff as if installation testsubprogs='' if [ "x$subprogs" != x ] then for j in $subprogs do testsubprogs="$testsubprogs `build_testprog $j`" || die "build_testprog $j failed" done fi testprog=`build_testprog $prog` || die "build_testprog $prog failed" final_cmd="$testprog $args < $P.in | sed -e 's/\([ ]\)\.\([0-9efgEFG]\)/\10.\2/g' -e 's/^\./0./' $cmd_tail > $P.trial" $verbose && echo $final_cmd eval $final_cmd # # Update mode? # $update && { echo " updating saved output $P.out" test -f $P.out && mv $P.out $P.out- test -f RCS/$P.out,v && co -l $P.out cp $P.trial $P.out } # # To try to work around different printf implementations, # make some attempt to normalize floating point numbers. # Currently our rather pathetic attempt just makes sure # that there is a zero before decimals in the range (-1..1) # eval $cmp $P.out $P.trial > $P.diff if [ -s $P.diff ] then echo $P FAILED cat $P.diff | sed 's/^/ /' exit 1 else rm $P.diff $P.trial $testprog for j in $testsubprogs do rm $j done test "x$cleanup" != '' && eval $cleanup eval $cleanup echo $P passed exit 0 fi die "db_test_suite: should never get here" ) if test $? -ne 0 then failed="$failed $i" fi done echo if [ "x$failed" = x ] then echo "all tests passed" else echo "TESTS FAILED: " $failed echo echo "Please consult the README file for known test script" echo "problems before thinking things are really broken." echo echo "If there is a real problem," echo "please report your os: " echo " " `uname -a` echo "and your perl version: " `perl -e 'print "$]\n";'` echo exit 1 fi echo exit 0