diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/testclnt.lua | 62 |
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) |
231 | print(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) |
233 | end | 234 | end |
@@ -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) |
412 | end | 413 | end |
413 | 414 | ||
414 | ------------------------------------------------------------------------ | 415 | ------------------------------------------------------------------------ |
415 | function connect_errors() | 416 | function 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) |
424 | end | 425 | end |
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) |
437 | end | 438 | end |
438 | 439 | ||
439 | ------------------------------------------------------------------------ | 440 | ------------------------------------------------------------------------ |
440 | |||
441 | test("character line") | ||
442 | test_asciiline(1) | ||
443 | test_asciiline(17) | ||
444 | test_asciiline(200) | ||
445 | test_asciiline(4091) | ||
446 | test_asciiline(80199) | ||
447 | test_asciiline(8000000) | ||
448 | test_asciiline(80199) | ||
449 | test_asciiline(4091) | ||
450 | test_asciiline(200) | ||
451 | test_asciiline(17) | ||
452 | test_asciiline(1) | ||
453 | |||
454 | test("method registration") | 441 | test("method registration") |
455 | test_methods(socket.tcp(), { | 442 | test_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(), { | |||
472 | test_methods(socket.udp(), { | 462 | test_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 | ||
486 | test("select function") | 480 | test("select function") |
@@ -504,7 +498,18 @@ test("accept function: ") | |||
504 | accept_timeout() | 498 | accept_timeout() |
505 | accept_errors() | 499 | accept_errors() |
506 | 500 | ||
507 | 501 | test("character line") | |
502 | test_asciiline(1) | ||
503 | test_asciiline(17) | ||
504 | test_asciiline(200) | ||
505 | test_asciiline(4091) | ||
506 | test_asciiline(80199) | ||
507 | test_asciiline(8000000) | ||
508 | test_asciiline(80199) | ||
509 | test_asciiline(4091) | ||
510 | test_asciiline(200) | ||
511 | test_asciiline(17) | ||
512 | test_asciiline(1) | ||
508 | 513 | ||
509 | test("mixed patterns") | 514 | test("mixed patterns") |
510 | test_mixed(1) | 515 | test_mixed(1) |
@@ -566,9 +571,10 @@ test_raw(1) | |||
566 | test("total timeout on send") | 571 | test("total timeout on send") |
567 | test_totaltimeoutsend(800091, 1, 3) | 572 | test_totaltimeoutsend(800091, 1, 3) |
568 | test_totaltimeoutsend(800091, 2, 3) | 573 | test_totaltimeoutsend(800091, 2, 3) |
569 | test_totaltimeoutsend(800091, 3, 2) | 574 | test_totaltimeoutsend(800091, 5, 2) |
570 | test_totaltimeoutsend(800091, 3, 1) | 575 | test_totaltimeoutsend(800091, 3, 1) |
571 | 576 | ||
577 | |||
572 | test("total timeout on receive") | 578 | test("total timeout on receive") |
573 | test_totaltimeoutreceive(800091, 1, 3) | 579 | test_totaltimeoutreceive(800091, 1, 3) |
574 | test_totaltimeoutreceive(800091, 2, 3) | 580 | test_totaltimeoutreceive(800091, 2, 3) |