Newer
Older
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
#!/usr/bin/env bash
# $1 test dir suffix (debug / release)
# SETTINGS
TESTCASE_TIMEOUT=10
LOGFILE="log_tests.txt"
EXECUTABLES="aecho2"
TESTS_DIR="../examples2"
RES_GOOD=0
RES_FAIL=0
RES_TIME=0
RES_SEGV=0
RES_UNKN=0
# ----------------------------
for FILE in $EXECUTABLES; do
if [ ! -f bin-$1/$FILE ]; then
echo "Executable $FILE is required for testing. Make sure it is in bin-$1 folder."
exit 1
fi
done
cd bin-$1/
rm -f $LOGFILE
# ----------------------------
# $1 = conv command
# $2 = return code
# $3 = input automaton
# $4 = output of conversion
function log {
echo "----------------------------------------------------------" >> $LOGFILE
echo "conv: " $1 >> $LOGFILE
echo "ret: " $2 >> $LOGFILE
echo "input automaton:" >> $LOGFILE
echo "command out:" >> $LOGFILE
echo "$4" >> $LOGFILE
}
# $1 = command for conversion. Output of such command must be (eps-)NFA !!
# $2 = automaton
function runTest2 {
OUT=`timeout $TESTCASE_TIMEOUT bash -c "cat $2 | ./aecho2 "`
RET=$?
if [ $RET == 0 ]; then # ok
return 0
fi
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
if [ $RET == 124 ]; then # timeout
return 2
elif [ $RET -ge 124 ]; then #segv
return 3
else
return 1
fi
}
function registerResult {
case $1 in
0)
echo -n "."
((RES_GOOD++))
;;
1)
echo -n "x"
((RES_FAIL++))
;;
2)
echo -n "T"
((RES_TIME++))
;;
3)
echo -n "E"
((RES_SEGV++))
;;
*)
echo -n "?"
((RES_UNKN++))
;;
esac
}
function clearResults {
RES_GOOD=0
RES_FAIL=0
RES_TIME=0
RES_SEGV=0
RES_UNKN=0
}
function outputResults {
# summary
echo -ne "\n\t"
echo "RES: GOOD:" $RES_GOOD ", FAIL:" $RES_FAIL ", TIME:" $RES_TIME ", SEGV:" $RES_SEGV, "UNKN:" $RES_UNKN
echo ""
}
# $1 - aconversions2 sequence
function runTest {
echo -ne "\t"
clearResults
# predefined tests first
for FILE in `ls $TESTS_DIR/$1/*.xml`; do
registerResult $?
done
outputResults
}
runTest "automaton"
runTest "grammar"
runTest "regexp"
runTest "string"