prot-a-parse-cov.exp 10.9 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
# Test suite for lyskomd.
Per Cederqvist's avatar
Per Cederqvist committed
2
# Copyright (C) 1999, 2001-2002  Lysator Academic Computer Association.
Per Cederqvist's avatar
Per Cederqvist committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# This file is part of the LysKOM server.
# 
# LysKOM 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 1, or (at your option) 
# any later version.
# 
# LysKOM 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 LysKOM; see the file COPYING.  If not, write to
# Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
# or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
# MA 02139, USA.
#
# Please mail bug reports to bug-lyskom@lysator.liu.se. 


David Byers's avatar
David Byers committed
25
26
27
# Supplemental test cases for prot-a-parse.c


28
# FIXME (bug 229): check long strings:
David Byers's avatar
David Byers committed
29
30
31
32
33
34
# Try to send a long string that is split into packages
# Try to send a string that will get truncated and that gets sent
#     in several packages
# These trigger the branches that longjump to ISC_MSG_INCOMPLETE 
# I think. But I'm not sure.

35
source "$srcdir/config/prot-a.exp"
David Byers's avatar
David Byers committed
36
37
read_versions

38
39
set bignum [exec ./bignum]

David Byers's avatar
David Byers committed
40
41
42
43
44
45
46
47
proc protocol_error {} {
    simple_expect "%% LysKOM protocol error."
}

lyskomd_start "" "\
Max password length: 8
Max aux_items deleted per call: 1
Max aux_items added per call: 1
David Byers's avatar
David Byers committed
48
Max links per text: 4
David Byers's avatar
David Byers committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Max text length: 100
"

# Send an insane token length

client_start 0
talk_to client 0
kom_connect "DejaGnu Test Sweet"
kom_accept_async "0 { }"
hose_client
simple_expect "%%Insane token length."
client_death 0


# Send some numbers followed by alphanumerics

client_start 0
talk_to client 0
kom_connect "DejaGnu Test Bitter"
kom_accept_async "0 { }"
send "1POPGOESTHEWEASEL 9999\n"
protocol_error


73
# Send a "negative" array size
David Byers's avatar
David Byers committed
74
75

send "1000 80 -1 { 1 }\n"
76
simple_expect "%% LysKOM protocol error."
77
send "1000 80 $bignum { 1 }\n"
David Byers's avatar
David Byers committed
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
simple_expect "%%Insane array size."
client_death 0


# Forget the opening curly of an array

client_start 0
talk_to client 0
kom_connect "DejaGnu Test Bitter"
kom_accept_async "0 { }"

send "1001 80 1 1 }\n"
protocol_error

# Forget the closing curly (or get the length wrong)

send "1002 80 1 { 1 10 }\n"
protocol_error

# For completeness, specify the array as longer than it is

send "1003 80 9 { 1 10 }\n"
protocol_error


103
104
# FIXME (bug 221): We should check that the parsers really handle
# variable-length bitfields.
David Byers's avatar
David Byers committed
105

David Byers's avatar
David Byers committed
106
# Sent a short or long aux-item-flags
David Byers's avatar
David Byers committed
107

David Byers's avatar
David Byers committed
108
109
110
111
112
113
114
115
116
117
118
119
120
# send "1015 86 [holl "Text"] 0 { } 1 { 1 0000000 0 [holl "A"] }\n"
# protocol_error
# 
# send "1016 86 [holl "Text"] 0 { } 1 { 1 000000000 0 [holl "A"] }\n"
# protocol_error

# Send priv bits that are too long

# send "1004 7 5 000000000000000\n"
# protocol_error

# send "1005 7 5 00000000000000000\n"
# protocol_error
David Byers's avatar
David Byers committed
121
122
123

# Send membership type that is not eight bits long

David Byers's avatar
David Byers committed
124
125
# send "1006 102 5 5 0000000\n"
# protocol_error
David Byers's avatar
David Byers committed
126

David Byers's avatar
David Byers committed
127
128
# send "1007 102 5 5 000000000\n"
# protocol_error
David Byers's avatar
David Byers committed
129
130
131

# Send conf type that is not four or eight bits long

David Byers's avatar
David Byers committed
132
133
# send "1008 21 5 000\n"
# protocol_error
David Byers's avatar
David Byers committed
134

David Byers's avatar
David Byers committed
135
136
# send "1009 21 5 00000\n"
# protocol_error
David Byers's avatar
David Byers committed
137

David Byers's avatar
David Byers committed
138
139
# send "1010 21 5 0000000\n"
# protocol_error
David Byers's avatar
David Byers committed
140

David Byers's avatar
David Byers committed
141
142
# send "1011 21 5 000000000\n"
# protocol_error
David Byers's avatar
David Byers committed
143
144


145
# Send a "negative" string length
David Byers's avatar
David Byers committed
146
147

send "1012 62 5 -6Hgazonk 0\n"
148
simple_expect "%% LysKOM protocol error."
149
send "1012 62 5 ${bignum}Hgazonk 0\n"
David Byers's avatar
David Byers committed
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
simple_expect "%%Insane string length."
client_death 0

client_start 0
talk_to client 0
kom_connect "DejaGnu Test Bitter"
kom_accept_async "0 { }"

# Try to send a string without an H, with a Q

send "1013 62 5 Hgazonk 0\n"
protocol_error

send "1014 62 5 6Qgazonk 0\n"
protocol_error

# Send a long string

send "1015 86 [holl "This
is
a
test
of
something
I 
think"] 0 { } 0 { }\n"
simple_expect "%1015 6 0"

send "1015 86 [holl "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX"] 0 { } 0 { }\n"
simple_expect "%1015 6 0"



# Forget opening brace in aux-item-list, closing brace, too long array
# negative length

send "1016 86 [holl "Text"] 0 { } 1 1 00000000 0 [holl "A"] }\n"
protocol_error

send "1017 86 [holl "Text"] 0 { } 1 { 1 00000000 0 [holl "A"] 1 00000000 0 [holl "A"] }\n"
protocol_error

send "1018 86 [holl "Text"] 0 { } 2 { 1 00000000 0 [holl "A"] }\n"
protocol_error

send "1019 86 [holl "Text"] 0 { } -1 { 1 00000000 0 [holl "A"] }\n"
202
simple_expect "%% LysKOM protocol error."
203
send "1019 86 [holl "Text"] 0 { } ${bignum} { 1 00000000 0 [holl "A"] }\n"
David Byers's avatar
David Byers committed
204
205
206
207
208
209
simple_expect "%%Insane array size."
client_death 0
client_start 0
kom_connect [holl "DejaGnu Test Suite"]
kom_accept_async "0 { }"

David Byers's avatar
David Byers committed
210
211
212
# Try to send a long number list

kom_login 5 "gazonk" 0
David Byers's avatar
David Byers committed
213
214

send "1020 92 1 10 { 1 2 3 4 5 6 7 8 9 10 } 0 { }\n"
David Byers's avatar
David Byers committed
215
simple_expect "%1020 46 1"
David Byers's avatar
David Byers committed
216

David Byers's avatar
David Byers committed
217
218
219
220
221
222
send "1021 92 1 0 { } 3 { 1 00000000 0 [holl "A"] 2 00000000 0 [holl "B"] 3 00000000 0 [holl "C"] }\n"
simple_expect "%1021 46 1"

# Try to send a short delete list, add list and misc-info list

send "1022 92 1 -1 { } 0 { }\n"
223
224
simple_expect "%% LysKOM protocol error."
send "1022 92 1 4294967295 { } 0 { }\n"
David Byers's avatar
David Byers committed
225
226
227
228
229
230
231
232
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "1023 92 1 0 { } -1 { }\n"
233
234
simple_expect "%% LysKOM protocol error."
send "1023 92 1 0 { } 4294967295 { }\n"
David Byers's avatar
David Byers committed
235
236
237
238
239
240
241
242
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "1024 86 [holl "TX"] -1 { } 0 { }\n"
243
244
simple_expect "%% LysKOM protocol error."
send "1024 86 [holl "TX"] 4294967295 { } 0 { }\n"
David Byers's avatar
David Byers committed
245
246
247
248
249
250
251
252
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "1025 86 [holl "TX"] 0 { } -1 { }\n"
253
254
simple_expect "%% LysKOM protocol error."
send "1025 86 [holl "TX"] 0 { } 4294967295 { }\n"
David Byers's avatar
David Byers committed
255
256
257
258
259
260
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"
David Byers's avatar
David Byers committed
261

David Byers's avatar
David Byers committed
262
# Bad syntax for misc-info list
David Byers's avatar
David Byers committed
263

David Byers's avatar
David Byers committed
264
265
send "1026 86 [holl "TX"] 1 2 0 { }\n"
protocol_error
David Byers's avatar
David Byers committed
266

David Byers's avatar
David Byers committed
267
send "1027 86 [holl "TX"] 1 { 0 2 0 { }\n"
David Byers's avatar
David Byers committed
268
269
protocol_error

David Byers's avatar
David Byers committed
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# Send a long misc-info list

kom_login 5 "gazonk" 0
send "1028 86 [holl "TX"] 6 { 0 1 0 2 0 3 0 4 0 9 0 10 } 0 { }\n"
simple_expect "%1028 46 4"

send "1029 86 [holl "TX"] 4 { 5 0 7 1 2 3 4 5 6 7 8 9 8 5 9 1 2 3 4 5 6 7 8 9 } 0 { }\n"
simple_expect "%1029 25 0"




# Send a misc-info list that contains an invalid item with complex data

kom_login 5 "gazonk" 0

send "1042 86 [holl "TX"] 1 { 999 999 3HABC 1 { 1 { } } } 0 { }\n"
simple_expect "%1042 26 999"

David Byers's avatar
David Byers committed
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306

# Tests for prot_a_hunt_nl

send "1100 9999 A\n"
protocol_error

send "1101 9999 [holl "Data"] [holl "End
of
Data"]\n"
simple_expect "%1101 2 0"

send "1102 9999 1 { 12 } \r\t 1234\n"
simple_expect "%1102 2 0"


send "1103 9999 ERROR\n"
protocol_error

David Byers's avatar
David Byers committed
307
308
309
# Bad array tests

send "2000 28 [holl "TX"] -1 { 0 5 }\n"
310
311
simple_expect "%% LysKOM protocol error."
send "2000 28 [holl "TX"] 4294967295 { 0 5 }\n"
David Byers's avatar
David Byers committed
312
313
314
315
316
317
318
319
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2001 59 [holl "TX"] -1 { 0 5 }\n"
320
321
simple_expect "%% LysKOM protocol error."
send "2001 59 [holl "TX"] 4294967295 { 0 5 }\n"
David Byers's avatar
David Byers committed
322
323
324
325
326
327
328
329
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2002 80 -1 { }\n"
330
331
simple_expect "%% LysKOM protocol error."
send "2002 80 4294967295 { }\n"
David Byers's avatar
David Byers committed
332
333
334
335
336
337
338
339
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2003 86 [holl "TX"] -1 { } 0 { }\n"
340
341
simple_expect "%% LysKOM protocol error."
send "2003 86 [holl "TX"] 4294967295 { } 0 { }\n"
David Byers's avatar
David Byers committed
342
343
344
345
346
347
348
349
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2003 87 [holl "TX"] -1 { } 0 { }\n"
350
351
simple_expect "%% LysKOM protocol error."
send "2003 87 [holl "TX"] 4294967295 { } 0 { }\n"
David Byers's avatar
David Byers committed
352
353
354
355
356
357
358
359
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2004 86 [holl "TX"] 0 { } -1 { }\n"
360
361
simple_expect "%% LysKOM protocol error."
send "2004 86 [holl "TX"] 0 { } 4294967295 { }\n"
David Byers's avatar
David Byers committed
362
363
364
365
366
367
368
369
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2005 87 [holl "TX"] 0 { } -1 { }\n"
370
371
simple_expect "%% LysKOM protocol error."
send "2005 87 [holl "TX"] 0 { } 4294967295 { }\n"
David Byers's avatar
David Byers committed
372
373
374
375
376
377
378
379
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2006 88 [holl "CC"] 00000000 -1 { }\n"
380
381
simple_expect "%% LysKOM protocol error."
send "2006 88 [holl "CC"] 00000000 4294967295 { }\n"
David Byers's avatar
David Byers committed
382
383
384
385
386
387
388
389
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2007 89 [holl "PP"] [holl "PW"] 0 -1 { }\n"
390
simple_expect "%% LysKOM protocol error."
391
send "2007 89 [holl "PP"] [holl "PW"] 0 ${bignum} { }\n"
David Byers's avatar
David Byers committed
392
393
394
395
396
397
398
399
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2008 92 1 -1 { } 0 { }\n"
400
simple_expect "%% LysKOM protocol error."
401
send "2008 92 1 ${bignum} { } 0 { }\n"
David Byers's avatar
David Byers committed
402
403
404
405
406
407
408
409
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2009 93 1 -1 { } 0 { }\n"
410
simple_expect "%% LysKOM protocol error."
411
send "2009 93 1 ${bignum} { } 0 { }\n"
David Byers's avatar
David Byers committed
412
413
414
415
416
417
418
419
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

send "2008 95 -1 { } 0 { }\n"
420
421
simple_expect "%% LysKOM protocol error."
send "2008 95 4294967295 { } 0 { }\n"
David Byers's avatar
David Byers committed
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
simple_expect "%%Insane array size."
client_death 0
client_start 0
talk_to client 0
kom_connect "DejaGnu Test Lager"
kom_accept_async "0 { }"

# Test some illegal stuff that has caused crashes in the past
# Get a parse error while truncating an array

send "3000 95 0 { } 10 { 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] 10000 00000000 0 [holl "X"] }\n"
protocol_error

send "3001 95 10 { 1 2 3 4 5 6 7 8 9 XX } 0 { }\n"
protocol_error

send "3001 86 [holl "A Text"] 10 { 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 XX } 0 { }\n"
protocol_error

David Byers's avatar
David Byers committed
441
442
443
444
445
446
447
448
449
450
451
# Finish

talk_to client 0
kom_login 5 "gazonk" 0
kom_enable 255

send "9999 44 0\n"
simple_expect "=9999"

client_death 0
lyskomd_death