diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2001-06-08 22:42:01 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2001-06-08 22:42:01 +0000 |
commit | c51283fa62331bb6db5e481da714493f0a91b936 (patch) | |
tree | cb9bafa2b79cec5ae31018152731af8ff5d06d46 /test | |
parent | bf4ca59463cf42a79510f42dd561f91c297b4738 (diff) | |
download | luasocket-c51283fa62331bb6db5e481da714493f0a91b936.tar.gz luasocket-c51283fa62331bb6db5e481da714493f0a91b936.tar.bz2 luasocket-c51283fa62331bb6db5e481da714493f0a91b936.zip |
Added select bug test.
time became _time.
Diffstat (limited to 'test')
-rw-r--r-- | test/testclnt.lua | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua index 1efb51d..4ee2c48 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua | |||
@@ -22,7 +22,7 @@ while control == nil do | |||
22 | if control then | 22 | if control then |
23 | print("client: control connection stablished!") | 23 | print("client: control connection stablished!") |
24 | else | 24 | else |
25 | sleep(2) | 25 | _sleep(2) |
26 | end | 26 | end |
27 | end | 27 | end |
28 | 28 | ||
@@ -48,7 +48,7 @@ function reconnect() | |||
48 | data = connect(HOST, PORT) | 48 | data = connect(HOST, PORT) |
49 | if not data then | 49 | if not data then |
50 | print("client: waiting for data connection.") | 50 | print("client: waiting for data connection.") |
51 | sleep(1) | 51 | _sleep(1) |
52 | end | 52 | end |
53 | end | 53 | end |
54 | sync() | 54 | sync() |
@@ -296,9 +296,6 @@ function test_returntimeout(len, t, s) | |||
296 | else fail("blocks don't match") end | 296 | else fail("blocks don't match") end |
297 | end | 297 | end |
298 | 298 | ||
299 | |||
300 | |||
301 | |||
302 | ----------------------------------------------------------------------------- | 299 | ----------------------------------------------------------------------------- |
303 | -- Tests read patterns | 300 | -- Tests read patterns |
304 | ----------------------------------------------------------------------------- | 301 | ----------------------------------------------------------------------------- |
@@ -364,9 +361,25 @@ function test_patterns() | |||
364 | end | 361 | end |
365 | 362 | ||
366 | ----------------------------------------------------------------------------- | 363 | ----------------------------------------------------------------------------- |
364 | -- Test for select bugs | ||
365 | ----------------------------------------------------------------------------- | ||
366 | function test_select() | ||
367 | local r, s, e = select(nil, nil, 0.1) | ||
368 | assert(type(r) == "table" and type(s) == "table" and e == "timeout") | ||
369 | pass("both nil") | ||
370 | data:close() | ||
371 | r, s, e = select({ data }, { data }, 0.1) | ||
372 | assert(type(r) == "table" and type(s) == "table" and e == "timeout") | ||
373 | pass("closed sockets") | ||
374 | e = call(select, {"wrong", 1, 0.1}, "x", nil) | ||
375 | assert(e == nil) | ||
376 | pass("invalid input") | ||
377 | end | ||
378 | |||
379 | ----------------------------------------------------------------------------- | ||
367 | -- Execute all tests | 380 | -- Execute all tests |
368 | ----------------------------------------------------------------------------- | 381 | ----------------------------------------------------------------------------- |
369 | start = time() | 382 | start = _time() |
370 | 383 | ||
371 | new_test("control connection test") | 384 | new_test("control connection test") |
372 | test_command(EXIT) | 385 | test_command(EXIT) |
@@ -376,7 +389,9 @@ test_command(ECHO_BLOCK, 12234) | |||
376 | test_command(SLEEP, 1111) | 389 | test_command(SLEEP, 1111) |
377 | test_command(ECHO_LINE) | 390 | test_command(ECHO_LINE) |
378 | 391 | ||
379 | --a = [[ | 392 | new_test("testing for select bugs") |
393 | test_select() | ||
394 | |||
380 | new_test("connection close test") | 395 | new_test("connection close test") |
381 | test_closed() | 396 | test_closed() |
382 | 397 | ||
@@ -438,17 +453,15 @@ test_returntimeout(8000, 1, 2) | |||
438 | test_returntimeout(80000, 2, 1) | 453 | test_returntimeout(80000, 2, 1) |
439 | test_returntimeout(800000, 0.1, 0) | 454 | test_returntimeout(800000, 0.1, 0) |
440 | test_returntimeout(800000, 2, 1) | 455 | test_returntimeout(800000, 2, 1) |
441 | --]] | ||
442 | 456 | ||
443 | ----------------------------------------------------------------------------- | 457 | ----------------------------------------------------------------------------- |
444 | -- Close connection and exit server. We are done. | 458 | -- Close connection and exit server. We are done. |
445 | ----------------------------------------------------------------------------- | 459 | ----------------------------------------------------------------------------- |
460 | new_test("the library has passed all tests") | ||
446 | print("client: closing connection with server") | 461 | print("client: closing connection with server") |
447 | send_command(CLOSE) | 462 | send_command(CLOSE) |
448 | send_command(EXIT) | 463 | send_command(EXIT) |
449 | control:close() | 464 | control:close() |
450 | 465 | print(format("time elapsed: %6.2fs", _time() - start)) | |
451 | new_test("the library has passed all tests") | ||
452 | print(format("time elapsed: %6.2fs", time() - start)) | ||
453 | print("client: exiting...") | 466 | print("client: exiting...") |
454 | exit() | 467 | exit() |