-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshilka.tst.in
225 lines (213 loc) · 5.33 KB
/
shilka.tst.in
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/sh
#
# Script to testing Shilka.
#
# Copyright (C) 1997-2016 Vladimir Makarov.
#
# Written by Vladimir Makarov <[email protected]>
#
# This file is part of the tool SHILKA.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU CC; see the file COPYING. If not, write to the Free
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
#
#
# Usage: shilka.tst
#
# The script requires GPERF.
#
SHILKA=./shilka
script_file=$0
CC='@CC@'
CC_options='@CFLAGS@'
test_shilka=temp.shilka
test_file=test.c
outfile=./a.out
stderr=_stderr.out
if test x$1 = x
then
start_test_number=1
else
if expr $1 + 0 >/dev/null
then
start_test_number=`expr $1 + 0`
else
echo $script_file:invalid argument $1 2>&1
exit 1
fi
fi
result=ok
# Test 1.
if test $result = ok -a $start_test_number -le 1; then
echo test 1
cat >$test_shilka <<'TEST1'
%%
sum
sync
ter
TEST1
echo ' ' $SHILKA $test_shilka "2>$stderr"
if $SHILKA $test_shilka 2>$stderr; then
cat >$test_file <<'TEST1'
#include <stdlib.h>
#include "temp.c"
int main ()
{
KR_reset ();
if (KR_find_keyword ("sum", 3) != KR_sum)
exit (1);
else if (KR_find_keyword ("SUM", 3) != KR__not_found)
exit (1);
else if (KR_find_keyword ("sync", 4) != KR_sync)
exit (1);
else if (KR_find_keyword ("SYNC", 4) != KR__not_found)
exit (1);
else if (KR_find_keyword ("ter", 3) != KR_ter)
exit (1);
else if (KR_find_keyword ("TER", 3) != KR__not_found)
exit (1);
else if (KR_find_keyword ("abraca", 6) != KR__not_found)
exit (1);
exit (0);
}
TEST1
echo ' ' $CC $CC_options $test_file -o $outfile
if $CC $CC_options $test_file -o $outfile; then
echo ' ' $outfile
if $outfile; then
result=ok
else
result=fail
fi
else
result=fail
fi
else
result=fail
fi
fi
# Test 2.
if test $result = ok -a $start_test_number -le 2; then
echo test 2
cat >$test_shilka <<'TEST2'
%%
sum
sync
ter
TEST2
echo ' ' $SHILKA -case $test_shilka "2>$stderr"
if $SHILKA -case $test_shilka 2>$stderr; then
cat >$test_file <<'TEST2'
#include <stdlib.h>
#include "temp.c"
int main ()
{
KR_reset ();
if (KR_find_keyword ("sum", 3) != KR_sum)
exit (1);
else if (KR_find_keyword ("SUM", 3) != KR_sum)
exit (1);
else if (KR_find_keyword ("sync", 4) != KR_sync)
exit (1);
else if (KR_find_keyword ("SYNC", 4) != KR_sync)
exit (1);
else if (KR_find_keyword ("ter", 3) != KR_ter)
exit (1);
else if (KR_find_keyword ("TER", 3) != KR_ter)
exit (1);
else if (KR_find_keyword ("abraca", 6) != KR__not_found)
exit (1);
exit (0);
}
TEST2
echo ' ' $CC $CC_options $test_file -o $outfile
if $CC $CC_options $test_file -o $outfile; then
echo ' ' $outfile
if $outfile; then
result=ok
else
result=fail
fi
else
result=fail
fi
else
result=fail
fi
fi
# Test 3.
if test $result = ok -a $start_test_number -le 3; then
echo test 3
cat >$test_shilka <<'TEST3'
%export {
#define THEN 2
#define THAN 3
#define IDENT 4
}
%%
Then {return THEN;}
than {return THAN;}
%other {return IDENT;}
TEST3
echo ' ' $SHILKA -case -no-definitions $test_shilka "2>$stderr"
if $SHILKA -case $test_shilka 2>$stderr; then
cat >$test_file <<'TEST3'
#include <stdlib.h>
#include "temp.c"
int main ()
{
KR_reset ();
if (KR_find_keyword ("Then", 4) != THEN)
exit (1);
else if (KR_find_keyword ("Than", 4) != THAN)
exit (1);
else if (KR_find_keyword ("then", 4) != THEN)
exit (1);
else if (KR_find_keyword ("than", 4) != THAN)
exit (1);
else if (KR_find_keyword ("THEN", 4) != THEN)
exit (1);
else if (KR_find_keyword ("THAN", 4) != THAN)
exit (1);
else if (KR_find_keyword ("abraca", 6) != IDENT)
exit (1);
exit (0);
}
TEST3
echo ' ' $CC $CC_options $test_file -o $outfile
if $CC $CC_options $test_file -o $outfile; then
echo ' ' $outfile
if $outfile; then
result=ok
else
result=fail
fi
else
result=fail
fi
else
result=fail
fi
fi
# Final message
if test $result = ok; then
echo $script_file: it is all ok
rm -f $test_file $test_shilka $outfile $stderr `basename $test_shilka .shilka`.c
exit 0
else
echo '***' $script_file: test is failed see files $test_file $test_shilka
exit 1
fi