diff options
Diffstat (limited to 'test/testclnt.lua')
| -rw-r--r-- | test/testclnt.lua | 16 |
1 files changed, 10 insertions, 6 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) |
