diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-28 21:08:50 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-28 21:08:50 +0000 |
commit | f18d1b7cd0ec4708518ab5e18ea33b6eadca0301 (patch) | |
tree | e831c6b1957af47db1301675b52c0d2a2e315fa7 /test/tftptest.lua | |
parent | 307603b24dde69eac62d2cb52123488137520c9c (diff) | |
download | luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.tar.gz luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.tar.bz2 luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.zip |
Closer to release...
Diffstat (limited to 'test/tftptest.lua')
-rw-r--r-- | test/tftptest.lua | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/test/tftptest.lua b/test/tftptest.lua index b29657a..a435ad4 100644 --- a/test/tftptest.lua +++ b/test/tftptest.lua | |||
@@ -1,25 +1,23 @@ | |||
1 | -- load tftpclng.lua | 1 | -- load tftpclnt.lua |
2 | assert(dofile("../examples/tftpclnt.lua")) | 2 | dofile("tftpclnt.lua") |
3 | 3 | ||
4 | -- needs tftp server running on localhost, with root pointing to | 4 | -- needs tftp server running on localhost, with root pointing to |
5 | -- /home/i/diego/public/html/luasocket/test | 5 | -- a directory with index.html in it |
6 | 6 | ||
7 | function readfile(file) | 7 | function readfile(file) |
8 | local f = openfile("file", "rb") | 8 | local f = io.open(file, "r") |
9 | local a | 9 | if not f then return nil end |
10 | if f then | 10 | local a = f:read("*a") |
11 | a = read(f, "*a") | 11 | f:close() |
12 | closefile(f) | 12 | return a |
13 | end | ||
14 | return a | ||
15 | end | 13 | end |
16 | 14 | ||
17 | host = host or "localhost" | 15 | host = host or "localhost" |
18 | print("downloading") | 16 | print("downloading") |
19 | err = tftp_get(host, 69, "index.html", "index.got") | 17 | err = tftp_get(host, 69, "index.html", "index.got") |
20 | assert(not err, err) | 18 | assert(not err, err) |
21 | original = readfile("index.index") | 19 | original = readfile("test/index.html") |
22 | retrieved = readfile("index.got") | 20 | retrieved = readfile("index.got") |
23 | remove("index.got") | 21 | os.remove("index.got") |
24 | assert(original == retrieved, "files differ!") | 22 | assert(original == retrieved, "files differ!") |
25 | print("passed") | 23 | print("passed") |