luasocket/test/tftptest.lua

21 lines
521 B
Lua
Raw Normal View History

2003-03-28 22:08:50 +01:00
-- load tftpclnt.lua
local tftp = require("socket.tftp")
2001-01-25 22:59:39 +01:00
-- needs tftp server running on localhost, with root pointing to
2003-03-28 22:08:50 +01:00
-- a directory with index.html in it
2001-01-25 22:59:39 +01:00
2001-09-25 23:32:52 +02:00
function readfile(file)
2003-03-28 22:08:50 +01:00
local f = io.open(file, "r")
if not f then return nil end
local a = f:read("*a")
f:close()
return a
2001-09-25 23:32:52 +02:00
end
2002-07-08 23:56:57 +02:00
host = host or "localhost"
retrieved, err = tftp.get("tftp://" .. host .."/index.html")
2001-01-25 22:59:39 +01:00
assert(not err, err)
2003-03-28 22:08:50 +01:00
original = readfile("test/index.html")
2001-01-25 22:59:39 +01:00
assert(original == retrieved, "files differ!")
print("passed")