aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2001-06-08 22:42:01 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2001-06-08 22:42:01 +0000
commitc51283fa62331bb6db5e481da714493f0a91b936 (patch)
treecb9bafa2b79cec5ae31018152731af8ff5d06d46 /test
parentbf4ca59463cf42a79510f42dd561f91c297b4738 (diff)
downloadluasocket-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.lua35
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
27end 27end
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
297end 297end
298 298
299
300
301
302----------------------------------------------------------------------------- 299-----------------------------------------------------------------------------
303-- Tests read patterns 300-- Tests read patterns
304----------------------------------------------------------------------------- 301-----------------------------------------------------------------------------
@@ -364,9 +361,25 @@ function test_patterns()
364end 361end
365 362
366----------------------------------------------------------------------------- 363-----------------------------------------------------------------------------
364-- Test for select bugs
365-----------------------------------------------------------------------------
366function 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")
377end
378
379-----------------------------------------------------------------------------
367-- Execute all tests 380-- Execute all tests
368----------------------------------------------------------------------------- 381-----------------------------------------------------------------------------
369start = time() 382start = _time()
370 383
371new_test("control connection test") 384new_test("control connection test")
372test_command(EXIT) 385test_command(EXIT)
@@ -376,7 +389,9 @@ test_command(ECHO_BLOCK, 12234)
376test_command(SLEEP, 1111) 389test_command(SLEEP, 1111)
377test_command(ECHO_LINE) 390test_command(ECHO_LINE)
378 391
379--a = [[ 392new_test("testing for select bugs")
393test_select()
394
380new_test("connection close test") 395new_test("connection close test")
381test_closed() 396test_closed()
382 397
@@ -438,17 +453,15 @@ test_returntimeout(8000, 1, 2)
438test_returntimeout(80000, 2, 1) 453test_returntimeout(80000, 2, 1)
439test_returntimeout(800000, 0.1, 0) 454test_returntimeout(800000, 0.1, 0)
440test_returntimeout(800000, 2, 1) 455test_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-----------------------------------------------------------------------------
460new_test("the library has passed all tests")
446print("client: closing connection with server") 461print("client: closing connection with server")
447send_command(CLOSE) 462send_command(CLOSE)
448send_command(EXIT) 463send_command(EXIT)
449control:close() 464control:close()
450 465print(format("time elapsed: %6.2fs", _time() - start))
451new_test("the library has passed all tests")
452print(format("time elapsed: %6.2fs", time() - start))
453print("client: exiting...") 466print("client: exiting...")
454exit() 467exit()