aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/smtptest.lua2
-rw-r--r--test/testclnt.lua12
-rw-r--r--test/testsrvr.lua6
-rw-r--r--test/tftptest.lua22
-rw-r--r--test/urltest.lua3
5 files changed, 21 insertions, 24 deletions
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()
60end 60end
61 61
62local get = function() 62local get = function()
63 s = "" 63 local s = ""
64 for i,v in ipairs(files) do 64 for i,v in ipairs(files) do
65 s = s .. "\n" .. readfile(v) 65 s = s .. "\n" .. readfile(v)
66 end 66 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 @@
1HOST = HOST or "localhost" 1host = host or "localhost"
2PORT = PORT or "8080" 2port = port or "8080"
3 3
4function pass(...) 4function pass(...)
5 local s = string.format(unpack(arg)) 5 local s = string.format(unpack(arg))
@@ -83,14 +83,14 @@ function tcpreconnect()
83 if data then data:close() data = nil end 83 if data then data:close() data = nil end
84 data = server:accept() 84 data = server:accept()
85 ]] 85 ]]
86 data, err = socket.connect(HOST, PORT) 86 data, err = socket.connect(host, port)
87 if not data then fail(err) 87 if not data then fail(err)
88 else pass("connected!") end 88 else pass("connected!") end
89end 89end
90reconnect = tcpreconnect 90reconnect = tcpreconnect
91 91
92pass("attempting control connection...") 92pass("attempting control connection...")
93control, err = socket.connect(HOST, PORT) 93control, err = socket.connect(host, port)
94if err then fail(err) 94if err then fail(err)
95else pass("connected!") end 95else pass("connected!") end
96 96
@@ -104,10 +104,10 @@ function empty_connect()
104 if data then data:close() data = nil end 104 if data then data:close() data = nil end
105 data = server:accept() 105 data = server:accept()
106 ]] 106 ]]
107 data, err = socket.connect("", PORT) 107 data, err = socket.connect("", port)
108 if not data then 108 if not data then
109 pass("ok") 109 pass("ok")
110 data = socket.connect(HOST, PORT) 110 data = socket.connect(host, port)
111 else fail("should not have connected!") end 111 else fail("should not have connected!") end
112end 112end
113 113
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 @@
1HOST = HOST or "localhost" 1host = host or "localhost"
2PORT = PORT or "8080" 2port = port or "8080"
3 3
4server, error = socket.bind(HOST, PORT) 4server, error = socket.bind(host, port)
5if not server then print("server: " .. tostring(error)) os.exit() end 5if not server then print("server: " .. tostring(error)) os.exit() end
6while 1 do 6while 1 do
7 print("server: waiting for client connection..."); 7 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 @@
1-- load tftpclng.lua 1-- load tftpclnt.lua
2assert(dofile("../examples/tftpclnt.lua")) 2dofile("tftpclnt.lua")
3 3
4-- needs tftp server running on localhost, with root pointing to 4-- needs tftp server running on localhost, with root pointing to
5-- /home/i/diego/public/html/luasocket/test 5-- a directory with index.html in it
6 6
7function readfile(file) 7function readfile(file)
8 local f = openfile("file", "rb") 8 local f = io.open(file, "r")
9 local a 9 if not f then return nil end
10 if f then 10 local a = f:read("*a")
11 a = read(f, "*a") 11 f:close()
12 closefile(f) 12 return a
13 end
14 return a
15end 13end
16 14
17host = host or "localhost" 15host = host or "localhost"
18print("downloading") 16print("downloading")
19err = tftp_get(host, 69, "index.html", "index.got") 17err = tftp_get(host, 69, "index.html", "index.got")
20assert(not err, err) 18assert(not err, err)
21original = readfile("index.index") 19original = readfile("test/index.html")
22retrieved = readfile("index.got") 20retrieved = readfile("index.got")
23remove("index.got") 21os.remove("index.got")
24assert(original == retrieved, "files differ!") 22assert(original == retrieved, "files differ!")
25print("passed") 23print("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 @@
1 1dofile("noglobals.lua")
2
3 2
4local check_build_url = function(parsed) 3local check_build_url = function(parsed)
5 local built = socket.url.build(parsed) 4 local built = socket.url.build(parsed)