racer 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. data/LICENSE +22 -0
  2. data/bin/racer +33 -0
  3. data/ext/libuv/AUTHORS +45 -0
  4. data/ext/libuv/LICENSE +42 -0
  5. data/ext/libuv/Makefile +119 -0
  6. data/ext/libuv/README.md +88 -0
  7. data/ext/libuv/build/gcc_version.py +20 -0
  8. data/ext/libuv/common.gypi +176 -0
  9. data/ext/libuv/config-mingw.mk +61 -0
  10. data/ext/libuv/config-unix.mk +171 -0
  11. data/ext/libuv/gyp_uv +64 -0
  12. data/ext/libuv/include/ares.h +591 -0
  13. data/ext/libuv/include/ares_version.h +24 -0
  14. data/ext/libuv/include/uv-private/eio.h +403 -0
  15. data/ext/libuv/include/uv-private/ev.h +838 -0
  16. data/ext/libuv/include/uv-private/ngx-queue.h +108 -0
  17. data/ext/libuv/include/uv-private/tree.h +768 -0
  18. data/ext/libuv/include/uv-private/uv-unix.h +310 -0
  19. data/ext/libuv/include/uv-private/uv-win.h +510 -0
  20. data/ext/libuv/include/uv.h +1796 -0
  21. data/ext/libuv/src/ares/AUTHORS +37 -0
  22. data/ext/libuv/src/ares/CHANGES +1218 -0
  23. data/ext/libuv/src/ares/CMakeLists.txt +22 -0
  24. data/ext/libuv/src/ares/NEWS +21 -0
  25. data/ext/libuv/src/ares/README +60 -0
  26. data/ext/libuv/src/ares/README.cares +13 -0
  27. data/ext/libuv/src/ares/README.msvc +142 -0
  28. data/ext/libuv/src/ares/README.node +21 -0
  29. data/ext/libuv/src/ares/RELEASE-NOTES +26 -0
  30. data/ext/libuv/src/ares/TODO +23 -0
  31. data/ext/libuv/src/ares/ares__close_sockets.c +66 -0
  32. data/ext/libuv/src/ares/ares__get_hostent.c +263 -0
  33. data/ext/libuv/src/ares/ares__read_line.c +71 -0
  34. data/ext/libuv/src/ares/ares__timeval.c +111 -0
  35. data/ext/libuv/src/ares/ares_cancel.c +63 -0
  36. data/ext/libuv/src/ares/ares_data.c +190 -0
  37. data/ext/libuv/src/ares/ares_data.h +65 -0
  38. data/ext/libuv/src/ares/ares_destroy.c +105 -0
  39. data/ext/libuv/src/ares/ares_dns.h +90 -0
  40. data/ext/libuv/src/ares/ares_expand_name.c +200 -0
  41. data/ext/libuv/src/ares/ares_expand_string.c +75 -0
  42. data/ext/libuv/src/ares/ares_fds.c +63 -0
  43. data/ext/libuv/src/ares/ares_free_hostent.c +42 -0
  44. data/ext/libuv/src/ares/ares_free_string.c +25 -0
  45. data/ext/libuv/src/ares/ares_getenv.c +30 -0
  46. data/ext/libuv/src/ares/ares_getenv.h +26 -0
  47. data/ext/libuv/src/ares/ares_gethostbyaddr.c +301 -0
  48. data/ext/libuv/src/ares/ares_gethostbyname.c +523 -0
  49. data/ext/libuv/src/ares/ares_getnameinfo.c +427 -0
  50. data/ext/libuv/src/ares/ares_getopt.c +122 -0
  51. data/ext/libuv/src/ares/ares_getopt.h +53 -0
  52. data/ext/libuv/src/ares/ares_getsock.c +72 -0
  53. data/ext/libuv/src/ares/ares_init.c +1809 -0
  54. data/ext/libuv/src/ares/ares_iphlpapi.h +221 -0
  55. data/ext/libuv/src/ares/ares_ipv6.h +78 -0
  56. data/ext/libuv/src/ares/ares_library_init.c +142 -0
  57. data/ext/libuv/src/ares/ares_library_init.h +42 -0
  58. data/ext/libuv/src/ares/ares_llist.c +86 -0
  59. data/ext/libuv/src/ares/ares_llist.h +42 -0
  60. data/ext/libuv/src/ares/ares_mkquery.c +195 -0
  61. data/ext/libuv/src/ares/ares_nowarn.c +181 -0
  62. data/ext/libuv/src/ares/ares_nowarn.h +55 -0
  63. data/ext/libuv/src/ares/ares_options.c +248 -0
  64. data/ext/libuv/src/ares/ares_parse_a_reply.c +263 -0
  65. data/ext/libuv/src/ares/ares_parse_aaaa_reply.c +259 -0
  66. data/ext/libuv/src/ares/ares_parse_mx_reply.c +170 -0
  67. data/ext/libuv/src/ares/ares_parse_ns_reply.c +182 -0
  68. data/ext/libuv/src/ares/ares_parse_ptr_reply.c +217 -0
  69. data/ext/libuv/src/ares/ares_parse_srv_reply.c +179 -0
  70. data/ext/libuv/src/ares/ares_parse_txt_reply.c +201 -0
  71. data/ext/libuv/src/ares/ares_platform.c +11035 -0
  72. data/ext/libuv/src/ares/ares_platform.h +43 -0
  73. data/ext/libuv/src/ares/ares_private.h +355 -0
  74. data/ext/libuv/src/ares/ares_process.c +1295 -0
  75. data/ext/libuv/src/ares/ares_query.c +183 -0
  76. data/ext/libuv/src/ares/ares_rules.h +144 -0
  77. data/ext/libuv/src/ares/ares_search.c +321 -0
  78. data/ext/libuv/src/ares/ares_send.c +134 -0
  79. data/ext/libuv/src/ares/ares_setup.h +199 -0
  80. data/ext/libuv/src/ares/ares_strcasecmp.c +66 -0
  81. data/ext/libuv/src/ares/ares_strcasecmp.h +30 -0
  82. data/ext/libuv/src/ares/ares_strdup.c +42 -0
  83. data/ext/libuv/src/ares/ares_strdup.h +26 -0
  84. data/ext/libuv/src/ares/ares_strerror.c +56 -0
  85. data/ext/libuv/src/ares/ares_timeout.c +80 -0
  86. data/ext/libuv/src/ares/ares_version.c +11 -0
  87. data/ext/libuv/src/ares/ares_writev.c +79 -0
  88. data/ext/libuv/src/ares/ares_writev.h +36 -0
  89. data/ext/libuv/src/ares/bitncmp.c +59 -0
  90. data/ext/libuv/src/ares/bitncmp.h +26 -0
  91. data/ext/libuv/src/ares/config_cygwin/ares_config.h +512 -0
  92. data/ext/libuv/src/ares/config_darwin/ares_config.h +512 -0
  93. data/ext/libuv/src/ares/config_freebsd/ares_config.h +512 -0
  94. data/ext/libuv/src/ares/config_linux/ares_config.h +512 -0
  95. data/ext/libuv/src/ares/config_netbsd/ares_config.h +512 -0
  96. data/ext/libuv/src/ares/config_openbsd/ares_config.h +512 -0
  97. data/ext/libuv/src/ares/config_sunos/ares_config.h +512 -0
  98. data/ext/libuv/src/ares/config_win32/ares_config.h +369 -0
  99. data/ext/libuv/src/ares/get_ver.awk +35 -0
  100. data/ext/libuv/src/ares/inet_net_pton.c +451 -0
  101. data/ext/libuv/src/ares/inet_net_pton.h +31 -0
  102. data/ext/libuv/src/ares/inet_ntop.c +208 -0
  103. data/ext/libuv/src/ares/inet_ntop.h +26 -0
  104. data/ext/libuv/src/ares/nameser.h +203 -0
  105. data/ext/libuv/src/ares/setup_once.h +504 -0
  106. data/ext/libuv/src/ares/windows_port.c +22 -0
  107. data/ext/libuv/src/cares.c +225 -0
  108. data/ext/libuv/src/fs-poll.c +237 -0
  109. data/ext/libuv/src/unix/async.c +119 -0
  110. data/ext/libuv/src/unix/core.c +647 -0
  111. data/ext/libuv/src/unix/cygwin.c +84 -0
  112. data/ext/libuv/src/unix/darwin.c +341 -0
  113. data/ext/libuv/src/unix/dl.c +83 -0
  114. data/ext/libuv/src/unix/eio/Changes +63 -0
  115. data/ext/libuv/src/unix/eio/LICENSE +36 -0
  116. data/ext/libuv/src/unix/eio/Makefile.am +15 -0
  117. data/ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
  118. data/ext/libuv/src/unix/eio/autogen.sh +3 -0
  119. data/ext/libuv/src/unix/eio/config.h.in +86 -0
  120. data/ext/libuv/src/unix/eio/config_cygwin.h +80 -0
  121. data/ext/libuv/src/unix/eio/config_darwin.h +141 -0
  122. data/ext/libuv/src/unix/eio/config_freebsd.h +81 -0
  123. data/ext/libuv/src/unix/eio/config_linux.h +94 -0
  124. data/ext/libuv/src/unix/eio/config_netbsd.h +81 -0
  125. data/ext/libuv/src/unix/eio/config_openbsd.h +137 -0
  126. data/ext/libuv/src/unix/eio/config_sunos.h +84 -0
  127. data/ext/libuv/src/unix/eio/configure.ac +22 -0
  128. data/ext/libuv/src/unix/eio/demo.c +194 -0
  129. data/ext/libuv/src/unix/eio/ecb.h +370 -0
  130. data/ext/libuv/src/unix/eio/eio.3 +3428 -0
  131. data/ext/libuv/src/unix/eio/eio.c +2593 -0
  132. data/ext/libuv/src/unix/eio/eio.pod +969 -0
  133. data/ext/libuv/src/unix/eio/libeio.m4 +195 -0
  134. data/ext/libuv/src/unix/eio/xthread.h +164 -0
  135. data/ext/libuv/src/unix/error.c +104 -0
  136. data/ext/libuv/src/unix/ev/Changes +388 -0
  137. data/ext/libuv/src/unix/ev/LICENSE +36 -0
  138. data/ext/libuv/src/unix/ev/Makefile.am +18 -0
  139. data/ext/libuv/src/unix/ev/Makefile.in +771 -0
  140. data/ext/libuv/src/unix/ev/README +58 -0
  141. data/ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
  142. data/ext/libuv/src/unix/ev/autogen.sh +6 -0
  143. data/ext/libuv/src/unix/ev/config.guess +1526 -0
  144. data/ext/libuv/src/unix/ev/config.h.in +125 -0
  145. data/ext/libuv/src/unix/ev/config.sub +1658 -0
  146. data/ext/libuv/src/unix/ev/config_cygwin.h +123 -0
  147. data/ext/libuv/src/unix/ev/config_darwin.h +122 -0
  148. data/ext/libuv/src/unix/ev/config_freebsd.h +120 -0
  149. data/ext/libuv/src/unix/ev/config_linux.h +141 -0
  150. data/ext/libuv/src/unix/ev/config_netbsd.h +120 -0
  151. data/ext/libuv/src/unix/ev/config_openbsd.h +126 -0
  152. data/ext/libuv/src/unix/ev/config_sunos.h +122 -0
  153. data/ext/libuv/src/unix/ev/configure +13037 -0
  154. data/ext/libuv/src/unix/ev/configure.ac +18 -0
  155. data/ext/libuv/src/unix/ev/depcomp +630 -0
  156. data/ext/libuv/src/unix/ev/ev++.h +816 -0
  157. data/ext/libuv/src/unix/ev/ev.3 +5311 -0
  158. data/ext/libuv/src/unix/ev/ev.c +3925 -0
  159. data/ext/libuv/src/unix/ev/ev.pod +5243 -0
  160. data/ext/libuv/src/unix/ev/ev_epoll.c +266 -0
  161. data/ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
  162. data/ext/libuv/src/unix/ev/ev_poll.c +148 -0
  163. data/ext/libuv/src/unix/ev/ev_port.c +179 -0
  164. data/ext/libuv/src/unix/ev/ev_select.c +310 -0
  165. data/ext/libuv/src/unix/ev/ev_vars.h +203 -0
  166. data/ext/libuv/src/unix/ev/ev_win32.c +153 -0
  167. data/ext/libuv/src/unix/ev/ev_wrap.h +196 -0
  168. data/ext/libuv/src/unix/ev/event.c +402 -0
  169. data/ext/libuv/src/unix/ev/event.h +170 -0
  170. data/ext/libuv/src/unix/ev/install-sh +294 -0
  171. data/ext/libuv/src/unix/ev/libev.m4 +39 -0
  172. data/ext/libuv/src/unix/ev/ltmain.sh +8413 -0
  173. data/ext/libuv/src/unix/ev/missing +336 -0
  174. data/ext/libuv/src/unix/ev/mkinstalldirs +111 -0
  175. data/ext/libuv/src/unix/freebsd.c +312 -0
  176. data/ext/libuv/src/unix/fs.c +699 -0
  177. data/ext/libuv/src/unix/internal.h +180 -0
  178. data/ext/libuv/src/unix/kqueue.c +122 -0
  179. data/ext/libuv/src/unix/linux/core.c +474 -0
  180. data/ext/libuv/src/unix/linux/inotify.c +209 -0
  181. data/ext/libuv/src/unix/linux/syscalls.c +268 -0
  182. data/ext/libuv/src/unix/linux/syscalls.h +93 -0
  183. data/ext/libuv/src/unix/loop-watcher.c +63 -0
  184. data/ext/libuv/src/unix/loop.c +81 -0
  185. data/ext/libuv/src/unix/netbsd.c +108 -0
  186. data/ext/libuv/src/unix/openbsd.c +295 -0
  187. data/ext/libuv/src/unix/pipe.c +261 -0
  188. data/ext/libuv/src/unix/poll.c +116 -0
  189. data/ext/libuv/src/unix/process.c +447 -0
  190. data/ext/libuv/src/unix/stream.c +1026 -0
  191. data/ext/libuv/src/unix/sunos.c +483 -0
  192. data/ext/libuv/src/unix/tcp.c +328 -0
  193. data/ext/libuv/src/unix/thread.c +211 -0
  194. data/ext/libuv/src/unix/timer.c +138 -0
  195. data/ext/libuv/src/unix/tty.c +146 -0
  196. data/ext/libuv/src/unix/udp.c +661 -0
  197. data/ext/libuv/src/unix/uv-eio.c +107 -0
  198. data/ext/libuv/src/unix/uv-eio.h +13 -0
  199. data/ext/libuv/src/uv-common.c +384 -0
  200. data/ext/libuv/src/uv-common.h +171 -0
  201. data/ext/libuv/src/win/async.c +130 -0
  202. data/ext/libuv/src/win/core.c +283 -0
  203. data/ext/libuv/src/win/dl.c +86 -0
  204. data/ext/libuv/src/win/error.c +150 -0
  205. data/ext/libuv/src/win/fs-event.c +512 -0
  206. data/ext/libuv/src/win/fs.c +1856 -0
  207. data/ext/libuv/src/win/getaddrinfo.c +365 -0
  208. data/ext/libuv/src/win/handle-inl.h +145 -0
  209. data/ext/libuv/src/win/handle.c +150 -0
  210. data/ext/libuv/src/win/internal.h +337 -0
  211. data/ext/libuv/src/win/loop-watcher.c +123 -0
  212. data/ext/libuv/src/win/pipe.c +1675 -0
  213. data/ext/libuv/src/win/poll.c +618 -0
  214. data/ext/libuv/src/win/process-stdio.c +479 -0
  215. data/ext/libuv/src/win/process.c +1013 -0
  216. data/ext/libuv/src/win/req-inl.h +225 -0
  217. data/ext/libuv/src/win/req.c +25 -0
  218. data/ext/libuv/src/win/stream-inl.h +69 -0
  219. data/ext/libuv/src/win/stream.c +167 -0
  220. data/ext/libuv/src/win/tcp.c +1400 -0
  221. data/ext/libuv/src/win/thread.c +372 -0
  222. data/ext/libuv/src/win/threadpool.c +74 -0
  223. data/ext/libuv/src/win/timer.c +226 -0
  224. data/ext/libuv/src/win/tty.c +1801 -0
  225. data/ext/libuv/src/win/udp.c +718 -0
  226. data/ext/libuv/src/win/util.c +864 -0
  227. data/ext/libuv/src/win/winapi.c +132 -0
  228. data/ext/libuv/src/win/winapi.h +4443 -0
  229. data/ext/libuv/src/win/winsock.c +557 -0
  230. data/ext/libuv/src/win/winsock.h +171 -0
  231. data/ext/libuv/test/benchmark-ares.c +117 -0
  232. data/ext/libuv/test/benchmark-fs-stat.c +164 -0
  233. data/ext/libuv/test/benchmark-getaddrinfo.c +94 -0
  234. data/ext/libuv/test/benchmark-list.h +114 -0
  235. data/ext/libuv/test/benchmark-loop-count.c +88 -0
  236. data/ext/libuv/test/benchmark-million-timers.c +65 -0
  237. data/ext/libuv/test/benchmark-ping-pongs.c +213 -0
  238. data/ext/libuv/test/benchmark-pound.c +324 -0
  239. data/ext/libuv/test/benchmark-pump.c +462 -0
  240. data/ext/libuv/test/benchmark-sizes.c +42 -0
  241. data/ext/libuv/test/benchmark-spawn.c +162 -0
  242. data/ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
  243. data/ext/libuv/test/benchmark-thread.c +64 -0
  244. data/ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
  245. data/ext/libuv/test/blackhole-server.c +118 -0
  246. data/ext/libuv/test/dns-server.c +321 -0
  247. data/ext/libuv/test/echo-server.c +378 -0
  248. data/ext/libuv/test/fixtures/empty_file +0 -0
  249. data/ext/libuv/test/fixtures/load_error.node +1 -0
  250. data/ext/libuv/test/run-benchmarks.c +64 -0
  251. data/ext/libuv/test/run-tests.c +138 -0
  252. data/ext/libuv/test/runner-unix.c +290 -0
  253. data/ext/libuv/test/runner-unix.h +36 -0
  254. data/ext/libuv/test/runner-win.c +285 -0
  255. data/ext/libuv/test/runner-win.h +42 -0
  256. data/ext/libuv/test/runner.c +326 -0
  257. data/ext/libuv/test/runner.h +159 -0
  258. data/ext/libuv/test/task.h +109 -0
  259. data/ext/libuv/test/test-async.c +118 -0
  260. data/ext/libuv/test/test-callback-order.c +76 -0
  261. data/ext/libuv/test/test-callback-stack.c +203 -0
  262. data/ext/libuv/test/test-connection-fail.c +148 -0
  263. data/ext/libuv/test/test-counters-init.c +215 -0
  264. data/ext/libuv/test/test-cwd-and-chdir.c +64 -0
  265. data/ext/libuv/test/test-delayed-accept.c +197 -0
  266. data/ext/libuv/test/test-dlerror.c +58 -0
  267. data/ext/libuv/test/test-error.c +59 -0
  268. data/ext/libuv/test/test-fail-always.c +29 -0
  269. data/ext/libuv/test/test-fs-event.c +442 -0
  270. data/ext/libuv/test/test-fs-poll.c +146 -0
  271. data/ext/libuv/test/test-fs.c +1843 -0
  272. data/ext/libuv/test/test-get-currentexe.c +63 -0
  273. data/ext/libuv/test/test-get-loadavg.c +36 -0
  274. data/ext/libuv/test/test-get-memory.c +38 -0
  275. data/ext/libuv/test/test-getaddrinfo.c +122 -0
  276. data/ext/libuv/test/test-gethostbyname.c +189 -0
  277. data/ext/libuv/test/test-getsockname.c +342 -0
  278. data/ext/libuv/test/test-hrtime.c +54 -0
  279. data/ext/libuv/test/test-idle.c +81 -0
  280. data/ext/libuv/test/test-ipc-send-recv.c +209 -0
  281. data/ext/libuv/test/test-ipc.c +620 -0
  282. data/ext/libuv/test/test-list.h +421 -0
  283. data/ext/libuv/test/test-loop-handles.c +336 -0
  284. data/ext/libuv/test/test-multiple-listen.c +102 -0
  285. data/ext/libuv/test/test-mutexes.c +63 -0
  286. data/ext/libuv/test/test-pass-always.c +28 -0
  287. data/ext/libuv/test/test-ping-pong.c +253 -0
  288. data/ext/libuv/test/test-pipe-bind-error.c +140 -0
  289. data/ext/libuv/test/test-pipe-connect-error.c +96 -0
  290. data/ext/libuv/test/test-platform-output.c +87 -0
  291. data/ext/libuv/test/test-poll-close.c +77 -0
  292. data/ext/libuv/test/test-poll.c +573 -0
  293. data/ext/libuv/test/test-process-title.c +42 -0
  294. data/ext/libuv/test/test-ref.c +338 -0
  295. data/ext/libuv/test/test-run-once.c +48 -0
  296. data/ext/libuv/test/test-semaphore.c +111 -0
  297. data/ext/libuv/test/test-shutdown-close.c +103 -0
  298. data/ext/libuv/test/test-shutdown-eof.c +183 -0
  299. data/ext/libuv/test/test-spawn.c +847 -0
  300. data/ext/libuv/test/test-stdio-over-pipes.c +246 -0
  301. data/ext/libuv/test/test-tcp-bind-error.c +191 -0
  302. data/ext/libuv/test/test-tcp-bind6-error.c +154 -0
  303. data/ext/libuv/test/test-tcp-close-while-connecting.c +80 -0
  304. data/ext/libuv/test/test-tcp-close.c +129 -0
  305. data/ext/libuv/test/test-tcp-connect-error-after-write.c +95 -0
  306. data/ext/libuv/test/test-tcp-connect-error.c +70 -0
  307. data/ext/libuv/test/test-tcp-connect-timeout.c +85 -0
  308. data/ext/libuv/test/test-tcp-connect6-error.c +68 -0
  309. data/ext/libuv/test/test-tcp-flags.c +51 -0
  310. data/ext/libuv/test/test-tcp-shutdown-after-write.c +131 -0
  311. data/ext/libuv/test/test-tcp-write-error.c +168 -0
  312. data/ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
  313. data/ext/libuv/test/test-tcp-writealot.c +170 -0
  314. data/ext/libuv/test/test-thread.c +183 -0
  315. data/ext/libuv/test/test-threadpool.c +57 -0
  316. data/ext/libuv/test/test-timer-again.c +141 -0
  317. data/ext/libuv/test/test-timer.c +152 -0
  318. data/ext/libuv/test/test-tty.c +110 -0
  319. data/ext/libuv/test/test-udp-dgram-too-big.c +86 -0
  320. data/ext/libuv/test/test-udp-ipv6.c +156 -0
  321. data/ext/libuv/test/test-udp-multicast-join.c +139 -0
  322. data/ext/libuv/test/test-udp-multicast-ttl.c +86 -0
  323. data/ext/libuv/test/test-udp-options.c +86 -0
  324. data/ext/libuv/test/test-udp-send-and-recv.c +208 -0
  325. data/ext/libuv/test/test-util.c +97 -0
  326. data/ext/libuv/test/test-walk-handles.c +77 -0
  327. data/ext/libuv/uv.gyp +452 -0
  328. data/ext/libuv/vcbuild.bat +105 -0
  329. data/ext/racer/extconf.rb +20 -0
  330. data/ext/racer/http_parser.c +2059 -0
  331. data/ext/racer/http_parser.h +318 -0
  332. data/ext/racer/mkmf.log +22 -0
  333. data/ext/racer/racer.c +551 -0
  334. data/lib/racer.rb +2 -0
  335. data/lib/racer/version.rb +3 -0
  336. metadata +382 -0
@@ -0,0 +1,421 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ TEST_DECLARE (platform_output)
23
+ TEST_DECLARE (callback_order)
24
+ TEST_DECLARE (run_once)
25
+ TEST_DECLARE (semaphore_1)
26
+ TEST_DECLARE (semaphore_2)
27
+ TEST_DECLARE (semaphore_3)
28
+ TEST_DECLARE (tty)
29
+ TEST_DECLARE (stdio_over_pipes)
30
+ TEST_DECLARE (ipc_listen_before_write)
31
+ TEST_DECLARE (ipc_listen_after_write)
32
+ #ifndef _WIN32
33
+ TEST_DECLARE (ipc_send_recv_pipe)
34
+ #endif
35
+ TEST_DECLARE (ipc_send_recv_tcp)
36
+ TEST_DECLARE (ipc_tcp_connection)
37
+ TEST_DECLARE (tcp_ping_pong)
38
+ TEST_DECLARE (tcp_ping_pong_v6)
39
+ TEST_DECLARE (pipe_ping_pong)
40
+ TEST_DECLARE (delayed_accept)
41
+ TEST_DECLARE (multiple_listen)
42
+ TEST_DECLARE (tcp_writealot)
43
+ TEST_DECLARE (tcp_connect_error_after_write)
44
+ TEST_DECLARE (tcp_shutdown_after_write)
45
+ TEST_DECLARE (tcp_bind_error_addrinuse)
46
+ TEST_DECLARE (tcp_bind_error_addrnotavail_1)
47
+ TEST_DECLARE (tcp_bind_error_addrnotavail_2)
48
+ TEST_DECLARE (tcp_bind_error_fault)
49
+ TEST_DECLARE (tcp_bind_error_inval)
50
+ TEST_DECLARE (tcp_bind_localhost_ok)
51
+ TEST_DECLARE (tcp_listen_without_bind)
52
+ TEST_DECLARE (tcp_connect_error_fault)
53
+ TEST_DECLARE (tcp_connect_timeout)
54
+ TEST_DECLARE (tcp_close_while_connecting)
55
+ TEST_DECLARE (tcp_close)
56
+ TEST_DECLARE (tcp_flags)
57
+ TEST_DECLARE (tcp_write_error)
58
+ TEST_DECLARE (tcp_write_to_half_open_connection)
59
+ TEST_DECLARE (tcp_bind6_error_addrinuse)
60
+ TEST_DECLARE (tcp_bind6_error_addrnotavail)
61
+ TEST_DECLARE (tcp_bind6_error_fault)
62
+ TEST_DECLARE (tcp_bind6_error_inval)
63
+ TEST_DECLARE (tcp_bind6_localhost_ok)
64
+ TEST_DECLARE (udp_send_and_recv)
65
+ TEST_DECLARE (udp_multicast_join)
66
+ TEST_DECLARE (udp_multicast_ttl)
67
+ TEST_DECLARE (udp_dgram_too_big)
68
+ TEST_DECLARE (udp_dual_stack)
69
+ TEST_DECLARE (udp_ipv6_only)
70
+ TEST_DECLARE (udp_options)
71
+ TEST_DECLARE (pipe_bind_error_addrinuse)
72
+ TEST_DECLARE (pipe_bind_error_addrnotavail)
73
+ TEST_DECLARE (pipe_bind_error_inval)
74
+ TEST_DECLARE (pipe_listen_without_bind)
75
+ TEST_DECLARE (pipe_connect_bad_name)
76
+ TEST_DECLARE (pipe_connect_to_file)
77
+ TEST_DECLARE (connection_fail)
78
+ TEST_DECLARE (connection_fail_doesnt_auto_close)
79
+ TEST_DECLARE (shutdown_close_tcp)
80
+ TEST_DECLARE (shutdown_close_pipe)
81
+ TEST_DECLARE (shutdown_eof)
82
+ TEST_DECLARE (callback_stack)
83
+ TEST_DECLARE (error_message)
84
+ TEST_DECLARE (timer)
85
+ TEST_DECLARE (timer_again)
86
+ TEST_DECLARE (timer_start_twice)
87
+ TEST_DECLARE (idle_starvation)
88
+ TEST_DECLARE (loop_handles)
89
+ TEST_DECLARE (get_loadavg)
90
+ TEST_DECLARE (walk_handles)
91
+ TEST_DECLARE (ref)
92
+ TEST_DECLARE (idle_ref)
93
+ TEST_DECLARE (async_ref)
94
+ TEST_DECLARE (prepare_ref)
95
+ TEST_DECLARE (check_ref)
96
+ TEST_DECLARE (unref_in_prepare_cb)
97
+ TEST_DECLARE (timer_ref)
98
+ TEST_DECLARE (timer_ref2)
99
+ TEST_DECLARE (fs_event_ref)
100
+ TEST_DECLARE (fs_poll_ref)
101
+ TEST_DECLARE (tcp_ref)
102
+ TEST_DECLARE (tcp_ref2)
103
+ TEST_DECLARE (tcp_ref3)
104
+ TEST_DECLARE (tcp_ref4)
105
+ TEST_DECLARE (udp_ref)
106
+ TEST_DECLARE (udp_ref2)
107
+ TEST_DECLARE (udp_ref3)
108
+ TEST_DECLARE (pipe_ref)
109
+ TEST_DECLARE (pipe_ref2)
110
+ TEST_DECLARE (pipe_ref3)
111
+ TEST_DECLARE (pipe_ref4)
112
+ TEST_DECLARE (process_ref)
113
+ TEST_DECLARE (async)
114
+ TEST_DECLARE (get_currentexe)
115
+ TEST_DECLARE (process_title)
116
+ TEST_DECLARE (cwd_and_chdir)
117
+ TEST_DECLARE (get_memory)
118
+ TEST_DECLARE (hrtime)
119
+ TEST_DECLARE (getaddrinfo_basic)
120
+ TEST_DECLARE (getaddrinfo_concurrent)
121
+ TEST_DECLARE (gethostbyname)
122
+ TEST_DECLARE (getsockname_tcp)
123
+ TEST_DECLARE (getsockname_udp)
124
+ TEST_DECLARE (fail_always)
125
+ TEST_DECLARE (pass_always)
126
+ TEST_DECLARE (spawn_exit_code)
127
+ TEST_DECLARE (spawn_stdout)
128
+ TEST_DECLARE (spawn_stdin)
129
+ TEST_DECLARE (spawn_stdio_greater_than_3)
130
+ TEST_DECLARE (spawn_ignored_stdio)
131
+ TEST_DECLARE (spawn_and_kill)
132
+ TEST_DECLARE (spawn_detached)
133
+ TEST_DECLARE (spawn_and_kill_with_std)
134
+ TEST_DECLARE (spawn_and_ping)
135
+ TEST_DECLARE (spawn_setuid_fails)
136
+ TEST_DECLARE (spawn_setgid_fails)
137
+ TEST_DECLARE (spawn_stdout_to_file)
138
+ TEST_DECLARE (fs_poll)
139
+ TEST_DECLARE (kill)
140
+ TEST_DECLARE (fs_file_noent)
141
+ TEST_DECLARE (fs_file_nametoolong)
142
+ TEST_DECLARE (fs_file_loop)
143
+ TEST_DECLARE (fs_file_async)
144
+ TEST_DECLARE (fs_file_sync)
145
+ TEST_DECLARE (fs_async_dir)
146
+ TEST_DECLARE (fs_async_sendfile)
147
+ TEST_DECLARE (fs_fstat)
148
+ TEST_DECLARE (fs_chmod)
149
+ TEST_DECLARE (fs_chown)
150
+ TEST_DECLARE (fs_link)
151
+ TEST_DECLARE (fs_symlink)
152
+ TEST_DECLARE (fs_symlink_dir)
153
+ TEST_DECLARE (fs_utime)
154
+ TEST_DECLARE (fs_futime)
155
+ TEST_DECLARE (fs_file_open_append)
156
+ TEST_DECLARE (fs_stat_missing_path)
157
+ TEST_DECLARE (fs_read_file_eof)
158
+ TEST_DECLARE (fs_event_watch_dir)
159
+ TEST_DECLARE (fs_event_watch_file)
160
+ TEST_DECLARE (fs_event_watch_file_current_dir)
161
+ TEST_DECLARE (fs_event_no_callback_on_close)
162
+ TEST_DECLARE (fs_event_immediate_close)
163
+ TEST_DECLARE (fs_event_close_with_pending_event)
164
+ TEST_DECLARE (fs_event_close_in_callback)
165
+ TEST_DECLARE (fs_readdir_empty_dir)
166
+ TEST_DECLARE (fs_readdir_file)
167
+ TEST_DECLARE (fs_open_dir)
168
+ TEST_DECLARE (fs_rename_to_existing_file)
169
+ TEST_DECLARE (threadpool_queue_work_simple)
170
+ TEST_DECLARE (threadpool_multiple_event_loops)
171
+ TEST_DECLARE (thread_mutex)
172
+ TEST_DECLARE (thread_rwlock)
173
+ TEST_DECLARE (thread_create)
174
+ TEST_DECLARE (strlcpy)
175
+ TEST_DECLARE (strlcat)
176
+ TEST_DECLARE (counters_init)
177
+ TEST_DECLARE (dlerror)
178
+ TEST_DECLARE (poll_duplex)
179
+ TEST_DECLARE (poll_unidirectional)
180
+ TEST_DECLARE (poll_close)
181
+ #ifdef _WIN32
182
+ TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows)
183
+ TEST_DECLARE (argument_escaping)
184
+ TEST_DECLARE (environment_creation)
185
+ TEST_DECLARE (listen_with_simultaneous_accepts)
186
+ TEST_DECLARE (listen_no_simultaneous_accepts)
187
+ TEST_DECLARE (fs_stat_root)
188
+ #else
189
+ TEST_DECLARE (spawn_setuid_setgid)
190
+ #endif
191
+ HELPER_DECLARE (tcp4_echo_server)
192
+ HELPER_DECLARE (tcp6_echo_server)
193
+ HELPER_DECLARE (udp4_echo_server)
194
+ HELPER_DECLARE (pipe_echo_server)
195
+
196
+
197
+ TASK_LIST_START
198
+ TEST_OUTPUT_ENTRY (platform_output)
199
+
200
+ #if 0
201
+ TEST_ENTRY (callback_order)
202
+ #endif
203
+ TEST_ENTRY (run_once)
204
+ TEST_ENTRY (semaphore_1)
205
+ TEST_ENTRY (semaphore_2)
206
+ TEST_ENTRY (semaphore_3)
207
+
208
+ TEST_ENTRY (pipe_connect_bad_name)
209
+ TEST_ENTRY (pipe_connect_to_file)
210
+
211
+ TEST_ENTRY (tty)
212
+ TEST_ENTRY (stdio_over_pipes)
213
+ TEST_ENTRY (ipc_listen_before_write)
214
+ TEST_ENTRY (ipc_listen_after_write)
215
+ #ifndef _WIN32
216
+ TEST_ENTRY (ipc_send_recv_pipe)
217
+ #endif
218
+ TEST_ENTRY (ipc_send_recv_tcp)
219
+ TEST_ENTRY (ipc_tcp_connection)
220
+
221
+ TEST_ENTRY (tcp_ping_pong)
222
+ TEST_HELPER (tcp_ping_pong, tcp4_echo_server)
223
+
224
+ TEST_ENTRY (tcp_ping_pong_v6)
225
+ TEST_HELPER (tcp_ping_pong_v6, tcp6_echo_server)
226
+
227
+ TEST_ENTRY (pipe_ping_pong)
228
+ TEST_HELPER (pipe_ping_pong, pipe_echo_server)
229
+
230
+ TEST_ENTRY (delayed_accept)
231
+ TEST_ENTRY (multiple_listen)
232
+
233
+ TEST_ENTRY (tcp_writealot)
234
+ TEST_HELPER (tcp_writealot, tcp4_echo_server)
235
+
236
+ TEST_ENTRY (tcp_shutdown_after_write)
237
+ TEST_HELPER (tcp_shutdown_after_write, tcp4_echo_server)
238
+
239
+ TEST_ENTRY (tcp_connect_error_after_write)
240
+ TEST_ENTRY (tcp_bind_error_addrinuse)
241
+ TEST_ENTRY (tcp_bind_error_addrnotavail_1)
242
+ TEST_ENTRY (tcp_bind_error_addrnotavail_2)
243
+ TEST_ENTRY (tcp_bind_error_fault)
244
+ TEST_ENTRY (tcp_bind_error_inval)
245
+ TEST_ENTRY (tcp_bind_localhost_ok)
246
+ TEST_ENTRY (tcp_listen_without_bind)
247
+ TEST_ENTRY (tcp_connect_error_fault)
248
+ TEST_ENTRY (tcp_connect_timeout)
249
+ TEST_ENTRY (tcp_close_while_connecting)
250
+ TEST_ENTRY (tcp_close)
251
+ TEST_ENTRY (tcp_flags)
252
+ TEST_ENTRY (tcp_write_error)
253
+ TEST_ENTRY (tcp_write_to_half_open_connection)
254
+
255
+ TEST_ENTRY (tcp_bind6_error_addrinuse)
256
+ TEST_ENTRY (tcp_bind6_error_addrnotavail)
257
+ TEST_ENTRY (tcp_bind6_error_fault)
258
+ TEST_ENTRY (tcp_bind6_error_inval)
259
+ TEST_ENTRY (tcp_bind6_localhost_ok)
260
+
261
+ TEST_ENTRY (udp_send_and_recv)
262
+ TEST_ENTRY (udp_dgram_too_big)
263
+ TEST_ENTRY (udp_dual_stack)
264
+ TEST_ENTRY (udp_ipv6_only)
265
+ TEST_ENTRY (udp_options)
266
+ TEST_ENTRY (udp_multicast_join)
267
+ TEST_ENTRY (udp_multicast_ttl)
268
+
269
+ TEST_ENTRY (pipe_bind_error_addrinuse)
270
+ TEST_ENTRY (pipe_bind_error_addrnotavail)
271
+ TEST_ENTRY (pipe_bind_error_inval)
272
+ TEST_ENTRY (pipe_listen_without_bind)
273
+
274
+ TEST_ENTRY (connection_fail)
275
+ TEST_ENTRY (connection_fail_doesnt_auto_close)
276
+
277
+ TEST_ENTRY (shutdown_close_tcp)
278
+ TEST_HELPER (shutdown_close_tcp, tcp4_echo_server)
279
+ TEST_ENTRY (shutdown_close_pipe)
280
+ TEST_HELPER (shutdown_close_pipe, pipe_echo_server)
281
+
282
+ TEST_ENTRY (shutdown_eof)
283
+ TEST_HELPER (shutdown_eof, tcp4_echo_server)
284
+
285
+ TEST_ENTRY (callback_stack)
286
+ TEST_HELPER (callback_stack, tcp4_echo_server)
287
+
288
+ TEST_ENTRY (error_message)
289
+
290
+ TEST_ENTRY (timer)
291
+ TEST_ENTRY (timer_again)
292
+ TEST_ENTRY (timer_start_twice)
293
+
294
+ TEST_ENTRY (idle_starvation)
295
+
296
+ TEST_ENTRY (ref)
297
+ TEST_ENTRY (idle_ref)
298
+ TEST_ENTRY (fs_poll_ref)
299
+ TEST_ENTRY (async_ref)
300
+ TEST_ENTRY (prepare_ref)
301
+ TEST_ENTRY (check_ref)
302
+ TEST_ENTRY (unref_in_prepare_cb)
303
+ TEST_ENTRY (timer_ref)
304
+ TEST_ENTRY (timer_ref2)
305
+ TEST_ENTRY (fs_event_ref)
306
+ TEST_ENTRY (tcp_ref)
307
+ TEST_ENTRY (tcp_ref2)
308
+ TEST_ENTRY (tcp_ref3)
309
+ TEST_HELPER (tcp_ref3, tcp4_echo_server)
310
+ TEST_ENTRY (tcp_ref4)
311
+ TEST_HELPER (tcp_ref4, tcp4_echo_server)
312
+ TEST_ENTRY (udp_ref)
313
+ TEST_ENTRY (udp_ref2)
314
+ TEST_ENTRY (udp_ref3)
315
+ TEST_HELPER (udp_ref3, udp4_echo_server)
316
+ TEST_ENTRY (pipe_ref)
317
+ TEST_ENTRY (pipe_ref2)
318
+ TEST_ENTRY (pipe_ref3)
319
+ TEST_HELPER (pipe_ref3, pipe_echo_server)
320
+ TEST_ENTRY (pipe_ref4)
321
+ TEST_HELPER (pipe_ref4, pipe_echo_server)
322
+ TEST_ENTRY (process_ref)
323
+
324
+ TEST_ENTRY (loop_handles)
325
+ TEST_ENTRY (walk_handles)
326
+
327
+ TEST_ENTRY (async)
328
+
329
+ TEST_ENTRY (get_currentexe)
330
+
331
+ TEST_ENTRY (process_title)
332
+
333
+ TEST_ENTRY (cwd_and_chdir)
334
+
335
+ TEST_ENTRY (get_memory)
336
+
337
+ TEST_ENTRY (get_loadavg)
338
+
339
+ TEST_ENTRY (hrtime)
340
+
341
+ TEST_ENTRY (getaddrinfo_basic)
342
+ TEST_ENTRY (getaddrinfo_concurrent)
343
+
344
+ TEST_ENTRY (gethostbyname)
345
+ TEST_HELPER (gethostbyname, tcp4_echo_server)
346
+
347
+ TEST_ENTRY (getsockname_tcp)
348
+ TEST_ENTRY (getsockname_udp)
349
+
350
+ TEST_ENTRY (poll_duplex)
351
+ TEST_ENTRY (poll_unidirectional)
352
+ TEST_ENTRY (poll_close)
353
+
354
+ TEST_ENTRY (spawn_exit_code)
355
+ TEST_ENTRY (spawn_stdout)
356
+ TEST_ENTRY (spawn_stdin)
357
+ TEST_ENTRY (spawn_stdio_greater_than_3)
358
+ TEST_ENTRY (spawn_ignored_stdio)
359
+ TEST_ENTRY (spawn_and_kill)
360
+ TEST_ENTRY (spawn_detached)
361
+ TEST_ENTRY (spawn_and_kill_with_std)
362
+ TEST_ENTRY (spawn_and_ping)
363
+ TEST_ENTRY (spawn_setuid_fails)
364
+ TEST_ENTRY (spawn_setgid_fails)
365
+ TEST_ENTRY (spawn_stdout_to_file)
366
+ TEST_ENTRY (fs_poll)
367
+ TEST_ENTRY (kill)
368
+ #ifdef _WIN32
369
+ TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows)
370
+ TEST_ENTRY (argument_escaping)
371
+ TEST_ENTRY (environment_creation)
372
+ TEST_ENTRY (listen_with_simultaneous_accepts)
373
+ TEST_ENTRY (listen_no_simultaneous_accepts)
374
+ TEST_ENTRY (fs_stat_root)
375
+ #else
376
+ TEST_ENTRY (spawn_setuid_setgid)
377
+ #endif
378
+
379
+ TEST_ENTRY (fs_file_noent)
380
+ TEST_ENTRY (fs_file_nametoolong)
381
+ TEST_ENTRY (fs_file_loop)
382
+ TEST_ENTRY (fs_file_async)
383
+ TEST_ENTRY (fs_file_sync)
384
+ TEST_ENTRY (fs_async_dir)
385
+ TEST_ENTRY (fs_async_sendfile)
386
+ TEST_ENTRY (fs_fstat)
387
+ TEST_ENTRY (fs_chmod)
388
+ TEST_ENTRY (fs_chown)
389
+ TEST_ENTRY (fs_utime)
390
+ TEST_ENTRY (fs_futime)
391
+ TEST_ENTRY (fs_symlink)
392
+ TEST_ENTRY (fs_symlink_dir)
393
+ TEST_ENTRY (fs_stat_missing_path)
394
+ TEST_ENTRY (fs_read_file_eof)
395
+ TEST_ENTRY (fs_file_open_append)
396
+ TEST_ENTRY (fs_event_watch_dir)
397
+ TEST_ENTRY (fs_event_watch_file)
398
+ TEST_ENTRY (fs_event_watch_file_current_dir)
399
+ TEST_ENTRY (fs_event_no_callback_on_close)
400
+ TEST_ENTRY (fs_event_immediate_close)
401
+ TEST_ENTRY (fs_event_close_with_pending_event)
402
+ TEST_ENTRY (fs_event_close_in_callback)
403
+ TEST_ENTRY (fs_readdir_empty_dir)
404
+ TEST_ENTRY (fs_readdir_file)
405
+ TEST_ENTRY (fs_open_dir)
406
+ TEST_ENTRY (fs_rename_to_existing_file)
407
+ TEST_ENTRY (threadpool_queue_work_simple)
408
+ TEST_ENTRY (threadpool_multiple_event_loops)
409
+ TEST_ENTRY (thread_mutex)
410
+ TEST_ENTRY (thread_rwlock)
411
+ TEST_ENTRY (thread_create)
412
+ TEST_ENTRY (strlcpy)
413
+ TEST_ENTRY (strlcat)
414
+ TEST_ENTRY (counters_init)
415
+ TEST_ENTRY (dlerror)
416
+ #if 0
417
+ /* These are for testing the test runner. */
418
+ TEST_ENTRY (fail_always)
419
+ TEST_ENTRY (pass_always)
420
+ #endif
421
+ TASK_LIST_END
@@ -0,0 +1,336 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ /* Tests commented out with XXX are ones that are failing on Linux */
23
+
24
+ /*
25
+ * Purpose of this test is to check semantics of starting and stopping
26
+ * prepare, check and idle watchers.
27
+ *
28
+ * - A watcher must be able to safely stop or close itself;
29
+ * - Once a watcher is stopped or closed its callback should never be called.
30
+ * - If a watcher is closed, it is implicitly stopped and its close_cb should
31
+ * be called exactly once.
32
+ * - A watcher can safely start and stop other watchers of the same type.
33
+ * - Prepare and check watchers are called once per event loop iterations.
34
+ * - All active idle watchers are queued when the event loop has no more work
35
+ * to do. This is done repeatedly until all idle watchers are inactive.
36
+ * - If a watcher starts another watcher of the same type its callback is not
37
+ * immediately queued. For check and prepare watchers, that means that if
38
+ * a watcher makes another of the same type active, it'll not be called until
39
+ * the next event loop iteration. For idle. watchers this means that the
40
+ * newly activated idle watcher might not be queued immediately.
41
+ * - Prepare, check, idle watchers keep the event loop alive even when they're
42
+ * not active.
43
+ *
44
+ * This is what the test globally does:
45
+ *
46
+ * - prepare_1 is always active and counts event loop iterations. It also
47
+ * creates and starts prepare_2 every other iteration. Finally it verifies
48
+ * that no idle watchers are active before polling.
49
+ * - prepare_2 is started by prepare_1 every other iteration. It immediately
50
+ * stops itself. It verifies that a watcher is not queued immediately
51
+ * if created by another watcher of the same type.
52
+ * - There's a check watcher that stops the event loop after a certain number
53
+ * of iterations. It starts a varying number of idle_1 watchers.
54
+ * - Idle_1 watchers stop themselves after being called a few times. All idle_1
55
+ * watchers try to start the idle_2 watcher if it is not already started or
56
+ * awaiting its close callback.
57
+ * - The idle_2 watcher always exists but immediately closes itself after
58
+ * being started by a check_1 watcher. It verifies that a watcher is
59
+ * implicitly stopped when closed, and that a watcher can close itself
60
+ * safely.
61
+ * - There is a repeating timer. It does not keep the event loop alive
62
+ * (ev_unref) but makes sure that the loop keeps polling the system for
63
+ * events.
64
+ */
65
+
66
+
67
+ #include "uv.h"
68
+ #include "task.h"
69
+
70
+ #include <math.h>
71
+
72
+
73
+ #define IDLE_COUNT 7
74
+ #define ITERATIONS 21
75
+ #define TIMEOUT 100
76
+
77
+
78
+ static uv_prepare_t prepare_1_handle;
79
+ static uv_prepare_t prepare_2_handle;
80
+
81
+ static uv_check_t check_handle;
82
+
83
+ static uv_idle_t idle_1_handles[IDLE_COUNT];
84
+ static uv_idle_t idle_2_handle;
85
+
86
+ static uv_timer_t timer_handle;
87
+
88
+
89
+ static int loop_iteration = 0;
90
+
91
+ static int prepare_1_cb_called = 0;
92
+ static int prepare_1_close_cb_called = 0;
93
+
94
+ static int prepare_2_cb_called = 0;
95
+ static int prepare_2_close_cb_called = 0;
96
+
97
+ static int check_cb_called = 0;
98
+ static int check_close_cb_called = 0;
99
+
100
+ static int idle_1_cb_called = 0;
101
+ static int idle_1_close_cb_called = 0;
102
+ static int idles_1_active = 0;
103
+
104
+ static int idle_2_cb_called = 0;
105
+ static int idle_2_close_cb_called = 0;
106
+ static int idle_2_cb_started = 0;
107
+ static int idle_2_is_active = 0;
108
+
109
+
110
+ static void timer_cb(uv_timer_t* handle, int status) {
111
+ ASSERT(handle == &timer_handle);
112
+ ASSERT(status == 0);
113
+ }
114
+
115
+
116
+ static void idle_2_close_cb(uv_handle_t* handle) {
117
+ LOG("IDLE_2_CLOSE_CB\n");
118
+
119
+ ASSERT(handle == (uv_handle_t*)&idle_2_handle);
120
+
121
+ ASSERT(idle_2_is_active);
122
+
123
+ idle_2_close_cb_called++;
124
+ idle_2_is_active = 0;
125
+ }
126
+
127
+
128
+ static void idle_2_cb(uv_idle_t* handle, int status) {
129
+ LOG("IDLE_2_CB\n");
130
+
131
+ ASSERT(handle == &idle_2_handle);
132
+ ASSERT(status == 0);
133
+
134
+ idle_2_cb_called++;
135
+
136
+ uv_close((uv_handle_t*)handle, idle_2_close_cb);
137
+ }
138
+
139
+
140
+ static void idle_1_cb(uv_idle_t* handle, int status) {
141
+ int r;
142
+
143
+ LOG("IDLE_1_CB\n");
144
+
145
+ ASSERT(handle != NULL);
146
+ ASSERT(status == 0);
147
+
148
+ ASSERT(idles_1_active > 0);
149
+
150
+ /* Init idle_2 and make it active */
151
+ if (!idle_2_is_active && !uv_is_closing((uv_handle_t*)&idle_2_handle)) {
152
+ r = uv_idle_init(uv_default_loop(), &idle_2_handle);
153
+ ASSERT(r == 0);
154
+ r = uv_idle_start(&idle_2_handle, idle_2_cb);
155
+ ASSERT(r == 0);
156
+ idle_2_is_active = 1;
157
+ idle_2_cb_started++;
158
+ }
159
+
160
+ idle_1_cb_called++;
161
+
162
+ if (idle_1_cb_called % 5 == 0) {
163
+ r = uv_idle_stop((uv_idle_t*)handle);
164
+ ASSERT(r == 0);
165
+ idles_1_active--;
166
+ }
167
+ }
168
+
169
+
170
+ static void idle_1_close_cb(uv_handle_t* handle) {
171
+ LOG("IDLE_1_CLOSE_CB\n");
172
+
173
+ ASSERT(handle != NULL);
174
+
175
+ idle_1_close_cb_called++;
176
+ }
177
+
178
+
179
+ static void prepare_1_close_cb(uv_handle_t* handle) {
180
+ LOG("PREPARE_1_CLOSE_CB");
181
+ ASSERT(handle == (uv_handle_t*)&prepare_1_handle);
182
+
183
+ prepare_1_close_cb_called++;
184
+ }
185
+
186
+
187
+ static void check_close_cb(uv_handle_t* handle) {
188
+ LOG("CHECK_CLOSE_CB\n");
189
+ ASSERT(handle == (uv_handle_t*)&check_handle);
190
+
191
+ check_close_cb_called++;
192
+ }
193
+
194
+
195
+ static void prepare_2_close_cb(uv_handle_t* handle) {
196
+ LOG("PREPARE_2_CLOSE_CB\n");
197
+ ASSERT(handle == (uv_handle_t*)&prepare_2_handle);
198
+
199
+ prepare_2_close_cb_called++;
200
+ }
201
+
202
+
203
+ static void check_cb(uv_check_t* handle, int status) {
204
+ int i, r;
205
+
206
+ LOG("CHECK_CB\n");
207
+
208
+ ASSERT(handle == &check_handle);
209
+ ASSERT(status == 0);
210
+
211
+ if (loop_iteration < ITERATIONS) {
212
+ /* Make some idle watchers active */
213
+ for (i = 0; i < 1 + (loop_iteration % IDLE_COUNT); i++) {
214
+ r = uv_idle_start(&idle_1_handles[i], idle_1_cb);
215
+ ASSERT(r == 0);
216
+ idles_1_active++;
217
+ }
218
+
219
+ } else {
220
+ /* End of the test - close all handles */
221
+ uv_close((uv_handle_t*)&prepare_1_handle, prepare_1_close_cb);
222
+ uv_close((uv_handle_t*)&check_handle, check_close_cb);
223
+ uv_close((uv_handle_t*)&prepare_2_handle, prepare_2_close_cb);
224
+
225
+ for (i = 0; i < IDLE_COUNT; i++) {
226
+ uv_close((uv_handle_t*)&idle_1_handles[i], idle_1_close_cb);
227
+ }
228
+
229
+ /* This handle is closed/recreated every time, close it only if it is */
230
+ /* active.*/
231
+ if (idle_2_is_active) {
232
+ uv_close((uv_handle_t*)&idle_2_handle, idle_2_close_cb);
233
+ }
234
+ }
235
+
236
+ check_cb_called++;
237
+ }
238
+
239
+
240
+ static void prepare_2_cb(uv_prepare_t* handle, int status) {
241
+ int r;
242
+
243
+ LOG("PREPARE_2_CB\n");
244
+
245
+ ASSERT(handle == &prepare_2_handle);
246
+ ASSERT(status == 0);
247
+
248
+ /* prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), */
249
+ /* and it stops itself immediately. A started watcher is not queued */
250
+ /* until the next round, so when this callback is made */
251
+ /* (loop_iteration % 2 == 0) cannot be true. */
252
+ ASSERT(loop_iteration % 2 != 0);
253
+
254
+ r = uv_prepare_stop((uv_prepare_t*)handle);
255
+ ASSERT(r == 0);
256
+
257
+ prepare_2_cb_called++;
258
+ }
259
+
260
+
261
+ static void prepare_1_cb(uv_prepare_t* handle, int status) {
262
+ int r;
263
+
264
+ LOG("PREPARE_1_CB\n");
265
+
266
+ ASSERT(handle == &prepare_1_handle);
267
+ ASSERT(status == 0);
268
+
269
+ if (loop_iteration % 2 == 0) {
270
+ r = uv_prepare_start(&prepare_2_handle, prepare_2_cb);
271
+ ASSERT(r == 0);
272
+ }
273
+
274
+ prepare_1_cb_called++;
275
+ loop_iteration++;
276
+
277
+ printf("Loop iteration %d of %d.\n", loop_iteration, ITERATIONS);
278
+ }
279
+
280
+
281
+ TEST_IMPL(loop_handles) {
282
+ int i;
283
+ int r;
284
+
285
+ r = uv_prepare_init(uv_default_loop(), &prepare_1_handle);
286
+ ASSERT(r == 0);
287
+ r = uv_prepare_start(&prepare_1_handle, prepare_1_cb);
288
+ ASSERT(r == 0);
289
+
290
+ r = uv_check_init(uv_default_loop(), &check_handle);
291
+ ASSERT(r == 0);
292
+ r = uv_check_start(&check_handle, check_cb);
293
+ ASSERT(r == 0);
294
+
295
+ /* initialize only, prepare_2 is started by prepare_1_cb */
296
+ r = uv_prepare_init(uv_default_loop(), &prepare_2_handle);
297
+ ASSERT(r == 0);
298
+
299
+ for (i = 0; i < IDLE_COUNT; i++) {
300
+ /* initialize only, idle_1 handles are started by check_cb */
301
+ r = uv_idle_init(uv_default_loop(), &idle_1_handles[i]);
302
+ ASSERT(r == 0);
303
+ }
304
+
305
+ /* don't init or start idle_2, both is done by idle_1_cb */
306
+
307
+ /* the timer callback is there to keep the event loop polling */
308
+ /* unref it as it is not supposed to keep the loop alive */
309
+ r = uv_timer_init(uv_default_loop(), &timer_handle);
310
+ ASSERT(r == 0);
311
+ r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT);
312
+ ASSERT(r == 0);
313
+ uv_unref((uv_handle_t*)&timer_handle);
314
+
315
+ r = uv_run(uv_default_loop());
316
+ ASSERT(r == 0);
317
+
318
+ ASSERT(loop_iteration == ITERATIONS);
319
+
320
+ ASSERT(prepare_1_cb_called == ITERATIONS);
321
+ ASSERT(prepare_1_close_cb_called == 1);
322
+
323
+ ASSERT(prepare_2_cb_called == floor(ITERATIONS / 2.0));
324
+ ASSERT(prepare_2_close_cb_called == 1);
325
+
326
+ ASSERT(check_cb_called == ITERATIONS);
327
+ ASSERT(check_close_cb_called == 1);
328
+
329
+ /* idle_1_cb should be called a lot */
330
+ ASSERT(idle_1_close_cb_called == IDLE_COUNT);
331
+
332
+ ASSERT(idle_2_close_cb_called == idle_2_cb_started);
333
+ ASSERT(idle_2_is_active == 0);
334
+
335
+ return 0;
336
+ }