tftptest.lua 539 B

1234567891011121314151617181920
  1. -- load tftpclnt.lua
  2. local tftp = require("socket.tftp")
  3. -- needs tftp server running on localhost, with root pointing to
  4. -- a directory with index.html in it
  5. function readfile(file)
  6. local f = io.open(file, "r")
  7. if not f then return nil end
  8. local a = f:read("*a")
  9. f:close()
  10. return a
  11. end
  12. host = host or "diego.student.princeton.edu"
  13. retrieved, err = tftp.get("tftp://" .. host .."/index.html")
  14. assert(not err, err)
  15. original = readfile("test/index.html")
  16. assert(original == retrieved, "files differ!")
  17. print("passed")