aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-01-21 20:16:48 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-01-21 20:16:48 +0000
commit42e0e74487ca62b58a8a1fa06580154c632b4942 (patch)
treeff258bb7dde0c43ac267c384efe63cf6105d3677 /test
parent195069cf5f929f445b0ce20e531cd482d2559083 (diff)
downloadluasocket-42e0e74487ca62b58a8a1fa06580154c632b4942.tar.gz
luasocket-42e0e74487ca62b58a8a1fa06580154c632b4942.tar.bz2
luasocket-42e0e74487ca62b58a8a1fa06580154c632b4942.zip
Adjusted wsocket to match usocket. Adjusted windows projects.
Diffstat (limited to 'test')
-rw-r--r--test/testclnt.lua16
-rw-r--r--test/testsrvr.lua3
2 files changed, 12 insertions, 7 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index a0d9fda..6dccd0c 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -132,6 +132,7 @@ end
132 132
133------------------------------------------------------------------------ 133------------------------------------------------------------------------
134function test_asciiline(len) 134function test_asciiline(len)
135 reconnect()
135 local str, str10, back, err 136 local str, str10, back, err
136 str = string.rep("x", math.mod(len, 10)) 137 str = string.rep("x", math.mod(len, 10))
137 str10 = string.rep("aZb.c#dAe?", math.floor(len/10)) 138 str10 = string.rep("aZb.c#dAe?", math.floor(len/10))
@@ -149,6 +150,7 @@ end
149 150
150------------------------------------------------------------------------ 151------------------------------------------------------------------------
151function test_rawline(len) 152function test_rawline(len)
153 reconnect()
152 local str, str10, back, err 154 local str, str10, back, err
153 str = string.rep(string.char(47), math.mod(len, 10)) 155 str = string.rep(string.char(47), math.mod(len, 10))
154 str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100), 156 str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100),
@@ -167,6 +169,7 @@ end
167 169
168------------------------------------------------------------------------ 170------------------------------------------------------------------------
169function test_raw(len) 171function test_raw(len)
172 reconnect()
170 local half = math.floor(len/2) 173 local half = math.floor(len/2)
171 local s1, s2, back, err 174 local s1, s2, back, err
172 s1 = string.rep("x", half) 175 s1 = string.rep("x", half)
@@ -186,8 +189,8 @@ end
186 189
187------------------------------------------------------------------------ 190------------------------------------------------------------------------
188function test_totaltimeoutreceive(len, tm, sl) 191function test_totaltimeoutreceive(len, tm, sl)
189 local str, err, total
190 reconnect() 192 reconnect()
193 local str, err, total
191 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) 194 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl)
192 remote (string.format ([[ 195 remote (string.format ([[
193 data:settimeout(%d) 196 data:settimeout(%d)
@@ -206,8 +209,8 @@ end
206 209
207------------------------------------------------------------------------ 210------------------------------------------------------------------------
208function test_totaltimeoutsend(len, tm, sl) 211function test_totaltimeoutsend(len, tm, sl)
209 local str, err, total
210 reconnect() 212 reconnect()
213 local str, err, total
211 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) 214 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl)
212 remote (string.format ([[ 215 remote (string.format ([[
213 data:settimeout(%d) 216 data:settimeout(%d)
@@ -226,8 +229,8 @@ end
226 229
227------------------------------------------------------------------------ 230------------------------------------------------------------------------
228function test_blockingtimeoutreceive(len, tm, sl) 231function test_blockingtimeoutreceive(len, tm, sl)
229 local str, err, total
230 reconnect() 232 reconnect()
233 local str, err, total
231 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl) 234 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl)
232 remote (string.format ([[ 235 remote (string.format ([[
233 data:settimeout(%d) 236 data:settimeout(%d)
@@ -246,8 +249,8 @@ end
246 249
247------------------------------------------------------------------------ 250------------------------------------------------------------------------
248function test_blockingtimeoutsend(len, tm, sl) 251function test_blockingtimeoutsend(len, tm, sl)
249 local str, err, total
250 reconnect() 252 reconnect()
253 local str, err, total
251 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl) 254 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl)
252 remote (string.format ([[ 255 remote (string.format ([[
253 data:settimeout(%d) 256 data:settimeout(%d)
@@ -266,11 +269,14 @@ end
266 269
267------------------------------------------------------------------------ 270------------------------------------------------------------------------
268function empty_connect() 271function empty_connect()
272 reconnect()
269 if data then data:close() data = nil end 273 if data then data:close() data = nil end
274print("before remote")
270 remote [[ 275 remote [[
271 if data then data:close() data = nil end 276 if data then data:close() data = nil end
272 data = server:accept() 277 data = server:accept()
273 ]] 278 ]]
279print("after remote")
274 data, err = socket.connect("", port) 280 data, err = socket.connect("", port)
275 if not data then 281 if not data then
276 pass("ok") 282 pass("ok")
@@ -445,7 +451,6 @@ test("connect with timeout (if it hangs, it failed:)")
445connect_timeout() 451connect_timeout()
446 452
447test("mixed patterns") 453test("mixed patterns")
448reconnect()
449test_mixed(1) 454test_mixed(1)
450test_mixed(17) 455test_mixed(17)
451test_mixed(200) 456test_mixed(200)
@@ -457,7 +462,6 @@ test_mixed(17)
457test_mixed(1) 462test_mixed(1)
458 463
459test("character line") 464test("character line")
460reconnect()
461test_asciiline(1) 465test_asciiline(1)
462test_asciiline(17) 466test_asciiline(17)
463test_asciiline(200) 467test_asciiline(200)
diff --git a/test/testsrvr.lua b/test/testsrvr.lua
index 6010789..99b54e5 100644
--- a/test/testsrvr.lua
+++ b/test/testsrvr.lua
@@ -6,7 +6,8 @@ if not server then print("server: " .. tostring(error)) os.exit() end
6ack = "\n" 6ack = "\n"
7while 1 do 7while 1 do
8 print("server: waiting for client connection..."); 8 print("server: waiting for client connection...");
9 control = server:accept() 9 control, error = server:accept()
10 assert(control, error)
10 -- control:setoption("nodelay", true) 11 -- control:setoption("nodelay", true)
11 while 1 do 12 while 1 do
12 command, error = control:receive() 13 command, error = control:receive()