diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-01-21 20:16:48 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-01-21 20:16:48 +0000 |
| commit | 42e0e74487ca62b58a8a1fa06580154c632b4942 (patch) | |
| tree | ff258bb7dde0c43ac267c384efe63cf6105d3677 /test | |
| parent | 195069cf5f929f445b0ce20e531cd482d2559083 (diff) | |
| download | luasocket-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.lua | 16 | ||||
| -rw-r--r-- | test/testsrvr.lua | 3 |
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 | ------------------------------------------------------------------------ |
| 134 | function test_asciiline(len) | 134 | function 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 | ------------------------------------------------------------------------ |
| 151 | function test_rawline(len) | 152 | function 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 | ------------------------------------------------------------------------ |
| 169 | function test_raw(len) | 171 | function 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 | ------------------------------------------------------------------------ |
| 188 | function test_totaltimeoutreceive(len, tm, sl) | 191 | function 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 | ------------------------------------------------------------------------ |
| 208 | function test_totaltimeoutsend(len, tm, sl) | 211 | function 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 | ------------------------------------------------------------------------ |
| 228 | function test_blockingtimeoutreceive(len, tm, sl) | 231 | function 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 | ------------------------------------------------------------------------ |
| 248 | function test_blockingtimeoutsend(len, tm, sl) | 251 | function 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 | ------------------------------------------------------------------------ |
| 268 | function empty_connect() | 271 | function empty_connect() |
| 272 | reconnect() | ||
| 269 | if data then data:close() data = nil end | 273 | if data then data:close() data = nil end |
| 274 | print("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 | ]] |
| 279 | print("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:)") | |||
| 445 | connect_timeout() | 451 | connect_timeout() |
| 446 | 452 | ||
| 447 | test("mixed patterns") | 453 | test("mixed patterns") |
| 448 | reconnect() | ||
| 449 | test_mixed(1) | 454 | test_mixed(1) |
| 450 | test_mixed(17) | 455 | test_mixed(17) |
| 451 | test_mixed(200) | 456 | test_mixed(200) |
| @@ -457,7 +462,6 @@ test_mixed(17) | |||
| 457 | test_mixed(1) | 462 | test_mixed(1) |
| 458 | 463 | ||
| 459 | test("character line") | 464 | test("character line") |
| 460 | reconnect() | ||
| 461 | test_asciiline(1) | 465 | test_asciiline(1) |
| 462 | test_asciiline(17) | 466 | test_asciiline(17) |
| 463 | test_asciiline(200) | 467 | test_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 | |||
| 6 | ack = "\n" | 6 | ack = "\n" |
| 7 | while 1 do | 7 | while 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() |
