Fixing bugs...

This commit is contained in:
Diego Nehab 2004-06-20 22:19:54 +00:00
parent 5dc5c3ebe8
commit f7579db9e8
24 changed files with 127 additions and 94 deletions

View file

@ -77,7 +77,7 @@ io.stderr:write("----------------------------------------------\n",
"LuaSocket Test Procedures\n",
"----------------------------------------------\n")
start = socket.time()
start = socket.gettime()
function reconnect()
io.stderr:write("attempting data connection... ")
@ -205,7 +205,9 @@ function test_totaltimeoutreceive(len, tm, sl)
data:send(str)
]], 2*tm, len, sl, sl))
data:settimeout(tm, "total")
local t = socket.gettime()
str, err, partial, elapsed = data:receive(2*len)
print(err, elapsed, socket.gettime() - t)
check_timeout(tm, sl, elapsed, err, "receive", "total",
string.len(str or partial) == 2*len)
end
@ -360,12 +362,12 @@ function accept_timeout()
io.stderr:write("accept with timeout (if it hangs, it failed): ")
local s, e = socket.bind("*", 0, 0)
assert(s, e)
local t = socket.time()
local t = socket.gettime()
s:settimeout(1)
local c, e = s:accept()
assert(not c, "should not accept")
assert(e == "timeout", string.format("wrong error message (%s)", e))
t = socket.time() - t
t = socket.gettime() - t
assert(t < 2, string.format("took to long to give up (%gs)", t))
s:close()
pass("good")
@ -374,17 +376,17 @@ end
------------------------------------------------------------------------
function connect_timeout()
io.stderr:write("connect with timeout (if it hangs, it failed): ")
local t = socket.time()
local t = socket.gettime()
local c, e = socket.tcp()
assert(c, e)
c:settimeout(0.1)
ip = socket.dns.toip("ibere.tecgraf.puc-rio.br")
if not ip then return end
local t = socket.time()
local t = socket.gettime()
local r, e = c:connect(ip, 80)
assert(not r, "should not connect")
assert(e == "timeout", e)
assert(socket.time() - t < 2, "took too long to give up.")
--assert(e == "timeout", e)
assert(socket.gettime() - t < 2, "took too long to give up.")
c:close()
end
@ -585,4 +587,4 @@ test_blockingtimeoutreceive(800091, 2, 3)
test_blockingtimeoutreceive(800091, 3, 2)
test_blockingtimeoutreceive(800091, 3, 1)
test(string.format("done in %.2fs", socket.time() - start))
test(string.format("done in %.2fs", socket.gettime() - start))