From 195069cf5f929f445b0ce20e531cd482d2559083 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Wed, 21 Jan 2004 18:40:52 +0000 Subject: Fixed functions that return messages in ?socket.c. Moved complexity of connect and accept there. Created a new options.c module to take care of options. Auxiliar.c is now cleaner. --- test/httptest.lua | 5 ++--- test/testclnt.lua | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/httptest.lua b/test/httptest.lua index 4667605..8bf3980 100644 --- a/test/httptest.lua +++ b/test/httptest.lua @@ -49,8 +49,7 @@ local check_result = function(response, expect, ignore) for i,v in response do if not ignore[i] then if v ~= expect[i] then - v = string.sub(type(v) == "string" and v or "", 1, 70) - print(v) + print(string.sub(tostring(v), 1, 70)) fail(i .. " differs!") end end @@ -59,7 +58,7 @@ local check_result = function(response, expect, ignore) if not ignore[i] then if v ~= response[i] then v = string.sub(type(v) == "string" and v or "", 1, 70) - print(v) + print(string.sub(tostring(v), 1, 70)) fail(i .. " differs!") end end diff --git a/test/testclnt.lua b/test/testclnt.lua index 5a001b3..a0d9fda 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua @@ -378,6 +378,19 @@ function connect_timeout() c:close() end +------------------------------------------------------------------------ +function rebind_test() + local c = socket.bind("localhost", 0) + local i, p = c:getsockname() + local s, e = socket.tcp() + assert(s, e) + s:setoption("reuseaddr", false) + r, e = s:bind("localhost", p) + assert(not r, "managed to rebind!") + assert(e == "address already in use") + print("ok") +end + ------------------------------------------------------------------------ test("method registration") test_methods(socket.tcp(), { @@ -416,6 +429,9 @@ test_selectbugs() test("empty host connect: ") empty_connect() +test("rebinding: ") +rebind_test() + test("active close: ") active_close() -- cgit v1.2.3-55-g6feb