diff options
Diffstat (limited to 'test/testclnt.lua')
-rw-r--r-- | test/testclnt.lua | 372 |
1 files changed, 184 insertions, 188 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua index 3e80a36..b2b4b18 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua | |||
@@ -43,7 +43,7 @@ function check_timeout(tm, sl, elapsed, err, opp, mode, alldone) | |||
43 | else pass("proper timeout") end | 43 | else pass("proper timeout") end |
44 | end | 44 | end |
45 | else | 45 | else |
46 | if mode == "return" then | 46 | if mode == "total" then |
47 | if elapsed > tm then | 47 | if elapsed > tm then |
48 | if err ~= "timeout" then fail("should have timed out") | 48 | if err ~= "timeout" then fail("should have timed out") |
49 | else pass("proper timeout") end | 49 | else pass("proper timeout") end |
@@ -66,17 +66,17 @@ function check_timeout(tm, sl, elapsed, err, opp, mode, alldone) | |||
66 | end | 66 | end |
67 | end | 67 | end |
68 | 68 | ||
69 | if not socket.debug then | ||
70 | fail("Please define LUASOCKET_DEBUG and recompile LuaSocket") | ||
71 | end | ||
72 | |||
69 | io.write("----------------------------------------------\n", | 73 | io.write("----------------------------------------------\n", |
70 | "LuaSocket Test Procedures\n", | 74 | "LuaSocket Test Procedures\n", |
71 | "----------------------------------------------\n") | 75 | "----------------------------------------------\n") |
72 | 76 | ||
73 | if not socket._time or not socket._sleep then | 77 | start = socket.time() |
74 | fail("not compiled with _DEBUG") | ||
75 | end | ||
76 | |||
77 | start = socket._time() | ||
78 | 78 | ||
79 | function tcpreconnect() | 79 | function reconnect() |
80 | io.write("attempting data connection... ") | 80 | io.write("attempting data connection... ") |
81 | if data then data:close() end | 81 | if data then data:close() end |
82 | remote [[ | 82 | remote [[ |
@@ -87,7 +87,6 @@ function tcpreconnect() | |||
87 | if not data then fail(err) | 87 | if not data then fail(err) |
88 | else pass("connected!") end | 88 | else pass("connected!") end |
89 | end | 89 | end |
90 | reconnect = tcpreconnect | ||
91 | 90 | ||
92 | pass("attempting control connection...") | 91 | pass("attempting control connection...") |
93 | control, err = socket.connect(host, port) | 92 | control, err = socket.connect(host, port) |
@@ -95,101 +94,78 @@ if err then fail(err) | |||
95 | else pass("connected!") end | 94 | else pass("connected!") end |
96 | 95 | ||
97 | ------------------------------------------------------------------------ | 96 | ------------------------------------------------------------------------ |
98 | test("bugs") | ||
99 | |||
100 | io.write("empty host connect: ") | ||
101 | function empty_connect() | ||
102 | if data then data:close() data = nil end | ||
103 | remote [[ | ||
104 | if data then data:close() data = nil end | ||
105 | data = server:accept() | ||
106 | ]] | ||
107 | data, err = socket.connect("", port) | ||
108 | if not data then | ||
109 | pass("ok") | ||
110 | data = socket.connect(host, port) | ||
111 | else fail("should not have connected!") end | ||
112 | end | ||
113 | |||
114 | empty_connect() | ||
115 | |||
116 | io.write("active close: ") | ||
117 | function active_close() | ||
118 | reconnect() | ||
119 | if socket._isclosed(data) then fail("should not be closed") end | ||
120 | data:close() | ||
121 | if not socket._isclosed(data) then fail("should be closed") end | ||
122 | data = nil | ||
123 | local udp = socket.udp() | ||
124 | if socket._isclosed(udp) then fail("should not be closed") end | ||
125 | udp:close() | ||
126 | if not socket._isclosed(udp) then fail("should be closed") end | ||
127 | pass("ok") | ||
128 | end | ||
129 | |||
130 | active_close() | ||
131 | |||
132 | ------------------------------------------------------------------------ | ||
133 | test("method registration") | 97 | test("method registration") |
134 | 98 | ||
135 | function test_methods(sock, methods) | 99 | function test_methods(sock, methods) |
136 | for _, v in methods do | 100 | for _, v in methods do |
137 | if type(sock[v]) ~= "function" then | 101 | if type(sock[v]) ~= "function" then |
138 | fail(type(sock) .. " method " .. v .. "not registered") | 102 | fail(sock.class .. " method '" .. v .. "' not registered") |
139 | end | 103 | end |
140 | end | 104 | end |
141 | pass(type(sock) .. " methods are ok") | 105 | pass(sock.class .. " methods are ok") |
142 | end | 106 | end |
143 | 107 | ||
144 | test_methods(control, { | 108 | test_methods(socket.tcp(), { |
145 | "close", | 109 | "connect", |
146 | "timeout", | 110 | "send", |
147 | "send", | 111 | "receive", |
148 | "receive", | 112 | "bind", |
113 | "accept", | ||
114 | "setpeername", | ||
115 | "setsockname", | ||
149 | "getpeername", | 116 | "getpeername", |
150 | "getsockname" | 117 | "getsockname", |
118 | "timeout", | ||
119 | "close", | ||
151 | }) | 120 | }) |
152 | 121 | ||
153 | if udpsocket then | 122 | test_methods(socket.udp(), { |
154 | test_methods(socket.udp(), { | 123 | "getpeername", |
155 | "close", | 124 | "getsockname", |
156 | "timeout", | 125 | "setsockname", |
157 | "send", | 126 | "setpeername", |
158 | "sendto", | 127 | "send", |
159 | "receive", | 128 | "sendto", |
160 | "receivefrom", | 129 | "receive", |
161 | "getpeername", | 130 | "receivefrom", |
162 | "getsockname", | ||
163 | "setsockname", | ||
164 | "setpeername" | ||
165 | }) | ||
166 | end | ||
167 | |||
168 | test_methods(socket.bind("*", 0), { | ||
169 | "close", | ||
170 | "timeout", | 131 | "timeout", |
171 | "accept" | 132 | "close", |
172 | }) | 133 | }) |
173 | 134 | ||
174 | ------------------------------------------------------------------------ | 135 | ------------------------------------------------------------------------ |
175 | test("select function") | 136 | test("mixed patterns") |
176 | function test_selectbugs() | 137 | |
177 | local r, s, e = socket.select(nil, nil, 0.1) | 138 | function test_mixed(len) |
178 | assert(type(r) == "table" and type(s) == "table" and e == "timeout") | 139 | reconnect() |
179 | pass("both nil: ok") | 140 | local inter = math.ceil(len/4) |
180 | local udp = socket.udp() | 141 | local p1 = "unix " .. string.rep("x", inter) .. "line\n" |
181 | udp:close() | 142 | local p2 = "dos " .. string.rep("y", inter) .. "line\r\n" |
182 | r, s, e = socket.select({ udp }, { udp }, 0.1) | 143 | local p3 = "raw " .. string.rep("z", inter) .. "bytes" |
183 | assert(type(r) == "table" and type(s) == "table" and e == "timeout") | 144 | local p4 = "end" .. string.rep("w", inter) .. "bytes" |
184 | pass("closed sockets: ok") | 145 | local bp1, bp2, bp3, bp4 |
185 | e = pcall(socket.select, "wrong", 1, 0.1) | 146 | pass(len .. " byte(s) patterns") |
186 | assert(e == false) | 147 | remote (string.format("str = data:receive(%d)", |
187 | e = pcall(socket.select, {}, 1, 0.1) | 148 | string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4))) |
188 | assert(e == false) | 149 | sent, err = data:send(p1, p2, p3, p4) |
189 | pass("invalid input: ok") | 150 | if err then fail(err) end |
151 | remote "data:send(str); data:close()" | ||
152 | bp1, bp2, bp3, bp4, err = data:receive("*l", "*l", string.len(p3), "*a") | ||
153 | if err then fail(err) end | ||
154 | if bp1.."\n" == p1 and bp2.."\r\n" == p2 and bp3 == p3 and bp4 == p4 then | ||
155 | pass("patterns match") | ||
156 | else fail("patterns don't match") end | ||
190 | end | 157 | end |
191 | 158 | ||
192 | test_selectbugs() | 159 | |
160 | test_mixed(1) | ||
161 | test_mixed(17) | ||
162 | test_mixed(200) | ||
163 | test_mixed(4091) | ||
164 | test_mixed(80199) | ||
165 | test_mixed(4091) | ||
166 | test_mixed(200) | ||
167 | test_mixed(17) | ||
168 | test_mixed(1) | ||
193 | 169 | ||
194 | ------------------------------------------------------------------------ | 170 | ------------------------------------------------------------------------ |
195 | test("character line") | 171 | test("character line") |
@@ -202,7 +178,7 @@ function test_asciiline(len) | |||
202 | str = str .. str10 | 178 | str = str .. str10 |
203 | pass(len .. " byte(s) line") | 179 | pass(len .. " byte(s) line") |
204 | remote "str = data:receive()" | 180 | remote "str = data:receive()" |
205 | err = data:send(str, "\n") | 181 | sent, err = data:send(str, "\n") |
206 | if err then fail(err) end | 182 | if err then fail(err) end |
207 | remote "data:send(str, '\\n')" | 183 | remote "data:send(str, '\\n')" |
208 | back, err = data:receive() | 184 | back, err = data:receive() |
@@ -230,7 +206,7 @@ function test_rawline(len) | |||
230 | str = str .. str10 | 206 | str = str .. str10 |
231 | pass(len .. " byte(s) line") | 207 | pass(len .. " byte(s) line") |
232 | remote "str = data:receive()" | 208 | remote "str = data:receive()" |
233 | err = data:send(str, "\n") | 209 | sent, err = data:send(str, "\n") |
234 | if err then fail(err) end | 210 | if err then fail(err) end |
235 | remote "data:send(str, '\\n')" | 211 | remote "data:send(str, '\\n')" |
236 | back, err = data:receive() | 212 | back, err = data:receive() |
@@ -262,9 +238,9 @@ function test_raw(len) | |||
262 | s2 = string.rep("y", len-half) | 238 | s2 = string.rep("y", len-half) |
263 | pass(len .. " byte(s) block") | 239 | pass(len .. " byte(s) block") |
264 | remote (string.format("str = data:receive(%d)", len)) | 240 | remote (string.format("str = data:receive(%d)", len)) |
265 | err = data:send(s1) | 241 | sent, err = data:send(s1) |
266 | if err then fail(err) end | 242 | if err then fail(err) end |
267 | err = data:send(s2) | 243 | sent, err = data:send(s2) |
268 | if err then fail(err) end | 244 | if err then fail(err) end |
269 | remote "data:send(str)" | 245 | remote "data:send(str)" |
270 | back, err = data:receive(len) | 246 | back, err = data:receive(len) |
@@ -304,127 +280,54 @@ test_raw(17) | |||
304 | test_raw(1) | 280 | test_raw(1) |
305 | 281 | ||
306 | ------------------------------------------------------------------------ | 282 | ------------------------------------------------------------------------ |
307 | test("mixed patterns") | 283 | test("total timeout on receive") |
308 | reconnect() | 284 | function test_totaltimeoutreceive(len, tm, sl) |
309 | |||
310 | function test_mixed(len) | ||
311 | local inter = math.floor(len/3) | ||
312 | local p1 = "unix " .. string.rep("x", inter) .. "line\n" | ||
313 | local p2 = "dos " .. string.rep("y", inter) .. "line\r\n" | ||
314 | local p3 = "raw " .. string.rep("z", inter) .. "bytes" | ||
315 | local bp1, bp2, bp3 | ||
316 | pass(len .. " byte(s) patterns") | ||
317 | remote (string.format("str = data:receive(%d)", | ||
318 | string.len(p1)+string.len(p2)+string.len(p3))) | ||
319 | err = data:send(p1, p2, p3) | ||
320 | if err then fail(err) end | ||
321 | remote "data:send(str)" | ||
322 | bp1, bp2, bp3, err = data:receive("*lu", "*l", string.len(p3)) | ||
323 | if err then fail(err) end | ||
324 | if bp1.."\n" == p1 and bp2.."\r\n" == p2 and bp3 == p3 then | ||
325 | pass("patterns match") | ||
326 | else fail("patterns don't match") end | ||
327 | end | ||
328 | |||
329 | test_mixed(1) | ||
330 | test_mixed(17) | ||
331 | test_mixed(200) | ||
332 | test_mixed(4091) | ||
333 | test_mixed(80199) | ||
334 | test_mixed(800000) | ||
335 | test_mixed(80199) | ||
336 | test_mixed(4091) | ||
337 | test_mixed(200) | ||
338 | test_mixed(17) | ||
339 | test_mixed(1) | ||
340 | |||
341 | ------------------------------------------------------------------------ | ||
342 | test("closed connection detection") | ||
343 | |||
344 | function test_closed() | ||
345 | local back, err | ||
346 | local str = 'little string' | ||
347 | reconnect() | ||
348 | pass("trying read detection") | ||
349 | remote (string.format ([[ | ||
350 | data:send('%s') | ||
351 | data:close() | ||
352 | data = nil | ||
353 | ]], str)) | ||
354 | -- try to get a line | ||
355 | back, err = data:receive() | ||
356 | if not err then fail("shold have gotten 'closed'.") | ||
357 | elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") | ||
358 | elseif str ~= back then fail("didn't receive partial result.") | ||
359 | else pass("graceful 'closed' received") end | ||
360 | reconnect() | ||
361 | pass("trying write detection") | ||
362 | remote [[ | ||
363 | data:close() | ||
364 | data = nil | ||
365 | ]] | ||
366 | err, total = data:send(string.rep("ugauga", 100000)) | ||
367 | if not err then | ||
368 | pass("failed: output buffer is at least %d bytes long!", total) | ||
369 | elseif err ~= "closed" then | ||
370 | fail("got '"..err.."' instead of 'closed'.") | ||
371 | else | ||
372 | pass("graceful 'closed' received after %d bytes were sent", total) | ||
373 | end | ||
374 | end | ||
375 | |||
376 | test_closed() | ||
377 | |||
378 | ------------------------------------------------------------------------ | ||
379 | test("return timeout on receive") | ||
380 | function test_blockingtimeoutreceive(len, tm, sl) | ||
381 | local str, err, total | 285 | local str, err, total |
382 | reconnect() | 286 | reconnect() |
383 | pass("%d bytes, %ds return timeout, %ds pause", len, tm, sl) | 287 | pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) |
384 | remote (string.format ([[ | 288 | remote (string.format ([[ |
385 | data:timeout(%d) | 289 | data:timeout(%d) |
386 | str = string.rep('a', %d) | 290 | str = string.rep('a', %d) |
387 | data:send(str) | 291 | data:send(str) |
388 | print('server: sleeping for %ds') | 292 | print('server: sleeping for %ds') |
389 | socket._sleep(%d) | 293 | socket.sleep(%d) |
390 | print('server: woke up') | 294 | print('server: woke up') |
391 | data:send(str) | 295 | data:send(str) |
392 | ]], 2*tm, len, sl, sl)) | 296 | ]], 2*tm, len, sl, sl)) |
393 | data:timeout(tm, "return") | 297 | data:timeout(tm, "total") |
394 | str, err, elapsed = data:receive(2*len) | 298 | str, err, elapsed = data:receive(2*len) |
395 | check_timeout(tm, sl, elapsed, err, "receive", "return", | 299 | check_timeout(tm, sl, elapsed, err, "receive", "total", |
396 | string.len(str) == 2*len) | 300 | string.len(str) == 2*len) |
397 | end | 301 | end |
398 | test_blockingtimeoutreceive(800091, 1, 3) | 302 | test_totaltimeoutreceive(800091, 1, 3) |
399 | test_blockingtimeoutreceive(800091, 2, 3) | 303 | test_totaltimeoutreceive(800091, 2, 3) |
400 | test_blockingtimeoutreceive(800091, 3, 2) | 304 | test_totaltimeoutreceive(800091, 3, 2) |
401 | test_blockingtimeoutreceive(800091, 3, 1) | 305 | test_totaltimeoutreceive(800091, 3, 1) |
402 | 306 | ||
403 | ------------------------------------------------------------------------ | 307 | ------------------------------------------------------------------------ |
404 | test("return timeout on send") | 308 | test("total timeout on send") |
405 | function test_returntimeoutsend(len, tm, sl) | 309 | function test_totaltimeoutsend(len, tm, sl) |
406 | local str, err, total | 310 | local str, err, total |
407 | reconnect() | 311 | reconnect() |
408 | pass("%d bytes, %ds return timeout, %ds pause", len, tm, sl) | 312 | pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) |
409 | remote (string.format ([[ | 313 | remote (string.format ([[ |
410 | data:timeout(%d) | 314 | data:timeout(%d) |
411 | str = data:receive(%d) | 315 | str = data:receive(%d) |
412 | print('server: sleeping for %ds') | 316 | print('server: sleeping for %ds') |
413 | socket._sleep(%d) | 317 | socket.sleep(%d) |
414 | print('server: woke up') | 318 | print('server: woke up') |
415 | str = data:receive(%d) | 319 | str = data:receive(%d) |
416 | ]], 2*tm, len, sl, sl, len)) | 320 | ]], 2*tm, len, sl, sl, len)) |
417 | data:timeout(tm, "return") | 321 | data:timeout(tm, "total") |
418 | str = string.rep("a", 2*len) | 322 | str = string.rep("a", 2*len) |
419 | err, total, elapsed = data:send(str) | 323 | total, err, elapsed = data:send(str) |
420 | check_timeout(tm, sl, elapsed, err, "send", "return", | 324 | check_timeout(tm, sl, elapsed, err, "send", "total", |
421 | total == 2*len) | 325 | total == 2*len) |
422 | end | 326 | end |
423 | test_returntimeoutsend(800091, 1, 3) | 327 | test_totaltimeoutsend(800091, 1, 3) |
424 | test_returntimeoutsend(800091, 2, 3) | 328 | test_totaltimeoutsend(800091, 2, 3) |
425 | test_returntimeoutsend(800091, 3, 2) | 329 | test_totaltimeoutsend(800091, 3, 2) |
426 | test_returntimeoutsend(800091, 3, 1) | 330 | test_totaltimeoutsend(800091, 3, 1) |
427 | |||
428 | 331 | ||
429 | ------------------------------------------------------------------------ | 332 | ------------------------------------------------------------------------ |
430 | test("blocking timeout on receive") | 333 | test("blocking timeout on receive") |
@@ -437,7 +340,7 @@ function test_blockingtimeoutreceive(len, tm, sl) | |||
437 | str = string.rep('a', %d) | 340 | str = string.rep('a', %d) |
438 | data:send(str) | 341 | data:send(str) |
439 | print('server: sleeping for %ds') | 342 | print('server: sleeping for %ds') |
440 | socket._sleep(%d) | 343 | socket.sleep(%d) |
441 | print('server: woke up') | 344 | print('server: woke up') |
442 | data:send(str) | 345 | data:send(str) |
443 | ]], 2*tm, len, sl, sl)) | 346 | ]], 2*tm, len, sl, sl)) |
@@ -451,7 +354,6 @@ test_blockingtimeoutreceive(800091, 2, 3) | |||
451 | test_blockingtimeoutreceive(800091, 3, 2) | 354 | test_blockingtimeoutreceive(800091, 3, 2) |
452 | test_blockingtimeoutreceive(800091, 3, 1) | 355 | test_blockingtimeoutreceive(800091, 3, 1) |
453 | 356 | ||
454 | |||
455 | ------------------------------------------------------------------------ | 357 | ------------------------------------------------------------------------ |
456 | test("blocking timeout on send") | 358 | test("blocking timeout on send") |
457 | function test_blockingtimeoutsend(len, tm, sl) | 359 | function test_blockingtimeoutsend(len, tm, sl) |
@@ -462,13 +364,13 @@ function test_blockingtimeoutsend(len, tm, sl) | |||
462 | data:timeout(%d) | 364 | data:timeout(%d) |
463 | str = data:receive(%d) | 365 | str = data:receive(%d) |
464 | print('server: sleeping for %ds') | 366 | print('server: sleeping for %ds') |
465 | socket._sleep(%d) | 367 | socket.sleep(%d) |
466 | print('server: woke up') | 368 | print('server: woke up') |
467 | str = data:receive(%d) | 369 | str = data:receive(%d) |
468 | ]], 2*tm, len, sl, sl, len)) | 370 | ]], 2*tm, len, sl, sl, len)) |
469 | data:timeout(tm) | 371 | data:timeout(tm) |
470 | str = string.rep("a", 2*len) | 372 | str = string.rep("a", 2*len) |
471 | err, total, elapsed = data:send(str) | 373 | total, err, elapsed = data:send(str) |
472 | check_timeout(tm, sl, elapsed, err, "send", "blocking", | 374 | check_timeout(tm, sl, elapsed, err, "send", "blocking", |
473 | total == 2*len) | 375 | total == 2*len) |
474 | end | 376 | end |
@@ -478,4 +380,98 @@ test_blockingtimeoutsend(800091, 3, 2) | |||
478 | test_blockingtimeoutsend(800091, 3, 1) | 380 | test_blockingtimeoutsend(800091, 3, 1) |
479 | 381 | ||
480 | ------------------------------------------------------------------------ | 382 | ------------------------------------------------------------------------ |
481 | test(string.format("done in %.2fs", socket._time() - start)) | 383 | test("bugs") |
384 | |||
385 | io.write("empty host connect: ") | ||
386 | function empty_connect() | ||
387 | if data then data:close() data = nil end | ||
388 | remote [[ | ||
389 | if data then data:close() data = nil end | ||
390 | data = server:accept() | ||
391 | ]] | ||
392 | data, err = socket.connect("", port) | ||
393 | if not data then | ||
394 | pass("ok") | ||
395 | data = socket.connect(host, port) | ||
396 | else fail("should not have connected!") end | ||
397 | end | ||
398 | |||
399 | empty_connect() | ||
400 | |||
401 | -- io.write("active close: ") | ||
402 | function active_close() | ||
403 | reconnect() | ||
404 | if socket._isclosed(data) then fail("should not be closed") end | ||
405 | data:close() | ||
406 | if not socket._isclosed(data) then fail("should be closed") end | ||
407 | data = nil | ||
408 | local udp = socket.udp() | ||
409 | if socket._isclosed(udp) then fail("should not be closed") end | ||
410 | udp:close() | ||
411 | if not socket._isclosed(udp) then fail("should be closed") end | ||
412 | pass("ok") | ||
413 | end | ||
414 | |||
415 | -- active_close() | ||
416 | |||
417 | ------------------------------------------------------------------------ | ||
418 | test("closed connection detection") | ||
419 | |||
420 | function test_closed() | ||
421 | local back, err | ||
422 | local str = 'little string' | ||
423 | reconnect() | ||
424 | pass("trying read detection") | ||
425 | remote (string.format ([[ | ||
426 | data:send('%s') | ||
427 | data:close() | ||
428 | data = nil | ||
429 | ]], str)) | ||
430 | -- try to get a line | ||
431 | back, err = data:receive() | ||
432 | if not err then fail("shold have gotten 'closed'.") | ||
433 | elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") | ||
434 | elseif str ~= back then fail("didn't receive partial result.") | ||
435 | else pass("graceful 'closed' received") end | ||
436 | reconnect() | ||
437 | pass("trying write detection") | ||
438 | remote [[ | ||
439 | data:close() | ||
440 | data = nil | ||
441 | ]] | ||
442 | total, err = data:send(string.rep("ugauga", 100000)) | ||
443 | if not err then | ||
444 | pass("failed: output buffer is at least %d bytes long!", total) | ||
445 | elseif err ~= "closed" then | ||
446 | fail("got '"..err.."' instead of 'closed'.") | ||
447 | else | ||
448 | pass("graceful 'closed' received after %d bytes were sent", total) | ||
449 | end | ||
450 | end | ||
451 | |||
452 | test_closed() | ||
453 | |||
454 | ------------------------------------------------------------------------ | ||
455 | test("select function") | ||
456 | function test_selectbugs() | ||
457 | local r, s, e = socket.select(nil, nil, 0.1) | ||
458 | assert(type(r) == "table" and type(s) == "table" and e == "timeout") | ||
459 | pass("both nil: ok") | ||
460 | local udp = socket.udp() | ||
461 | udp:close() | ||
462 | r, s, e = socket.select({ udp }, { udp }, 0.1) | ||
463 | assert(type(r) == "table" and type(s) == "table" and e == "timeout") | ||
464 | pass("closed sockets: ok") | ||
465 | e = pcall(socket.select, "wrong", 1, 0.1) | ||
466 | assert(e == false) | ||
467 | e = pcall(socket.select, {}, 1, 0.1) | ||
468 | assert(e == false) | ||
469 | pass("invalid input: ok") | ||
470 | end | ||
471 | |||
472 | -- test_selectbugs() | ||
473 | |||
474 | |||
475 | |||
476 | |||
477 | test(string.format("done in %.2fs", socket.time() - start)) | ||