diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-06-26 18:47:49 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-06-26 18:47:49 +0000 |
| commit | 71f6bb60bf2b7457091c7106190f92ab7e51f7c6 (patch) | |
| tree | 8ad3668667bd3da3c34f7ff7ae0a9a7a4daa4679 /test | |
| parent | f330540576031528f0daac231c61d4dd06e8ba1e (diff) | |
| download | luasocket-71f6bb60bf2b7457091c7106190f92ab7e51f7c6.tar.gz luasocket-71f6bb60bf2b7457091c7106190f92ab7e51f7c6.tar.bz2 luasocket-71f6bb60bf2b7457091c7106190f92ab7e51f7c6.zip | |
Finished implementation of LuaSocket 2.0 alpha on Linux.
Some testing still needed.
Diffstat (limited to 'test')
| -rw-r--r-- | test/testclnt.lua | 28 | ||||
| -rw-r--r-- | test/testsrvr.lua | 5 |
2 files changed, 22 insertions, 11 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua index b2b4b18..e38c248 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua | |||
| @@ -17,12 +17,14 @@ function warn(...) | |||
| 17 | io.write("WARNING: ", s, "\n") | 17 | io.write("WARNING: ", s, "\n") |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | pad = string.rep(" ", 8192) | ||
| 21 | |||
| 20 | function remote(...) | 22 | function remote(...) |
| 21 | local s = string.format(unpack(arg)) | 23 | local s = string.format(unpack(arg)) |
| 22 | s = string.gsub(s, "\n", ";") | 24 | s = string.gsub(s, "\n", ";") |
| 23 | s = string.gsub(s, "%s+", " ") | 25 | s = string.gsub(s, "%s+", " ") |
| 24 | s = string.gsub(s, "^%s*", "") | 26 | s = string.gsub(s, "^%s*", "") |
| 25 | control:send(s, "\n") | 27 | control:send(pad, s, "\n") |
| 26 | control:receive() | 28 | control:receive() |
| 27 | end | 29 | end |
| 28 | 30 | ||
| @@ -82,16 +84,19 @@ function reconnect() | |||
| 82 | remote [[ | 84 | remote [[ |
| 83 | if data then data:close() data = nil end | 85 | if data then data:close() data = nil end |
| 84 | data = server:accept() | 86 | data = server:accept() |
| 87 | data:setoption("nodelay", true) | ||
| 85 | ]] | 88 | ]] |
| 86 | data, err = socket.connect(host, port) | 89 | data, err = socket.connect(host, port) |
| 87 | if not data then fail(err) | 90 | if not data then fail(err) |
| 88 | else pass("connected!") end | 91 | else pass("connected!") end |
| 92 | data:setoption("nodelay", true) | ||
| 89 | end | 93 | end |
| 90 | 94 | ||
| 91 | pass("attempting control connection...") | 95 | pass("attempting control connection...") |
| 92 | control, err = socket.connect(host, port) | 96 | control, err = socket.connect(host, port) |
| 93 | if err then fail(err) | 97 | if err then fail(err) |
| 94 | else pass("connected!") end | 98 | else pass("connected!") end |
| 99 | control:setoption("nodelay", true) | ||
| 95 | 100 | ||
| 96 | ------------------------------------------------------------------------ | 101 | ------------------------------------------------------------------------ |
| 97 | test("method registration") | 102 | test("method registration") |
| @@ -157,16 +162,21 @@ remote "data:send(str); data:close()" | |||
| 157 | end | 162 | end |
| 158 | 163 | ||
| 159 | 164 | ||
| 160 | test_mixed(1) | 165 | --test_mixed(1) |
| 161 | test_mixed(17) | 166 | --test_mixed(17) |
| 162 | test_mixed(200) | 167 | --test_mixed(200) |
| 168 | --test_mixed(4091) | ||
| 169 | --test_mixed(80199) | ||
| 170 | --test_mixed(4091) | ||
| 171 | --test_mixed(200) | ||
| 172 | --test_mixed(17) | ||
| 173 | --test_mixed(1) | ||
| 174 | |||
| 175 | test_mixed(4091) | ||
| 176 | test_mixed(4091) | ||
| 177 | test_mixed(4091) | ||
| 163 | test_mixed(4091) | 178 | test_mixed(4091) |
| 164 | test_mixed(80199) | ||
| 165 | test_mixed(4091) | 179 | test_mixed(4091) |
| 166 | test_mixed(200) | ||
| 167 | test_mixed(17) | ||
| 168 | test_mixed(1) | ||
| 169 | |||
| 170 | ------------------------------------------------------------------------ | 180 | ------------------------------------------------------------------------ |
| 171 | test("character line") | 181 | test("character line") |
| 172 | reconnect() | 182 | reconnect() |
diff --git a/test/testsrvr.lua b/test/testsrvr.lua index 3c40840..39fe274 100644 --- a/test/testsrvr.lua +++ b/test/testsrvr.lua | |||
| @@ -3,9 +3,11 @@ port = port or "8080" | |||
| 3 | 3 | ||
| 4 | server, error = socket.bind(host, port) | 4 | server, error = socket.bind(host, port) |
| 5 | if not server then print("server: " .. tostring(error)) os.exit() end | 5 | if not server then print("server: " .. tostring(error)) os.exit() end |
| 6 | ack = "\n" | ||
| 6 | while 1 do | 7 | while 1 do |
| 7 | print("server: waiting for client connection..."); | 8 | print("server: waiting for client connection..."); |
| 8 | control = server:accept() | 9 | control = server:accept() |
| 10 | control:setoption("nodelay", true) | ||
| 9 | while 1 do | 11 | while 1 do |
| 10 | command, error = control:receive() | 12 | command, error = control:receive() |
| 11 | if error then | 13 | if error then |
| @@ -13,13 +15,12 @@ while 1 do | |||
| 13 | print("server: closing connection...") | 15 | print("server: closing connection...") |
| 14 | break | 16 | break |
| 15 | end | 17 | end |
| 16 | sent, error = control:send("\n") | 18 | sent, error = control:send(ack) |
| 17 | if error then | 19 | if error then |
| 18 | control:close() | 20 | control:close() |
| 19 | print("server: closing connection...") | 21 | print("server: closing connection...") |
| 20 | break | 22 | break |
| 21 | end | 23 | end |
| 22 | print(command); | ||
| 23 | (loadstring(command))() | 24 | (loadstring(command))() |
| 24 | end | 25 | end |
| 25 | end | 26 | end |
