passenger 5.0.4 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (550) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +10 -0
  5. data/CHANGELOG +21 -0
  6. data/build/agents.rb +2 -2
  7. data/build/apache2.rb +6 -5
  8. data/build/common_library.rb +22 -7
  9. data/build/cxx_tests.rb +0 -3
  10. data/build/misc.rb +1 -1
  11. data/dev/parse_file_descriptor_log +119 -0
  12. data/doc/CloudLicensingConfiguration.html +387 -0
  13. data/doc/Design and Architecture.html +2430 -0
  14. data/doc/Packaging.html +488 -0
  15. data/doc/Security of user switching support.html +1833 -0
  16. data/doc/ServerOptimizationGuide.html +659 -0
  17. data/doc/ServerOptimizationGuide.txt.md +8 -0
  18. data/doc/Users guide Apache.html +9116 -0
  19. data/doc/Users guide Apache.idmap.txt +6 -2
  20. data/doc/Users guide Apache.txt +26 -7
  21. data/doc/Users guide Nginx.html +9025 -0
  22. data/doc/Users guide Nginx.idmap.txt +7 -3
  23. data/doc/Users guide Nginx.txt +29 -6
  24. data/doc/Users guide Standalone.html +3983 -0
  25. data/doc/Users guide.html +1748 -0
  26. data/doc/users_guide_snippets/installation.txt +4 -4
  27. data/ext/apache2/Configuration.cpp +16 -5
  28. data/ext/apache2/Configuration.hpp +4 -2
  29. data/ext/apache2/Hooks.cpp +44 -19
  30. data/ext/boost/libs/thread/src/pthread/once.cpp +2 -0
  31. data/ext/boost/libs/thread/src/pthread/once_atomic.cpp +6 -0
  32. data/ext/common/AgentsStarter.h +3 -2
  33. data/ext/common/ApplicationPool2/DirectSpawner.h +14 -4
  34. data/ext/common/ApplicationPool2/DummySpawner.h +12 -7
  35. data/ext/common/ApplicationPool2/Implementation.cpp +1 -1
  36. data/ext/common/ApplicationPool2/Process.h +2 -1
  37. data/ext/common/ApplicationPool2/Session.h +6 -6
  38. data/ext/common/ApplicationPool2/SmartSpawner.h +19 -4
  39. data/ext/common/ApplicationPool2/Socket.h +59 -27
  40. data/ext/common/ApplicationPool2/Spawner.h +2 -2
  41. data/ext/common/BackgroundEventLoop.cpp +6 -1
  42. data/ext/common/Constants.h +1 -1
  43. data/ext/common/EventedClient.h +1 -1
  44. data/ext/common/EventedServer.h +2 -2
  45. data/ext/common/FileDescriptor.h +25 -6
  46. data/ext/common/Logging.cpp +107 -52
  47. data/ext/common/Logging.h +146 -19
  48. data/ext/common/MessageClient.h +2 -2
  49. data/ext/common/MessageServer.h +3 -2
  50. data/ext/common/RandomGenerator.h +8 -7
  51. data/ext/common/SafeLibev.h +5 -1
  52. data/ext/common/ServerKit/AcceptLoadBalancer.h +9 -4
  53. data/ext/common/ServerKit/FdSinkChannel.h +5 -2
  54. data/ext/common/ServerKit/FdSourceChannel.h +5 -2
  55. data/ext/common/ServerKit/FileBufferedChannel.h +2 -0
  56. data/ext/common/ServerKit/FileBufferedFdSinkChannel.h +7 -2
  57. data/ext/common/ServerKit/HttpServer.h +6 -0
  58. data/ext/common/ServerKit/Server.h +40 -3
  59. data/ext/common/StaticString.h +20 -0
  60. data/ext/common/UnionStation/Connection.h +3 -1
  61. data/ext/common/UnionStation/Core.h +6 -4
  62. data/ext/common/Utils.cpp +4 -3
  63. data/ext/common/Utils/DateParsing.h +19 -5
  64. data/ext/common/Utils/FastStringStream.h +183 -0
  65. data/ext/common/Utils/IOUtils.cpp +47 -28
  66. data/ext/common/Utils/IOUtils.h +56 -12
  67. data/ext/common/Utils/MessagePassing.h +3 -3
  68. data/ext/common/Utils/ProcessMetricsCollector.h +2 -2
  69. data/ext/common/Utils/ScopeGuard.h +16 -5
  70. data/ext/common/Utils/SpeedMeter.h +2 -2
  71. data/ext/common/Utils/StrIntUtils.cpp +6 -6
  72. data/ext/common/Utils/StrIntUtils.h +2 -1
  73. data/ext/common/agents/Base.cpp +56 -4
  74. data/ext/common/agents/Base.h +2 -1
  75. data/ext/common/agents/HelperAgent/AdminServer.h +122 -11
  76. data/ext/common/agents/HelperAgent/Main.cpp +16 -5
  77. data/ext/common/agents/HelperAgent/OptionParser.h +7 -1
  78. data/ext/common/agents/HelperAgent/RequestHandler.h +1 -1
  79. data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +10 -1
  80. data/ext/common/agents/HelperAgent/RequestHandler/Request.h +8 -0
  81. data/ext/common/agents/HelperAgent/RequestHandler/TurboCaching.h +4 -3
  82. data/ext/common/agents/LoggingAgent/AdminServer.h +57 -11
  83. data/ext/common/agents/LoggingAgent/LoggingServer.h +3 -3
  84. data/ext/common/agents/LoggingAgent/Main.cpp +11 -3
  85. data/ext/common/agents/Watchdog/AdminServer.h +53 -11
  86. data/ext/common/agents/Watchdog/AgentWatcher.cpp +3 -3
  87. data/ext/common/agents/Watchdog/Main.cpp +13 -6
  88. data/ext/libeio/ecb.h +1 -1
  89. data/ext/libev/ev.c +13 -1
  90. data/ext/libev/ev.h +3 -0
  91. data/ext/nginx/Configuration.c +28 -6
  92. data/ext/nginx/Configuration.h +2 -1
  93. data/ext/nginx/ngx_http_passenger_module.c +5 -4
  94. data/ext/oxt/dynamic_thread_group.hpp +38 -5
  95. data/lib/phusion_passenger.rb +1 -1
  96. data/lib/phusion_passenger/common_library.rb +9 -5
  97. data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
  98. data/lib/phusion_passenger/packaging.rb +23 -37
  99. data/passenger.gemspec +21 -21
  100. metadata +4 -453
  101. metadata.gz.asc +7 -7
  102. data/.gitignore +0 -68
  103. data/.travis.yml +0 -16
  104. data/Gemfile +0 -17
  105. data/Gemfile.lock +0 -39
  106. data/Vagrantfile +0 -54
  107. data/debian.template/README.Debian +0 -15
  108. data/debian.template/changelog +0 -316
  109. data/debian.template/compat +0 -1
  110. data/debian.template/control.erb +0 -91
  111. data/debian.template/copyright +0 -385
  112. data/debian.template/libapache2-mod-passenger.install +0 -3
  113. data/debian.template/libapache2-mod-passenger.postinst +0 -36
  114. data/debian.template/libapache2-mod-passenger.prerm +0 -15
  115. data/debian.template/locations.ini.erb +0 -14
  116. data/debian.template/passenger-dev.install.erb +0 -3
  117. data/debian.template/passenger-doc.install.erb +0 -2
  118. data/debian.template/passenger.conf +0 -6
  119. data/debian.template/passenger.docs +0 -4
  120. data/debian.template/passenger.install.erb +0 -14
  121. data/debian.template/passenger.load +0 -3
  122. data/debian.template/passenger.manpages +0 -3
  123. data/debian.template/patches/series +0 -0
  124. data/debian.template/rules.erb +0 -76
  125. data/debian.template/source/format +0 -1
  126. data/ext/common/EventedBufferedInput.h +0 -458
  127. data/packaging/rpm/LICENSE.txt +0 -19
  128. data/packaging/rpm/Makefile +0 -13
  129. data/packaging/rpm/README.md +0 -41
  130. data/packaging/rpm/Vagrantfile +0 -38
  131. data/packaging/rpm/Vagrantfile.centos +0 -30
  132. data/packaging/rpm/build +0 -170
  133. data/packaging/rpm/create_project +0 -41
  134. data/packaging/rpm/git_update +0 -88
  135. data/packaging/rpm/image/Dockerfile +0 -37
  136. data/packaging/rpm/image/Gemfile +0 -3
  137. data/packaging/rpm/image/Gemfile.lock +0 -12
  138. data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +0 -19
  139. data/packaging/rpm/image/amazon2014-i386.cfg +0 -96
  140. data/packaging/rpm/image/amazon2014-x86_64.cfg +0 -96
  141. data/packaging/rpm/image/site-defaults.cfg +0 -168
  142. data/packaging/rpm/internal/build_tasks.rb +0 -238
  143. data/packaging/rpm/internal/dummygpg +0 -11
  144. data/packaging/rpm/internal/exec_build +0 -42
  145. data/packaging/rpm/internal/get_distro_arch +0 -14
  146. data/packaging/rpm/internal/get_distro_id +0 -10
  147. data/packaging/rpm/internal/git_update +0 -27
  148. data/packaging/rpm/internal/inituidgid +0 -17
  149. data/packaging/rpm/internal/my_init +0 -344
  150. data/packaging/rpm/internal/python27 +0 -3
  151. data/packaging/rpm/internal/repo_update +0 -46
  152. data/packaging/rpm/internal/setuser +0 -26
  153. data/packaging/rpm/internal/tracking_helper +0 -40
  154. data/packaging/rpm/jenkins_release +0 -99
  155. data/packaging/rpm/lib/build_tasks_support.rb +0 -402
  156. data/packaging/rpm/lib/preprocessor.rb +0 -341
  157. data/packaging/rpm/nginx_spec/404.html +0 -119
  158. data/packaging/rpm/nginx_spec/50x.html +0 -119
  159. data/packaging/rpm/nginx_spec/index.html +0 -116
  160. data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +0 -13
  161. data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
  162. data/packaging/rpm/nginx_spec/nginx-upgrade +0 -13
  163. data/packaging/rpm/nginx_spec/nginx-upgrade.8 +0 -151
  164. data/packaging/rpm/nginx_spec/nginx.conf +0 -131
  165. data/packaging/rpm/nginx_spec/nginx.init +0 -144
  166. data/packaging/rpm/nginx_spec/nginx.logrotate +0 -13
  167. data/packaging/rpm/nginx_spec/nginx.service +0 -15
  168. data/packaging/rpm/nginx_spec/nginx.spec.template +0 -560
  169. data/packaging/rpm/nginx_spec/nginx.sysconfig +0 -4
  170. data/packaging/rpm/nginx_spec/passenger.conf +0 -9
  171. data/packaging/rpm/nginx_spec/poweredby.png +0 -0
  172. data/packaging/rpm/passenger_spec/apache-passenger.conf.in +0 -26
  173. data/packaging/rpm/passenger_spec/config.json +0 -30
  174. data/packaging/rpm/passenger_spec/passenger.logrotate +0 -7
  175. data/packaging/rpm/passenger_spec/passenger.spec.template +0 -478
  176. data/packaging/rpm/passenger_spec/passenger_dynamic_thread_group.patch +0 -16
  177. data/packaging/rpm/passenger_spec/passenger_tests_default_config_example.patch +0 -44
  178. data/packaging/rpm/passenger_spec/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -21
  179. data/packaging/rpm/repo_update +0 -114
  180. data/packaging/rpm/setup-system +0 -61
  181. data/packaging/rpm/shell +0 -10
  182. data/test/.rspec +0 -4
  183. data/test/config.json.example +0 -42
  184. data/test/config.json.rpm-automation +0 -15
  185. data/test/config.json.travis +0 -15
  186. data/test/config.json.vagrant +0 -30
  187. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +0 -124
  188. data/test/cxx/ApplicationPool2/OptionsTest.cpp +0 -30
  189. data/test/cxx/ApplicationPool2/PoolTest.cpp +0 -2062
  190. data/test/cxx/ApplicationPool2/ProcessTest.cpp +0 -130
  191. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +0 -243
  192. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +0 -823
  193. data/test/cxx/BufferedIOTest.cpp +0 -364
  194. data/test/cxx/CachedFileStatTest.cpp +0 -402
  195. data/test/cxx/CxxTestMain.cpp +0 -181
  196. data/test/cxx/DataStructures/LStringTest.cpp +0 -275
  197. data/test/cxx/DataStructures/StringKeyTableTest.cpp +0 -199
  198. data/test/cxx/DateParsingTest.cpp +0 -75
  199. data/test/cxx/DechunkerTest.cpp +0 -250
  200. data/test/cxx/EventedBufferedInputTest.cpp +0 -758
  201. data/test/cxx/EventedClientTest.cpp +0 -523
  202. data/test/cxx/FileChangeCheckerTest.cpp +0 -331
  203. data/test/cxx/FileDescriptorTest.cpp +0 -69
  204. data/test/cxx/FilterSupportTest.cpp +0 -433
  205. data/test/cxx/IOUtilsTest.cpp +0 -861
  206. data/test/cxx/MemoryKit/MbufTest.cpp +0 -213
  207. data/test/cxx/MessageIOTest.cpp +0 -360
  208. data/test/cxx/MessagePassingTest.cpp +0 -81
  209. data/test/cxx/MessageReadersWritersTest.cpp +0 -576
  210. data/test/cxx/MessageServerTest.cpp +0 -393
  211. data/test/cxx/ProcessMetricsCollectorTest.cpp +0 -123
  212. data/test/cxx/RequestHandlerTest.cpp +0 -1463
  213. data/test/cxx/ResponseCacheTest.cpp +0 -322
  214. data/test/cxx/ServerKit/ChannelTest.cpp +0 -1467
  215. data/test/cxx/ServerKit/CookieUtilsTest.cpp +0 -274
  216. data/test/cxx/ServerKit/FileBufferedChannelTest.cpp +0 -992
  217. data/test/cxx/ServerKit/HeaderTableTest.cpp +0 -177
  218. data/test/cxx/ServerKit/HttpServerTest.cpp +0 -1580
  219. data/test/cxx/ServerKit/ServerTest.cpp +0 -408
  220. data/test/cxx/StaticStringTest.cpp +0 -220
  221. data/test/cxx/StringMapTest.cpp +0 -131
  222. data/test/cxx/SystemTimeTest.cpp +0 -37
  223. data/test/cxx/TemplateTest.cpp +0 -118
  224. data/test/cxx/TestSupport.cpp +0 -207
  225. data/test/cxx/TestSupport.h +0 -333
  226. data/test/cxx/UnionStationTest.cpp +0 -741
  227. data/test/cxx/Utils/StrIntUtilsTest.cpp +0 -39
  228. data/test/cxx/UtilsTest.cpp +0 -672
  229. data/test/cxx/VariantMapTest.cpp +0 -191
  230. data/test/gdbinit.example +0 -34
  231. data/test/integration_tests/apache2_tests.rb +0 -585
  232. data/test/integration_tests/downloaded_binaries_tests.rb +0 -185
  233. data/test/integration_tests/native_packaging_spec.rb +0 -368
  234. data/test/integration_tests/nginx_tests.rb +0 -402
  235. data/test/integration_tests/shared/example_webapp_tests.rb +0 -289
  236. data/test/integration_tests/source_packaging_test.rb +0 -201
  237. data/test/integration_tests/spec_helper.rb +0 -22
  238. data/test/integration_tests/standalone_tests.rb +0 -392
  239. data/test/node/line_reader_spec.js +0 -338
  240. data/test/node/spec_helper.js +0 -65
  241. data/test/oxt/backtrace_test.cpp +0 -88
  242. data/test/oxt/counter.hpp +0 -55
  243. data/test/oxt/dynamic_thread_group_test.cpp +0 -131
  244. data/test/oxt/oxt_test_main.cpp +0 -27
  245. data/test/oxt/spin_lock_test.cpp +0 -59
  246. data/test/oxt/syscall_interruption_test.cpp +0 -39
  247. data/test/ruby/debug_logging_spec.rb +0 -145
  248. data/test/ruby/message_channel_spec.rb +0 -196
  249. data/test/ruby/rack/loader_spec.rb +0 -42
  250. data/test/ruby/rack/preloader_spec.rb +0 -48
  251. data/test/ruby/rails3.0/loader_spec.rb +0 -26
  252. data/test/ruby/rails3.0/preloader_spec.rb +0 -32
  253. data/test/ruby/rails3.1/loader_spec.rb +0 -26
  254. data/test/ruby/rails3.1/preloader_spec.rb +0 -32
  255. data/test/ruby/rails3.2/loader_spec.rb +0 -26
  256. data/test/ruby/rails3.2/preloader_spec.rb +0 -32
  257. data/test/ruby/rails4.0/loader_spec.rb +0 -28
  258. data/test/ruby/rails4.0/preloader_spec.rb +0 -34
  259. data/test/ruby/rails4.1/loader_spec.rb +0 -28
  260. data/test/ruby/rails4.1/preloader_spec.rb +0 -34
  261. data/test/ruby/request_handler_spec.rb +0 -747
  262. data/test/ruby/shared/loader_sharedspec.rb +0 -247
  263. data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +0 -357
  264. data/test/ruby/shared/ruby_loader_sharedspec.rb +0 -55
  265. data/test/ruby/spec_helper.rb +0 -114
  266. data/test/ruby/standalone/runtime_installer_spec.rb +0 -402
  267. data/test/ruby/union_station_spec.rb +0 -288
  268. data/test/ruby/utils/file_system_watcher_spec.rb +0 -229
  269. data/test/ruby/utils/hosts_file_parser.rb +0 -258
  270. data/test/ruby/utils/tee_input_spec.rb +0 -235
  271. data/test/ruby/utils/unseekable_socket_spec.rb +0 -66
  272. data/test/ruby/utils_spec.rb +0 -41
  273. data/test/stub/apache2/httpd.conf.erb +0 -122
  274. data/test/stub/apache2/mime.types +0 -748
  275. data/test/stub/garbage1.dat +0 -0
  276. data/test/stub/garbage2.dat +0 -0
  277. data/test/stub/garbage3.dat +0 -0
  278. data/test/stub/http_request.yml +0 -23
  279. data/test/stub/index.html +0 -1
  280. data/test/stub/nginx/koi-utf +0 -109
  281. data/test/stub/nginx/koi-win +0 -103
  282. data/test/stub/nginx/mime.types +0 -70
  283. data/test/stub/nginx/nginx.conf.erb +0 -70
  284. data/test/stub/nginx/win-utf +0 -126
  285. data/test/stub/node/app.js +0 -133
  286. data/test/stub/node/public/.gitignore +0 -0
  287. data/test/stub/node/tmp/.gitignore +0 -0
  288. data/test/stub/rack/config.ru +0 -95
  289. data/test/stub/rack/library.rb +0 -16
  290. data/test/stub/rack/public/.gitignore +0 -0
  291. data/test/stub/rack/start.rb +0 -52
  292. data/test/stub/rack/tmp/.gitignore +0 -0
  293. data/test/stub/rails3.0/.gitignore +0 -4
  294. data/test/stub/rails3.0/Gemfile +0 -22
  295. data/test/stub/rails3.0/Gemfile.lock +0 -80
  296. data/test/stub/rails3.0/Rakefile +0 -10
  297. data/test/stub/rails3.0/app/controllers/application_controller.rb +0 -4
  298. data/test/stub/rails3.0/app/helpers/application_helper.rb +0 -2
  299. data/test/stub/rails3.0/app/views/layouts/application.html.erb +0 -14
  300. data/test/stub/rails3.0/config.ru +0 -4
  301. data/test/stub/rails3.0/config/application.rb +0 -48
  302. data/test/stub/rails3.0/config/boot.rb +0 -13
  303. data/test/stub/rails3.0/config/database.yml +0 -22
  304. data/test/stub/rails3.0/config/environment.rb +0 -5
  305. data/test/stub/rails3.0/config/environments/development.rb +0 -19
  306. data/test/stub/rails3.0/config/environments/production.rb +0 -48
  307. data/test/stub/rails3.0/config/environments/test.rb +0 -32
  308. data/test/stub/rails3.0/config/initializers/backtrace_silencers.rb +0 -7
  309. data/test/stub/rails3.0/config/initializers/inflections.rb +0 -10
  310. data/test/stub/rails3.0/config/initializers/mime_types.rb +0 -5
  311. data/test/stub/rails3.0/config/initializers/passenger.rb +0 -2
  312. data/test/stub/rails3.0/config/initializers/secret_token.rb +0 -7
  313. data/test/stub/rails3.0/config/initializers/session_store.rb +0 -8
  314. data/test/stub/rails3.0/config/locales/en.yml +0 -5
  315. data/test/stub/rails3.0/config/routes.rb +0 -58
  316. data/test/stub/rails3.0/db/seeds.rb +0 -7
  317. data/test/stub/rails3.0/doc/README_FOR_APP +0 -2
  318. data/test/stub/rails3.0/lib/tasks/.gitkeep +0 -0
  319. data/test/stub/rails3.0/log/.gitignore +0 -0
  320. data/test/stub/rails3.0/public/404.html +0 -26
  321. data/test/stub/rails3.0/public/422.html +0 -26
  322. data/test/stub/rails3.0/public/500.html +0 -26
  323. data/test/stub/rails3.0/public/favicon.ico +0 -0
  324. data/test/stub/rails3.0/public/index.html +0 -279
  325. data/test/stub/rails3.0/public/robots.txt +0 -5
  326. data/test/stub/rails3.0/public/stylesheets/.gitkeep +0 -0
  327. data/test/stub/rails3.0/script/rails +0 -9
  328. data/test/stub/rails3.0/test/performance/browsing_test.rb +0 -9
  329. data/test/stub/rails3.0/test/test_helper.rb +0 -13
  330. data/test/stub/rails3.0/vendor/plugins/.gitkeep +0 -0
  331. data/test/stub/rails3.1/.gitignore +0 -15
  332. data/test/stub/rails3.1/Gemfile +0 -37
  333. data/test/stub/rails3.1/Gemfile.lock +0 -115
  334. data/test/stub/rails3.1/README +0 -261
  335. data/test/stub/rails3.1/Rakefile +0 -7
  336. data/test/stub/rails3.1/app/assets/images/rails.png +0 -0
  337. data/test/stub/rails3.1/app/assets/stylesheets/application.css +0 -7
  338. data/test/stub/rails3.1/app/controllers/application_controller.rb +0 -3
  339. data/test/stub/rails3.1/app/helpers/application_helper.rb +0 -2
  340. data/test/stub/rails3.1/app/mailers/.gitkeep +0 -0
  341. data/test/stub/rails3.1/app/models/.gitkeep +0 -0
  342. data/test/stub/rails3.1/app/views/layouts/application.html.erb +0 -14
  343. data/test/stub/rails3.1/config.ru +0 -4
  344. data/test/stub/rails3.1/config/application.rb +0 -48
  345. data/test/stub/rails3.1/config/boot.rb +0 -6
  346. data/test/stub/rails3.1/config/database.yml +0 -25
  347. data/test/stub/rails3.1/config/environment.rb +0 -5
  348. data/test/stub/rails3.1/config/environments/development.rb +0 -30
  349. data/test/stub/rails3.1/config/environments/production.rb +0 -60
  350. data/test/stub/rails3.1/config/environments/test.rb +0 -39
  351. data/test/stub/rails3.1/config/initializers/backtrace_silencers.rb +0 -7
  352. data/test/stub/rails3.1/config/initializers/inflections.rb +0 -10
  353. data/test/stub/rails3.1/config/initializers/mime_types.rb +0 -5
  354. data/test/stub/rails3.1/config/initializers/passenger.rb +0 -2
  355. data/test/stub/rails3.1/config/initializers/secret_token.rb +0 -7
  356. data/test/stub/rails3.1/config/initializers/session_store.rb +0 -8
  357. data/test/stub/rails3.1/config/initializers/wrap_parameters.rb +0 -14
  358. data/test/stub/rails3.1/config/locales/en.yml +0 -5
  359. data/test/stub/rails3.1/config/routes.rb +0 -58
  360. data/test/stub/rails3.1/db/seeds.rb +0 -7
  361. data/test/stub/rails3.1/doc/README_FOR_APP +0 -2
  362. data/test/stub/rails3.1/lib/assets/.gitkeep +0 -0
  363. data/test/stub/rails3.1/lib/tasks/.gitkeep +0 -0
  364. data/test/stub/rails3.1/log/.gitkeep +0 -0
  365. data/test/stub/rails3.1/public/404.html +0 -26
  366. data/test/stub/rails3.1/public/422.html +0 -26
  367. data/test/stub/rails3.1/public/500.html +0 -26
  368. data/test/stub/rails3.1/public/favicon.ico +0 -0
  369. data/test/stub/rails3.1/public/index.html +0 -241
  370. data/test/stub/rails3.1/public/robots.txt +0 -5
  371. data/test/stub/rails3.1/script/rails +0 -6
  372. data/test/stub/rails3.1/test/fixtures/.gitkeep +0 -0
  373. data/test/stub/rails3.1/test/functional/.gitkeep +0 -0
  374. data/test/stub/rails3.1/test/integration/.gitkeep +0 -0
  375. data/test/stub/rails3.1/test/performance/browsing_test.rb +0 -12
  376. data/test/stub/rails3.1/test/test_helper.rb +0 -13
  377. data/test/stub/rails3.1/test/unit/.gitkeep +0 -0
  378. data/test/stub/rails3.1/vendor/assets/stylesheets/.gitkeep +0 -0
  379. data/test/stub/rails3.1/vendor/plugins/.gitkeep +0 -0
  380. data/test/stub/rails3.2/.gitignore +0 -15
  381. data/test/stub/rails3.2/Gemfile +0 -39
  382. data/test/stub/rails3.2/Gemfile.lock +0 -113
  383. data/test/stub/rails3.2/Rakefile +0 -7
  384. data/test/stub/rails3.2/app/assets/images/rails.png +0 -0
  385. data/test/stub/rails3.2/app/assets/stylesheets/application.css +0 -13
  386. data/test/stub/rails3.2/app/controllers/application_controller.rb +0 -3
  387. data/test/stub/rails3.2/app/helpers/application_helper.rb +0 -2
  388. data/test/stub/rails3.2/app/mailers/.gitkeep +0 -0
  389. data/test/stub/rails3.2/app/models/.gitkeep +0 -0
  390. data/test/stub/rails3.2/app/views/layouts/application.html.erb +0 -14
  391. data/test/stub/rails3.2/config.ru +0 -4
  392. data/test/stub/rails3.2/config/application.rb +0 -62
  393. data/test/stub/rails3.2/config/boot.rb +0 -6
  394. data/test/stub/rails3.2/config/database.yml +0 -25
  395. data/test/stub/rails3.2/config/environment.rb +0 -5
  396. data/test/stub/rails3.2/config/environments/development.rb +0 -37
  397. data/test/stub/rails3.2/config/environments/production.rb +0 -67
  398. data/test/stub/rails3.2/config/environments/test.rb +0 -37
  399. data/test/stub/rails3.2/config/initializers/backtrace_silencers.rb +0 -7
  400. data/test/stub/rails3.2/config/initializers/inflections.rb +0 -15
  401. data/test/stub/rails3.2/config/initializers/mime_types.rb +0 -5
  402. data/test/stub/rails3.2/config/initializers/passenger.rb +0 -2
  403. data/test/stub/rails3.2/config/initializers/secret_token.rb +0 -7
  404. data/test/stub/rails3.2/config/initializers/session_store.rb +0 -8
  405. data/test/stub/rails3.2/config/initializers/wrap_parameters.rb +0 -14
  406. data/test/stub/rails3.2/config/locales/en.yml +0 -5
  407. data/test/stub/rails3.2/config/routes.rb +0 -58
  408. data/test/stub/rails3.2/db/seeds.rb +0 -7
  409. data/test/stub/rails3.2/doc/README_FOR_APP +0 -2
  410. data/test/stub/rails3.2/lib/assets/.gitkeep +0 -0
  411. data/test/stub/rails3.2/lib/tasks/.gitkeep +0 -0
  412. data/test/stub/rails3.2/log/.gitkeep +0 -0
  413. data/test/stub/rails3.2/public/404.html +0 -26
  414. data/test/stub/rails3.2/public/422.html +0 -26
  415. data/test/stub/rails3.2/public/500.html +0 -25
  416. data/test/stub/rails3.2/public/favicon.ico +0 -0
  417. data/test/stub/rails3.2/public/index.html +0 -241
  418. data/test/stub/rails3.2/public/robots.txt +0 -5
  419. data/test/stub/rails3.2/script/rails +0 -6
  420. data/test/stub/rails3.2/test/fixtures/.gitkeep +0 -0
  421. data/test/stub/rails3.2/test/functional/.gitkeep +0 -0
  422. data/test/stub/rails3.2/test/integration/.gitkeep +0 -0
  423. data/test/stub/rails3.2/test/performance/browsing_test.rb +0 -12
  424. data/test/stub/rails3.2/test/test_helper.rb +0 -13
  425. data/test/stub/rails3.2/test/unit/.gitkeep +0 -0
  426. data/test/stub/rails3.2/vendor/assets/stylesheets/.gitkeep +0 -0
  427. data/test/stub/rails3.2/vendor/plugins/.gitkeep +0 -0
  428. data/test/stub/rails4.0/.gitignore +0 -16
  429. data/test/stub/rails4.0/Gemfile +0 -45
  430. data/test/stub/rails4.0/Gemfile.lock +0 -126
  431. data/test/stub/rails4.0/README.rdoc +0 -28
  432. data/test/stub/rails4.0/Rakefile +0 -6
  433. data/test/stub/rails4.0/app/assets/images/.keep +0 -0
  434. data/test/stub/rails4.0/app/assets/javascripts/application.js +0 -16
  435. data/test/stub/rails4.0/app/assets/stylesheets/application.css +0 -13
  436. data/test/stub/rails4.0/app/controllers/application_controller.rb +0 -5
  437. data/test/stub/rails4.0/app/controllers/concerns/.keep +0 -0
  438. data/test/stub/rails4.0/app/helpers/application_helper.rb +0 -2
  439. data/test/stub/rails4.0/app/mailers/.keep +0 -0
  440. data/test/stub/rails4.0/app/models/.keep +0 -0
  441. data/test/stub/rails4.0/app/models/concerns/.keep +0 -0
  442. data/test/stub/rails4.0/app/views/layouts/application.html.erb +0 -14
  443. data/test/stub/rails4.0/bin/bundle +0 -3
  444. data/test/stub/rails4.0/bin/rails +0 -4
  445. data/test/stub/rails4.0/bin/rake +0 -4
  446. data/test/stub/rails4.0/config.ru +0 -4
  447. data/test/stub/rails4.0/config/application.rb +0 -23
  448. data/test/stub/rails4.0/config/boot.rb +0 -4
  449. data/test/stub/rails4.0/config/database.yml +0 -25
  450. data/test/stub/rails4.0/config/environment.rb +0 -5
  451. data/test/stub/rails4.0/config/environments/development.rb +0 -29
  452. data/test/stub/rails4.0/config/environments/production.rb +0 -80
  453. data/test/stub/rails4.0/config/environments/test.rb +0 -36
  454. data/test/stub/rails4.0/config/initializers/backtrace_silencers.rb +0 -7
  455. data/test/stub/rails4.0/config/initializers/filter_parameter_logging.rb +0 -4
  456. data/test/stub/rails4.0/config/initializers/inflections.rb +0 -16
  457. data/test/stub/rails4.0/config/initializers/mime_types.rb +0 -5
  458. data/test/stub/rails4.0/config/initializers/passenger.rb +0 -2
  459. data/test/stub/rails4.0/config/initializers/secret_token.rb +0 -12
  460. data/test/stub/rails4.0/config/initializers/session_store.rb +0 -3
  461. data/test/stub/rails4.0/config/initializers/wrap_parameters.rb +0 -14
  462. data/test/stub/rails4.0/config/locales/en.yml +0 -23
  463. data/test/stub/rails4.0/config/routes.rb +0 -57
  464. data/test/stub/rails4.0/db/seeds.rb +0 -7
  465. data/test/stub/rails4.0/lib/assets/.keep +0 -0
  466. data/test/stub/rails4.0/lib/tasks/.keep +0 -0
  467. data/test/stub/rails4.0/log/.keep +0 -0
  468. data/test/stub/rails4.0/public/404.html +0 -58
  469. data/test/stub/rails4.0/public/422.html +0 -58
  470. data/test/stub/rails4.0/public/500.html +0 -57
  471. data/test/stub/rails4.0/public/favicon.ico +0 -0
  472. data/test/stub/rails4.0/public/robots.txt +0 -5
  473. data/test/stub/rails4.0/test/controllers/.keep +0 -0
  474. data/test/stub/rails4.0/test/fixtures/.keep +0 -0
  475. data/test/stub/rails4.0/test/helpers/.keep +0 -0
  476. data/test/stub/rails4.0/test/integration/.keep +0 -0
  477. data/test/stub/rails4.0/test/mailers/.keep +0 -0
  478. data/test/stub/rails4.0/test/models/.keep +0 -0
  479. data/test/stub/rails4.0/test/test_helper.rb +0 -15
  480. data/test/stub/rails4.0/vendor/assets/javascripts/.keep +0 -0
  481. data/test/stub/rails4.0/vendor/assets/stylesheets/.keep +0 -0
  482. data/test/stub/rails4.1/.gitignore +0 -16
  483. data/test/stub/rails4.1/Gemfile +0 -45
  484. data/test/stub/rails4.1/Gemfile.lock +0 -129
  485. data/test/stub/rails4.1/README.rdoc +0 -28
  486. data/test/stub/rails4.1/Rakefile +0 -6
  487. data/test/stub/rails4.1/app/assets/images/.keep +0 -0
  488. data/test/stub/rails4.1/app/assets/javascripts/application.js +0 -16
  489. data/test/stub/rails4.1/app/assets/stylesheets/application.css +0 -13
  490. data/test/stub/rails4.1/app/controllers/application_controller.rb +0 -5
  491. data/test/stub/rails4.1/app/controllers/concerns/.keep +0 -0
  492. data/test/stub/rails4.1/app/helpers/application_helper.rb +0 -2
  493. data/test/stub/rails4.1/app/mailers/.keep +0 -0
  494. data/test/stub/rails4.1/app/models/.keep +0 -0
  495. data/test/stub/rails4.1/app/models/concerns/.keep +0 -0
  496. data/test/stub/rails4.1/app/views/layouts/application.html.erb +0 -14
  497. data/test/stub/rails4.1/bin/bundle +0 -3
  498. data/test/stub/rails4.1/bin/rails +0 -4
  499. data/test/stub/rails4.1/bin/rake +0 -4
  500. data/test/stub/rails4.1/config.ru +0 -4
  501. data/test/stub/rails4.1/config/application.rb +0 -23
  502. data/test/stub/rails4.1/config/boot.rb +0 -4
  503. data/test/stub/rails4.1/config/database.yml +0 -25
  504. data/test/stub/rails4.1/config/environment.rb +0 -5
  505. data/test/stub/rails4.1/config/environments/development.rb +0 -29
  506. data/test/stub/rails4.1/config/environments/production.rb +0 -80
  507. data/test/stub/rails4.1/config/environments/test.rb +0 -36
  508. data/test/stub/rails4.1/config/initializers/backtrace_silencers.rb +0 -7
  509. data/test/stub/rails4.1/config/initializers/filter_parameter_logging.rb +0 -4
  510. data/test/stub/rails4.1/config/initializers/inflections.rb +0 -16
  511. data/test/stub/rails4.1/config/initializers/mime_types.rb +0 -5
  512. data/test/stub/rails4.1/config/initializers/passenger.rb +0 -5
  513. data/test/stub/rails4.1/config/initializers/secret_token.rb +0 -12
  514. data/test/stub/rails4.1/config/initializers/session_store.rb +0 -3
  515. data/test/stub/rails4.1/config/initializers/wrap_parameters.rb +0 -14
  516. data/test/stub/rails4.1/config/locales/en.yml +0 -23
  517. data/test/stub/rails4.1/config/routes.rb +0 -57
  518. data/test/stub/rails4.1/db/seeds.rb +0 -7
  519. data/test/stub/rails4.1/lib/assets/.keep +0 -0
  520. data/test/stub/rails4.1/lib/tasks/.keep +0 -0
  521. data/test/stub/rails4.1/log/.keep +0 -0
  522. data/test/stub/rails4.1/public/404.html +0 -58
  523. data/test/stub/rails4.1/public/422.html +0 -58
  524. data/test/stub/rails4.1/public/500.html +0 -57
  525. data/test/stub/rails4.1/public/favicon.ico +0 -0
  526. data/test/stub/rails4.1/public/robots.txt +0 -5
  527. data/test/stub/rails4.1/test/controllers/.keep +0 -0
  528. data/test/stub/rails4.1/test/fixtures/.keep +0 -0
  529. data/test/stub/rails4.1/test/helpers/.keep +0 -0
  530. data/test/stub/rails4.1/test/integration/.keep +0 -0
  531. data/test/stub/rails4.1/test/mailers/.keep +0 -0
  532. data/test/stub/rails4.1/test/models/.keep +0 -0
  533. data/test/stub/rails4.1/test/test_helper.rb +0 -15
  534. data/test/stub/rails4.1/vendor/assets/javascripts/.keep +0 -0
  535. data/test/stub/rails4.1/vendor/assets/stylesheets/.keep +0 -0
  536. data/test/stub/start_error.pl +0 -24
  537. data/test/stub/upload_data.txt +0 -494
  538. data/test/stub/wsgi/passenger_wsgi.py +0 -212
  539. data/test/stub/wsgi/public/.gitignore +0 -0
  540. data/test/stub/wsgi/tmp/.gitignore +0 -0
  541. data/test/support/allocate_memory.c +0 -14
  542. data/test/support/apache2_controller.rb +0 -258
  543. data/test/support/multipart.rb +0 -62
  544. data/test/support/nginx_controller.rb +0 -97
  545. data/test/support/placebo-preloader.rb +0 -88
  546. data/test/support/test_helper.rb +0 -455
  547. data/test/support/valgrind.h +0 -2539
  548. data/test/tut/tut.h +0 -1310
  549. data/test/tut/tut_reporter.h +0 -256
  550. data/test/valgrind-osx.supp +0 -7
@@ -1,274 +0,0 @@
1
- #include <TestSupport.h>
2
- #include <ServerKit/CookieUtils.h>
3
-
4
- using namespace Passenger;
5
- using namespace Passenger::ServerKit;
6
- using namespace std;
7
-
8
- namespace tut {
9
- struct ServerKit_CookieUtilsTest {
10
- psg_pool_t *pool;
11
- LString name;
12
- LString value;
13
- LString header;
14
- LString *result;
15
-
16
- ServerKit_CookieUtilsTest() {
17
- pool = psg_create_pool(PSG_DEFAULT_POOL_SIZE);
18
- psg_lstr_init(&name);
19
- psg_lstr_append(&name, pool, "foo");
20
- psg_lstr_init(&value);
21
- psg_lstr_append(&value, pool, "bar");
22
- psg_lstr_init(&header);
23
- result = NULL;
24
- }
25
-
26
- ~ServerKit_CookieUtilsTest() {
27
- psg_lstr_deinit(&name);
28
- psg_lstr_deinit(&value);
29
- psg_lstr_deinit(&header);
30
- if (result != NULL) {
31
- psg_lstr_deinit(result);
32
- }
33
- psg_destroy_pool(pool);
34
- }
35
- };
36
-
37
- DEFINE_TEST_GROUP(ServerKit_CookieUtilsTest);
38
-
39
- TEST_METHOD(1) {
40
- set_test_name("1 cookie in 1 part");
41
- psg_lstr_append(&header, pool, "foo=bar");
42
-
43
- result = findCookie(pool, &header, &name);
44
- ensure("(1)", result != NULL);
45
- ensure("(2)", psg_lstr_cmp(result, &value));
46
- }
47
-
48
-
49
- TEST_METHOD(2) {
50
- set_test_name("1 cookie in multiple parts (1)");
51
- psg_lstr_append(&header, pool, "fo");
52
- psg_lstr_append(&header, pool, "o=");
53
- psg_lstr_append(&header, pool, "bar");
54
-
55
- result = findCookie(pool, &header, &name);
56
- ensure("(1)", result != NULL);
57
- ensure("(2)", psg_lstr_cmp(result, &value));
58
- }
59
-
60
- TEST_METHOD(3) {
61
- set_test_name("1 cookie in multiple parts (2)");
62
- psg_lstr_append(&header, pool, "foo");
63
- psg_lstr_append(&header, pool, "=");
64
- psg_lstr_append(&header, pool, "bar");
65
-
66
- result = findCookie(pool, &header, &name);
67
- ensure("(1)", result != NULL);
68
- ensure("(2)", psg_lstr_cmp(result, &value));
69
- }
70
-
71
- TEST_METHOD(4) {
72
- set_test_name("1 cookie in multiple parts (3)");
73
- psg_lstr_append(&header, pool, "foo=");
74
- psg_lstr_append(&header, pool, "bar");
75
-
76
- result = findCookie(pool, &header, &name);
77
- ensure("(1)", result != NULL);
78
- ensure("(2)", psg_lstr_cmp(result, &value));
79
- }
80
-
81
- TEST_METHOD(5) {
82
- set_test_name("1 cookie in multiple parts (4)");
83
- psg_lstr_append(&header, pool, "foo=b");
84
- psg_lstr_append(&header, pool, "ar");
85
-
86
- result = findCookie(pool, &header, &name);
87
- ensure("(1)", result != NULL);
88
- ensure("(2)", psg_lstr_cmp(result, &value));
89
- }
90
-
91
-
92
- TEST_METHOD(10) {
93
- set_test_name("Multiple cookies in 1 part (1)");
94
- psg_lstr_append(&header, pool, "foo=bar; hello=world");
95
-
96
- result = findCookie(pool, &header, &name);
97
- ensure("(1)", result != NULL);
98
- ensure("(2)", psg_lstr_cmp(result, &value));
99
- }
100
-
101
- TEST_METHOD(11) {
102
- set_test_name("Multiple cookies in 1 part (2)");
103
- psg_lstr_append(&header, pool, "hello=world; foo=bar");
104
-
105
- result = findCookie(pool, &header, &name);
106
- ensure("(1)", result != NULL);
107
- ensure("(2)", psg_lstr_cmp(result, &value));
108
- }
109
-
110
- TEST_METHOD(12) {
111
- set_test_name("Multiple cookies in 1 part (3)");
112
- psg_lstr_append(&header, pool, "hello=world; foo=bar; a=b");
113
-
114
- result = findCookie(pool, &header, &name);
115
- ensure("(1)", result != NULL);
116
- ensure("(2)", psg_lstr_cmp(result, &value));
117
- }
118
-
119
-
120
- TEST_METHOD(15) {
121
- set_test_name("Multiple cookies in multiple parts (1)");
122
- psg_lstr_append(&header, pool, "fo");
123
- psg_lstr_append(&header, pool, "o=bar; hello=world");
124
-
125
- result = findCookie(pool, &header, &name);
126
- ensure("(1)", result != NULL);
127
- ensure("(2)", psg_lstr_cmp(result, &value));
128
- }
129
-
130
- TEST_METHOD(16) {
131
- set_test_name("Multiple cookies in multiple parts (2)");
132
- psg_lstr_append(&header, pool, "foo");
133
- psg_lstr_append(&header, pool, "=");
134
- psg_lstr_append(&header, pool, "bar; hello=world");
135
-
136
- result = findCookie(pool, &header, &name);
137
- ensure("(1)", result != NULL);
138
- ensure("(2)", psg_lstr_cmp(result, &value));
139
- }
140
-
141
- TEST_METHOD(17) {
142
- set_test_name("Multiple cookies in multiple parts (3)");
143
- psg_lstr_append(&header, pool, "foo");
144
- psg_lstr_append(&header, pool, "=bar; hello=world");
145
-
146
- result = findCookie(pool, &header, &name);
147
- ensure("(1)", result != NULL);
148
- ensure("(2)", psg_lstr_cmp(result, &value));
149
- }
150
-
151
- TEST_METHOD(18) {
152
- set_test_name("Multiple cookies in multiple parts (4)");
153
- psg_lstr_append(&header, pool, "foo=");
154
- psg_lstr_append(&header, pool, "bar; hello=world");
155
-
156
- result = findCookie(pool, &header, &name);
157
- ensure("(1)", result != NULL);
158
- ensure("(2)", psg_lstr_cmp(result, &value));
159
- }
160
-
161
- TEST_METHOD(19) {
162
- set_test_name("Multiple cookies in multiple parts (5)");
163
- psg_lstr_append(&header, pool, "foo=b");
164
- psg_lstr_append(&header, pool, "ar; hello=world");
165
-
166
- result = findCookie(pool, &header, &name);
167
- ensure("(1)", result != NULL);
168
- ensure("(2)", psg_lstr_cmp(result, &value));
169
- }
170
-
171
-
172
- TEST_METHOD(20) {
173
- set_test_name("Multiple cookies in multiple parts (6)");
174
- psg_lstr_append(&header, pool, "hello=world; fo");
175
- psg_lstr_append(&header, pool, "o=bar");
176
-
177
- result = findCookie(pool, &header, &name);
178
- ensure("(1)", result != NULL);
179
- ensure("(2)", psg_lstr_cmp(result, &value));
180
- }
181
-
182
- TEST_METHOD(21) {
183
- set_test_name("Multiple cookies in multiple parts (7)");
184
- psg_lstr_append(&header, pool, "hello=world; foo");
185
- psg_lstr_append(&header, pool, "=");
186
- psg_lstr_append(&header, pool, "bar");
187
-
188
- result = findCookie(pool, &header, &name);
189
- ensure("(1)", result != NULL);
190
- ensure("(2)", psg_lstr_cmp(result, &value));
191
- }
192
-
193
- TEST_METHOD(22) {
194
- set_test_name("Multiple cookies in multiple parts (8)");
195
- psg_lstr_append(&header, pool, "hello=world; foo");
196
- psg_lstr_append(&header, pool, "=bar");
197
-
198
- result = findCookie(pool, &header, &name);
199
- ensure("(1)", result != NULL);
200
- ensure("(2)", psg_lstr_cmp(result, &value));
201
- }
202
-
203
- TEST_METHOD(23) {
204
- set_test_name("Multiple cookies in multiple parts (9)");
205
- psg_lstr_append(&header, pool, "hello=world; foo=");
206
- psg_lstr_append(&header, pool, "bar");
207
-
208
- result = findCookie(pool, &header, &name);
209
- ensure("(1)", result != NULL);
210
- ensure("(2)", psg_lstr_cmp(result, &value));
211
- }
212
-
213
- TEST_METHOD(24) {
214
- set_test_name("Multiple cookies in multiple parts (10)");
215
- psg_lstr_append(&header, pool, "hello=world; foo=b");
216
- psg_lstr_append(&header, pool, "ar");
217
-
218
- result = findCookie(pool, &header, &name);
219
- ensure("(1)", result != NULL);
220
- ensure("(2)", psg_lstr_cmp(result, &value));
221
- }
222
-
223
-
224
- TEST_METHOD(30) {
225
- set_test_name("Multiple cookies in multiple parts (11)");
226
- psg_lstr_append(&header, pool, "hello=world; fo");
227
- psg_lstr_append(&header, pool, "o=bar; a=b");
228
-
229
- result = findCookie(pool, &header, &name);
230
- ensure("(1)", result != NULL);
231
- ensure("(2)", psg_lstr_cmp(result, &value));
232
- }
233
-
234
- TEST_METHOD(31) {
235
- set_test_name("Multiple cookies in multiple parts (12)");
236
- psg_lstr_append(&header, pool, "hello=world; foo");
237
- psg_lstr_append(&header, pool, "=");
238
- psg_lstr_append(&header, pool, "bar; a=b");
239
-
240
- result = findCookie(pool, &header, &name);
241
- ensure("(1)", result != NULL);
242
- ensure("(2)", psg_lstr_cmp(result, &value));
243
- }
244
-
245
- TEST_METHOD(32) {
246
- set_test_name("Multiple cookies in multiple parts (13)");
247
- psg_lstr_append(&header, pool, "hello=world; foo");
248
- psg_lstr_append(&header, pool, "=bar; a=b");
249
-
250
- result = findCookie(pool, &header, &name);
251
- ensure("(1)", result != NULL);
252
- ensure("(2)", psg_lstr_cmp(result, &value));
253
- }
254
-
255
- TEST_METHOD(33) {
256
- set_test_name("Multiple cookies in multiple parts (14)");
257
- psg_lstr_append(&header, pool, "hello=world; foo=");
258
- psg_lstr_append(&header, pool, "bar; a=b");
259
-
260
- result = findCookie(pool, &header, &name);
261
- ensure("(1)", result != NULL);
262
- ensure("(2)", psg_lstr_cmp(result, &value));
263
- }
264
-
265
- TEST_METHOD(34) {
266
- set_test_name("Multiple cookies in multiple parts (15)");
267
- psg_lstr_append(&header, pool, "hello=world; foo=b");
268
- psg_lstr_append(&header, pool, "ar; a=b");
269
-
270
- result = findCookie(pool, &header, &name);
271
- ensure("(1)", result != NULL);
272
- ensure("(2)", psg_lstr_cmp(result, &value));
273
- }
274
- }
@@ -1,992 +0,0 @@
1
- #include <TestSupport.h>
2
- #include <boost/thread.hpp>
3
- #include <string>
4
- #include <BackgroundEventLoop.h>
5
- #include <Constants.h>
6
- #include <Logging.h>
7
- #include <StaticString.h>
8
- #include <ServerKit/FileBufferedChannel.h>
9
- #include <Utils/StrIntUtils.h>
10
-
11
- using namespace Passenger;
12
- using namespace Passenger::ServerKit;
13
- using namespace Passenger::MemoryKit;
14
- using namespace std;
15
-
16
- namespace tut {
17
- #define CONSUME_FULLY -2
18
-
19
- struct ServerKit_FileBufferedChannelTest: public ServerKit::Hooks {
20
- BackgroundEventLoop bg;
21
- ServerKit::Context context;
22
- FileBufferedChannel channel;
23
- boost::mutex syncher;
24
- int toConsume;
25
- bool endConsume;
26
- unsigned int counter;
27
- unsigned int buffersFlushed;
28
- string log;
29
-
30
- ServerKit_FileBufferedChannelTest()
31
- : bg(false, true),
32
- context(bg.safe),
33
- channel(&context),
34
- toConsume(CONSUME_FULLY),
35
- endConsume(false),
36
- counter(0),
37
- buffersFlushed(0)
38
- {
39
- initializeLibeio();
40
- channel.setDataCallback(dataCallback);
41
- channel.setBuffersFlushedCallback(buffersFlushedCallback);
42
- channel.setHooks(this);
43
- Hooks::impl = NULL;
44
- Hooks::userData = NULL;
45
- }
46
-
47
- ~ServerKit_FileBufferedChannelTest() {
48
- bg.stop(); // Prevent any runLater callbacks from running.
49
- channel.deinitialize(); // Cancel any event loop next tick callbacks.
50
- setLogLevel(DEFAULT_LOG_LEVEL);
51
- shutdownLibeio();
52
- }
53
-
54
- void startLoop() {
55
- bg.start();
56
- }
57
-
58
- static Channel::Result dataCallback(Channel *_channel, const mbuf &buffer, int errcode)
59
- {
60
- FileBufferedChannel *channel = reinterpret_cast<FileBufferedChannel *>(_channel);
61
- ServerKit_FileBufferedChannelTest *self = (ServerKit_FileBufferedChannelTest *)
62
- channel->getHooks();
63
- boost::lock_guard<boost::mutex> l(self->syncher);
64
- if (errcode == 0) {
65
- self->counter++;
66
- if (buffer.empty()) {
67
- self->log.append("EOF\n");
68
- } else {
69
- StaticString str(buffer.start, buffer.size());
70
- self->log.append("Data: " + cEscapeString(str) + "\n");
71
- }
72
- } else {
73
- self->log.append("Error: " + toString(errcode) + "\n");
74
- }
75
- if (self->toConsume == CONSUME_FULLY) {
76
- return Channel::Result(buffer.size(), self->endConsume);
77
- } else {
78
- return Channel::Result(self->toConsume, self->endConsume);
79
- }
80
- }
81
-
82
- static void buffersFlushedCallback(FileBufferedChannel *channel) {
83
- ServerKit_FileBufferedChannelTest *self = (ServerKit_FileBufferedChannelTest *)
84
- channel->getHooks();
85
- boost::lock_guard<boost::mutex> l(self->syncher);
86
- self->buffersFlushed++;
87
- }
88
-
89
- void feedChannel(const string &data) {
90
- bg.safe->runLater(boost::bind(&ServerKit_FileBufferedChannelTest::_feedChannel,
91
- this, data));
92
- }
93
-
94
- void _feedChannel(string data) {
95
- assert(data.size() < context.mbuf_pool.mbuf_block_chunk_size);
96
- mbuf buf = mbuf_get(&context.mbuf_pool);
97
- memcpy(buf.start, data.data(), data.size());
98
- buf = mbuf(buf, 0, (unsigned int) data.size());
99
- channel.feed(buf);
100
- }
101
-
102
- void feedChannelError(int errcode) {
103
- bg.safe->runLater(boost::bind(&ServerKit_FileBufferedChannelTest::_feedChannelError,
104
- this, errcode));
105
- }
106
-
107
- void _feedChannelError(int errcode) {
108
- channel.feedError(errcode);
109
- }
110
-
111
- void channelConsumed(int size, bool end) {
112
- bg.safe->runLater(boost::bind(&ServerKit_FileBufferedChannelTest::_channelConsumed,
113
- this, size, end));
114
- }
115
-
116
- void _channelConsumed(int size, bool end) {
117
- channel.consumed(size, end);
118
- }
119
-
120
- Channel::State getChannelState() {
121
- Channel::State result;
122
- bg.safe->runSync(boost::bind(&ServerKit_FileBufferedChannelTest::_getChannelState,
123
- this, &result));
124
- return result;
125
- }
126
-
127
- void _getChannelState(Channel::State *result) {
128
- *result = channel.getState();
129
- }
130
-
131
- FileBufferedChannel::Mode getChannelMode() {
132
- FileBufferedChannel::Mode result;
133
- bg.safe->runSync(boost::bind(&ServerKit_FileBufferedChannelTest::_getChannelMode,
134
- this, &result));
135
- return result;
136
- }
137
-
138
- void _getChannelMode(FileBufferedChannel::Mode *result) {
139
- *result = channel.getMode();
140
- }
141
-
142
- FileBufferedChannel::ReaderState getChannelReaderState() {
143
- FileBufferedChannel::ReaderState result;
144
- bg.safe->runSync(boost::bind(&ServerKit_FileBufferedChannelTest::_getChannelReaderState,
145
- this, &result));
146
- return result;
147
- }
148
-
149
- void _getChannelReaderState(FileBufferedChannel::ReaderState *result) {
150
- *result = channel.getReaderState();
151
- }
152
-
153
- FileBufferedChannel::WriterState getChannelWriterState() {
154
- FileBufferedChannel::WriterState result;
155
- bg.safe->runSync(boost::bind(&ServerKit_FileBufferedChannelTest::_getChannelWriterState,
156
- this, &result));
157
- return result;
158
- }
159
-
160
- void _getChannelWriterState(FileBufferedChannel::WriterState *result) {
161
- *result = channel.getWriterState();
162
- }
163
-
164
- unsigned int getChannelBytesBuffered() {
165
- unsigned int result;
166
- bg.safe->runSync(boost::bind(&ServerKit_FileBufferedChannelTest::_getChannelBytesBuffered,
167
- this, &result));
168
- return result;
169
- }
170
-
171
- void _getChannelBytesBuffered(unsigned int *result) {
172
- *result = channel.getBytesBuffered();
173
- }
174
-
175
- void channelEnableAutoStartMover(bool enabled) {
176
- bg.safe->runSync(boost::bind(&ServerKit_FileBufferedChannelTest::_channelEnableAutoStartMover,
177
- this, enabled));
178
- }
179
-
180
- void _channelEnableAutoStartMover(bool enabled) {
181
- context.defaultFileBufferedChannelConfig.autoStartMover = enabled;
182
- }
183
-
184
- void startChannel() {
185
- bg.safe->runLater(boost::bind(&ServerKit_FileBufferedChannelTest::_startChannel,
186
- this));
187
- }
188
-
189
- void _startChannel() {
190
- channel.start();
191
- }
192
-
193
- void setChannelDataCallback(FileBufferedChannel::DataCallback callback) {
194
- bg.safe->runLater(boost::bind(&ServerKit_FileBufferedChannelTest::_setChannelDataCallback,
195
- this, callback));
196
- }
197
-
198
- void _setChannelDataCallback(FileBufferedChannel::DataCallback callback) {
199
- channel.setDataCallback(callback);
200
- }
201
- };
202
-
203
- DEFINE_TEST_GROUP_WITH_LIMIT(ServerKit_FileBufferedChannelTest, 100);
204
-
205
- #define LOCK() boost::unique_lock<boost::mutex> l(syncher)
206
- #define UNLOCK() l.unlock()
207
-
208
-
209
- /***** Initial state *****/
210
-
211
- TEST_METHOD(1) {
212
- set_test_name("It is initially in the in-memory mode, and the reader is initially inactive");
213
- startLoop();
214
- ensure_equals(getChannelMode(), FileBufferedChannel::IN_MEMORY_MODE);
215
- ensure_equals(getChannelReaderState(), FileBufferedChannel::RS_INACTIVE);
216
- }
217
-
218
-
219
- /***** When in the in-memory mode *****/
220
-
221
- TEST_METHOD(5) {
222
- set_test_name("Upon feeding data, it calls the callback");
223
-
224
- startLoop();
225
- feedChannel("hello");
226
- EVENTUALLY(5,
227
- LOCK();
228
- result = log == "Data: hello\n";
229
- );
230
- EVENTUALLY(5,
231
- result = getChannelReaderState() == FileBufferedChannel::RS_INACTIVE;
232
- );
233
- }
234
-
235
- TEST_METHOD(6) {
236
- set_test_name("Upon feeding data, and the previous data callback isn't done "
237
- "consuming yet, it calls the callback with the new data "
238
- "after the previous data callback is done consuming");
239
-
240
- toConsume = -1;
241
- startLoop();
242
-
243
- feedChannel("hello");
244
- feedChannel("world");
245
- feedChannel("!");
246
- SHOULD_NEVER_HAPPEN(100,
247
- LOCK();
248
- result = log.find("world") != string::npos
249
- || log.find("!") != string::npos;
250
- );
251
-
252
- channelConsumed(sizeof("hello") - 1, false);
253
- EVENTUALLY(5,
254
- LOCK();
255
- result = log ==
256
- "Data: hello\n"
257
- "Data: world\n";
258
- );
259
- channelConsumed(sizeof("world") - 1, false);
260
- EVENTUALLY(5,
261
- LOCK();
262
- result = log ==
263
- "Data: hello\n"
264
- "Data: world\n"
265
- "Data: !\n";
266
- );
267
-
268
- channelConsumed(sizeof("!") - 1, false);
269
- EVENTUALLY(5,
270
- result = getChannelReaderState() == FileBufferedChannel::RS_INACTIVE;
271
- );
272
- }
273
-
274
- TEST_METHOD(7) {
275
- set_test_name("Upon feeding data, if the total amount of data is below the threshold, "
276
- "then it remains in the in-memory mode");
277
-
278
- toConsume = -1;
279
- startLoop();
280
-
281
- feedChannel("hello");
282
- SHOULD_NEVER_HAPPEN(100,
283
- result = getChannelMode() != FileBufferedChannel::IN_MEMORY_MODE;
284
- );
285
- }
286
-
287
- TEST_METHOD(9) {
288
- set_test_name("Upon feeding EOF, it calls the callback with an EOF");
289
-
290
- startLoop();
291
- feedChannel("");
292
- EVENTUALLY(5,
293
- LOCK();
294
- result = log == "EOF\n";
295
- );
296
- }
297
-
298
- TEST_METHOD(10) {
299
- set_test_name("Upon feeding EOF, the internal reader eventually switches to RS_TERMINATED");
300
-
301
- startLoop();
302
- feedChannel("");
303
- EVENTUALLY(5,
304
- result = getChannelReaderState() == FileBufferedChannel::RS_TERMINATED;
305
- );
306
- }
307
-
308
- TEST_METHOD(11) {
309
- set_test_name("Once EOF has been fed, any further data feds have no effect");
310
-
311
- startLoop();
312
- feedChannel("");
313
- feedChannel("hello");
314
- EVENTUALLY(5,
315
- LOCK();
316
- result = log == "EOF\n";
317
- );
318
- SHOULD_NEVER_HAPPEN(100,
319
- LOCK();
320
- result = log != "EOF\n";
321
- );
322
- }
323
-
324
- TEST_METHOD(12) {
325
- set_test_name("If the callback indicates that it is done consuming, the internal "
326
- "reader eventually switches to RS_TERMINATED");
327
-
328
- endConsume = true;
329
- startLoop();
330
- feedChannel("hello");
331
- EVENTUALLY(5,
332
- LOCK();
333
- result = log == "Data: hello\n";
334
- );
335
- EVENTUALLY(5,
336
- result = getChannelReaderState() == FileBufferedChannel::RS_TERMINATED;
337
- );
338
- }
339
-
340
- TEST_METHOD(13) {
341
- set_test_name("Once the callback has indicated that it is done consuming, any further data "
342
- "feds have no effect");
343
-
344
- endConsume = true;
345
- startLoop();
346
-
347
- feedChannel("hello");
348
- feedChannel("world");
349
- EVENTUALLY(5,
350
- LOCK();
351
- result = log == "Data: hello\n";
352
- );
353
- SHOULD_NEVER_HAPPEN(100,
354
- LOCK();
355
- result = log != "Data: hello\n";
356
- );
357
- }
358
-
359
- TEST_METHOD(14) {
360
- set_test_name("Upon feeding an error, it calls the callback with an error");
361
-
362
- startLoop();
363
- feedChannelError(EIO);
364
- EVENTUALLY(5,
365
- LOCK();
366
- result = log == "Error: " + toString(EIO) + "\n";
367
- );
368
- }
369
-
370
- TEST_METHOD(15) {
371
- set_test_name("Upon feeding an error, the internal reader eventually switches to RS_TERMINATED");
372
-
373
- startLoop();
374
- feedChannelError(EIO);
375
- EVENTUALLY(5,
376
- result = getChannelReaderState() == FileBufferedChannel::RS_TERMINATED;
377
- );
378
- }
379
-
380
- TEST_METHOD(16) {
381
- set_test_name("Once an error has been fed, any further data feds have no effect");
382
-
383
- startLoop();
384
- feedChannelError(EIO);
385
- feedChannel("hello");
386
- EVENTUALLY(5,
387
- LOCK();
388
- result = log == "Error: " + toString(EIO) + "\n";
389
- );
390
- SHOULD_NEVER_HAPPEN(100,
391
- LOCK();
392
- result = log != "Error: " + toString(EIO) + "\n";
393
- );
394
- }
395
-
396
-
397
- /***** When switching from in-memory mode to in-file mode *****/
398
-
399
- TEST_METHOD(20) {
400
- set_test_name("Upon feeding so much data that the threshold is passed, "
401
- "it switches to the in-file mode and calls the callback later with the fed data");
402
-
403
- toConsume = -1;
404
- context.defaultFileBufferedChannelConfig.threshold = 1;
405
- startLoop();
406
-
407
- feedChannel("hello");
408
- EVENTUALLY(5,
409
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
410
- );
411
-
412
- channelConsumed(sizeof("hello") - 1, false);
413
- EVENTUALLY(5,
414
- LOCK();
415
- result = log == "Data: hello\n";
416
- );
417
- EVENTUALLY(5,
418
- result = getChannelReaderState() == FileBufferedChannel::RS_INACTIVE;
419
- );
420
- }
421
-
422
- TEST_METHOD(21) {
423
- set_test_name("Any fed data is immediately passed to the callback");
424
-
425
- context.defaultFileBufferedChannelConfig.threshold = 1;
426
- context.defaultFileBufferedChannelConfig.delayInFileModeSwitching = 50000;
427
- context.defaultFileBufferedChannelConfig.autoTruncateFile = false;
428
- startLoop();
429
-
430
- feedChannel("hello");
431
- EVENTUALLY(5,
432
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
433
- );
434
- ensure_equals(getChannelWriterState(), FileBufferedChannel::WS_CREATING_FILE);
435
- EVENTUALLY(5,
436
- LOCK();
437
- result = log == "Data: hello\n";
438
- );
439
- }
440
-
441
- TEST_METHOD(22) {
442
- set_test_name("If the previous callback isn't done consuming, any fed data is "
443
- "buffered in memory, and passed to the callback when the previous callback "
444
- "is done");
445
-
446
- toConsume = -1;
447
- context.defaultFileBufferedChannelConfig.threshold = 1;
448
- context.defaultFileBufferedChannelConfig.delayInFileModeSwitching = 50000;
449
- context.defaultFileBufferedChannelConfig.autoTruncateFile = false;
450
- startLoop();
451
-
452
- feedChannel("hello");
453
- feedChannel("world");
454
- feedChannel("!");
455
- EVENTUALLY(5,
456
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
457
- );
458
- ensure_equals(getChannelWriterState(), FileBufferedChannel::WS_CREATING_FILE);
459
- SHOULD_NEVER_HAPPEN(100,
460
- LOCK();
461
- result = log != "Data: hello\n";
462
- );
463
- ensure_equals(getChannelBytesBuffered(), sizeof("helloworld!") - 1);
464
-
465
- EVENTUALLY(5,
466
- result = getChannelState() == Channel::WAITING_FOR_CALLBACK;
467
- );
468
- channelConsumed(sizeof("hello") - 1, false);
469
- EVENTUALLY(5,
470
- LOCK();
471
- result = log ==
472
- "Data: hello\n"
473
- "Data: world\n";
474
- );
475
- ensure_equals(getChannelBytesBuffered(), sizeof("helloworld!") - 1);
476
-
477
- EVENTUALLY(5,
478
- result = getChannelState() == Channel::WAITING_FOR_CALLBACK;
479
- );
480
- channelConsumed(sizeof("world") - 1, false);
481
- EVENTUALLY(5,
482
- LOCK();
483
- result = log ==
484
- "Data: hello\n"
485
- "Data: world\n"
486
- "Data: !\n";
487
- );
488
- ensure_equals(getChannelBytesBuffered(), sizeof("helloworld!") - 1);
489
- }
490
-
491
-
492
- /***** When in the in-file mode *****/
493
-
494
- TEST_METHOD(30) {
495
- set_test_name("It slowly moves memory buffers to disk");
496
-
497
- toConsume = -1;
498
- context.defaultFileBufferedChannelConfig.threshold = 1;
499
- startLoop();
500
-
501
- feedChannel("hello");
502
- EVENTUALLY(5,
503
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
504
- );
505
- EVENTUALLY(5,
506
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
507
- );
508
- ensure_equals(getChannelBytesBuffered(), 0u);
509
- }
510
-
511
- TEST_METHOD(31) {
512
- set_test_name("If all memory buffers have been moved to disk, then "
513
- "when new data is fed, the new data is also eventually moved to disk");
514
-
515
- toConsume = -1;
516
- context.defaultFileBufferedChannelConfig.threshold = 1;
517
- startLoop();
518
-
519
- feedChannel("hello");
520
- EVENTUALLY(5,
521
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
522
- );
523
- EVENTUALLY(5,
524
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
525
- );
526
- ensure_equals(getChannelBytesBuffered(), 0u);
527
-
528
- feedChannel("world");
529
- EVENTUALLY(5,
530
- result = getChannelBytesBuffered() == 0;
531
- );
532
- ensure_equals(getChannelWriterState(), FileBufferedChannel::WS_INACTIVE);
533
- }
534
-
535
- TEST_METHOD(32) {
536
- set_test_name("If there is unread data on disk, it reads them and passes "
537
- "them to the callback");
538
-
539
- toConsume = -1;
540
- context.defaultFileBufferedChannelConfig.threshold = 1;
541
- startLoop();
542
-
543
- feedChannel("hello");
544
- feedChannel("world!");
545
- EVENTUALLY(5,
546
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
547
- );
548
- EVENTUALLY(5,
549
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
550
- );
551
- ensure_equals(getChannelBytesBuffered(), 0u);
552
-
553
- channelConsumed(sizeof("hello") - 1, false);
554
- EVENTUALLY(5,
555
- LOCK();
556
- result = log ==
557
- "Data: hello\n"
558
- "Data: world!\n";
559
- );
560
- }
561
-
562
- TEST_METHOD(33) {
563
- set_test_name("Suppose that a data chunk from disk is being passed to the callback. "
564
- "If the callback consumes the chunk immediately and is willing to accept "
565
- "further data, then the FileBufferedChannel will repeat this process with the "
566
- "next chunk from disk");
567
-
568
- // Setup a FileBufferedChannel in the in-file mode.
569
- toConsume = -1;
570
- context.defaultFileBufferedChannelConfig.threshold = 1;
571
- startLoop();
572
- feedChannel("hello");
573
- feedChannel("world!");
574
- EVENTUALLY(5,
575
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
576
- );
577
- EVENTUALLY(5,
578
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
579
- );
580
- ensure_equals(getChannelBytesBuffered(), 0u);
581
-
582
- // Consume the initial "hello" so that the FileBufferedChannel starts
583
- // reading "world" from disk. When "world" is read, we first consume
584
- // "world" only, then "!" too.
585
- context.defaultFileBufferedChannelConfig.maxDiskChunkReadSize = sizeof("world") - 1;
586
- toConsume = CONSUME_FULLY;
587
- channelConsumed(sizeof("hello") - 1, false);
588
- EVENTUALLY(5,
589
- LOCK();
590
- result = log ==
591
- "Data: hello\n"
592
- "Data: world\n"
593
- "Data: !\n";
594
- );
595
- }
596
-
597
- TEST_METHOD(34) {
598
- set_test_name("Suppose that a data chunk from disk is being passed to the callback. "
599
- "If the callback consumes the chunk asynchronously, and is willing "
600
- "to accept further data, then the FileBufferedChannel will repeat this process "
601
- "with the next chunk from disk after the channel has become idle");
602
-
603
- // Setup a FileBufferedChannel in the in-file mode.
604
- toConsume = -1;
605
- context.defaultFileBufferedChannelConfig.threshold = 1;
606
- startLoop();
607
- feedChannel("hello");
608
- feedChannel("world!");
609
- EVENTUALLY(5,
610
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
611
- );
612
- EVENTUALLY(5,
613
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
614
- );
615
- ensure_equals(getChannelBytesBuffered(), 0u);
616
-
617
- // Consume the initial "hello" so that the FileBufferedChannel starts
618
- // reading "world" from disk.
619
- context.defaultFileBufferedChannelConfig.maxDiskChunkReadSize = sizeof("world") - 1;
620
- channelConsumed(sizeof("hello") - 1, false);
621
- EVENTUALLY(5,
622
- LOCK();
623
- result = log ==
624
- "Data: hello\n";
625
- );
626
- // We haven't consumed "world" yet, so the FileBufferedChannel should
627
- // be waiting for it to become idle.
628
- EVENTUALLY(5,
629
- result = getChannelReaderState() == FileBufferedChannel::RS_WAITING_FOR_CHANNEL_IDLE;
630
- );
631
-
632
- // Now consume "world".
633
- channelConsumed(sizeof("world") - 1, false);
634
- EVENTUALLY(5,
635
- LOCK();
636
- result = log ==
637
- "Data: hello\n"
638
- "Data: world\n";
639
- );
640
- // We haven't consumed "!" yet, so the FileBufferedChannel should
641
- // be waiting for it to become idle.
642
- EVENTUALLY(5,
643
- result = getChannelReaderState() == FileBufferedChannel::RS_WAITING_FOR_CHANNEL_IDLE;
644
- );
645
-
646
- // Now consume "!".
647
- channelConsumed(sizeof("!") - 1, false);
648
- EVENTUALLY(5,
649
- LOCK();
650
- result = log ==
651
- "Data: hello\n"
652
- "Data: world\n"
653
- "Data: !\n";
654
- );
655
- }
656
-
657
- TEST_METHOD(35) {
658
- set_test_name("Suppose that a data chunk from disk is being passed to the callback. "
659
- "If the callback consumes the chunk immediately, but is not willing "
660
- "to accept further data, then the FileBufferedChannel will terminate");
661
-
662
- // Setup a FileBufferedChannel in the in-file mode.
663
- toConsume = -1;
664
- context.defaultFileBufferedChannelConfig.threshold = 1;
665
- startLoop();
666
- feedChannel("hello");
667
- feedChannel("world!");
668
- EVENTUALLY(5,
669
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
670
- );
671
- EVENTUALLY(5,
672
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
673
- );
674
- ensure_equals(getChannelBytesBuffered(), 0u);
675
-
676
- // Consume the initial "hello" so that the FileBufferedChannel starts
677
- // reading "world" from disk. When it is read, we will consume it fully
678
- // while ending the channel.
679
- context.defaultFileBufferedChannelConfig.maxDiskChunkReadSize = sizeof("world") - 1;
680
- toConsume = CONSUME_FULLY;
681
- endConsume = true;
682
- channelConsumed(sizeof("hello") - 1, false);
683
- EVENTUALLY(5,
684
- LOCK();
685
- result = log ==
686
- "Data: hello\n"
687
- "Data: world\n";
688
- );
689
- EVENTUALLY(5,
690
- result = getChannelReaderState() == FileBufferedChannel::RS_TERMINATED;
691
- );
692
- SHOULD_NEVER_HAPPEN(100,
693
- LOCK();
694
- result = log !=
695
- "Data: hello\n"
696
- "Data: world\n";
697
- );
698
- }
699
-
700
- TEST_METHOD(36) {
701
- set_test_name("If there is no unread data on disk, it passes the next "
702
- "in-memory buffer to the callback");
703
-
704
- toConsume = -1;
705
- context.defaultFileBufferedChannelConfig.threshold = 1;
706
- startLoop();
707
-
708
- feedChannel("hello");
709
- EVENTUALLY(5,
710
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
711
- );
712
- EVENTUALLY(5,
713
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
714
- );
715
- ensure_equals(getChannelBytesBuffered(), 0u);
716
-
717
- channelEnableAutoStartMover(false);
718
- feedChannel("world!");
719
- feedChannel("the end");
720
- ensure_equals(getChannelBytesBuffered(), sizeof("world!the end") - 1);
721
- ensure_equals("channelEnableAutoStartMover works",
722
- getChannelWriterState(), FileBufferedChannel::WS_INACTIVE);
723
-
724
- channelConsumed(sizeof("hello") - 1, false);
725
- EVENTUALLY(5,
726
- LOCK();
727
- result = counter == 2
728
- && getChannelState() == Channel::WAITING_FOR_CALLBACK;
729
- );
730
-
731
- channelConsumed(sizeof("world!") - 1, false);
732
- EVENTUALLY(5,
733
- LOCK();
734
- result = counter == 3
735
- && getChannelState() == Channel::WAITING_FOR_CALLBACK;
736
- );
737
-
738
- EVENTUALLY(5,
739
- LOCK();
740
- result = log ==
741
- "Data: hello\n"
742
- "Data: world!\n"
743
- "Data: the end\n";
744
- );
745
- }
746
-
747
- TEST_METHOD(37) {
748
- set_test_name("Upon feeding EOF, the EOF is passed to the callback after "
749
- "all on-disk and in-memory data is passed");
750
-
751
- toConsume = -1;
752
- context.defaultFileBufferedChannelConfig.threshold = 1;
753
- startLoop();
754
-
755
- feedChannel("hello");
756
- EVENTUALLY(5,
757
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
758
- );
759
- EVENTUALLY(5,
760
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
761
- );
762
- ensure_equals(getChannelBytesBuffered(), 0u);
763
-
764
- channelEnableAutoStartMover(false);
765
- feedChannel("world!");
766
- feedChannel("the end");
767
- feedChannel("");
768
- ensure_equals(getChannelBytesBuffered(), sizeof("world!the end") - 1);
769
- ensure_equals("channelDisableAutoStartMover works",
770
- getChannelWriterState(), FileBufferedChannel::WS_INACTIVE);
771
-
772
- channelConsumed(sizeof("hello") - 1, false);
773
- EVENTUALLY(5,
774
- LOCK();
775
- result = counter == 2
776
- && getChannelState() == Channel::WAITING_FOR_CALLBACK;
777
- );
778
-
779
- channelConsumed(sizeof("world!") - 1, false);
780
- EVENTUALLY(5,
781
- LOCK();
782
- result = counter == 3
783
- && getChannelState() == Channel::WAITING_FOR_CALLBACK;
784
- );
785
- SHOULD_NEVER_HAPPEN(100,
786
- LOCK();
787
- result = log !=
788
- "Data: hello\n"
789
- "Data: world!\n"
790
- "Data: the end\n";
791
- );
792
-
793
- channelConsumed(sizeof("the end") - 1, false);
794
- EVENTUALLY(5,
795
- LOCK();
796
- result = counter == 4
797
- && getChannelState() == Channel::EOF_WAITING;
798
- );
799
- EVENTUALLY(5,
800
- LOCK();
801
- result = log ==
802
- "Data: hello\n"
803
- "Data: world!\n"
804
- "Data: the end\n"
805
- "EOF\n";
806
- );
807
- }
808
-
809
- TEST_METHOD(38) {
810
- set_test_name("Upon feeding an error, it switches to the error mode immediately "
811
- "and it doesn't call the callback");
812
-
813
- toConsume = -1;
814
- context.defaultFileBufferedChannelConfig.threshold = 1;
815
- startLoop();
816
-
817
- feedChannel("hello");
818
- feedChannel("world");
819
- EVENTUALLY(5,
820
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
821
- );
822
- EVENTUALLY(5,
823
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
824
- );
825
- ensure_equals(getChannelBytesBuffered(), 0u);
826
-
827
- feedChannelError(EIO);
828
- EVENTUALLY(5,
829
- result = getChannelReaderState() == FileBufferedChannel::RS_TERMINATED;
830
- );
831
- ensure_equals(getChannelMode(), FileBufferedChannel::ERROR_WAITING);
832
-
833
- channelConsumed(sizeof("hello") - 1, false);
834
- EVENTUALLY(5,
835
- LOCK();
836
- result = log ==
837
- "Data: hello\n"
838
- "Error: " + toString(EIO) + "\n";
839
- );
840
- }
841
-
842
-
843
- /***** Switching from in-file mode to in-memory mode *****/
844
-
845
- TEST_METHOD(40) {
846
- set_test_name("When all on-disk and in-memory buffers have been read, it switches to in-memory mode");
847
-
848
- toConsume = -1;
849
- context.defaultFileBufferedChannelConfig.threshold = 1;
850
- startLoop();
851
-
852
- feedChannel("hello");
853
- feedChannel("world!");
854
- EVENTUALLY(5,
855
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
856
- );
857
- EVENTUALLY(5,
858
- result = getChannelWriterState() == FileBufferedChannel::WS_INACTIVE;
859
- );
860
- ensure_equals(getChannelBytesBuffered(), 0u);
861
-
862
- channelConsumed(sizeof("hello") - 1, false);
863
- EVENTUALLY(5,
864
- LOCK();
865
- result = counter == 2
866
- && getChannelState() == Channel::WAITING_FOR_CALLBACK;
867
- );
868
-
869
- channelConsumed(sizeof("world!") - 1, false);
870
- EVENTUALLY(5,
871
- result = getChannelMode() == FileBufferedChannel::IN_MEMORY_MODE;
872
- );
873
-
874
- {
875
- LOCK();
876
- toConsume = CONSUME_FULLY;
877
- }
878
- feedChannel("!");
879
- EVENTUALLY(5,
880
- LOCK();
881
- result = log ==
882
- "Data: hello\n"
883
- "Data: world!\n"
884
- "Data: !\n";
885
- );
886
- }
887
-
888
- TEST_METHOD(41) {
889
- set_test_name("It calls the buffersFlushedCallback if the switching happens while "
890
- "there are buffers in memory that haven't been written to disk yet");
891
-
892
- toConsume = -1;
893
- context.defaultFileBufferedChannelConfig.threshold = 1;
894
- context.defaultFileBufferedChannelConfig.delayInFileModeSwitching = 1000;
895
- startLoop();
896
-
897
- feedChannel("hello");
898
- feedChannel("world!");
899
- EVENTUALLY(5,
900
- result = getChannelMode() == FileBufferedChannel::IN_FILE_MODE;
901
- );
902
- ensure_equals(getChannelBytesBuffered(), 11u);
903
-
904
- channelConsumed(sizeof("hello") - 1, false);
905
- channelConsumed(sizeof("world!") - 1, false);
906
- EVENTUALLY(5,
907
- result = getChannelMode() == FileBufferedChannel::IN_MEMORY_MODE;
908
- );
909
- EVENTUALLY(5,
910
- LOCK();
911
- result = buffersFlushed == 1;
912
- );
913
- }
914
-
915
-
916
- /***** When stopped *****/
917
-
918
- TEST_METHOD(45) {
919
- set_test_name("Upon feeding data, it calls the callback when start() is called");
920
-
921
- channel.stop();
922
- startLoop();
923
-
924
- feedChannel("hello");
925
- ensure_equals(getChannelBytesBuffered(), 5u);
926
- feedChannel("world");
927
- ensure_equals(getChannelBytesBuffered(), 10u);
928
- ensure_equals(getChannelReaderState(),
929
- FileBufferedChannel::RS_WAITING_FOR_CHANNEL_IDLE);
930
- SHOULD_NEVER_HAPPEN(100,
931
- result = getChannelBytesBuffered() != 10;
932
- );
933
- SHOULD_NEVER_HAPPEN(100,
934
- LOCK();
935
- result = !log.empty();
936
- );
937
-
938
- startChannel();
939
- EVENTUALLY(5,
940
- result = getChannelBytesBuffered() == 0;
941
- );
942
- EVENTUALLY(5,
943
- LOCK();
944
- result = log ==
945
- "Data: hello\n"
946
- "Data: world\n";
947
- );
948
- }
949
-
950
- static Channel::Result test_46_callback(Channel *_channel, const mbuf &buffer,
951
- int errcode)
952
- {
953
- FileBufferedChannel *channel = reinterpret_cast<FileBufferedChannel *>(_channel);
954
- ServerKit_FileBufferedChannelTest *self = (ServerKit_FileBufferedChannelTest *)
955
- channel->getHooks();
956
- boost::mutex &syncher = self->syncher;
957
-
958
- {
959
- LOCK();
960
- self->counter++;
961
- }
962
- channel->stop();
963
- return Channel::Result(buffer.size(), false);
964
- }
965
-
966
- TEST_METHOD(46) {
967
- set_test_name("If stop() is called in the callback, it doesn't call the "
968
- "callback with remaining buffers until start() is called");
969
-
970
- channel.setDataCallback(test_46_callback);
971
- startLoop();
972
- feedChannel("hello");
973
- feedChannel("world");
974
- EVENTUALLY(5,
975
- result = getChannelBytesBuffered() == 5;
976
- );
977
- {
978
- LOCK();
979
- ensure_equals(counter, 1u);
980
- }
981
-
982
- setChannelDataCallback(dataCallback);
983
- startChannel();
984
- EVENTUALLY(5,
985
- result = getChannelBytesBuffered() == 0;
986
- );
987
- {
988
- LOCK();
989
- ensure_equals(counter, 2u);
990
- }
991
- }
992
- }