aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/testclnt.lua28
-rw-r--r--test/testsrvr.lua5
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")
18end 18end
19 19
20pad = string.rep(" ", 8192)
21
20function remote(...) 22function 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()
27end 29end
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)
89end 93end
90 94
91pass("attempting control connection...") 95pass("attempting control connection...")
92control, err = socket.connect(host, port) 96control, err = socket.connect(host, port)
93if err then fail(err) 97if err then fail(err)
94else pass("connected!") end 98else pass("connected!") end
99control:setoption("nodelay", true)
95 100
96------------------------------------------------------------------------ 101------------------------------------------------------------------------
97test("method registration") 102test("method registration")
@@ -157,16 +162,21 @@ remote "data:send(str); data:close()"
157end 162end
158 163
159 164
160test_mixed(1) 165--test_mixed(1)
161test_mixed(17) 166--test_mixed(17)
162test_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
175test_mixed(4091)
176test_mixed(4091)
177test_mixed(4091)
163test_mixed(4091) 178test_mixed(4091)
164test_mixed(80199)
165test_mixed(4091) 179test_mixed(4091)
166test_mixed(200)
167test_mixed(17)
168test_mixed(1)
169
170------------------------------------------------------------------------ 180------------------------------------------------------------------------
171test("character line") 181test("character line")
172reconnect() 182reconnect()
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
4server, error = socket.bind(host, port) 4server, error = socket.bind(host, port)
5if not server then print("server: " .. tostring(error)) os.exit() end 5if not server then print("server: " .. tostring(error)) os.exit() end
6ack = "\n"
6while 1 do 7while 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
25end 26end