Decent makefiles!
This commit is contained in:
parent
d1a72435d5
commit
bce60be30f
58 changed files with 852 additions and 546 deletions
|
@ -8,5 +8,7 @@ The files provided are:
|
|||
|
||||
To run these tests, just run lua on the server and then on the client.
|
||||
|
||||
hello.lua -- run to verify if installation worked
|
||||
|
||||
Good luck,
|
||||
Diego.
|
||||
|
|
3
test/hello.lua
Normal file
3
test/hello.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
require"socket"
|
||||
require"mime"
|
||||
print("Hello from " .. socket._VERSION .. " and " .. mime._VERSION .. "!")
|
|
@ -420,17 +420,17 @@ print("ok")
|
|||
io.write("testing HEAD method: ")
|
||||
local r, c, h = http.request {
|
||||
method = "HEAD",
|
||||
url = "http://www.cs.princeton.edu/~diego/"
|
||||
url = "http://www.tecgraf.puc-rio.br/~diego/"
|
||||
}
|
||||
assert(r and h and (c == 200), c)
|
||||
print("ok")
|
||||
|
||||
------------------------------------------------------------------------
|
||||
io.write("testing host not found: ")
|
||||
local c, e = socket.connect("wronghost", 80)
|
||||
local r, re = http.request{url = "http://wronghost/does/not/exist"}
|
||||
assert(r == nil and e == re)
|
||||
r, re = http.request("http://wronghost/does/not/exist")
|
||||
local c, e = socket.connect("example.invalid", 80)
|
||||
local r, re = http.request{url = "http://example.invalid/does/not/exist"}
|
||||
assert(r == nil and e == re, tostring(r) .. " " .. tostring(re))
|
||||
r, re = http.request("http://example.invalid/does/not/exist")
|
||||
assert(r == nil and e == re)
|
||||
print("ok")
|
||||
|
||||
|
|
|
@ -251,6 +251,28 @@ io.write("testing b64 padding: ")
|
|||
print("ok")
|
||||
end
|
||||
|
||||
local function test_b64lowlevel()
|
||||
io.write("testing b64 low-level: ")
|
||||
local a, b
|
||||
a, b = mime.b64("", "")
|
||||
assert(a == "" and b == "")
|
||||
a, b = mime.b64(nil, "blablabla")
|
||||
assert(a == nil and b == nil)
|
||||
a, b = mime.b64("", nil)
|
||||
assert(a == nil and b == nil)
|
||||
a, b = mime.unb64("", "")
|
||||
assert(a == "" and b == "")
|
||||
a, b = mime.unb64(nil, "blablabla")
|
||||
assert(a == nil and b == nil)
|
||||
a, b = mime.unb64("", nil)
|
||||
assert(a == nil and b == nil)
|
||||
local binary=string.char(0x00,0x44,0x1D,0x14,0x0F,0xF4,0xDA,0x11,0xA9,0x78,0x00,0x14,0x38,0x50,0x60,0xCE)
|
||||
local encoded = mime.b64(binary)
|
||||
local decoded=mime.unb64(encoded)
|
||||
assert(binary == decoded)
|
||||
print("ok")
|
||||
end
|
||||
|
||||
local t = socket.gettime()
|
||||
|
||||
create_b64test()
|
||||
|
@ -260,6 +282,7 @@ decode_b64test()
|
|||
compare_b64test()
|
||||
cleanup_b64test()
|
||||
padding_b64test()
|
||||
test_b64lowlevel()
|
||||
|
||||
create_qptest()
|
||||
encode_qptest()
|
||||
|
@ -270,4 +293,5 @@ decode_qptest()
|
|||
compare_qptest()
|
||||
cleanup_qptest()
|
||||
|
||||
|
||||
print(string.format("done in %.2fs", socket.gettime() - t))
|
||||
|
|
|
@ -342,6 +342,7 @@ end
|
|||
------------------------------------------------------------------------
|
||||
function test_selectbugs()
|
||||
local r, s, e = socket.select(nil, nil, 0.1)
|
||||
print(r, s, e)
|
||||
assert(type(r) == "table" and type(s) == "table" and
|
||||
(e == "timeout" or e == "error"))
|
||||
pass("both nil: ok")
|
||||
|
@ -352,10 +353,23 @@ function test_selectbugs()
|
|||
(e == "timeout" or e == "error"))
|
||||
pass("closed sockets: ok")
|
||||
e = pcall(socket.select, "wrong", 1, 0.1)
|
||||
assert(e == false)
|
||||
assert(e == false, tostring(e))
|
||||
e = pcall(socket.select, {}, 1, 0.1)
|
||||
assert(e == false)
|
||||
assert(e == false, tostring(e))
|
||||
pass("invalid input: ok")
|
||||
local toomany = {}
|
||||
for i = 1, socket._SETSIZE+1 do
|
||||
toomany[#toomany+1] = socket.udp()
|
||||
end
|
||||
if #toomany > socket._SETSIZE then
|
||||
local e = pcall(socket.select, toomany, nil, 0.1)
|
||||
assert(e == false, tostring(e))
|
||||
pass("too many sockets (" .. #toomany .. "): ok")
|
||||
else
|
||||
pass("unable to create enough sockets (max was "..#toomany..")")
|
||||
pass("try using ulimit")
|
||||
end
|
||||
for _, c in ipairs(toomany) do c:close() end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
@ -555,6 +569,25 @@ function test_readafterclose()
|
|||
print("ok")
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
function test_writeafterclose()
|
||||
local str = 'little string'
|
||||
reconnect()
|
||||
remote (string.format ([[
|
||||
data:close()
|
||||
data = nil
|
||||
]]))
|
||||
local sent, err, errsent
|
||||
while not err do
|
||||
sent, err, errsent, time = data:send(str)
|
||||
end
|
||||
print(sent, err, errsent, time)
|
||||
print("ok")
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--test_writeafterclose()
|
||||
|
||||
test("method registration")
|
||||
test_methods(socket.tcp(), {
|
||||
"accept",
|
||||
|
@ -596,12 +629,12 @@ test_methods(socket.udp(), {
|
|||
"settimeout"
|
||||
})
|
||||
|
||||
test("testing read after close")
|
||||
test_readafterclose()
|
||||
|
||||
test("select function")
|
||||
test_selectbugs()
|
||||
|
||||
test("testing read after close")
|
||||
test_readafterclose()
|
||||
|
||||
test("connect function")
|
||||
connect_timeout()
|
||||
empty_connect()
|
||||
|
|
|
@ -32,6 +32,8 @@ r, e = smtp.send{
|
|||
port = 2525
|
||||
}
|
||||
|
||||
print(r, e)
|
||||
|
||||
-- creates a source to send a message with two parts. The first part is
|
||||
-- plain text, the second part is a PNG image, encoded as base64.
|
||||
source = smtp.message{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue