aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/testclnt.lua62
1 files changed, 34 insertions, 28 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index 9aa07fe..58a3574 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -228,6 +228,7 @@ function test_totaltimeoutsend(len, tm, sl)
228 data:settimeout(tm, "total") 228 data:settimeout(tm, "total")
229 str = string.rep("a", 2*len) 229 str = string.rep("a", 2*len)
230 total, err, partial, elapsed = data:send(str) 230 total, err, partial, elapsed = data:send(str)
231print(elapsed, "!")
231 check_timeout(tm, sl, elapsed, err, "send", "total", 232 check_timeout(tm, sl, elapsed, err, "send", "total",
232 total == 2*len) 233 total == 2*len)
233end 234end
@@ -400,27 +401,27 @@ function accept_errors()
400 d:setfd(c:getfd()) 401 d:setfd(c:getfd())
401 d:settimeout(2) 402 d:settimeout(2)
402 local r, e = d:accept() 403 local r, e = d:accept()
403 assert(not r and e == "not listening", e) 404 assert(not r and e)
404 print("ok") 405 print("ok: ", e)
405 io.stderr:write("not supported: ") 406 io.stderr:write("not supported: ")
406 local c, e = socket.udp() 407 local c, e = socket.udp()
407 assert(c, e); 408 assert(c, e);
408 d:setfd(c:getfd()) 409 d:setfd(c:getfd())
409 local r, e = d:accept() 410 local r, e = d:accept()
410 assert(not r and e == "not supported" or e == "not listening", e) 411 assert(not r and e)
411 print("ok") 412 print("ok: ", e)
412end 413end
413 414
414------------------------------------------------------------------------ 415------------------------------------------------------------------------
415function connect_errors() 416function connect_errors()
416 io.stderr:write("connection refused: ") 417 io.stderr:write("connection refused: ")
417 local c, e = socket.connect("localhost", 1); 418 local c, e = socket.connect("localhost", 1);
418 assert(not c and e == "connection refused", e) 419 assert(not c and e)
419 print("ok") 420 print("ok: ", e)
420 io.stderr:write("host not found: ") 421 io.stderr:write("host not found: ")
421 local c, e = socket.connect("host.is.invalid", 1); 422 local c, e = socket.connect("host.is.invalid", 1);
422 assert(not c and e == "host not found", e) 423 assert(not c and e, e)
423 print("ok") 424 print("ok: ", e)
424end 425end
425 426
426------------------------------------------------------------------------ 427------------------------------------------------------------------------
@@ -432,36 +433,25 @@ function rebind_test()
432 s:setoption("reuseaddr", false) 433 s:setoption("reuseaddr", false)
433 r, e = s:bind("localhost", p) 434 r, e = s:bind("localhost", p)
434 assert(not r, "managed to rebind!") 435 assert(not r, "managed to rebind!")
435 assert(e == "address already in use") 436 assert(e)
436 print("ok") 437 print("ok: ", e)
437end 438end
438 439
439------------------------------------------------------------------------ 440------------------------------------------------------------------------
440
441test("character line")
442test_asciiline(1)
443test_asciiline(17)
444test_asciiline(200)
445test_asciiline(4091)
446test_asciiline(80199)
447test_asciiline(8000000)
448test_asciiline(80199)
449test_asciiline(4091)
450test_asciiline(200)
451test_asciiline(17)
452test_asciiline(1)
453
454test("method registration") 441test("method registration")
455test_methods(socket.tcp(), { 442test_methods(socket.tcp(), {
456 "accept", 443 "accept",
457 "bind", 444 "bind",
458 "close", 445 "close",
459 "connect", 446 "connect",
447 "dirty",
448 "getfd",
460 "getpeername", 449 "getpeername",
461 "getsockname", 450 "getsockname",
462 "listen", 451 "listen",
463 "receive", 452 "receive",
464 "send", 453 "send",
454 "setfd",
465 "setoption", 455 "setoption",
466 "setpeername", 456 "setpeername",
467 "setsockname", 457 "setsockname",
@@ -472,15 +462,19 @@ test_methods(socket.tcp(), {
472test_methods(socket.udp(), { 462test_methods(socket.udp(), {
473 "close", 463 "close",
474 "getpeername", 464 "getpeername",
465 "dirty",
466 "getfd",
467 "getpeername",
475 "getsockname", 468 "getsockname",
476 "receive", 469 "receive",
477 "receivefrom", 470 "receivefrom",
478 "send", 471 "send",
479 "sendto", 472 "sendto",
473 "setfd",
480 "setoption", 474 "setoption",
481 "setpeername", 475 "setpeername",
482 "setsockname", 476 "setsockname",
483 "settimeout", 477 "settimeout"
484}) 478})
485 479
486test("select function") 480test("select function")
@@ -504,7 +498,18 @@ test("accept function: ")
504accept_timeout() 498accept_timeout()
505accept_errors() 499accept_errors()
506 500
507 501test("character line")
502test_asciiline(1)
503test_asciiline(17)
504test_asciiline(200)
505test_asciiline(4091)
506test_asciiline(80199)
507test_asciiline(8000000)
508test_asciiline(80199)
509test_asciiline(4091)
510test_asciiline(200)
511test_asciiline(17)
512test_asciiline(1)
508 513
509test("mixed patterns") 514test("mixed patterns")
510test_mixed(1) 515test_mixed(1)
@@ -566,9 +571,10 @@ test_raw(1)
566test("total timeout on send") 571test("total timeout on send")
567test_totaltimeoutsend(800091, 1, 3) 572test_totaltimeoutsend(800091, 1, 3)
568test_totaltimeoutsend(800091, 2, 3) 573test_totaltimeoutsend(800091, 2, 3)
569test_totaltimeoutsend(800091, 3, 2) 574test_totaltimeoutsend(800091, 5, 2)
570test_totaltimeoutsend(800091, 3, 1) 575test_totaltimeoutsend(800091, 3, 1)
571 576
577
572test("total timeout on receive") 578test("total timeout on receive")
573test_totaltimeoutreceive(800091, 1, 3) 579test_totaltimeoutreceive(800091, 1, 3)
574test_totaltimeoutreceive(800091, 2, 3) 580test_totaltimeoutreceive(800091, 2, 3)