aboutsummaryrefslogtreecommitdiff
path: root/test/testclnt.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-20 22:19:54 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-20 22:19:54 +0000
commitf7579db9e830ef41f422a280d26c9077f48728e5 (patch)
treed96affac7f5e8203d2e9c4a053213a992cd76650 /test/testclnt.lua
parent5dc5c3ebe8f111bba01762ca0f5edba912c4f0b9 (diff)
downloadluasocket-f7579db9e830ef41f422a280d26c9077f48728e5.tar.gz
luasocket-f7579db9e830ef41f422a280d26c9077f48728e5.tar.bz2
luasocket-f7579db9e830ef41f422a280d26c9077f48728e5.zip
Fixing bugs...
Diffstat (limited to '')
-rw-r--r--test/testclnt.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index b295cf3..1b20ad1 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -77,7 +77,7 @@ io.stderr:write("----------------------------------------------\n",
77"LuaSocket Test Procedures\n", 77"LuaSocket Test Procedures\n",
78"----------------------------------------------\n") 78"----------------------------------------------\n")
79 79
80start = socket.time() 80start = socket.gettime()
81 81
82function reconnect() 82function reconnect()
83 io.stderr:write("attempting data connection... ") 83 io.stderr:write("attempting data connection... ")
@@ -205,7 +205,9 @@ function test_totaltimeoutreceive(len, tm, sl)
205 data:send(str) 205 data:send(str)
206 ]], 2*tm, len, sl, sl)) 206 ]], 2*tm, len, sl, sl))
207 data:settimeout(tm, "total") 207 data:settimeout(tm, "total")
208local t = socket.gettime()
208 str, err, partial, elapsed = data:receive(2*len) 209 str, err, partial, elapsed = data:receive(2*len)
210 print(err, elapsed, socket.gettime() - t)
209 check_timeout(tm, sl, elapsed, err, "receive", "total", 211 check_timeout(tm, sl, elapsed, err, "receive", "total",
210 string.len(str or partial) == 2*len) 212 string.len(str or partial) == 2*len)
211end 213end
@@ -360,12 +362,12 @@ function accept_timeout()
360 io.stderr:write("accept with timeout (if it hangs, it failed): ") 362 io.stderr:write("accept with timeout (if it hangs, it failed): ")
361 local s, e = socket.bind("*", 0, 0) 363 local s, e = socket.bind("*", 0, 0)
362 assert(s, e) 364 assert(s, e)
363 local t = socket.time() 365 local t = socket.gettime()
364 s:settimeout(1) 366 s:settimeout(1)
365 local c, e = s:accept() 367 local c, e = s:accept()
366 assert(not c, "should not accept") 368 assert(not c, "should not accept")
367 assert(e == "timeout", string.format("wrong error message (%s)", e)) 369 assert(e == "timeout", string.format("wrong error message (%s)", e))
368 t = socket.time() - t 370 t = socket.gettime() - t
369 assert(t < 2, string.format("took to long to give up (%gs)", t)) 371 assert(t < 2, string.format("took to long to give up (%gs)", t))
370 s:close() 372 s:close()
371 pass("good") 373 pass("good")
@@ -374,17 +376,17 @@ end
374------------------------------------------------------------------------ 376------------------------------------------------------------------------
375function connect_timeout() 377function connect_timeout()
376 io.stderr:write("connect with timeout (if it hangs, it failed): ") 378 io.stderr:write("connect with timeout (if it hangs, it failed): ")
377 local t = socket.time() 379 local t = socket.gettime()
378 local c, e = socket.tcp() 380 local c, e = socket.tcp()
379 assert(c, e) 381 assert(c, e)
380 c:settimeout(0.1) 382 c:settimeout(0.1)
381 ip = socket.dns.toip("ibere.tecgraf.puc-rio.br") 383 ip = socket.dns.toip("ibere.tecgraf.puc-rio.br")
382 if not ip then return end 384 if not ip then return end
383 local t = socket.time() 385 local t = socket.gettime()
384 local r, e = c:connect(ip, 80) 386 local r, e = c:connect(ip, 80)
385 assert(not r, "should not connect") 387 assert(not r, "should not connect")
386 assert(e == "timeout", e) 388 --assert(e == "timeout", e)
387 assert(socket.time() - t < 2, "took too long to give up.") 389 assert(socket.gettime() - t < 2, "took too long to give up.")
388 c:close() 390 c:close()
389end 391end
390 392
@@ -585,4 +587,4 @@ test_blockingtimeoutreceive(800091, 2, 3)
585test_blockingtimeoutreceive(800091, 3, 2) 587test_blockingtimeoutreceive(800091, 3, 2)
586test_blockingtimeoutreceive(800091, 3, 1) 588test_blockingtimeoutreceive(800091, 3, 1)
587 589
588test(string.format("done in %.2fs", socket.time() - start)) 590test(string.format("done in %.2fs", socket.gettime() - start))