diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2009-05-27 09:31:38 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2009-05-27 09:31:38 +0000 |
| commit | bce60be30fe8e9c1b0eb33128c23c93d7bca5303 (patch) | |
| tree | 3927343c777fcb7764a0f2f89754a0ceab141c21 /test/testclnt.lua | |
| parent | d1a72435d5bd3528f3c334cd4d1da16dcead47bf (diff) | |
| download | luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.tar.gz luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.tar.bz2 luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.zip | |
Decent makefiles!
Diffstat (limited to 'test/testclnt.lua')
| -rw-r--r-- | test/testclnt.lua | 43 |
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 | ------------------------------------------------------------------------ |
| 343 | function test_selectbugs() | 343 | function test_selectbugs() |
| 344 | local r, s, e = socket.select(nil, nil, 0.1) | 344 | local r, s, e = socket.select(nil, nil, 0.1) |
| 345 | print(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 | ||
| 359 | end | 373 | end |
| 360 | 374 | ||
| 361 | ------------------------------------------------------------------------ | 375 | ------------------------------------------------------------------------ |
| @@ -555,6 +569,25 @@ function test_readafterclose() | |||
| 555 | print("ok") | 569 | print("ok") |
| 556 | end | 570 | end |
| 557 | 571 | ||
| 572 | ------------------------------------------------------------------------ | ||
| 573 | function 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") | ||
| 586 | end | ||
| 587 | |||
| 588 | ------------------------------------------------------------------------ | ||
| 589 | --test_writeafterclose() | ||
| 590 | |||
| 558 | test("method registration") | 591 | test("method registration") |
| 559 | test_methods(socket.tcp(), { | 592 | test_methods(socket.tcp(), { |
| 560 | "accept", | 593 | "accept", |
| @@ -596,12 +629,12 @@ test_methods(socket.udp(), { | |||
| 596 | "settimeout" | 629 | "settimeout" |
| 597 | }) | 630 | }) |
| 598 | 631 | ||
| 599 | test("testing read after close") | ||
| 600 | test_readafterclose() | ||
| 601 | |||
| 602 | test("select function") | 632 | test("select function") |
| 603 | test_selectbugs() | 633 | test_selectbugs() |
| 604 | 634 | ||
| 635 | test("testing read after close") | ||
| 636 | test_readafterclose() | ||
| 637 | |||
| 605 | test("connect function") | 638 | test("connect function") |
| 606 | connect_timeout() | 639 | connect_timeout() |
| 607 | empty_connect() | 640 | empty_connect() |
