testclnt.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. local socket = require"socket"
  2. host = host or "localhost"
  3. port = port or "8383"
  4. function printf(...)
  5. io.stderr:write(string.format(...))
  6. end
  7. function pass(...)
  8. printf(...)
  9. io.stderr:write("\n")
  10. end
  11. function fail(...)
  12. io.stderr:write("ERROR: ")
  13. printf(...)
  14. io.stderr:write("!\n")
  15. os.exit()
  16. end
  17. function warn(...)
  18. local s = string.format(...)
  19. io.stderr:write("WARNING: ", s, "\n")
  20. end
  21. function remote(...)
  22. local s = string.format(...)
  23. s = string.gsub(s, "\n", ";")
  24. s = string.gsub(s, "%s+", " ")
  25. s = string.gsub(s, "^%s*", "")
  26. control:send(s .. "\n")
  27. control:receive()
  28. end
  29. function test(test)
  30. io.stderr:write("----------------------------------------------\n",
  31. "testing: ", test, "\n",
  32. "----------------------------------------------\n")
  33. end
  34. function check_timeout(tm, sl, elapsed, err, opp, mode, alldone)
  35. if tm < sl then
  36. if opp == "send" then
  37. if not err then warn("must be buffered")
  38. elseif err == "timeout" then pass("proper timeout")
  39. else fail("unexpected error '%s'", err) end
  40. else
  41. if err ~= "timeout" then fail("should have timed out")
  42. else pass("proper timeout") end
  43. end
  44. else
  45. if mode == "total" then
  46. if elapsed > tm then
  47. if err ~= "timeout" then fail("should have timed out")
  48. else pass("proper timeout") end
  49. elseif elapsed < tm then
  50. if err then fail(err)
  51. else pass("ok") end
  52. else
  53. if alldone then
  54. if err then fail("unexpected error '%s'", err)
  55. else pass("ok") end
  56. else
  57. if err ~= "timeout" then fail(err)
  58. else pass("proper timeoutk") end
  59. end
  60. end
  61. else
  62. if err then fail(err)
  63. else pass("ok") end
  64. end
  65. end
  66. end
  67. if not socket._DEBUG then
  68. fail("Please define LUASOCKET_DEBUG and recompile LuaSocket")
  69. end
  70. io.stderr:write("----------------------------------------------\n",
  71. "LuaSocket Test Procedures\n",
  72. "----------------------------------------------\n")
  73. start = socket.gettime()
  74. function reconnect()
  75. if data then data:close() end
  76. remote [[
  77. if data then data:close() data = nil end
  78. data = server:accept()
  79. data:setoption("tcp-nodelay", true)
  80. ]]
  81. data, err = socket.connect(host, port)
  82. if not data then fail(err) end
  83. data:setoption("tcp-nodelay", true)
  84. end
  85. printf("attempting control connection...")
  86. control, err = socket.connect(host, port)
  87. if err then fail(err)
  88. else pass("connected!") end
  89. control:setoption("tcp-nodelay", true)
  90. ------------------------------------------------------------------------
  91. function test_methods(sock, methods)
  92. for _, v in pairs(methods) do
  93. if type(sock[v]) ~= "function" then
  94. fail(sock.class .. " method '" .. v .. "' not registered")
  95. end
  96. end
  97. pass(sock.class .. " methods are ok")
  98. end
  99. ------------------------------------------------------------------------
  100. function test_mixed(len)
  101. reconnect()
  102. io.stderr:write("length " .. len .. ": ")
  103. local inter = math.ceil(len/4)
  104. local p1 = "unix " .. string.rep("x", inter) .. "line\n"
  105. local p2 = "dos " .. string.rep("y", inter) .. "line\r\n"
  106. local p3 = "raw " .. string.rep("z", inter) .. "bytes"
  107. local p4 = "end" .. string.rep("w", inter) .. "bytes"
  108. local bp1, bp2, bp3, bp4
  109. remote (string.format("str = data:receive(%d)",
  110. string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4)))
  111. sent, err = data:send(p1..p2..p3..p4)
  112. if err then fail(err) end
  113. remote "data:send(str); data:close()"
  114. bp1, err = data:receive()
  115. if err then fail(err) end
  116. bp2, err = data:receive()
  117. if err then fail(err) end
  118. bp3, err = data:receive(string.len(p3))
  119. if err then fail(err) end
  120. bp4, err = data:receive("*a")
  121. if err then fail(err) end
  122. if bp1.."\n" == p1 and bp2.."\r\n" == p2 and bp3 == p3 and bp4 == p4 then
  123. pass("patterns match")
  124. else fail("patterns don't match") end
  125. end
  126. ------------------------------------------------------------------------
  127. if not math.mod then
  128. math.mod = math.fmod
  129. end
  130. function test_asciiline(len)
  131. reconnect()
  132. io.stderr:write("length " .. len .. ": ")
  133. local str, str10, back, err
  134. str = string.rep("x", math.mod(len, 10))
  135. str10 = string.rep("aZb.c#dAe?", math.floor(len/10))
  136. str = str .. str10
  137. remote "str = data:receive()"
  138. sent, err = data:send(str.."\n")
  139. if err then fail(err) end
  140. remote "data:send(str ..'\\n')"
  141. back, err = data:receive()
  142. if err then fail(err) end
  143. if back == str then pass("lines match")
  144. else fail("lines don't match") end
  145. end
  146. ------------------------------------------------------------------------
  147. function test_rawline(len)
  148. reconnect()
  149. io.stderr:write("length " .. len .. ": ")
  150. local str, str10, back, err
  151. str = string.rep(string.char(47), math.mod(len, 10))
  152. str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100),
  153. math.floor(len/10))
  154. str = str .. str10
  155. remote "str = data:receive()"
  156. sent, err = data:send(str.."\n")
  157. if err then fail(err) end
  158. remote "data:send(str..'\\n')"
  159. back, err = data:receive()
  160. if err then fail(err) end
  161. if back == str then pass("lines match")
  162. else fail("lines don't match") end
  163. end
  164. ------------------------------------------------------------------------
  165. function test_raw(len)
  166. reconnect()
  167. io.stderr:write("length " .. len .. ": ")
  168. local half = math.floor(len/2)
  169. local s1, s2, back, err
  170. s1 = string.rep("x", half)
  171. s2 = string.rep("y", len-half)
  172. remote (string.format("str = data:receive(%d)", len))
  173. sent, err = data:send(s1)
  174. if err then fail(err) end
  175. sent, err = data:send(s2)
  176. if err then fail(err) end
  177. remote "data:send(str)"
  178. back, err = data:receive(len)
  179. if err then fail(err) end
  180. if back == s1..s2 then pass("blocks match")
  181. else fail("blocks don't match") end
  182. end
  183. ------------------------------------------------------------------------
  184. function test_totaltimeoutreceive(len, tm, sl)
  185. reconnect()
  186. local str, err, partial
  187. printf("%d bytes, %ds total timeout, %ds pause: ", len, tm, sl)
  188. remote (string.format ([[
  189. data:settimeout(%d)
  190. str = string.rep('a', %d)
  191. data:send(str)
  192. print('server: sleeping for %ds')
  193. socket.sleep(%d)
  194. print('server: woke up')
  195. data:send(str)
  196. ]], 2*tm, len, sl, sl))
  197. data:settimeout(tm, "total")
  198. local t = socket.gettime()
  199. str, err, partial, elapsed = data:receive(2*len)
  200. check_timeout(tm, sl, elapsed, err, "receive", "total",
  201. string.len(str or partial) == 2*len)
  202. end
  203. ------------------------------------------------------------------------
  204. function test_totaltimeoutsend(len, tm, sl)
  205. reconnect()
  206. local str, err, total
  207. printf("%d bytes, %ds total timeout, %ds pause: ", len, tm, sl)
  208. remote (string.format ([[
  209. data:settimeout(%d)
  210. str = data:receive(%d)
  211. print('server: sleeping for %ds')
  212. socket.sleep(%d)
  213. print('server: woke up')
  214. str = data:receive(%d)
  215. ]], 2*tm, len, sl, sl, len))
  216. data:settimeout(tm, "total")
  217. str = string.rep("a", 2*len)
  218. total, err, partial, elapsed = data:send(str)
  219. check_timeout(tm, sl, elapsed, err, "send", "total",
  220. total == 2*len)
  221. end
  222. ------------------------------------------------------------------------
  223. function test_blockingtimeoutreceive(len, tm, sl)
  224. reconnect()
  225. local str, err, partial
  226. printf("%d bytes, %ds blocking timeout, %ds pause: ", len, tm, sl)
  227. remote (string.format ([[
  228. data:settimeout(%d)
  229. str = string.rep('a', %d)
  230. data:send(str)
  231. print('server: sleeping for %ds')
  232. socket.sleep(%d)
  233. print('server: woke up')
  234. data:send(str)
  235. ]], 2*tm, len, sl, sl))
  236. data:settimeout(tm)
  237. str, err, partial, elapsed = data:receive(2*len)
  238. check_timeout(tm, sl, elapsed, err, "receive", "blocking",
  239. string.len(str or partial) == 2*len)
  240. end
  241. ------------------------------------------------------------------------
  242. function test_blockingtimeoutsend(len, tm, sl)
  243. reconnect()
  244. local str, err, total
  245. printf("%d bytes, %ds blocking timeout, %ds pause: ", len, tm, sl)
  246. remote (string.format ([[
  247. data:settimeout(%d)
  248. str = data:receive(%d)
  249. print('server: sleeping for %ds')
  250. socket.sleep(%d)
  251. print('server: woke up')
  252. str = data:receive(%d)
  253. ]], 2*tm, len, sl, sl, len))
  254. data:settimeout(tm)
  255. str = string.rep("a", 2*len)
  256. total, err, partial, elapsed = data:send(str)
  257. check_timeout(tm, sl, elapsed, err, "send", "blocking",
  258. total == 2*len)
  259. end
  260. ------------------------------------------------------------------------
  261. function empty_connect()
  262. printf("empty connect: ")
  263. reconnect()
  264. if data then data:close() data = nil end
  265. remote [[
  266. if data then data:close() data = nil end
  267. data = server:accept()
  268. ]]
  269. data, err = socket.connect("", port)
  270. if not data then
  271. pass("ok")
  272. data = socket.connect(host, port)
  273. else
  274. pass("gethostbyname returns localhost on empty string...")
  275. end
  276. end
  277. ------------------------------------------------------------------------
  278. function isclosed(c)
  279. return c:getfd() == -1 or c:getfd() == (2^32-1)
  280. end
  281. function active_close()
  282. local tcp = socket.tcp4()
  283. if isclosed(tcp) then fail("should not be closed") end
  284. tcp:close()
  285. if not isclosed(tcp) then fail("should be closed") end
  286. tcp = socket.tcp()
  287. if not isclosed(tcp) then fail("should be closed") end
  288. tcp = nil
  289. local udp = socket.udp4()
  290. if isclosed(udp) then fail("should not be closed") end
  291. udp:close()
  292. if not isclosed(udp) then fail("should be closed") end
  293. udp = socket.udp()
  294. if not isclosed(udp) then fail("should be closed") end
  295. udp = nil
  296. pass("ok")
  297. end
  298. ------------------------------------------------------------------------
  299. function test_closed()
  300. local back, partial, err
  301. local str = 'little string'
  302. reconnect()
  303. printf("trying read detection: ")
  304. remote (string.format ([[
  305. data:send('%s')
  306. data:close()
  307. data = nil
  308. ]], str))
  309. -- try to get a line
  310. back, err, partial = data:receive()
  311. if not err then fail("should have gotten 'closed'.")
  312. elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.")
  313. elseif str ~= partial then fail("didn't receive partial result.")
  314. else pass("graceful 'closed' received") end
  315. reconnect()
  316. printf("trying write detection: ")
  317. remote [[
  318. data:close()
  319. data = nil
  320. ]]
  321. total, err, partial = data:send(string.rep("ugauga", 100000))
  322. if not err then
  323. pass("failed: output buffer is at least %d bytes long!", total)
  324. elseif err ~= "closed" then
  325. fail("got '"..err.."' instead of 'closed'.")
  326. else
  327. pass("graceful 'closed' received after %d bytes were sent", partial)
  328. end
  329. end
  330. ------------------------------------------------------------------------
  331. function test_selectbugs()
  332. local r, s, e = socket.select(nil, nil, 0.1)
  333. assert(type(r) == "table" and type(s) == "table" and
  334. (e == "timeout" or e == "error"))
  335. pass("both nil: ok")
  336. local udp = socket.udp()
  337. udp:close()
  338. r, s, e = socket.select({ udp }, { udp }, 0.1)
  339. assert(type(r) == "table" and type(s) == "table" and
  340. (e == "timeout" or e == "error"))
  341. pass("closed sockets: ok")
  342. e = pcall(socket.select, "wrong", 1, 0.1)
  343. assert(e == false, tostring(e))
  344. e = pcall(socket.select, {}, 1, 0.1)
  345. assert(e == false, tostring(e))
  346. pass("invalid input: ok")
  347. local toomany = {}
  348. for i = 1, socket._SETSIZE+1 do
  349. toomany[#toomany+1] = socket.udp4()
  350. end
  351. if #toomany > socket._SETSIZE then
  352. local e = pcall(socket.select, toomany, nil, 0.1)
  353. assert(e == false, tostring(e))
  354. pass("too many sockets (" .. #toomany .. "): ok")
  355. else
  356. pass("unable to create enough sockets (max was "..#toomany..")")
  357. pass("try using ulimit")
  358. end
  359. for _, c in ipairs(toomany) do c:close() end
  360. end
  361. ------------------------------------------------------------------------
  362. function accept_timeout()
  363. printf("accept with timeout (if it hangs, it failed): ")
  364. local s, e = socket.bind("*", 0, 0)
  365. assert(s, e)
  366. local t = socket.gettime()
  367. s:settimeout(1)
  368. local c, e = s:accept()
  369. assert(not c, "should not accept")
  370. assert(e == "timeout", string.format("wrong error message (%s)", e))
  371. t = socket.gettime() - t
  372. assert(t < 2, string.format("took to long to give up (%gs)", t))
  373. s:close()
  374. pass("good")
  375. end
  376. ------------------------------------------------------------------------
  377. function connect_timeout()
  378. printf("connect with timeout (if it hangs, it failed!): ")
  379. local t = socket.gettime()
  380. local c, e = socket.tcp()
  381. assert(c, e)
  382. c:settimeout(0.1)
  383. local t = socket.gettime()
  384. local r, e = c:connect("10.0.0.1", 81)
  385. assert(not r, "should not connect")
  386. assert(socket.gettime() - t < 2, "took too long to give up.")
  387. c:close()
  388. pass("ok")
  389. end
  390. ------------------------------------------------------------------------
  391. function accept_errors()
  392. printf("not listening: ")
  393. local d, e = socket.bind("*", 0)
  394. assert(d, e);
  395. local c, e = socket.tcp();
  396. assert(c, e);
  397. d:setfd(c:getfd())
  398. d:settimeout(2)
  399. local r, e = d:accept()
  400. assert(not r and e)
  401. pass("ok")
  402. printf("not supported: ")
  403. local c, e = socket.udp()
  404. assert(c, e);
  405. d:setfd(c:getfd())
  406. local r, e = d:accept()
  407. assert(not r and e)
  408. pass("ok")
  409. end
  410. ------------------------------------------------------------------------
  411. function connect_errors()
  412. printf("connection refused: ")
  413. local c, e = socket.connect("localhost", 1);
  414. assert(not c and e)
  415. pass("ok")
  416. printf("host not found: ")
  417. local c, e = socket.connect("host.is.invalid", 1);
  418. assert(not c and e, e)
  419. pass("ok")
  420. end
  421. ------------------------------------------------------------------------
  422. function rebind_test()
  423. local c ,c1 = socket.bind("127.0.0.1", 0)
  424. if not c then pass ("failed to bind! " .. tostring(c) .. ' ' .. tostring(c1)) return end
  425. assert(c,c1)
  426. local i, p = c:getsockname()
  427. local s, e = socket.tcp()
  428. assert(s, e)
  429. s:setoption("reuseaddr", false)
  430. r, e = s:bind(i, p)
  431. assert(not r, "managed to rebind!")
  432. assert(e)
  433. pass("ok")
  434. end
  435. ------------------------------------------------------------------------
  436. function getstats_test()
  437. reconnect()
  438. local t = 0
  439. for i = 1, 25 do
  440. local c = math.random(1, 100)
  441. remote (string.format ([[
  442. str = data:receive(%d)
  443. data:send(str)
  444. ]], c))
  445. data:send(string.rep("a", c))
  446. data:receive(c)
  447. t = t + c
  448. local r, s, a = data:getstats()
  449. assert(r == t, "received count failed" .. tostring(r)
  450. .. "/" .. tostring(t))
  451. assert(s == t, "sent count failed" .. tostring(s)
  452. .. "/" .. tostring(t))
  453. end
  454. pass("ok")
  455. end
  456. ------------------------------------------------------------------------
  457. function test_nonblocking(size)
  458. reconnect()
  459. printf("testing " .. 2*size .. " bytes: ")
  460. remote(string.format([[
  461. data:send(string.rep("a", %d))
  462. socket.sleep(0.5)
  463. data:send(string.rep("b", %d) .. "\n")
  464. ]], size, size))
  465. local err = "timeout"
  466. local part = ""
  467. local str
  468. data:settimeout(0)
  469. while 1 do
  470. str, err, part = data:receive("*l", part)
  471. if err ~= "timeout" then break end
  472. end
  473. assert(str == (string.rep("a", size) .. string.rep("b", size)))
  474. reconnect()
  475. remote(string.format([[
  476. str = data:receive(%d)
  477. socket.sleep(0.5)
  478. str = data:receive(2*%d, str)
  479. data:send(str)
  480. ]], size, size))
  481. data:settimeout(0)
  482. local start = 0
  483. while 1 do
  484. ret, err, start = data:send(str, start+1)
  485. if err ~= "timeout" then break end
  486. end
  487. data:send("\n")
  488. data:settimeout(-1)
  489. local back = data:receive(2*size)
  490. assert(back == str, "'" .. back .. "' vs '" .. str .. "'")
  491. pass("ok")
  492. end
  493. ------------------------------------------------------------------------
  494. function test_readafterclose()
  495. local back, partial, err
  496. local str = 'little string'
  497. reconnect()
  498. printf("trying repeated '*a' pattern")
  499. remote (string.format ([[
  500. data:send('%s')
  501. data:close()
  502. data = nil
  503. ]], str))
  504. back, err, partial = data:receive("*a")
  505. assert(back == str, "unexpected data read")
  506. back, err, partial = data:receive("*a")
  507. assert(back == nil and err == "closed", "should have returned 'closed'")
  508. pass("ok")
  509. reconnect()
  510. printf("trying active close before '*a'")
  511. remote (string.format ([[
  512. data:close()
  513. data = nil
  514. ]]))
  515. data:close()
  516. back, err, partial = data:receive("*a")
  517. assert(back == nil and err == "closed", "should have returned 'closed'")
  518. pass("ok")
  519. reconnect()
  520. printf("trying active close before '*l'")
  521. remote (string.format ([[
  522. data:close()
  523. data = nil
  524. ]]))
  525. data:close()
  526. back, err, partial = data:receive()
  527. assert(back == nil and err == "closed", "should have returned 'closed'")
  528. pass("ok")
  529. reconnect()
  530. printf("trying active close before raw 1")
  531. remote (string.format ([[
  532. data:close()
  533. data = nil
  534. ]]))
  535. data:close()
  536. back, err, partial = data:receive(1)
  537. assert(back == nil and err == "closed", "should have returned 'closed'")
  538. pass("ok")
  539. reconnect()
  540. printf("trying active close before raw 0")
  541. remote (string.format ([[
  542. data:close()
  543. data = nil
  544. ]]))
  545. data:close()
  546. back, err, partial = data:receive(0)
  547. assert(back == nil and err == "closed", "should have returned 'closed'")
  548. pass("ok")
  549. end
  550. ------------------------------------------------------------------------
  551. function test_writeafterclose()
  552. local str = 'little string'
  553. reconnect()
  554. remote (string.format ([[
  555. data:close()
  556. data = nil
  557. ]]))
  558. local sent, err, errsent
  559. while not err do
  560. sent, err, errsent, time = data:send(str)
  561. end
  562. assert(err == "closed", "got " .. err .. " instead of 'closed'")
  563. pass("ok")
  564. end
  565. ------------------------------------------------------------------------
  566. function test_partialrecv()
  567. local str = 'little string'
  568. reconnect()
  569. remote([[
  570. data:send("7890")
  571. ]])
  572. data:settimeout(1)
  573. back, err = data:receive(10, "123456")
  574. assert(back == "1234567890", "failed on exact mixed length")
  575. back, err = data:receive(8, "87654321")
  576. assert(back == "87654321", "failed on exact length")
  577. back, err = data:receive(4, "87654321")
  578. assert(back == "87654321", "failed on smaller length")
  579. pass("ok")
  580. end
  581. ------------------------------------------------------------------------
  582. test("method registration")
  583. local tcp_methods = {
  584. "accept",
  585. "bind",
  586. "close",
  587. "connect",
  588. "dirty",
  589. "getfamily",
  590. "getfd",
  591. "getoption",
  592. "getpeername",
  593. "getsockname",
  594. "getstats",
  595. "setstats",
  596. "listen",
  597. "receive",
  598. "send",
  599. "setfd",
  600. "setoption",
  601. "setpeername",
  602. "setsockname",
  603. "settimeout",
  604. "shutdown",
  605. }
  606. test_methods(socket.tcp(), tcp_methods)
  607. do local sock = socket.tcp6()
  608. if sock then test_methods(socket.tcp6(), tcp_methods)
  609. else io.stderr:write("Warning! IPv6 does not support!\n") end
  610. end
  611. local udp_methods = {
  612. "close",
  613. "dirty",
  614. "getfamily",
  615. "getfd",
  616. "getoption",
  617. "getpeername",
  618. "getsockname",
  619. "receive",
  620. "receivefrom",
  621. "send",
  622. "sendto",
  623. "setfd",
  624. "setoption",
  625. "setpeername",
  626. "setsockname",
  627. "settimeout"
  628. }
  629. ------------------------------------------------------------------------
  630. test_methods(socket.udp(), udp_methods)
  631. do local sock = socket.tcp6()
  632. if sock then test_methods(socket.udp6(), udp_methods)
  633. else io.stderr:write("Warning! IPv6 does not support!\n") end
  634. end
  635. test("closed connection detection: ")
  636. test_closed()
  637. test("partial receive")
  638. test_partialrecv()
  639. test("select function")
  640. test_selectbugs()
  641. test("read after close")
  642. test_readafterclose()
  643. test("write after close")
  644. test_writeafterclose()
  645. test("connect function")
  646. connect_timeout()
  647. empty_connect()
  648. connect_errors()
  649. test("rebinding: ")
  650. rebind_test()
  651. test("active close: ")
  652. active_close()
  653. test("accept function: ")
  654. accept_timeout()
  655. accept_errors()
  656. test("getstats test")
  657. getstats_test()
  658. test("character line")
  659. test_asciiline(1)
  660. test_asciiline(17)
  661. test_asciiline(200)
  662. test_asciiline(4091)
  663. test_asciiline(80199)
  664. test_asciiline(8000000)
  665. test_asciiline(80199)
  666. test_asciiline(4091)
  667. test_asciiline(200)
  668. test_asciiline(17)
  669. test_asciiline(1)
  670. test("mixed patterns")
  671. test_mixed(1)
  672. test_mixed(17)
  673. test_mixed(200)
  674. test_mixed(4091)
  675. test_mixed(801990)
  676. test_mixed(4091)
  677. test_mixed(200)
  678. test_mixed(17)
  679. test_mixed(1)
  680. test("binary line")
  681. test_rawline(1)
  682. test_rawline(17)
  683. test_rawline(200)
  684. test_rawline(4091)
  685. test_rawline(80199)
  686. test_rawline(8000000)
  687. test_rawline(80199)
  688. test_rawline(4091)
  689. test_rawline(200)
  690. test_rawline(17)
  691. test_rawline(1)
  692. test("raw transfer")
  693. test_raw(1)
  694. test_raw(17)
  695. test_raw(200)
  696. test_raw(4091)
  697. test_raw(80199)
  698. test_raw(8000000)
  699. test_raw(80199)
  700. test_raw(4091)
  701. test_raw(200)
  702. test_raw(17)
  703. test_raw(1)
  704. test("non-blocking transfer")
  705. test_nonblocking(1)
  706. test_nonblocking(17)
  707. test_nonblocking(200)
  708. test_nonblocking(4091)
  709. test_nonblocking(80199)
  710. test_nonblocking(800000)
  711. test_nonblocking(80199)
  712. test_nonblocking(4091)
  713. test_nonblocking(200)
  714. test_nonblocking(17)
  715. test_nonblocking(1)
  716. test("total timeout on send")
  717. test_totaltimeoutsend(800091, 1, 3)
  718. test_totaltimeoutsend(800091, 2, 3)
  719. test_totaltimeoutsend(800091, 5, 2)
  720. test_totaltimeoutsend(800091, 3, 1)
  721. test("total timeout on receive")
  722. test_totaltimeoutreceive(800091, 1, 3)
  723. test_totaltimeoutreceive(800091, 2, 3)
  724. test_totaltimeoutreceive(800091, 3, 2)
  725. test_totaltimeoutreceive(800091, 3, 1)
  726. test("blocking timeout on send")
  727. test_blockingtimeoutsend(800091, 1, 3)
  728. test_blockingtimeoutsend(800091, 2, 3)
  729. test_blockingtimeoutsend(800091, 3, 2)
  730. test_blockingtimeoutsend(800091, 3, 1)
  731. test("blocking timeout on receive")
  732. test_blockingtimeoutreceive(800091, 1, 3)
  733. test_blockingtimeoutreceive(800091, 2, 3)
  734. test_blockingtimeoutreceive(800091, 3, 2)
  735. test_blockingtimeoutreceive(800091, 3, 1)
  736. test("shutting server down")
  737. reconnect()
  738. remote("os.exit()")
  739. test(string.format("done in %.2fs", socket.gettime() - start))