[3c30b59] | 1 | #!/bin/sh |
---|
| 2 | |
---|
[831da18] | 3 | debug=0 |
---|
[3c30b59] | 4 | |
---|
| 5 | # look for creddy, |
---|
[1bf0f03] | 6 | if [ -z "${TEST_INSTALL}" ] && [ -n "${CREDDY_LOCATION}" ]; then |
---|
[3c30b59] | 7 | eloc=${CREDDY_LOCATION} |
---|
| 8 | if ! [ -e $eloc/creddy ] ; then |
---|
| 9 | echo "ERROR: has CREDDY_LOCATION but creddy is not there!!!" |
---|
| 10 | exit 1 |
---|
| 11 | fi |
---|
| 12 | else |
---|
| 13 | eloc=`which creddy | sed 's/\/creddy//'` |
---|
| 14 | if [ -z "$eloc" ]; then |
---|
| 15 | echo "ERROR: creddy is not in the search path nor CREDDY_LOCATION defined!!!" |
---|
| 16 | exit 1 |
---|
| 17 | fi |
---|
| 18 | fi |
---|
| 19 | |
---|
| 20 | # look for abac_prover, |
---|
[1bf0f03] | 21 | if [ -z "${TEST_INSTALL}" ] && [ -n "${PROVER_LOCATION}" ]; then |
---|
[3c30b59] | 22 | ploc=${PROVER_LOCATION} |
---|
| 23 | if ! [ -e $ploc/abac_prover ] ; then |
---|
| 24 | echo "ERROR: has PROVER_LOCATION but abac_provery is not there!!!" |
---|
| 25 | exit 1 |
---|
| 26 | fi |
---|
| 27 | else |
---|
| 28 | ploc=`which abac_prover | sed 's/\/abac_prover//'` |
---|
| 29 | if [ -z "$ploc" ]; then |
---|
| 30 | echo "ERROR: abac_prover is not in the search path nor PROVER_LOCATION defined!!!" |
---|
| 31 | exit 1 |
---|
| 32 | fi |
---|
| 33 | fi |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | # runTest fname test1 testbody expect msg |
---|
| 37 | # if expect success, expect=0 |
---|
| 38 | # if expect failure, expect=1 |
---|
| 39 | runTest() { |
---|
| 40 | FNAME=$1 |
---|
| 41 | LABEL=$2 |
---|
| 42 | TESTBODY=$3 |
---|
| 43 | EXPECT=$4 |
---|
| 44 | MSG=$5 |
---|
| 45 | rc=`${TESTBODY} 2>&1` |
---|
| 46 | if [ $? -eq $EXPECT ]; then |
---|
| 47 | echo "GOOD:${FNAME}:${LABEL}:${MSG}" |
---|
| 48 | else |
---|
[4f79997] | 49 | if [ $EXPECT -eq 1 ]; then |
---|
[3c30b59] | 50 | echo "BAD:${FNAME}:${LABEL}:expected failure but got success,${MSG}" |
---|
| 51 | else |
---|
| 52 | echo "BAD:${FNAME}:${LABEL}:${MSG}" |
---|
| 53 | fi |
---|
| 54 | fi |
---|
| 55 | if [ $debug -eq 1 ]; then |
---|
[4f79997] | 56 | echo ${EXPECT} |
---|
| 57 | echo ${TESTBODY} |
---|
[3c30b59] | 58 | echo $rc |
---|
| 59 | fi |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | # runXTest fname test1 testbody expect matchResult msg |
---|
| 63 | # if expect success, expect=0 |
---|
| 64 | # if expect failure, expect=1 |
---|
| 65 | runXTest() { |
---|
| 66 | FNAME=$1 |
---|
| 67 | LABEL=$2 |
---|
| 68 | TESTBODY=$3 |
---|
| 69 | EXPECT=$4 |
---|
| 70 | MATCH=$5 |
---|
| 71 | MSG=$6 |
---|
| 72 | rc=`${TESTBODY} 2>&1` |
---|
| 73 | if [ $? -eq $EXPECT ]; then |
---|
| 74 | match=`echo "${rc}" | grep "${MATCH}" | wc -l` |
---|
| 75 | if [ $match -eq 1 ]; then |
---|
| 76 | echo "GOOD:${FNAME}:${LABEL}:${MSG}" |
---|
| 77 | else |
---|
| 78 | echo "BADX:${FNAME}:${LABEL}:${MSG}, but result is not as expected" |
---|
| 79 | fi |
---|
| 80 | else |
---|
| 81 | echo "BAD:${FNAME}:${LABEL}:${MSG}" |
---|
| 82 | fi |
---|
| 83 | if [ $debug -eq 1 ]; then |
---|
| 84 | echo $rc |
---|
| 85 | fi |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | # runCTest fname test1 testbody expect msg pattern count |
---|
| 89 | # if expect success, expect=0 |
---|
| 90 | # if expect failure, expect=1 |
---|
| 91 | runCTest() { |
---|
| 92 | FNAME=$1 |
---|
| 93 | LABEL=$2 |
---|
| 94 | TESTBODY=$3 |
---|
| 95 | EXPECT=$4 |
---|
| 96 | MSG=$5 |
---|
| 97 | PATTERN=$6 |
---|
| 98 | COUNT=$7 |
---|
| 99 | rc=`${TESTBODY} 1>atmp 2>/dev/null` |
---|
| 100 | if [ $? -eq $EXPECT ]; then |
---|
| 101 | cnt=`grep "$PATTERN" atmp | wc -l` |
---|
| 102 | if [ $cnt -eq $COUNT ]; then |
---|
| 103 | echo "GOOD:${FNAME}:${LABEL}:${MSG}" |
---|
| 104 | else |
---|
| 105 | echo "BAD:${FNAME}:${LABEL}:${MSG},did not have expected output" |
---|
| 106 | fi |
---|
| 107 | else |
---|
| 108 | if [ $EXPECT ]; then |
---|
| 109 | echo "BAD:${FNAME}:${LABEL}:expected failure but got success,${MSG}" |
---|
| 110 | else |
---|
| 111 | echo "BAD:${FNAME}:${LABEL}:${MSG}" |
---|
| 112 | fi |
---|
| 113 | fi |
---|
| 114 | rm -rf atmp |
---|
| 115 | return 0 |
---|
| 116 | } |
---|