1 | #!/bin/sh |
---|
2 | |
---|
3 | debug=0 |
---|
4 | |
---|
5 | # look for creddy, |
---|
6 | if [ -n "${CREDDY_LOCATION}" ]; then |
---|
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, |
---|
21 | if [ -n "${PROVER_LOCATION}" ]; then |
---|
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 |
---|
49 | if [ $EXPECT ]; then |
---|
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 |
---|
56 | echo $rc |
---|
57 | fi |
---|
58 | } |
---|
59 | |
---|
60 | # runXTest fname test1 testbody expect matchResult msg |
---|
61 | # if expect success, expect=0 |
---|
62 | # if expect failure, expect=1 |
---|
63 | runXTest() { |
---|
64 | FNAME=$1 |
---|
65 | LABEL=$2 |
---|
66 | TESTBODY=$3 |
---|
67 | EXPECT=$4 |
---|
68 | MATCH=$5 |
---|
69 | MSG=$6 |
---|
70 | rc=`${TESTBODY} 2>&1` |
---|
71 | if [ $? -eq $EXPECT ]; then |
---|
72 | match=`echo "${rc}" | grep "${MATCH}" | wc -l` |
---|
73 | if [ $match -eq 1 ]; then |
---|
74 | echo "GOOD:${FNAME}:${LABEL}:${MSG}" |
---|
75 | else |
---|
76 | echo "BADX:${FNAME}:${LABEL}:${MSG}, but result is not as expected" |
---|
77 | fi |
---|
78 | else |
---|
79 | echo "BAD:${FNAME}:${LABEL}:${MSG}" |
---|
80 | fi |
---|
81 | if [ $debug -eq 1 ]; then |
---|
82 | echo $rc |
---|
83 | fi |
---|
84 | } |
---|
85 | |
---|
86 | # runCTest fname test1 testbody expect msg pattern count |
---|
87 | # if expect success, expect=0 |
---|
88 | # if expect failure, expect=1 |
---|
89 | runCTest() { |
---|
90 | FNAME=$1 |
---|
91 | LABEL=$2 |
---|
92 | TESTBODY=$3 |
---|
93 | EXPECT=$4 |
---|
94 | MSG=$5 |
---|
95 | PATTERN=$6 |
---|
96 | COUNT=$7 |
---|
97 | rc=`${TESTBODY} 1>atmp 2>/dev/null` |
---|
98 | if [ $? -eq $EXPECT ]; then |
---|
99 | cnt=`grep "$PATTERN" atmp | wc -l` |
---|
100 | if [ $cnt -eq $COUNT ]; then |
---|
101 | echo "GOOD:${FNAME}:${LABEL}:${MSG}" |
---|
102 | else |
---|
103 | echo "BAD:${FNAME}:${LABEL}:${MSG},did not have expected output" |
---|
104 | fi |
---|
105 | else |
---|
106 | if [ $EXPECT ]; then |
---|
107 | echo "BAD:${FNAME}:${LABEL}:expected failure but got success,${MSG}" |
---|
108 | else |
---|
109 | echo "BAD:${FNAME}:${LABEL}:${MSG}" |
---|
110 | fi |
---|
111 | fi |
---|
112 | rm -rf atmp |
---|
113 | return 0 |
---|
114 | } |
---|