diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-28 21:08:50 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-28 21:08:50 +0000 |
| commit | f18d1b7cd0ec4708518ab5e18ea33b6eadca0301 (patch) | |
| tree | e831c6b1957af47db1301675b52c0d2a2e315fa7 /test | |
| parent | 307603b24dde69eac62d2cb52123488137520c9c (diff) | |
| download | luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.tar.gz luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.tar.bz2 luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.zip | |
Closer to release...
Diffstat (limited to 'test')
| -rw-r--r-- | test/smtptest.lua | 2 | ||||
| -rw-r--r-- | test/testclnt.lua | 12 | ||||
| -rw-r--r-- | test/testsrvr.lua | 6 | ||||
| -rw-r--r-- | test/tftptest.lua | 22 | ||||
| -rw-r--r-- | test/urltest.lua | 3 |
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() | |||
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | local get = function() | 62 | local 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 @@ | |||
| 1 | HOST = HOST or "localhost" | 1 | host = host or "localhost" |
| 2 | PORT = PORT or "8080" | 2 | port = port or "8080" |
| 3 | 3 | ||
| 4 | function pass(...) | 4 | function 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 |
| 89 | end | 89 | end |
| 90 | reconnect = tcpreconnect | 90 | reconnect = tcpreconnect |
| 91 | 91 | ||
| 92 | pass("attempting control connection...") | 92 | pass("attempting control connection...") |
| 93 | control, err = socket.connect(HOST, PORT) | 93 | control, err = socket.connect(host, port) |
| 94 | if err then fail(err) | 94 | if err then fail(err) |
| 95 | else pass("connected!") end | 95 | else 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 |
| 112 | end | 112 | end |
| 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 @@ | |||
| 1 | HOST = HOST or "localhost" | 1 | host = host or "localhost" |
| 2 | PORT = PORT or "8080" | 2 | port = port or "8080" |
| 3 | 3 | ||
| 4 | server, error = socket.bind(HOST, PORT) | 4 | server, error = socket.bind(host, port) |
| 5 | if not server then print("server: " .. tostring(error)) os.exit() end | 5 | if not server then print("server: " .. tostring(error)) os.exit() end |
| 6 | while 1 do | 6 | while 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 |
| 2 | assert(dofile("../examples/tftpclnt.lua")) | 2 | dofile("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 | ||
| 7 | function readfile(file) | 7 | function 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 | ||
| 15 | end | 13 | end |
| 16 | 14 | ||
| 17 | host = host or "localhost" | 15 | host = host or "localhost" |
| 18 | print("downloading") | 16 | print("downloading") |
| 19 | err = tftp_get(host, 69, "index.html", "index.got") | 17 | err = tftp_get(host, 69, "index.html", "index.got") |
| 20 | assert(not err, err) | 18 | assert(not err, err) |
| 21 | original = readfile("index.index") | 19 | original = readfile("test/index.html") |
| 22 | retrieved = readfile("index.got") | 20 | retrieved = readfile("index.got") |
| 23 | remove("index.got") | 21 | os.remove("index.got") |
| 24 | assert(original == retrieved, "files differ!") | 22 | assert(original == retrieved, "files differ!") |
| 25 | print("passed") | 23 | 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 @@ | |||
| 1 | 1 | dofile("noglobals.lua") | |
| 2 | |||
| 3 | 2 | ||
| 4 | local check_build_url = function(parsed) | 3 | local check_build_url = function(parsed) |
| 5 | local built = socket.url.build(parsed) | 4 | local built = socket.url.build(parsed) |
