forked from hercules-team/augeas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-interpreter.sh
executable file
·104 lines (91 loc) · 2.29 KB
/
test-interpreter.sh
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
#! /bin/bash
# Run test modules that make sure the interpreter fails/succeeds in
# various hairy situations.
#
# If run with option '-v', error output from each augparse run is printed
TOPDIR=$(cd $(dirname $0)/.. && pwd)
DATADIR=${abs_top_srcdir-${TOPDIR}}/tests
MODULES=${DATADIR}/modules
AUGPARSE=${abs_top_builddir-${DATADIR}/..}/src/augparse
set -e
VERBOSE=n
if [ "x$1" = "x-v" ]; then
VERBOSE=y
fi
run_tests_plain ()
{
ret_succ=$1
ret_fail=$(( 1 - $ret_succ ))
action=$2
shift
shift
for g in $*; do
if [ ! -r "$g" ]; then
echo "Grammar file $g is not readable"
exit 19
fi
printf "$action %-30s ... " $(basename $g .aug)
set +e
errs=$(augparse --nostdinc -I ${MODULES} $g 2>&1 > /dev/null)
ret=$?
set -e
if [ $ret -eq $ret_fail ]; then
echo FAIL
result=1
elif [ $ret -eq $ret_succ ]; then
echo PASS
else
echo ERROR
result=19
fi
if [ "$VERBOSE" = "y" ] ; then
echo $errs
fi
done
}
run_tests_valgrind ()
{
ret_succ=$1
ret_fail=$(( 1 - $ret_succ ))
action=$2
shift
shift
for g in $*; do
if [ ! -r "$g" ]; then
echo "Grammar file $g is not readable"
exit 19
fi
echo "========================================================="
printf "$action %-30s \n" $(basename $g .aug)
set +e
$VALGRIND $AUGPARSE --nostdinc -I ${MODULES} $g
ret=$?
set -e
if [ $ret -eq $ret_fail ]; then
echo FAIL
result=1
elif [ $ret -eq $ret_succ ]; then
echo PASS
else
echo ERROR
result=19
fi
if [ "$VERBOSE" = "y" ] ; then
echo $errs
fi
echo "---------------------------------------------------------"
done
}
if [ ! -x $AUGPARSE ] ; then
echo "Failed to find executable augparse"
echo " looked for $AUGPARSE"
exit 127
fi
echo "--------------------------------"
echo "Running interpreter tests"
echo
result=0
[ -z "$VALGRIND" ] && flavor=plain || flavor=valgrind
run_tests_$flavor 1 reject $MODULES/fail_*.aug
run_tests_$flavor 0 accept $MODULES/pass_*.aug
exit $result