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
data/test/Base64Test.cpp
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#include "tut.h"
|
2
|
+
#include "Base64.h"
|
3
|
+
|
4
|
+
using namespace Passenger;
|
5
|
+
using namespace std;
|
6
|
+
|
7
|
+
namespace tut {
|
8
|
+
struct Base64Test {
|
9
|
+
};
|
10
|
+
|
11
|
+
DEFINE_TEST_GROUP(Base64Test);
|
12
|
+
|
13
|
+
TEST_METHOD(1) {
|
14
|
+
// Test encoding.
|
15
|
+
ensure_equals(Base64::encode(""), "");
|
16
|
+
ensure_equals(Base64::encode("a"), "YQ==");
|
17
|
+
ensure_equals(Base64::encode("b"), "Yg==");
|
18
|
+
ensure_equals(Base64::encode("ab"), "YWI=");
|
19
|
+
ensure_equals(Base64::encode("abc"), "YWJj");
|
20
|
+
ensure_equals(Base64::encode("abcd"), "YWJjZA==");
|
21
|
+
ensure_equals(Base64::encode("\1\2\3\4\5\6\7\255"), "AQIDBAUGB60=");
|
22
|
+
ensure_equals(Base64::encode("The gamma-ray burst from April 23, a "
|
23
|
+
"powerful explosion from a dying star, was detected by the "
|
24
|
+
"Swift satellite using on-board gamma-ray and X-ray instruments."),
|
25
|
+
"VGhlIGdhbW1hLXJheSBidXJzdCBmcm9tIEFwcmlsIDIzLCBhIHBvd2VyZnVs"
|
26
|
+
"IGV4cGxvc2lvbiBmcm9tIGEgZHlpbmcgc3Rhciwgd2FzIGRldGVjdGVkIGJ5"
|
27
|
+
"IHRoZSBTd2lmdCBzYXRlbGxpdGUgdXNpbmcgb24tYm9hcmQgZ2FtbWEtcmF5"
|
28
|
+
"IGFuZCBYLXJheSBpbnN0cnVtZW50cy4=");
|
29
|
+
}
|
30
|
+
|
31
|
+
TEST_METHOD(2) {
|
32
|
+
// Test decoding.
|
33
|
+
ensure_equals(Base64::decode(""), "");
|
34
|
+
ensure_equals(Base64::decode("YQ=="), "a");
|
35
|
+
ensure_equals(Base64::decode("Yg=="), "b");
|
36
|
+
ensure_equals(Base64::decode("YWI="), "ab");
|
37
|
+
ensure_equals(Base64::decode("YWJj"), "abc");
|
38
|
+
ensure_equals(Base64::decode("YWJjZA=="), "abcd");
|
39
|
+
ensure_equals(Base64::decode("AQIDBAUGB60="), "\1\2\3\4\5\6\7\255");
|
40
|
+
ensure_equals(Base64::decode("VGhlIGdhbW1hLXJheSBidXJzdCBmcm9tIEFwcmlsIDIzLCBhIHBvd2VyZnVs"
|
41
|
+
"IGV4cGxvc2lvbiBmcm9tIGEgZHlpbmcgc3Rhciwgd2FzIGRldGVjdGVkIGJ5"
|
42
|
+
"IHRoZSBTd2lmdCBzYXRlbGxpdGUgdXNpbmcgb24tYm9hcmQgZ2FtbWEtcmF5"
|
43
|
+
"IGFuZCBYLXJheSBpbnN0cnVtZW50cy4="),
|
44
|
+
"The gamma-ray burst from April 23, a "
|
45
|
+
"powerful explosion from a dying star, was detected by the "
|
46
|
+
"Swift satellite using on-board gamma-ray and X-ray instruments.");
|
47
|
+
}
|
48
|
+
}
|
data/test/CachedFileStatTest.cpp
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#include "tut.h"
|
2
|
-
#include "CachedFileStat.
|
2
|
+
#include "CachedFileStat.hpp"
|
3
3
|
#include "SystemTime.h"
|
4
4
|
#include <sys/types.h>
|
5
5
|
#include <utime.h>
|
@@ -9,21 +9,9 @@ using namespace Passenger;
|
|
9
9
|
|
10
10
|
namespace tut {
|
11
11
|
struct CachedFileStatTest {
|
12
|
-
|
13
|
-
CachedMultiFileStat *mstat;
|
14
|
-
|
15
|
-
CachedFileStatTest() {
|
16
|
-
stat = (CachedFileStat *) NULL;
|
17
|
-
mstat = (CachedMultiFileStat *) NULL;
|
18
|
-
}
|
12
|
+
struct stat buf;
|
19
13
|
|
20
14
|
~CachedFileStatTest() {
|
21
|
-
if (stat != NULL) {
|
22
|
-
delete stat;
|
23
|
-
}
|
24
|
-
if (mstat != NULL) {
|
25
|
-
cached_multi_file_stat_free(mstat);
|
26
|
-
}
|
27
15
|
SystemTime::release();
|
28
16
|
unlink("test.txt");
|
29
17
|
unlink("test2.txt");
|
@@ -32,6 +20,8 @@ namespace tut {
|
|
32
20
|
}
|
33
21
|
};
|
34
22
|
|
23
|
+
DEFINE_TEST_GROUP(CachedFileStatTest);
|
24
|
+
|
35
25
|
static void touch(const char *filename, time_t timestamp = 0) {
|
36
26
|
FILE *f = fopen(filename, "w");
|
37
27
|
fprintf(f, "hi");
|
@@ -44,129 +34,106 @@ namespace tut {
|
|
44
34
|
}
|
45
35
|
}
|
46
36
|
|
47
|
-
|
48
|
-
|
49
|
-
/************ Tests for CachedFileStat ************/
|
37
|
+
/************ Tests involving a single file ************/
|
50
38
|
|
51
39
|
TEST_METHOD(1) {
|
52
|
-
//
|
40
|
+
// Statting a new file works.
|
53
41
|
touch("test.txt");
|
54
|
-
stat
|
55
|
-
ensure_equals(
|
56
|
-
ensure_equals(
|
42
|
+
CachedFileStat stat(1);
|
43
|
+
ensure_equals(stat.stat("test.txt", &buf, 1), 0);
|
44
|
+
ensure_equals((long) buf.st_size, (long) 2);
|
57
45
|
}
|
58
46
|
|
59
47
|
TEST_METHOD(2) {
|
60
|
-
//
|
61
|
-
|
62
|
-
|
63
|
-
stat = new CachedFileStat("test.txt");
|
64
|
-
ensure_equals(stat->refresh(1), 0);
|
65
|
-
ensure_equals((long) stat->info.st_size, (long) 2);
|
66
|
-
}
|
67
|
-
|
68
|
-
TEST_METHOD(3) {
|
69
|
-
// cached_file_stat_refresh() does not re-stat the file
|
70
|
-
// until the cache has expired.
|
48
|
+
// It does not re-stat an existing file until the cache has expired.
|
49
|
+
CachedFileStat stat(1);
|
50
|
+
|
71
51
|
SystemTime::force(5);
|
72
|
-
stat = new CachedFileStat("test.txt");
|
73
52
|
touch("test.txt", 1);
|
74
|
-
ensure_equals("1st
|
75
|
-
stat
|
53
|
+
ensure_equals("1st stat succceeded",
|
54
|
+
stat.stat("test.txt", &buf, 1),
|
76
55
|
0);
|
77
56
|
|
78
57
|
touch("test.txt", 1000);
|
79
|
-
ensure_equals("2nd
|
80
|
-
stat
|
58
|
+
ensure_equals("2nd stat succceeded",
|
59
|
+
stat.stat("test.txt", &buf, 1),
|
81
60
|
0);
|
82
61
|
ensure_equals("Cached value was used",
|
83
|
-
|
62
|
+
buf.st_mtime,
|
84
63
|
(time_t) 1);
|
85
64
|
|
86
65
|
SystemTime::force(6);
|
87
|
-
ensure_equals("3rd
|
88
|
-
stat
|
66
|
+
ensure_equals("3rd stat succceeded",
|
67
|
+
stat.stat("test.txt", &buf, 1),
|
89
68
|
0);
|
90
69
|
ensure_equals("Cache has been invalidated",
|
91
|
-
|
70
|
+
buf.st_mtime,
|
92
71
|
(time_t) 1000);
|
93
72
|
}
|
94
73
|
|
95
|
-
TEST_METHOD(
|
96
|
-
//
|
97
|
-
|
98
|
-
stat
|
99
|
-
ensure_equals(stat->refresh(1), -1);
|
74
|
+
TEST_METHOD(3) {
|
75
|
+
// Statting a nonexistant file returns an error.
|
76
|
+
CachedFileStat stat(1);
|
77
|
+
ensure_equals(stat.stat("test.txt", &buf, 1), -1);
|
100
78
|
ensure_equals("It sets errno appropriately", errno, ENOENT);
|
101
79
|
}
|
102
80
|
|
103
|
-
TEST_METHOD(
|
104
|
-
//
|
105
|
-
//
|
81
|
+
TEST_METHOD(4) {
|
82
|
+
// It does not re-stat a previously nonexistant file until
|
83
|
+
// the cache has expired.
|
106
84
|
SystemTime::force(5);
|
107
|
-
stat
|
108
|
-
ensure_equals("1st
|
109
|
-
stat
|
85
|
+
CachedFileStat stat(1);
|
86
|
+
ensure_equals("1st stat failed",
|
87
|
+
stat.stat("test.txt", &buf, 1),
|
110
88
|
-1);
|
111
89
|
ensure_equals("It sets errno appropriately", errno, ENOENT);
|
112
90
|
|
113
91
|
errno = EEXIST;
|
114
|
-
|
115
|
-
|
92
|
+
touch("test.txt", 1000);
|
93
|
+
ensure_equals("2nd stat failed",
|
94
|
+
stat.stat("test.txt", &buf, 1),
|
116
95
|
-1);
|
117
96
|
ensure_equals("It sets errno appropriately", errno, ENOENT);
|
118
97
|
ensure_equals("Cached value was used",
|
119
|
-
|
98
|
+
buf.st_mtime,
|
120
99
|
(time_t) 0);
|
121
100
|
|
122
|
-
touch("test.txt", 1000);
|
123
101
|
SystemTime::force(6);
|
124
|
-
ensure_equals("3rd
|
125
|
-
stat
|
102
|
+
ensure_equals("3rd stat succeeded",
|
103
|
+
stat.stat("test.txt", &buf, 1),
|
126
104
|
0);
|
127
105
|
ensure_equals("Cache has been invalidated",
|
128
|
-
|
106
|
+
buf.st_mtime,
|
129
107
|
(time_t) 1000);
|
130
108
|
|
131
109
|
unlink("test.txt");
|
132
|
-
ensure_equals("4th
|
133
|
-
stat
|
110
|
+
ensure_equals("4th stat succeeded even though file was unlinked",
|
111
|
+
stat.stat("test.txt", &buf, 1),
|
134
112
|
0);
|
135
113
|
ensure_equals("Cached value was used",
|
136
|
-
|
114
|
+
buf.st_mtime,
|
137
115
|
(time_t) 1000);
|
138
116
|
}
|
139
117
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
118
|
+
TEST_METHOD(5) {
|
119
|
+
// If the throttling rate is 0 then the cache will be bypassed.
|
120
|
+
SystemTime::force(5);
|
121
|
+
CachedFileStat stat(2);
|
122
|
+
ensure_equals("1st stat returns -1",
|
123
|
+
stat.stat("test.txt", &buf, 0),
|
124
|
+
-1);
|
147
125
|
touch("test.txt");
|
148
|
-
|
149
|
-
|
150
|
-
cached_multi_file_stat_perform(mstat, "test.txt", &buf, 0),
|
126
|
+
ensure_equals("2nd stat did not go through the cache",
|
127
|
+
stat.stat("test.txt", &buf, 0),
|
151
128
|
0);
|
152
|
-
ensure_equals((long) buf.st_size, (long) 2);
|
153
129
|
}
|
154
130
|
|
155
|
-
TEST_METHOD(11) {
|
156
|
-
// Statting a nonexistant file works.
|
157
|
-
struct stat buf;
|
158
|
-
|
159
|
-
mstat = cached_multi_file_stat_new(1);
|
160
|
-
ensure_equals(
|
161
|
-
cached_multi_file_stat_perform(mstat, "test.txt", &buf, 0),
|
162
|
-
-1);
|
163
|
-
}
|
164
131
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
132
|
+
/************ Tests involving multiple files ************/
|
133
|
+
|
134
|
+
TEST_METHOD(10) {
|
135
|
+
// Throttling in combination with multiple files works.
|
136
|
+
CachedFileStat stat(2);
|
170
137
|
SystemTime::force(5);
|
171
138
|
|
172
139
|
// Touch and stat test.txt. The next stat should return
|
@@ -174,13 +141,13 @@ namespace tut {
|
|
174
141
|
|
175
142
|
touch("test.txt", 10);
|
176
143
|
ensure_equals(
|
177
|
-
|
144
|
+
stat.stat("test.txt", &buf, 1),
|
178
145
|
0);
|
179
146
|
ensure_equals(buf.st_mtime, (time_t) 10);
|
180
147
|
|
181
148
|
touch("test.txt", 20);
|
182
149
|
ensure_equals(
|
183
|
-
|
150
|
+
stat.stat("test.txt", &buf, 1),
|
184
151
|
0);
|
185
152
|
ensure_equals(buf.st_mtime, (time_t) 10);
|
186
153
|
|
@@ -189,13 +156,13 @@ namespace tut {
|
|
189
156
|
|
190
157
|
touch("test2.txt", 30);
|
191
158
|
ensure_equals(
|
192
|
-
|
159
|
+
stat.stat("test2.txt", &buf, 1),
|
193
160
|
0);
|
194
161
|
ensure_equals(buf.st_mtime, (time_t) 30);
|
195
162
|
|
196
163
|
touch("test2.txt", 40);
|
197
164
|
ensure_equals(
|
198
|
-
|
165
|
+
stat.stat("test2.txt", &buf, 1),
|
199
166
|
0);
|
200
167
|
ensure_equals(buf.st_mtime, (time_t) 30);
|
201
168
|
|
@@ -204,39 +171,37 @@ namespace tut {
|
|
204
171
|
|
205
172
|
SystemTime::force(6);
|
206
173
|
ensure_equals(
|
207
|
-
|
174
|
+
stat.stat("test.txt", &buf, 1),
|
208
175
|
0);
|
209
176
|
ensure_equals(buf.st_mtime, (time_t) 20);
|
210
177
|
ensure_equals(
|
211
|
-
|
178
|
+
stat.stat("test2.txt", &buf, 1),
|
212
179
|
0);
|
213
180
|
ensure_equals(buf.st_mtime, (time_t) 40);
|
214
181
|
}
|
215
182
|
|
216
|
-
TEST_METHOD(
|
183
|
+
TEST_METHOD(11) {
|
217
184
|
// Cache limiting works.
|
218
|
-
|
219
|
-
|
220
|
-
mstat = cached_multi_file_stat_new(3);
|
185
|
+
CachedFileStat stat(3);
|
221
186
|
SystemTime::force(5);
|
222
187
|
|
223
188
|
// Create and stat test.txt, test2.txt and test3.txt.
|
224
189
|
|
225
190
|
touch("test.txt", 1000);
|
226
191
|
ensure_equals(
|
227
|
-
|
192
|
+
stat.stat("test.txt", &buf, 1),
|
228
193
|
0);
|
229
194
|
ensure_equals(buf.st_mtime, (time_t) 1000);
|
230
195
|
|
231
196
|
touch("test2.txt", 1001);
|
232
197
|
ensure_equals(
|
233
|
-
|
198
|
+
stat.stat("test2.txt", &buf, 1),
|
234
199
|
0);
|
235
200
|
ensure_equals(buf.st_mtime, (time_t) 1001);
|
236
201
|
|
237
202
|
touch("test3.txt", 1003);
|
238
203
|
ensure_equals(
|
239
|
-
|
204
|
+
stat.stat("test3.txt", &buf, 1),
|
240
205
|
0);
|
241
206
|
ensure_equals(buf.st_mtime, (time_t) 1003);
|
242
207
|
|
@@ -245,18 +210,193 @@ namespace tut {
|
|
245
210
|
// upon statting it again its new timestamp should be returned.
|
246
211
|
|
247
212
|
ensure_equals(
|
248
|
-
|
213
|
+
stat.stat("test2.txt", &buf, 1),
|
249
214
|
0);
|
250
215
|
|
251
216
|
touch("test4.txt", 1004);
|
252
217
|
ensure_equals(
|
253
|
-
|
218
|
+
stat.stat("test4.txt", &buf, 1),
|
254
219
|
0);
|
255
220
|
|
256
221
|
touch("test.txt", 3000);
|
257
222
|
ensure_equals(
|
258
|
-
|
223
|
+
stat.stat("test.txt", &buf, 1),
|
259
224
|
0);
|
260
225
|
ensure_equals(buf.st_mtime, (time_t) 3000);
|
261
226
|
}
|
227
|
+
|
228
|
+
TEST_METHOD(12) {
|
229
|
+
// Increasing the cache size dynamically works.
|
230
|
+
SystemTime::force(5);
|
231
|
+
CachedFileStat stat(2);
|
232
|
+
touch("test.txt", 1);
|
233
|
+
touch("test2.txt", 2);
|
234
|
+
touch("test3.txt", 3);
|
235
|
+
|
236
|
+
ensure_equals("1st stat succeeded",
|
237
|
+
stat.stat("test.txt", &buf, 1),
|
238
|
+
0);
|
239
|
+
ensure_equals("2nd stat succeeded",
|
240
|
+
stat.stat("test2.txt", &buf, 1),
|
241
|
+
0);
|
242
|
+
ensure_equals("3rd stat succeeded",
|
243
|
+
stat.stat("test3.txt", &buf, 1),
|
244
|
+
0);
|
245
|
+
|
246
|
+
// test.txt should now be removed from the cache.
|
247
|
+
|
248
|
+
touch("test.txt", 10);
|
249
|
+
ensure_equals("4th stat succeeded",
|
250
|
+
stat.stat("test.txt", &buf, 1),
|
251
|
+
0);
|
252
|
+
ensure_equals(buf.st_mtime, (time_t) 10);
|
253
|
+
|
254
|
+
// test2.txt should now be removed from the cache.
|
255
|
+
// If we stat test2.txt now, test3.txt would normally
|
256
|
+
// be removed from the cache. But if we increase the
|
257
|
+
// cache size here then that won't happen:
|
258
|
+
stat.setMaxSize(3);
|
259
|
+
touch("test2.txt", 11);
|
260
|
+
touch("test3.txt", 12);
|
261
|
+
|
262
|
+
ensure_equals("5th stat succeeded",
|
263
|
+
stat.stat("test2.txt", &buf, 1),
|
264
|
+
0);
|
265
|
+
ensure_equals(buf.st_mtime, (time_t) 11);
|
266
|
+
|
267
|
+
ensure_equals("6th stat succeeded",
|
268
|
+
stat.stat("test3.txt", &buf, 1),
|
269
|
+
0);
|
270
|
+
ensure_equals("test3.txt is still cached",
|
271
|
+
buf.st_mtime,
|
272
|
+
(time_t) 3);
|
273
|
+
|
274
|
+
ensure_equals("7th stat succeeded",
|
275
|
+
stat.stat("test.txt", &buf, 1),
|
276
|
+
0);
|
277
|
+
ensure_equals("test.txt is still cached",
|
278
|
+
buf.st_mtime,
|
279
|
+
(time_t) 10);
|
280
|
+
}
|
281
|
+
|
282
|
+
TEST_METHOD(13) {
|
283
|
+
// If we decrease the cache size dynamically, then
|
284
|
+
// the oldest entries will be removed.
|
285
|
+
SystemTime::force(5);
|
286
|
+
CachedFileStat stat(3);
|
287
|
+
touch("test.txt", 1);
|
288
|
+
touch("test2.txt", 2);
|
289
|
+
touch("test3.txt", 3);
|
290
|
+
|
291
|
+
ensure_equals("1st stat succeeded",
|
292
|
+
stat.stat("test.txt", &buf, 1),
|
293
|
+
0);
|
294
|
+
ensure_equals("2nd stat succeeded",
|
295
|
+
stat.stat("test2.txt", &buf, 1),
|
296
|
+
0);
|
297
|
+
ensure_equals("3rd stat succeeded",
|
298
|
+
stat.stat("test3.txt", &buf, 1),
|
299
|
+
0);
|
300
|
+
|
301
|
+
// The following should remove test.txt and test2.txt from the cache.
|
302
|
+
stat.setMaxSize(1);
|
303
|
+
|
304
|
+
touch("test.txt", 10);
|
305
|
+
touch("test2.txt", 11);
|
306
|
+
touch("test3.txt", 12);
|
307
|
+
|
308
|
+
ensure_equals("6th stat succeeded",
|
309
|
+
stat.stat("test3.txt", &buf, 1),
|
310
|
+
0);
|
311
|
+
ensure_equals("test3.txt is still in the cache",
|
312
|
+
buf.st_mtime,
|
313
|
+
(time_t) 3);
|
314
|
+
|
315
|
+
ensure_equals("4th stat succeeded",
|
316
|
+
stat.stat("test.txt", &buf, 1),
|
317
|
+
0);
|
318
|
+
ensure_equals("test.txt is removed from the cache",
|
319
|
+
buf.st_mtime,
|
320
|
+
(time_t) 10);
|
321
|
+
|
322
|
+
ensure_equals("5th stat succeeded",
|
323
|
+
stat.stat("test2.txt", &buf, 1),
|
324
|
+
0);
|
325
|
+
ensure_equals("test2.txt is removed from the cache",
|
326
|
+
buf.st_mtime,
|
327
|
+
(time_t) 11);
|
328
|
+
}
|
329
|
+
|
330
|
+
TEST_METHOD(14) {
|
331
|
+
// An initial cache size of 0 means that the cache size is unlimited.
|
332
|
+
SystemTime::force(1);
|
333
|
+
CachedFileStat stat(0);
|
334
|
+
|
335
|
+
touch("test.txt", 1);
|
336
|
+
touch("test2.txt", 2);
|
337
|
+
touch("test3.txt", 3);
|
338
|
+
stat.stat("test.txt", &buf, 1);
|
339
|
+
stat.stat("test2.txt", &buf, 1);
|
340
|
+
stat.stat("test3.txt", &buf, 1);
|
341
|
+
|
342
|
+
touch("test.txt", 11);
|
343
|
+
touch("test2.txt", 12);
|
344
|
+
touch("test3.txt", 13);
|
345
|
+
stat.stat("test.txt", &buf, 1);
|
346
|
+
ensure_equals(buf.st_mtime, (time_t) 1);
|
347
|
+
stat.stat("test2.txt", &buf, 1);
|
348
|
+
ensure_equals(buf.st_mtime, (time_t) 2);
|
349
|
+
stat.stat("test3.txt", &buf, 1);
|
350
|
+
ensure_equals(buf.st_mtime, (time_t) 3);
|
351
|
+
}
|
352
|
+
|
353
|
+
TEST_METHOD(15) {
|
354
|
+
// Setting the cache size dynamically to 0 makes the cache size unlimited.
|
355
|
+
SystemTime::force(1);
|
356
|
+
CachedFileStat stat(2);
|
357
|
+
|
358
|
+
touch("test.txt", 1);
|
359
|
+
touch("test2.txt", 2);
|
360
|
+
touch("test3.txt", 3);
|
361
|
+
stat.stat("test.txt", &buf, 1);
|
362
|
+
stat.stat("test2.txt", &buf, 1);
|
363
|
+
stat.stat("test3.txt", &buf, 1);
|
364
|
+
|
365
|
+
// test.txt is now no longer in the cache.
|
366
|
+
|
367
|
+
stat.setMaxSize(0);
|
368
|
+
touch("test.txt", 11);
|
369
|
+
touch("test2.txt", 12);
|
370
|
+
touch("test3.txt", 13);
|
371
|
+
stat.stat("test.txt", &buf, 1);
|
372
|
+
stat.stat("test2.txt", &buf, 1);
|
373
|
+
stat.stat("test3.txt", &buf, 1);
|
374
|
+
|
375
|
+
// test.txt should now have been re-statted while test2.txt
|
376
|
+
// and test3.txt are still cached.
|
377
|
+
|
378
|
+
stat.stat("test.txt", &buf, 1);
|
379
|
+
ensure_equals("test.txt is re-statted", buf.st_mtime, (time_t) 11);
|
380
|
+
stat.stat("test2.txt", &buf, 1);
|
381
|
+
ensure_equals("test2.txt is still cached", buf.st_mtime, (time_t) 2);
|
382
|
+
stat.stat("test3.txt", &buf, 1);
|
383
|
+
ensure_equals("test3.txt is still cached", buf.st_mtime, (time_t) 3);
|
384
|
+
}
|
385
|
+
|
386
|
+
TEST_METHOD(16) {
|
387
|
+
// Changing the cache size dynamically from 0 to non-0 works;
|
388
|
+
// it removes the oldest entries, if necessary.
|
389
|
+
CachedFileStat stat(0);
|
390
|
+
stat.stat("test.txt", &buf, 1);
|
391
|
+
stat.stat("test2.txt", &buf, 1);
|
392
|
+
stat.stat("test3.txt", &buf, 1);
|
393
|
+
stat.stat("test4.txt", &buf, 1);
|
394
|
+
stat.stat("test5.txt", &buf, 1);
|
395
|
+
stat.setMaxSize(2);
|
396
|
+
ensure(!stat.knows("test.txt"));
|
397
|
+
ensure(!stat.knows("test2.txt"));
|
398
|
+
ensure(!stat.knows("test3.txt"));
|
399
|
+
ensure(stat.knows("test4.txt"));
|
400
|
+
ensure(stat.knows("test5.txt"));
|
401
|
+
}
|
262
402
|
}
|