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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#!/bin/sh
#--------------------------------------------------------------------------#
die () {
cecho "${HIDE}test/usage/run.sh:${NORMAL} ${BAD}error:${NORMAL} $*"
exit 1
}
msg () {
cecho "${HIDE}test/usage/run.sh:${NORMAL} $*"
}
for dir in . .. ../..
do
[ -f $dir/scripts/colors.sh ] || continue
. $dir/scripts/colors.sh || exit 1
break
done
#--------------------------------------------------------------------------#
[ -d ../test -a -d ../test/cnf ] || \
die "needs to be called from a top-level sub-directory of CaDiCaL"
[ x"$CADICALBUILD" = x ] && CADICALBUILD="../build"
[ -x "$CADICALBUILD/cadical" ] || \
die "can not find '$CADICALBUILD/cadical' (run 'make' first)"
cecho -n "$HILITE"
cecho "---------------------------------------------------------"
cecho "usage testing in '$CADICALBUILD'"
cecho "---------------------------------------------------------"
cecho -n "$NORMAL"
make -C $CADICALBUILD
res=$?
[ $res = 0 ] || exit $res
#--------------------------------------------------------------------------#
solver="$CADICALBUILD/cadical"
#--------------------------------------------------------------------------#
cecho "starting test run `pwd`"
ok=0
failed=0
run () {
expected="$1"
options=`echo "$*"|sed -e 's,[^ ]*,,'`
name=`echo "@-$options"|sed -e 's,\.\./test/.*/,,g' -e 's,\.cnf\>,,g' -e 's,@,,' -e 's,[ \./],-,g' -e 's,--*,-,g'`
msg "running usage test ${HILITE}'test-usage$name'${NORMAL}"
buildprefix="$CADICALBUILD/test-usage$name"
log="$buildprefix.log"
err="$buildprefix.err"
cmd="$solver $options"
cecho -n "$cmd"
$cmd 1>$log 2>$err
res=$?
if [ $res = $expected ]
then
cecho " # ${GOOD}ok${NORMAL} (expected exit code '$res')"
ok=`expr $ok + 1`
else
cecho " # ${BAD}FAILED${NORMAL} (unexpected exit code '$res')"
failed=`expr $failed + 1`
fi
}
run 0 -h
run 0 --help
run 0 --version
run 0 --build
run 0 --copyright
run 10 ../test/cnf/empty.cnf
run 20 ../test/cnf/false.cnf
if [ x"`$solver --build 2>/dev/null|grep QUIET`" = x ]
then
run 10 -n ../test/cnf/empty.cnf
run 10 -v ../test/cnf/empty.cnf
run 10 -v -v ../test/cnf/empty.cnf
run 10 -v -v -v ../test/cnf/empty.cnf
run 10 -q ../test/cnf/empty.cnf
fi
run 1 ../test/usage/missing-clause.cnf
run 1 ../test/usage/variable-too-large.cnf
run 1 --strict relaxed-header.cnf
for option in "-f" "--force" "--force=1" "--force=true"
do
run 10 $option ../test/usage/missing-clause.cnf
run 10 $option ../test/usage/variable-too-large.cnf
done
run 20 ../test/usage/relaxed-header.cnf
# TODO: still need to add test cases for these:
for option in -O1 -O2 -O3
do
run 10 $option ../test/cnf/prime2209.cnf
done
for option in -L1 -L2 -L10
do
run 10 $option ../test/cnf/prime9.cnf
done
for option in -P1 -P2 -P16 -P128 -P1024
do
run 20 $option ../test/cnf/add16.cnf
done
# run 0 -t
# run 0 -O
# run 0 -c 0
# run 0 -c 1
# run 0 -c 2
# run 0 -d 0
# run 0 -d 1
# run 0 -d 2
# run 0 --colors # TODO all versions ....
# run 0 --no-colors # TODO all versions ....
# run 0 --no-leak # not needed
#--------------------------------------------------------------------------#
# not needed since tested in '../cnf'
# run 0 -o # working version not needed since testet in CNF tests
# run 0 -e # working version not needed since testet in CNF tests
# run 0 -s # working version not needed since tested in CNF tests
#--------------------------------------------------------------------------#
[ $ok -gt 0 ] && OK="$GOOD"
[ $failed -gt 0 ] && FAILED="$BAD"
msg "${HILITE}usage testing results:${NORMAL} ${OK}$ok ok${NORMAL}, ${FAILED}$failed failed${NORMAL}"
exit $failed
|