2003-03-28 21:08:50 +00:00
|
|
|
-- load tftpclnt.lua
|
2004-10-11 06:18:57 +00:00
|
|
|
local tftp = require("socket.tftp")
|
2001-01-25 21:59:39 +00:00
|
|
|
|
|
|
|
-- needs tftp server running on localhost, with root pointing to
|
2003-03-28 21:08:50 +00:00
|
|
|
-- a directory with index.html in it
|
2001-01-25 21:59:39 +00:00
|
|
|
|
2001-09-25 21:32:52 +00:00
|
|
|
function readfile(file)
|
2003-03-28 21:08:50 +00: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 21:32:52 +00:00
|
|
|
end
|
|
|
|
|
2004-11-27 07:58:04 +00:00
|
|
|
host = host or "diego.student.princeton.edu"
|
2004-06-16 01:02:07 +00:00
|
|
|
retrieved, err = tftp.get("tftp://" .. host .."/index.html")
|
2001-01-25 21:59:39 +00:00
|
|
|
assert(not err, err)
|
2003-03-28 21:08:50 +00:00
|
|
|
original = readfile("test/index.html")
|
2001-01-25 21:59:39 +00:00
|
|
|
assert(original == retrieved, "files differ!")
|
|
|
|
print("passed")
|