prot-a-parse-cov.exp 9.2 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Test suite for lyskomd.
# Copyright (C) 1999  Lysator Academic Computer Association.
#
# 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
38
39
40
41
42
43
44
45
read_versions

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
46
Max links per text: 4
David Byers's avatar
David Byers committed
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
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


# Send a negative array size

send "1000 80 -1 { 1 }\n"
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


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

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

David Byers's avatar
David Byers committed
104
105
106
107
108
109
110
111
112
113
114
115
116
# 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
117
118
119

# Send membership type that is not eight bits long

David Byers's avatar
David Byers committed
120
121
# send "1006 102 5 5 0000000\n"
# protocol_error
David Byers's avatar
David Byers committed
122

David Byers's avatar
David Byers committed
123
124
# send "1007 102 5 5 000000000\n"
# protocol_error
David Byers's avatar
David Byers committed
125
126
127

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

David Byers's avatar
David Byers committed
128
129
# send "1008 21 5 000\n"
# protocol_error
David Byers's avatar
David Byers committed
130

David Byers's avatar
David Byers committed
131
132
# send "1009 21 5 00000\n"
# protocol_error
David Byers's avatar
David Byers committed
133

David Byers's avatar
David Byers committed
134
135
# send "1010 21 5 0000000\n"
# protocol_error
David Byers's avatar
David Byers committed
136

David Byers's avatar
David Byers committed
137
138
# send "1011 21 5 000000000\n"
# protocol_error
David Byers's avatar
David Byers committed
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


# Send a negative string length

send "1012 62 5 -6Hgazonk 0\n"
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"
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
202
203
204
# Try to send a long number list

kom_login 5 "gazonk" 0
David Byers's avatar
David Byers committed
205
206

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

David Byers's avatar
David Byers committed
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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"
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"
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"
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"
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
245

David Byers's avatar
David Byers committed
246
# Bad syntax for misc-info list
David Byers's avatar
David Byers committed
247

David Byers's avatar
David Byers committed
248
249
send "1026 86 [holl "TX"] 1 2 0 { }\n"
protocol_error
David Byers's avatar
David Byers committed
250

David Byers's avatar
David Byers committed
251
send "1027 86 [holl "TX"] 1 { 0 2 0 { }\n"
David Byers's avatar
David Byers committed
252
253
protocol_error

David Byers's avatar
David Byers committed
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290

# 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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# Bad array tests

send "2000 28 [holl "TX"] -1 { 0 5 }\n"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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
401
402
403
404
405
406
407
408
409
410
411
# 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