aboutsummaryrefslogtreecommitdiff
path: root/test/testclnt.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-07-26 05:17:37 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-07-26 05:17:37 +0000
commit911e8d7e7f63e6e90814e82955bfaf26328afb19 (patch)
tree575a916f4616a0f865bff9928faa9be67a8c867e /test/testclnt.lua
parentd914007507a6a4ad3489cca19652af403fef7074 (diff)
downloadluasocket-911e8d7e7f63e6e90814e82955bfaf26328afb19.tar.gz
luasocket-911e8d7e7f63e6e90814e82955bfaf26328afb19.tar.bz2
luasocket-911e8d7e7f63e6e90814e82955bfaf26328afb19.zip
Beta2 is out! Total timeout works on Windows.
Diffstat (limited to 'test/testclnt.lua')
-rw-r--r--test/testclnt.lua39
1 files changed, 21 insertions, 18 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index 356350a..f838533 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -461,6 +461,7 @@ end
461------------------------------------------------------------------------ 461------------------------------------------------------------------------
462function test_nonblocking(size) 462function test_nonblocking(size)
463 reconnect() 463 reconnect()
464print("Testing " .. 2*size .. " bytes")
464remote(string.format([[ 465remote(string.format([[
465 data:send(string.rep("a", %d)) 466 data:send(string.rep("a", %d))
466 socket.sleep(0.5) 467 socket.sleep(0.5)
@@ -471,7 +472,9 @@ remote(string.format([[
471 local str 472 local str
472 data:settimeout(0) 473 data:settimeout(0)
473 while 1 do 474 while 1 do
474 str, err, part = data:receive(2*size - string.len(part), part) 475 local needed = 2*size - string.len(part)
476 assert(needed > 0, "weird")
477 str, err, part = data:receive(needed, part)
475 if err ~= "timeout" then break end 478 if err ~= "timeout" then break end
476 end 479 end
477 assert(str == (string.rep("a", size) .. string.rep("b", size))) 480 assert(str == (string.rep("a", size) .. string.rep("b", size)))
@@ -480,9 +483,7 @@ remote(string.format([[
480 str = data:receive(%d) 483 str = data:receive(%d)
481 socket.sleep(0.5) 484 socket.sleep(0.5)
482 str = data:receive(%d, str) 485 str = data:receive(%d, str)
483 str = data:receive("*l", str)
484 data:send(str) 486 data:send(str)
485 data:send("\n")
486]], size, size)) 487]], size, size))
487 data:settimeout(0) 488 data:settimeout(0)
488 local sofar = 1 489 local sofar = 1
@@ -493,25 +494,12 @@ remote(string.format([[
493 end 494 end
494 data:send("\n") 495 data:send("\n")
495 data:settimeout(-1) 496 data:settimeout(-1)
496 local back = data:receive() 497 local back = data:receive(2*size)
497 assert(back == str) 498 assert(back == str, "'" .. back .. "' vs '" .. str .. "'")
498 print("ok") 499 print("ok")
499end 500end
500 501
501
502------------------------------------------------------------------------ 502------------------------------------------------------------------------
503test("non-blocking transfer")
504test_nonblocking(1)
505test_nonblocking(17)
506test_nonblocking(200)
507test_nonblocking(4091)
508test_nonblocking(80199)
509test_nonblocking(8000000)
510test_nonblocking(80199)
511test_nonblocking(4091)
512test_nonblocking(200)
513test_nonblocking(17)
514test_nonblocking(1)
515 503
516test("method registration") 504test("method registration")
517test_methods(socket.tcp(), { 505test_methods(socket.tcp(), {
@@ -524,6 +512,7 @@ test_methods(socket.tcp(), {
524 "getpeername", 512 "getpeername",
525 "getsockname", 513 "getsockname",
526 "getstats", 514 "getstats",
515 "setstats",
527 "listen", 516 "listen",
528 "receive", 517 "receive",
529 "send", 518 "send",
@@ -628,6 +617,20 @@ test_raw(200)
628test_raw(17) 617test_raw(17)
629test_raw(1) 618test_raw(1)
630 619
620test("non-blocking transfer")
621test_nonblocking(1)
622test_nonblocking(17)
623test_nonblocking(200)
624test_nonblocking(4091)
625test_nonblocking(80199)
626test_nonblocking(8000000)
627test_nonblocking(80199)
628test_nonblocking(4091)
629test_nonblocking(200)
630test_nonblocking(17)
631test_nonblocking(1)
632
633
631test("total timeout on send") 634test("total timeout on send")
632test_totaltimeoutsend(800091, 1, 3) 635test_totaltimeoutsend(800091, 1, 3)
633test_totaltimeoutsend(800091, 2, 3) 636test_totaltimeoutsend(800091, 2, 3)