passenger 2.2.2 → 2.2.3
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.
- data/DEVELOPERS.TXT +13 -3
- data/Rakefile +42 -33
- data/bin/passenger-install-apache2-module +1 -2
- data/bin/passenger-install-nginx-module +7 -19
- data/bin/passenger-status +64 -15
- data/bin/passenger-stress-test +2 -2
- data/doc/ApplicationPool algorithm.txt +26 -22
- data/doc/Users guide Apache.html +374 -149
- data/doc/Users guide Apache.txt +318 -51
- data/doc/Users guide Nginx.html +13 -13
- data/doc/Users guide Nginx.txt +7 -2
- data/doc/cxxapi/Bucket_8h-source.html +62 -25
- data/doc/cxxapi/Configuration_8h-source.html +343 -326
- data/doc/cxxapi/DirectoryMapper_8h-source.html +12 -12
- data/doc/cxxapi/Hooks_8h-source.html +1 -1
- data/doc/cxxapi/annotated.html +1 -1
- data/doc/cxxapi/classHooks-members.html +1 -1
- data/doc/cxxapi/classHooks.html +1 -1
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +2 -2
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +9 -9
- data/doc/cxxapi/classes.html +1 -1
- data/doc/cxxapi/definitions_8h-source.html +1 -1
- data/doc/cxxapi/files.html +1 -1
- data/doc/cxxapi/functions.html +2 -2
- data/doc/cxxapi/functions_func.html +2 -2
- data/doc/cxxapi/graph_legend.html +1 -1
- data/doc/cxxapi/group__Configuration.html +1 -1
- data/doc/cxxapi/group__Core.html +1 -1
- data/doc/cxxapi/group__Hooks.html +1 -1
- data/doc/cxxapi/group__Support.html +1 -1
- data/doc/cxxapi/main.html +1 -1
- data/doc/cxxapi/modules.html +1 -1
- data/doc/rdoc/classes/ConditionVariable.html +194 -0
- data/doc/rdoc/classes/Exception.html +120 -0
- data/doc/rdoc/classes/GC.html +113 -0
- data/doc/rdoc/classes/IO.html +169 -0
- data/doc/rdoc/classes/PhusionPassenger.html +238 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +153 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +517 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +719 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +97 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +96 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +97 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +96 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +598 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +140 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +317 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +138 -0
- data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +154 -0
- data/doc/rdoc/classes/PhusionPassenger/Application.html +283 -0
- data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +172 -0
- data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +145 -0
- data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +175 -0
- data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +141 -0
- data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
- data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +489 -0
- data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +350 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +188 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +194 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz.html +95 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +442 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +200 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +436 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +155 -0
- data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +402 -0
- data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +125 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils.html +805 -0
- data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +140 -0
- data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
- data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +188 -0
- data/doc/rdoc/classes/PlatformInfo.html +831 -0
- data/doc/rdoc/classes/RakeExtensions.html +197 -0
- data/doc/rdoc/classes/Signal.html +131 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/DEVELOPERS_TXT.html +255 -0
- data/doc/rdoc/files/README.html +157 -0
- data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +92 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +129 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +131 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +130 -0
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +130 -0
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +134 -0
- data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +133 -0
- data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +143 -0
- data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +145 -0
- data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +127 -0
- data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +161 -0
- data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +175 -0
- data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +129 -0
- data/doc/rdoc/files/misc/rake/extensions_rb.html +130 -0
- data/doc/rdoc/fr_class_index.html +90 -0
- data/doc/rdoc/fr_file_index.html +76 -0
- data/doc/rdoc/fr_method_index.html +200 -0
- data/doc/rdoc/index.html +26 -0
- data/doc/rdoc/rdoc-style.css +187 -0
- data/doc/users_guide_snippets/rackup_specifications.txt +2 -8
- data/ext/apache2/Bucket.cpp +71 -38
- data/ext/apache2/Bucket.h +53 -16
- data/ext/apache2/Configuration.cpp +15 -0
- data/ext/apache2/Configuration.h +19 -2
- data/ext/apache2/DirectoryMapper.h +10 -10
- data/ext/apache2/Hooks.cpp +334 -74
- data/ext/boost/mpl/apply.hpp +5 -1
- data/ext/boost/mpl/apply_wrap.hpp +5 -2
- data/ext/boost/mpl/aux_/full_lambda.hpp +5 -1
- data/ext/boost/mpl/bind.hpp +5 -1
- data/ext/common/Application.h +11 -31
- data/ext/common/ApplicationPool.h +2 -1
- data/ext/common/ApplicationPoolServer.h +61 -20
- data/ext/common/ApplicationPoolServerExecutable.cpp +132 -4
- data/ext/common/ApplicationPoolStatusReporter.h +189 -65
- data/ext/common/Base64.cpp +143 -0
- data/ext/common/Base64.h +57 -0
- data/ext/common/CachedFileStat.cpp +25 -82
- data/ext/common/CachedFileStat.h +11 -125
- data/ext/common/CachedFileStat.hpp +243 -0
- data/ext/common/Exceptions.h +13 -0
- data/ext/common/FileChangeChecker.h +209 -0
- data/ext/common/Logging.h +3 -2
- data/ext/common/MessageChannel.h +10 -10
- data/ext/common/PoolOptions.h +72 -5
- data/ext/common/SpawnManager.h +11 -8
- data/ext/common/StandardApplicationPool.h +38 -39
- data/ext/common/StaticString.h +1 -0
- data/ext/common/StringListCreator.h +83 -0
- data/ext/common/SystemTime.h +3 -2
- data/ext/common/Timer.h +88 -0
- data/ext/common/Utils.cpp +161 -42
- data/ext/common/Utils.h +62 -31
- data/ext/common/Version.h +1 -1
- data/ext/nginx/Configuration.c +0 -4
- data/ext/nginx/ContentHandler.c +8 -6
- data/ext/nginx/HelperServer.cpp +45 -55
- data/ext/nginx/HttpStatusExtractor.h +4 -0
- data/ext/nginx/StaticContentHandler.c +25 -5
- data/ext/nginx/config +3 -0
- data/ext/nginx/ngx_http_passenger_module.c +72 -17
- data/ext/nginx/ngx_http_passenger_module.h +2 -2
- data/lib/phusion_passenger/abstract_request_handler.rb +15 -7
- data/lib/phusion_passenger/abstract_server.rb +16 -2
- data/lib/phusion_passenger/admin_tools/control_process.rb +36 -25
- data/lib/phusion_passenger/constants.rb +1 -1
- data/lib/phusion_passenger/dependencies.rb +10 -0
- data/lib/phusion_passenger/platform_info.rb +1 -1
- data/lib/phusion_passenger/rack/application_spawner.rb +21 -2
- data/lib/phusion_passenger/rack/request_handler.rb +10 -0
- data/lib/phusion_passenger/railz/application_spawner.rb +38 -2
- data/lib/phusion_passenger/railz/framework_spawner.rb +26 -28
- data/lib/phusion_passenger/railz/request_handler.rb +5 -1
- data/lib/phusion_passenger/spawn_manager.rb +6 -2
- data/lib/phusion_passenger/utils.rb +79 -27
- data/misc/rake/cplusplus.rb +5 -5
- data/test/ApplicationPoolServerTest.cpp +42 -0
- data/test/ApplicationPoolTest.cpp +255 -267
- data/test/Base64Test.cpp +48 -0
- data/test/CachedFileStatTest.cpp +243 -103
- data/test/FileChangeCheckerTest.cpp +331 -0
- data/test/PoolOptionsTest.cpp +80 -0
- data/test/UtilsTest.cpp +5 -17
- data/test/integration_tests/apache2_tests.rb +15 -4
- data/test/integration_tests/mycook_spec.rb +3 -4
- data/test/oxt/syscall_interruption_test.cpp +2 -14
- data/test/ruby/abstract_server_collection_spec.rb +1 -1
- data/test/ruby/abstract_server_spec.rb +35 -1
- data/test/ruby/rack/application_spawner_spec.rb +23 -6
- data/test/ruby/rails/application_spawner_spec.rb +6 -6
- data/test/ruby/rails/framework_spawner_spec.rb +6 -5
- data/test/ruby/rails/minimal_spawner_spec.rb +19 -0
- data/test/ruby/rails/spawner_error_handling_spec.rb +62 -7
- data/test/ruby/spawn_manager_spec.rb +10 -7
- data/test/ruby/spawn_server_spec.rb +1 -1
- data/test/ruby/utils_spec.rb +193 -20
- data/test/ruby/wsgi/application_spawner_spec.rb +3 -1
- data/test/stub/apache2/httpd.conf.erb +3 -0
- data/test/stub/rack/config.ru +1 -1
- data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +8 -0
- data/test/support/Support.cpp +84 -0
- data/test/support/Support.h +66 -8
- data/test/support/config.rb +14 -2
- data/test/support/test_helper.rb +5 -0
- data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +123 -116
- data/vendor/rack-1.0.0-git/lib/rack/cascade.rb +17 -12
- data/vendor/rack-1.0.0-git/lib/rack/commonlogger.rb +34 -43
- data/vendor/rack-1.0.0-git/lib/rack/handler/cgi.rb +1 -1
- data/vendor/rack-1.0.0-git/lib/rack/handler/fastcgi.rb +1 -1
- data/vendor/rack-1.0.0-git/lib/rack/handler/lsws.rb +1 -1
- data/vendor/rack-1.0.0-git/lib/rack/handler/mongrel.rb +1 -1
- data/vendor/rack-1.0.0-git/lib/rack/handler/scgi.rb +1 -1
- data/vendor/rack-1.0.0-git/lib/rack/handler/webrick.rb +1 -1
- data/vendor/rack-1.0.0-git/lib/rack/mock.rb +4 -17
- data/vendor/rack-1.0.0-git/lib/rack/request.rb +3 -9
- data/vendor/rack-1.0.0-git/lib/rack/rewindable_input.rb +2 -0
- data/vendor/rack-1.0.0-git/lib/rack/utils.rb +38 -12
- metadata +231 -186
- data/ext/common/FileChecker.h +0 -112
- data/test/FileCheckerTest.cpp +0 -79
- data/test/stub/minimal-railsapp/README +0 -3
- data/test/stub/minimal-railsapp/config/application.rb +0 -0
- data/test/stub/minimal-railsapp/config/environment.rb +0 -3
- data/test/stub/minimal-railsapp/vendor/rails/actionmailer/lib/action_mailer.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +0 -10
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_pack.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_view.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +0 -7
- data/test/stub/minimal-railsapp/vendor/rails/activeresource/lib/active_resource.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support.rb +0 -17
- data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/railties/lib/dispatcher.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/railties/lib/initializer.rb +0 -8
- data/test/stub/minimal-railsapp/vendor/rails/railties/lib/ruby_version_check.rb +0 -1
- data/test/stub/railsapp/app/controllers/application.rb +0 -12
- data/test/stub/railsapp/app/controllers/bar_controller.rb +0 -5
- data/test/stub/railsapp/app/controllers/bar_controller_1.txt +0 -5
- data/test/stub/railsapp/app/controllers/bar_controller_2.txt +0 -5
- data/test/stub/railsapp/app/controllers/foo_controller.rb +0 -9
- data/test/stub/railsapp/app/helpers/application_helper.rb +0 -3
- data/test/stub/railsapp/config/boot.rb +0 -108
- data/test/stub/railsapp/config/database.yml +0 -19
- data/test/stub/railsapp/config/environment.rb +0 -59
- data/test/stub/railsapp/config/environments/development.rb +0 -18
- data/test/stub/railsapp/config/environments/production.rb +0 -19
- data/test/stub/railsapp/config/initializers/inflections.rb +0 -10
- data/test/stub/railsapp/config/initializers/mime_types.rb +0 -5
- data/test/stub/railsapp/config/routes.rb +0 -35
- data/test/stub/railsapp/public/useless.txt +0 -1
- data/test/stub/railsapp2/app/controllers/application.rb +0 -12
- data/test/stub/railsapp2/app/controllers/foo_controller.rb +0 -5
- data/test/stub/railsapp2/app/helpers/application_helper.rb +0 -3
- data/test/stub/railsapp2/config/boot.rb +0 -108
- data/test/stub/railsapp2/config/database.yml +0 -19
- data/test/stub/railsapp2/config/environment.rb +0 -59
- data/test/stub/railsapp2/config/environments/development.rb +0 -18
- data/test/stub/railsapp2/config/environments/production.rb +0 -19
- data/test/stub/railsapp2/config/initializers/inflections.rb +0 -10
- data/test/stub/railsapp2/config/initializers/mime_types.rb +0 -5
- data/test/stub/railsapp2/config/routes.rb +0 -35
- data/test/stub/railsapp2/public/useless.txt +0 -1
@@ -0,0 +1,331 @@
|
|
1
|
+
#include "tut.h"
|
2
|
+
#include "support/Support.h"
|
3
|
+
#include "FileChangeChecker.h"
|
4
|
+
#include "SystemTime.h"
|
5
|
+
#include <unistd.h>
|
6
|
+
|
7
|
+
using namespace Passenger;
|
8
|
+
using namespace std;
|
9
|
+
using namespace Test;
|
10
|
+
|
11
|
+
namespace tut {
|
12
|
+
struct FileChangeCheckerTest {
|
13
|
+
FileChangeCheckerTest() {
|
14
|
+
}
|
15
|
+
|
16
|
+
~FileChangeCheckerTest() {
|
17
|
+
unlink("test.txt");
|
18
|
+
unlink("test2.txt");
|
19
|
+
SystemTime::release();
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
DEFINE_TEST_GROUP(FileChangeCheckerTest);
|
24
|
+
|
25
|
+
TEST_METHOD(1) {
|
26
|
+
// If a file is checked for the first time, then it
|
27
|
+
// returns whether the file exists.
|
28
|
+
FileChangeChecker checker(10);
|
29
|
+
touchFile("test.txt");
|
30
|
+
ensure(checker.changed("test.txt"));
|
31
|
+
ensure(!checker.changed("test2.txt"));
|
32
|
+
}
|
33
|
+
|
34
|
+
TEST_METHOD(2) {
|
35
|
+
// If a file is checked for the first time, and its
|
36
|
+
// directory is not accessible, then false is returned.
|
37
|
+
if (geteuid() != 0) {
|
38
|
+
// Root can read everything so no point in
|
39
|
+
// testing if we're running as root.
|
40
|
+
|
41
|
+
FileChangeChecker checker(10);
|
42
|
+
TempDir d("test.tmp");
|
43
|
+
touchFile("test.tmp/test.txt");
|
44
|
+
|
45
|
+
system("chmod a= test.tmp");
|
46
|
+
ensure(!checker.changed("test.tmp/test.txt"));
|
47
|
+
|
48
|
+
// Should still be false.
|
49
|
+
ensure(!checker.changed("test.tmp/test.txt"));
|
50
|
+
|
51
|
+
// Now make it accessible again...
|
52
|
+
system("chmod u=rwx test.tmp");
|
53
|
+
ensure(checker.changed("test.tmp/test.txt"));
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
TEST_METHOD(3) {
|
58
|
+
// File is not changed if it didn't exist and
|
59
|
+
// still doesn't exist.
|
60
|
+
FileChangeChecker checker(10);
|
61
|
+
|
62
|
+
checker.changed("test.txt");
|
63
|
+
ensure("test.txt not changed", !checker.changed("test.txt"));
|
64
|
+
|
65
|
+
checker.changed("test2.txt");
|
66
|
+
ensure("test2.txt not changed", !checker.changed("test2.txt"));
|
67
|
+
}
|
68
|
+
|
69
|
+
TEST_METHOD(4) {
|
70
|
+
// File is not changed if its ctime and mtime didn't change.
|
71
|
+
FileChangeChecker checker(10);
|
72
|
+
|
73
|
+
touchFile("test.txt");
|
74
|
+
checker.changed("test.txt");
|
75
|
+
ensure(!checker.changed("test.txt"));
|
76
|
+
|
77
|
+
touchFile("test2.txt");
|
78
|
+
checker.changed("test2.txt");
|
79
|
+
ensure(!checker.changed("test2.txt"));
|
80
|
+
}
|
81
|
+
|
82
|
+
TEST_METHOD(5) {
|
83
|
+
// File is changed if it didn't exist but has now been created.
|
84
|
+
FileChangeChecker checker(10);
|
85
|
+
|
86
|
+
checker.changed("test.txt");
|
87
|
+
checker.changed("test2.txt");
|
88
|
+
touchFile("test.txt");
|
89
|
+
touchFile("test2.txt");
|
90
|
+
ensure(checker.changed("test.txt"));
|
91
|
+
ensure(checker.changed("test2.txt"));
|
92
|
+
}
|
93
|
+
|
94
|
+
TEST_METHOD(6) {
|
95
|
+
// File is changed if existed but has now been deleted.
|
96
|
+
FileChangeChecker checker(10);
|
97
|
+
|
98
|
+
touchFile("test.txt");
|
99
|
+
checker.changed("test.txt");
|
100
|
+
unlink("test.txt");
|
101
|
+
ensure("test.txt is considered changed if it has been deleted",
|
102
|
+
checker.changed("test.txt"));
|
103
|
+
|
104
|
+
touchFile("test2.txt");
|
105
|
+
checker.changed("test2.txt");
|
106
|
+
unlink("test2.txt");
|
107
|
+
ensure("test2.txt is considered changed if it has been deleted",
|
108
|
+
checker.changed("test2.txt"));
|
109
|
+
}
|
110
|
+
|
111
|
+
TEST_METHOD(7) {
|
112
|
+
// File is changed if its mtime changed.
|
113
|
+
FileChangeChecker checker(1);
|
114
|
+
|
115
|
+
touchFile("test.txt", 5);
|
116
|
+
checker.changed("test.txt");
|
117
|
+
touchFile("test.txt", 10);
|
118
|
+
ensure("First check: changed", checker.changed("test.txt"));
|
119
|
+
ensure("Second check: unchanged", !checker.changed("test.txt"));
|
120
|
+
|
121
|
+
touchFile("test2.txt", 5);
|
122
|
+
checker.changed("test2.txt");
|
123
|
+
touchFile("test2.txt", 10);
|
124
|
+
ensure("First check test2.txt: changed", checker.changed("test2.txt"));
|
125
|
+
ensure("Second check test2.txt: unchanged", !checker.changed("test2.txt"));
|
126
|
+
}
|
127
|
+
|
128
|
+
TEST_METHOD(8) {
|
129
|
+
// If a file is not checked for the first time and its
|
130
|
+
// information is still in the cache, but the directory
|
131
|
+
// in which the file lives is now suddenly inaccessible,
|
132
|
+
// then false is returned.
|
133
|
+
if (geteuid() != 0) {
|
134
|
+
// Root can read everything so no point in
|
135
|
+
// testing if we're running as root.
|
136
|
+
|
137
|
+
FileChangeChecker checker(10);
|
138
|
+
TempDir d("test.tmp");
|
139
|
+
touchFile("test.tmp/test.txt", 1);
|
140
|
+
checker.changed("test.tmp/test.txt");
|
141
|
+
|
142
|
+
touchFile("test.tmp/test.txt", 2);
|
143
|
+
system("chmod a= test.tmp");
|
144
|
+
ensure("First check returns false", !checker.changed("test.tmp/test.txt"));
|
145
|
+
|
146
|
+
// Now make it accessible again...
|
147
|
+
system("chmod u=rwx test.tmp");
|
148
|
+
ensure("Second check returns true", checker.changed("test.tmp/test.txt"));
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
TEST_METHOD(9) {
|
153
|
+
// Throttling works.
|
154
|
+
SystemTime::force(5);
|
155
|
+
|
156
|
+
FileChangeChecker checker(1);
|
157
|
+
checker.changed("test.txt", 3);
|
158
|
+
touchFile("test.txt");
|
159
|
+
ensure(!checker.changed("test.txt", 3));
|
160
|
+
|
161
|
+
SystemTime::force(6);
|
162
|
+
ensure(!checker.changed("test.txt", 3));
|
163
|
+
|
164
|
+
SystemTime::force(8);
|
165
|
+
ensure(checker.changed("test.txt", 3));
|
166
|
+
ensure(!checker.changed("test.txt", 3));
|
167
|
+
}
|
168
|
+
|
169
|
+
TEST_METHOD(10) {
|
170
|
+
// Test scenario involving multiple files.
|
171
|
+
FileChangeChecker checker(10);
|
172
|
+
|
173
|
+
checker.changed("test.txt");
|
174
|
+
checker.changed("test2.txt");
|
175
|
+
checker.changed("test3.txt");
|
176
|
+
|
177
|
+
touchFile("test2.txt", 1);
|
178
|
+
ensure(!checker.changed("test.txt"));
|
179
|
+
ensure(checker.changed("test2.txt"));
|
180
|
+
ensure(!checker.changed("test3.txt"));
|
181
|
+
|
182
|
+
touchFile("test.txt", 2);
|
183
|
+
touchFile("test3.txt", 3);
|
184
|
+
ensure(checker.changed("test.txt"));
|
185
|
+
ensure(!checker.changed("test2.txt"));
|
186
|
+
ensure(checker.changed("test3.txt"));
|
187
|
+
}
|
188
|
+
|
189
|
+
TEST_METHOD(11) {
|
190
|
+
// Different filenames are treated as different files.
|
191
|
+
FileChangeChecker checker(10);
|
192
|
+
checker.changed("test.txt");
|
193
|
+
checker.changed("./test.txt");
|
194
|
+
touchFile("test.txt", 1);
|
195
|
+
ensure(checker.changed("test.txt"));
|
196
|
+
ensure(checker.changed("./test.txt"));
|
197
|
+
}
|
198
|
+
|
199
|
+
TEST_METHOD(12) {
|
200
|
+
if (geteuid() != 0) {
|
201
|
+
// Root can read everything so no point in
|
202
|
+
// testing if we're running as root.
|
203
|
+
|
204
|
+
FileChangeChecker checker(10);
|
205
|
+
TempDir d("test.tmp");
|
206
|
+
touchFile("test.tmp/test.txt");
|
207
|
+
|
208
|
+
checker.changed("test.tmp/test.txt");
|
209
|
+
unlink("test.tmp/test.txt");
|
210
|
+
system("chmod a= test.tmp");
|
211
|
+
ensure(!checker.changed("test.tmp/test.txt"));
|
212
|
+
system("chmod u=rwx test.tmp");
|
213
|
+
ensure(checker.changed("test.tmp/test.txt"));
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
TEST_METHOD(13) {
|
218
|
+
// Size limitation works.
|
219
|
+
FileChangeChecker checker(2);
|
220
|
+
touchFile("test.txt", 1);
|
221
|
+
touchFile("test2.txt", 2);
|
222
|
+
touchFile("test3.txt", 3);
|
223
|
+
|
224
|
+
checker.changed("test.txt");
|
225
|
+
checker.changed("test2.txt");
|
226
|
+
checker.changed("test3.txt");
|
227
|
+
|
228
|
+
// test.txt is now removed from the file list.
|
229
|
+
|
230
|
+
unlink("test.txt");
|
231
|
+
unlink("test2.txt");
|
232
|
+
unlink("test3.txt");
|
233
|
+
ensure("test2.txt is still in the file list", checker.changed("test2.txt"));
|
234
|
+
ensure("test3.txt is still in the file list", checker.changed("test3.txt"));
|
235
|
+
ensure("test.txt is removed from the file list", !checker.changed("test.txt"));
|
236
|
+
}
|
237
|
+
|
238
|
+
TEST_METHOD(14) {
|
239
|
+
// Increasing the file list size dynamically works.
|
240
|
+
FileChangeChecker checker(2);
|
241
|
+
touchFile("test.txt", 1);
|
242
|
+
touchFile("test2.txt", 2);
|
243
|
+
touchFile("test3.txt", 3);
|
244
|
+
|
245
|
+
checker.changed("test.txt");
|
246
|
+
checker.changed("test2.txt");
|
247
|
+
checker.changed("test3.txt");
|
248
|
+
|
249
|
+
// test.txt is now removed from the file list.
|
250
|
+
|
251
|
+
checker.setMaxSize(3);
|
252
|
+
unlink("test.txt");
|
253
|
+
unlink("test2.txt");
|
254
|
+
unlink("test3.txt");
|
255
|
+
|
256
|
+
ensure("test.txt is removed from the file list", !checker.knows("test.txt"));
|
257
|
+
// The above changed() call should not remove test2.txt from the file list.
|
258
|
+
ensure("test2.txt is still in the file list", checker.knows("test2.txt"));
|
259
|
+
ensure("test3.txt is still in the file list", checker.knows("test3.txt"));
|
260
|
+
|
261
|
+
checker.changed("test.txt");
|
262
|
+
checker.changed("test4.txt");
|
263
|
+
ensure("test2.txt is removed from the file list, again", !checker.knows("test2.txt"));
|
264
|
+
}
|
265
|
+
|
266
|
+
TEST_METHOD(16) {
|
267
|
+
// Decreasing the file list size dynamically works, and will
|
268
|
+
// remove the oldest entries.
|
269
|
+
FileChangeChecker checker(4);
|
270
|
+
checker.changed("test.txt");
|
271
|
+
checker.changed("test2.txt");
|
272
|
+
checker.changed("test3.txt");
|
273
|
+
checker.changed("test4.txt");
|
274
|
+
|
275
|
+
checker.setMaxSize(2);
|
276
|
+
ensure(!checker.knows("test.txt"));
|
277
|
+
ensure(!checker.knows("test2.txt"));
|
278
|
+
ensure(checker.knows("test3.txt"));
|
279
|
+
ensure(checker.knows("test4.txt"));
|
280
|
+
|
281
|
+
checker.changed("test.txt");
|
282
|
+
ensure(!checker.knows("test3.txt"));
|
283
|
+
}
|
284
|
+
|
285
|
+
TEST_METHOD(17) {
|
286
|
+
// An initial maxSize of 0 makes the file list's size unlimited.
|
287
|
+
FileChangeChecker checker(0);
|
288
|
+
checker.changed("test.txt");
|
289
|
+
checker.changed("test2.txt");
|
290
|
+
checker.changed("test3.txt");
|
291
|
+
checker.changed("test4.txt");
|
292
|
+
|
293
|
+
ensure(checker.knows("test.txt"));
|
294
|
+
ensure(checker.knows("test2.txt"));
|
295
|
+
ensure(checker.knows("test3.txt"));
|
296
|
+
ensure(checker.knows("test4.txt"));
|
297
|
+
}
|
298
|
+
|
299
|
+
TEST_METHOD(18) {
|
300
|
+
// Dynamically setting the file list size to 0 makes
|
301
|
+
// the file list's size unlimited.
|
302
|
+
FileChangeChecker checker(2);
|
303
|
+
checker.changed("test.txt");
|
304
|
+
checker.changed("test2.txt");
|
305
|
+
checker.setMaxSize(0);
|
306
|
+
checker.changed("test3.txt");
|
307
|
+
checker.changed("test4.txt");
|
308
|
+
|
309
|
+
ensure(checker.knows("test.txt"));
|
310
|
+
ensure(checker.knows("test2.txt"));
|
311
|
+
ensure(checker.knows("test3.txt"));
|
312
|
+
ensure(checker.knows("test4.txt"));
|
313
|
+
}
|
314
|
+
|
315
|
+
TEST_METHOD(19) {
|
316
|
+
// Changing the file list size dynamically from 0 to non-0 works;
|
317
|
+
// it removes the oldest entries, if necessary.
|
318
|
+
FileChangeChecker checker(0);
|
319
|
+
checker.changed("test.txt");
|
320
|
+
checker.changed("test2.txt");
|
321
|
+
checker.changed("test3.txt");
|
322
|
+
checker.changed("test4.txt");
|
323
|
+
checker.changed("test5.txt");
|
324
|
+
checker.setMaxSize(2);
|
325
|
+
ensure(!checker.knows("test.txt"));
|
326
|
+
ensure(!checker.knows("test2.txt"));
|
327
|
+
ensure(!checker.knows("test3.txt"));
|
328
|
+
ensure(checker.knows("test4.txt"));
|
329
|
+
ensure(checker.knows("test5.txt"));
|
330
|
+
}
|
331
|
+
}
|
data/test/PoolOptionsTest.cpp
CHANGED
@@ -34,4 +34,84 @@ namespace tut {
|
|
34
34
|
ensure_equals(options.appSpawnerTimeout, copy.appSpawnerTimeout);
|
35
35
|
ensure_equals(options.maxRequests, copy.maxRequests);
|
36
36
|
}
|
37
|
+
|
38
|
+
// Test empty environmentVariables serialization and deserialization.
|
39
|
+
TEST_METHOD(2) {
|
40
|
+
PoolOptions options;
|
41
|
+
vector<string> args;
|
42
|
+
options.toVector(args);
|
43
|
+
|
44
|
+
PoolOptions options2(args);
|
45
|
+
ensure_equals(options2.environmentVariables->getItems()->size(), 0u);
|
46
|
+
}
|
47
|
+
|
48
|
+
// Test single item environmentVariables serialization and deserialization.
|
49
|
+
TEST_METHOD(3) {
|
50
|
+
PoolOptions options;
|
51
|
+
SimpleStringListCreatorPtr list = ptr(new SimpleStringListCreator());
|
52
|
+
vector<string> args;
|
53
|
+
list->items->push_back("hello");
|
54
|
+
list->items->push_back("world !!");
|
55
|
+
options.environmentVariables = list;
|
56
|
+
options.toVector(args);
|
57
|
+
|
58
|
+
PoolOptions options2(args);
|
59
|
+
const StringListPtr list2 = options2.environmentVariables->getItems();
|
60
|
+
ensure_equals(list2->size(), 2u);
|
61
|
+
ensure_equals(list2->at(0), "hello");
|
62
|
+
ensure_equals(list2->at(1), "world !!");
|
63
|
+
}
|
64
|
+
|
65
|
+
// Test multiple items environmentVariables serialization and deserialization.
|
66
|
+
TEST_METHOD(4) {
|
67
|
+
PoolOptions options;
|
68
|
+
SimpleStringListCreatorPtr list = ptr(new SimpleStringListCreator());
|
69
|
+
vector<string> args;
|
70
|
+
list->items->push_back("hello");
|
71
|
+
list->items->push_back("world !!");
|
72
|
+
list->items->push_back("PATH");
|
73
|
+
list->items->push_back("/usr/local/bin");
|
74
|
+
options.environmentVariables = list;
|
75
|
+
options.toVector(args);
|
76
|
+
|
77
|
+
PoolOptions options2(args);
|
78
|
+
const StringListPtr list2 = options2.environmentVariables->getItems();
|
79
|
+
ensure_equals(list2->size(), 4u);
|
80
|
+
ensure_equals(list2->at(0), "hello");
|
81
|
+
ensure_equals(list2->at(1), "world !!");
|
82
|
+
ensure_equals(list2->at(2), "PATH");
|
83
|
+
ensure_equals(list2->at(3), "/usr/local/bin");
|
84
|
+
}
|
85
|
+
|
86
|
+
// Calling toVector() with storeEnvVars = false on a PoolOption object that
|
87
|
+
// has no environment variables works, and the resulting data can be unserialized.
|
88
|
+
TEST_METHOD(5) {
|
89
|
+
PoolOptions options;
|
90
|
+
vector<string> args;
|
91
|
+
options.appRoot = "hello";
|
92
|
+
options.toVector(args, false);
|
93
|
+
|
94
|
+
PoolOptions options2(args);
|
95
|
+
ensure_equals(options2.appRoot, "hello");
|
96
|
+
ensure_equals(options2.environmentVariables, StringListCreatorPtr());
|
97
|
+
}
|
98
|
+
|
99
|
+
// Calling toVector() with storeEnvVars = false on a PoolOption object that
|
100
|
+
// has no environment variables works, and the resulting data can be unserialized.
|
101
|
+
TEST_METHOD(6) {
|
102
|
+
PoolOptions options;
|
103
|
+
SimpleStringListCreatorPtr list = ptr(new SimpleStringListCreator());
|
104
|
+
vector<string> args;
|
105
|
+
list->items->push_back("hello");
|
106
|
+
list->items->push_back("world");
|
107
|
+
list->items->push_back("foo");
|
108
|
+
list->items->push_back("bar");
|
109
|
+
options.appRoot = "hello";
|
110
|
+
options.environmentVariables = list;
|
111
|
+
options.toVector(args, false);
|
112
|
+
|
113
|
+
PoolOptions options2(args);
|
114
|
+
ensure_equals(options2.appRoot, "hello");
|
115
|
+
ensure_equals(options2.environmentVariables, StringListCreatorPtr());
|
116
|
+
}
|
37
117
|
}
|
data/test/UtilsTest.cpp
CHANGED
@@ -192,22 +192,10 @@ namespace tut {
|
|
192
192
|
|
193
193
|
/***** Test BufferedUpload *****/
|
194
194
|
|
195
|
-
struct TemporarilySetInstanceTempDir {
|
196
|
-
TemporarilySetInstanceTempDir() {
|
197
|
-
setPassengerTempDir("utils_test.tmp");
|
198
|
-
mkdir("utils_test.tmp", S_IRWXU);
|
199
|
-
mkdir(BufferedUpload::getDir().c_str(), S_IRWXU);
|
200
|
-
}
|
201
|
-
|
202
|
-
~TemporarilySetInstanceTempDir() {
|
203
|
-
removeDirTree("utils_test.tmp");
|
204
|
-
}
|
205
|
-
};
|
206
|
-
|
207
195
|
TEST_METHOD(20) {
|
208
196
|
// The resulting file handle is readable and writable.
|
209
|
-
|
210
|
-
BufferedUpload t;
|
197
|
+
TempDir td("utils_test.tmp");
|
198
|
+
BufferedUpload t("utils_test.tmp");
|
211
199
|
char line[30];
|
212
200
|
|
213
201
|
fprintf(t.handle, "hello world!");
|
@@ -220,9 +208,9 @@ namespace tut {
|
|
220
208
|
|
221
209
|
TEST_METHOD(21) {
|
222
210
|
// It immediately unlinks the temp file.
|
223
|
-
|
224
|
-
BufferedUpload t;
|
225
|
-
ensure_equals(listDir(
|
211
|
+
TempDir td("utils_test.tmp");
|
212
|
+
BufferedUpload t("utils_test.tmp");
|
213
|
+
ensure_equals(listDir("utils_test.tmp").size(), 0u);
|
226
214
|
}
|
227
215
|
|
228
216
|
/***** Test escapeForXml() *****/
|