From f18d1b7cd0ec4708518ab5e18ea33b6eadca0301 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 28 Mar 2003 21:08:50 +0000 Subject: Closer to release... --- test/smtptest.lua | 2 +- test/testclnt.lua | 12 ++++++------ test/testsrvr.lua | 6 +++--- test/tftptest.lua | 22 ++++++++++------------ test/urltest.lua | 3 +-- 5 files changed, 21 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/smtptest.lua b/test/smtptest.lua index 1bba27f..27ba400 100644 --- a/test/smtptest.lua +++ b/test/smtptest.lua @@ -60,7 +60,7 @@ local empty = function() end local get = function() - s = "" + local s = "" for i,v in ipairs(files) do s = s .. "\n" .. readfile(v) end diff --git a/test/testclnt.lua b/test/testclnt.lua index 7c65823..3e80a36 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua @@ -1,5 +1,5 @@ -HOST = HOST or "localhost" -PORT = PORT or "8080" +host = host or "localhost" +port = port or "8080" function pass(...) local s = string.format(unpack(arg)) @@ -83,14 +83,14 @@ function tcpreconnect() if data then data:close() data = nil end data = server:accept() ]] - data, err = socket.connect(HOST, PORT) + data, err = socket.connect(host, port) if not data then fail(err) else pass("connected!") end end reconnect = tcpreconnect pass("attempting control connection...") -control, err = socket.connect(HOST, PORT) +control, err = socket.connect(host, port) if err then fail(err) else pass("connected!") end @@ -104,10 +104,10 @@ function empty_connect() if data then data:close() data = nil end data = server:accept() ]] - data, err = socket.connect("", PORT) + data, err = socket.connect("", port) if not data then pass("ok") - data = socket.connect(HOST, PORT) + data = socket.connect(host, port) else fail("should not have connected!") end end diff --git a/test/testsrvr.lua b/test/testsrvr.lua index 141c058..fb77ea5 100644 --- a/test/testsrvr.lua +++ b/test/testsrvr.lua @@ -1,7 +1,7 @@ -HOST = HOST or "localhost" -PORT = PORT or "8080" +host = host or "localhost" +port = port or "8080" -server, error = socket.bind(HOST, PORT) +server, error = socket.bind(host, port) if not server then print("server: " .. tostring(error)) os.exit() end while 1 do print("server: waiting for client connection..."); diff --git a/test/tftptest.lua b/test/tftptest.lua index b29657a..a435ad4 100644 --- a/test/tftptest.lua +++ b/test/tftptest.lua @@ -1,25 +1,23 @@ --- load tftpclng.lua -assert(dofile("../examples/tftpclnt.lua")) +-- load tftpclnt.lua +dofile("tftpclnt.lua") -- needs tftp server running on localhost, with root pointing to --- /home/i/diego/public/html/luasocket/test +-- a directory with index.html in it function readfile(file) - local f = openfile("file", "rb") - local a - if f then - a = read(f, "*a") - closefile(f) - end - return a + local f = io.open(file, "r") + if not f then return nil end + local a = f:read("*a") + f:close() + return a end host = host or "localhost" print("downloading") err = tftp_get(host, 69, "index.html", "index.got") assert(not err, err) -original = readfile("index.index") +original = readfile("test/index.html") retrieved = readfile("index.got") -remove("index.got") +os.remove("index.got") assert(original == retrieved, "files differ!") print("passed") diff --git a/test/urltest.lua b/test/urltest.lua index b97844d..7b1f0c0 100644 --- a/test/urltest.lua +++ b/test/urltest.lua @@ -1,5 +1,4 @@ - - +dofile("noglobals.lua") local check_build_url = function(parsed) local built = socket.url.build(parsed) -- cgit v1.2.3-55-g6feb