aboutsummaryrefslogtreecommitdiff
path: root/test/testclnt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/testclnt.lua')
-rw-r--r--test/testclnt.lua43
1 files changed, 38 insertions, 5 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index a7ca1ba..1f03b10 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -342,6 +342,7 @@ end
342------------------------------------------------------------------------ 342------------------------------------------------------------------------
343function test_selectbugs() 343function test_selectbugs()
344 local r, s, e = socket.select(nil, nil, 0.1) 344 local r, s, e = socket.select(nil, nil, 0.1)
345print(r, s, e)
345 assert(type(r) == "table" and type(s) == "table" and 346 assert(type(r) == "table" and type(s) == "table" and
346 (e == "timeout" or e == "error")) 347 (e == "timeout" or e == "error"))
347 pass("both nil: ok") 348 pass("both nil: ok")
@@ -352,10 +353,23 @@ function test_selectbugs()
352 (e == "timeout" or e == "error")) 353 (e == "timeout" or e == "error"))
353 pass("closed sockets: ok") 354 pass("closed sockets: ok")
354 e = pcall(socket.select, "wrong", 1, 0.1) 355 e = pcall(socket.select, "wrong", 1, 0.1)
355 assert(e == false) 356 assert(e == false, tostring(e))
356 e = pcall(socket.select, {}, 1, 0.1) 357 e = pcall(socket.select, {}, 1, 0.1)
357 assert(e == false) 358 assert(e == false, tostring(e))
358 pass("invalid input: ok") 359 pass("invalid input: ok")
360 local toomany = {}
361 for i = 1, socket._SETSIZE+1 do
362 toomany[#toomany+1] = socket.udp()
363 end
364 if #toomany > socket._SETSIZE then
365 local e = pcall(socket.select, toomany, nil, 0.1)
366 assert(e == false, tostring(e))
367 pass("too many sockets (" .. #toomany .. "): ok")
368 else
369 pass("unable to create enough sockets (max was "..#toomany..")")
370 pass("try using ulimit")
371 end
372 for _, c in ipairs(toomany) do c:close() end
359end 373end
360 374
361------------------------------------------------------------------------ 375------------------------------------------------------------------------
@@ -555,6 +569,25 @@ function test_readafterclose()
555 print("ok") 569 print("ok")
556end 570end
557 571
572------------------------------------------------------------------------
573function test_writeafterclose()
574 local str = 'little string'
575 reconnect()
576 remote (string.format ([[
577 data:close()
578 data = nil
579 ]]))
580 local sent, err, errsent
581 while not err do
582 sent, err, errsent, time = data:send(str)
583 end
584 print(sent, err, errsent, time)
585 print("ok")
586end
587
588------------------------------------------------------------------------
589--test_writeafterclose()
590
558test("method registration") 591test("method registration")
559test_methods(socket.tcp(), { 592test_methods(socket.tcp(), {
560 "accept", 593 "accept",
@@ -596,12 +629,12 @@ test_methods(socket.udp(), {
596 "settimeout" 629 "settimeout"
597}) 630})
598 631
599test("testing read after close")
600test_readafterclose()
601
602test("select function") 632test("select function")
603test_selectbugs() 633test_selectbugs()
604 634
635test("testing read after close")
636test_readafterclose()
637
605test("connect function") 638test("connect function")
606connect_timeout() 639connect_timeout()
607empty_connect() 640empty_connect()