2003-03-28 22:08:50 +01:00
|
|
|
-- load tftpclnt.lua
|
|
|
|
dofile("tftpclnt.lua")
|
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"
|
2001-01-25 22:59:39 +01:00
|
|
|
print("downloading")
|
2001-09-25 23:32:52 +02:00
|
|
|
err = tftp_get(host, 69, "index.html", "index.got")
|
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-09-25 23:32:52 +02:00
|
|
|
retrieved = readfile("index.got")
|
2003-03-28 22:08:50 +01:00
|
|
|
os.remove("index.got")
|
2001-01-25 22:59:39 +01:00
|
|
|
assert(original == retrieved, "files differ!")
|
|
|
|
print("passed")
|