| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. - |
| 2 | # $Id$ |
| 3 | # |
| 4 | # Run just one C++ regression test, the single argument |
| 5 | # is the basename of the test, e.g. TestRpcServer |
| 6 | |
| 7 | errorscip-shell shell db5.3 5.3.28+dfsg2-11 error().() |
| 8 | { |
| 9 | echoscip-shell system . . echo. '' >&2 |
| 10 | echoscip-shell system . . echo. "C++ regression error: $@" >&2 |
| 11 | echoscip-shell system . . echo. '' >&2 |
| 12 | ecode=1 |
| 13 | } |
| 14 | |
| 15 | # compares the result against the good version, |
| 16 | # reports differences, and removes the result file |
| 17 | # if there are no differences. |
| 18 | # |
| 19 | compare_resultscip-shell shell db5.3 5.3.28+dfsg2-11 compare_result().() |
| 20 | { |
| 21 | good="$1" |
| 22 | latest="$2" |
| 23 | if [scip-shell system . . `[`. ! -e "$good" ]; then |
| 24 | echoscip-shell system . . echo. "Note: $good does not exist" |
| 25 | return |
| 26 | fi |
| 27 | tmpout=/tmp/blddb$$.tmp |
| 28 | diffscip-shell system . . diff. "$good" "$latest" > $tmpout |
| 29 | if [scip-shell system . . `[`. -s $tmpout ]; then |
| 30 | nbad=`grepscip-shell system . . grep. '^[0-9]' $tmpout | wcscip-shell system . . wc. -l` |
| 31 | errorscip-shell shell db5.3 5.3.28+dfsg2-11 error(). "$good and $latest differ in $nbad places." |
| 32 | else |
| 33 | rmscip-shell system . . rm. $latest |
| 34 | fi |
| 35 | rmscip-shell system . . rm. -f $tmpout |
| 36 | } |
| 37 | |
| 38 | ecode=0 |
| 39 | stdinflag=n |
| 40 | gdbflag=n |
| 41 | CXX=${CXX:-c++} |
| 42 | LIBS=${LIBS:-} |
| 43 | |
| 44 | # remove any -c option in the CXXFLAGS |
| 45 | CXXFLAGS="`echoscip-shell system . . echo. " ${CXXFLAGS} " | sedscip-shell system . . sed. -e 's/ -c //g'`" |
| 46 | |
| 47 | # determine the prefix of the install tree |
| 48 | prefix="" |
| 49 | while : |
| 50 | do |
| 51 | case "$1" in |
| 52 | --prefix=* ) |
| 53 | prefix="`echoscip-shell system . . echo. $1 | sedscip-shell system . . sed. -e 's/--prefix=//'`"; shift |
| 54 | LIBS="-L$prefix/lib -ldb_cxx $LIBS" |
| 55 | CXXFLAGS="-I$prefix/include $CXXFLAGS" |
| 56 | export LD_LIBRARY_PATH="$prefix/lib:$LD_LIBRARY_PATH" |
| 57 | ;; |
| 58 | --stdin ) |
| 59 | stdinflag=y; shift |
| 60 | ;; |
| 61 | --gdb ) |
| 62 | CXXFLAGS="-g $CXXFLAGS" |
| 63 | gdbflag=y; shift |
| 64 | ;; |
| 65 | * ) |
| 66 | break |
| 67 | ;; |
| 68 | esac |
| 69 | done |
| 70 | |
| 71 | if [scip-shell system . . `[`. "$#" = 0 ]; then |
| 72 | echoscip-shell system . . echo. 'Usage: testone [ --prefix=<dir> | --stdin ] TestName' |
| 73 | exit 1 |
| 74 | fi |
| 75 | name="$1" |
| 76 | |
| 77 | # compile |
| 78 | rmscip-shell system . . rm. -rf TESTDIR; mkdirscip-shell system . . mkdir. TESTDIR |
| 79 | cd ./TESTDIR |
| 80 | |
| 81 | ${CXX} ${CXXFLAGS} -o $name ../$name.cpp ${LIBS} > ../$name.compileout 2>&1 |
| 82 | if [scip-shell system . . `[`. $? != 0 -o -s ../$name.compileout ]; then |
| 83 | errorscip-shell shell db5.3 5.3.28+dfsg2-11 error(). "compilation of $name failed, see $name.compileout" |
| 84 | exit 1 |
| 85 | fi |
| 86 | rmscip-shell system . . rm. -f ../$name.compileout |
| 87 | |
| 88 | # find input and error file |
| 89 | infile=../$name.testin |
| 90 | if [scip-shell system . . `[`. ! -f $infile ]; then |
| 91 | infile=/dev/nullscip-shell filesystem . . `/dev/null`. |
| 92 | fi |
| 93 | |
| 94 | # run and diff results |
| 95 | rmscip-shell system . . rm. -rf TESTDIR |
| 96 | if [scip-shell system . . `[`. "$gdbflag" = y ]; then |
| 97 | if [scip-shell system . . `[`. -s $infile ]; then |
| 98 | echoscip-shell system . . echo. "Input file is $infile" |
| 99 | fi |
| 100 | gdb ./$name |
| 101 | exit 0 |
| 102 | elif [scip-shell system . . `[`. "$stdinflag" = y ]; then |
| 103 | ./$name >../$name.out 2>../$name.err |
| 104 | else |
| 105 | ./$name <$infile >../$name.out 2>../$name.err |
| 106 | fi |
| 107 | cd .. |
| 108 | |
| 109 | testerr=$name.testerr |
| 110 | if [scip-shell system . . `[`. ! -f $testerr ]; then |
| 111 | testerr=/dev/nullscip-shell filesystem . . `/dev/null`. |
| 112 | fi |
| 113 | |
| 114 | testout=$name.testout |
| 115 | if [scip-shell system . . `[`. ! -f $testout ]; then |
| 116 | testout=/dev/nullscip-shell filesystem . . `/dev/null`. |
| 117 | fi |
| 118 | |
| 119 | compare_resultscip-shell shell db5.3 5.3.28+dfsg2-11 compare_result(). $testout $name.out |
| 120 | compare_resultscip-shell shell db5.3 5.3.28+dfsg2-11 compare_result(). $testerr $name.err |
| 121 | rmscip-shell system . . rm. -rf TESTDIR |
| 122 | exit $ecode |