passenger 4.0.48 → 4.0.49
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.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +36 -2
- data/.travis.yml +1 -1
- data/CHANGELOG +16 -0
- data/Rakefile +0 -1
- data/build/apache2.rb +4 -4
- data/build/common_library.rb +18 -18
- data/build/cplusplus_support.rb +2 -2
- data/build/documentation.rb +1 -1
- data/build/integration_tests.rb +12 -4
- data/build/misc.rb +12 -7
- data/build/packaging.rb +14 -14
- data/build/preprocessor.rb +10 -10
- data/build/rake_extensions.rb +11 -11
- data/build/ruby_extension.rb +2 -2
- data/dev/ci/inituidgid +24 -0
- data/dev/ci/run_jenkins.sh +57 -0
- data/dev/ci/run_rpm_tests.sh +77 -0
- data/dev/{run_travis.sh → ci/run_travis.sh} +60 -4
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/users_guide_snippets/environment_variables.txt +0 -2
- data/doc/users_guide_snippets/tips.txt +20 -1
- data/ext/apache2/Bucket.cpp +18 -18
- data/ext/apache2/Bucket.h +4 -4
- data/ext/apache2/Configuration.cpp +7 -7
- data/ext/apache2/Configuration.hpp +43 -43
- data/ext/apache2/DirectoryMapper.h +5 -5
- data/ext/apache2/Hooks.cpp +142 -142
- data/ext/apache2/MergeDirConfig.cpp +40 -40
- data/ext/common/Account.h +17 -17
- data/ext/common/AccountsDatabase.h +9 -9
- data/ext/common/AgentsStarter.cpp +2 -2
- data/ext/common/AgentsStarter.h +40 -40
- data/ext/common/ApplicationPool2/Common.h +10 -6
- data/ext/common/ApplicationPool2/ComponentInfo.h +2 -2
- data/ext/common/ApplicationPool2/DirectSpawner.h +17 -17
- data/ext/common/ApplicationPool2/DummySpawner.h +5 -5
- data/ext/common/ApplicationPool2/Group.h +54 -38
- data/ext/common/ApplicationPool2/Implementation.cpp +76 -49
- data/ext/common/ApplicationPool2/Options.h +98 -91
- data/ext/common/ApplicationPool2/Pool.h +70 -69
- data/ext/common/ApplicationPool2/Process.h +21 -21
- data/ext/common/ApplicationPool2/Session.h +11 -11
- data/ext/common/ApplicationPool2/SmartSpawner.h +60 -60
- data/ext/common/ApplicationPool2/Socket.h +19 -19
- data/ext/common/ApplicationPool2/Spawner.h +64 -72
- data/ext/common/ApplicationPool2/SpawnerFactory.h +4 -4
- data/ext/common/ApplicationPool2/SuperGroup.h +41 -41
- data/ext/common/BackgroundEventLoop.cpp +1 -1
- data/ext/common/BackgroundEventLoop.h +2 -2
- data/ext/common/Constants.h +1 -1
- data/ext/common/EventedBufferedInput.h +5 -5
- data/ext/common/EventedClient.h +51 -51
- data/ext/common/EventedMessageServer.h +39 -39
- data/ext/common/EventedServer.h +32 -32
- data/ext/common/Exceptions.h +23 -23
- data/ext/common/FileDescriptor.h +18 -18
- data/ext/common/Logging.cpp +1 -1
- data/ext/common/MessageClient.h +27 -27
- data/ext/common/MessageReadersWriters.h +79 -79
- data/ext/common/MessageServer.h +59 -59
- data/ext/common/RandomGenerator.h +12 -12
- data/ext/common/ResourceLocator.h +8 -8
- data/ext/common/SafeLibev.h +54 -25
- data/ext/common/ServerInstanceDir.h +31 -31
- data/ext/common/StaticString.h +50 -48
- data/ext/common/Utils.cpp +73 -78
- data/ext/common/Utils.h +6 -6
- data/ext/common/Utils/Base64.cpp +3 -3
- data/ext/common/Utils/Base64.h +7 -7
- data/ext/common/Utils/BlockingQueue.h +9 -9
- data/ext/common/Utils/BufferedIO.h +17 -17
- data/ext/common/Utils/CachedFileStat.hpp +16 -16
- data/ext/common/Utils/Dechunker.h +25 -25
- data/ext/common/Utils/FileChangeChecker.h +10 -10
- data/ext/common/Utils/MemZeroGuard.h +5 -5
- data/ext/common/Utils/MemoryBarrier.h +1 -1
- data/ext/common/Utils/MessageIO.h +61 -61
- data/ext/common/Utils/ProcessMetricsCollector.h +40 -40
- data/ext/common/Utils/ScopeGuard.h +7 -7
- data/ext/common/Utils/SpeedMeter.h +1 -1
- data/ext/common/Utils/StrIntUtils.cpp +13 -13
- data/ext/common/Utils/StrIntUtils.h +3 -3
- data/ext/common/Utils/StringScanning.h +5 -5
- data/ext/common/Utils/SystemMetricsCollector.h +2 -2
- data/ext/common/Utils/SystemTime.h +10 -10
- data/ext/common/Utils/Template.h +2 -2
- data/ext/common/Utils/Timer.h +6 -6
- data/ext/common/Utils/VariantMap.h +29 -29
- data/ext/common/agents/Base.cpp +19 -19
- data/ext/common/agents/HelperAgent/AgentOptions.h +1 -1
- data/ext/common/agents/HelperAgent/FileBackedPipe.h +6 -6
- data/ext/common/agents/HelperAgent/Main.cpp +44 -43
- data/ext/common/agents/HelperAgent/RequestHandler.cpp +4 -4
- data/ext/common/agents/HelperAgent/RequestHandler.h +29 -28
- data/ext/common/agents/HelperAgent/ScgiRequestParser.h +56 -50
- data/ext/common/agents/LoggingAgent/AdminController.h +8 -8
- data/ext/common/agents/LoggingAgent/DataStoreId.h +17 -17
- data/ext/common/agents/LoggingAgent/FilterSupport.h +167 -167
- data/ext/common/agents/LoggingAgent/LoggingServer.h +122 -122
- data/ext/common/agents/LoggingAgent/Main.cpp +7 -7
- data/ext/common/agents/LoggingAgent/RemoteSender.h +54 -54
- data/ext/common/agents/SpawnPreparer.cpp +4 -4
- data/ext/common/agents/TempDirToucher.c +2 -2
- data/ext/common/agents/Watchdog/AgentWatcher.cpp +47 -47
- data/ext/common/agents/Watchdog/HelperAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/Main.cpp +22 -22
- data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +9 -9
- data/ext/libeio/eio.c +1 -1
- data/ext/nginx/Configuration.c +30 -30
- data/ext/nginx/Configuration.h +1 -1
- data/ext/nginx/ContentHandler.c +54 -54
- data/ext/nginx/ContentHandler.h +3 -3
- data/ext/nginx/StaticContentHandler.c +2 -2
- data/ext/nginx/ngx_http_passenger_module.c +21 -21
- data/ext/oxt/detail/backtrace_enabled.hpp +1 -1
- data/ext/oxt/detail/context.hpp +1 -1
- data/ext/oxt/detail/spin_lock_darwin.hpp +4 -4
- data/ext/oxt/detail/spin_lock_gcc_x86.hpp +3 -3
- data/ext/oxt/detail/spin_lock_pthreads.hpp +4 -4
- data/ext/oxt/detail/tracable_exception_disabled.hpp +1 -1
- data/ext/oxt/dynamic_thread_group.hpp +18 -18
- data/ext/oxt/implementation.cpp +9 -8
- data/ext/oxt/macros.hpp +2 -2
- data/ext/oxt/system_calls.cpp +11 -11
- data/ext/oxt/system_calls.hpp +13 -13
- data/ext/oxt/thread.hpp +22 -14
- data/ext/ruby/passenger_native_support.c +55 -55
- data/lib/phusion_passenger.rb +24 -24
- data/lib/phusion_passenger/common_library.rb +2 -0
- data/lib/phusion_passenger/loader_shared_helpers.rb +18 -18
- data/lib/phusion_passenger/packaging.rb +9 -4
- data/lib/phusion_passenger/platform_info/apache.rb +45 -31
- data/lib/phusion_passenger/platform_info/compiler.rb +11 -11
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
- data/lib/phusion_passenger/request_handler/thread_handler.rb +8 -8
- data/lib/phusion_passenger/standalone/app_finder.rb +16 -16
- data/lib/phusion_passenger/standalone/command.rb +22 -22
- data/packaging/rpm/LICENSE.txt +19 -0
- data/packaging/rpm/Makefile +13 -0
- data/packaging/rpm/README.md +41 -0
- data/packaging/rpm/Vagrantfile +38 -0
- data/{rpm/Vagrantfile → packaging/rpm/Vagrantfile.centos} +0 -0
- data/packaging/rpm/build +170 -0
- data/packaging/rpm/create_project +41 -0
- data/packaging/rpm/git_update +88 -0
- data/packaging/rpm/image/Dockerfile +37 -0
- data/packaging/rpm/image/Gemfile +3 -0
- data/packaging/rpm/image/Gemfile.lock +12 -0
- data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +19 -0
- data/packaging/rpm/image/amazon2014-i386.cfg +96 -0
- data/packaging/rpm/image/amazon2014-x86_64.cfg +96 -0
- data/packaging/rpm/image/site-defaults.cfg +168 -0
- data/packaging/rpm/internal/build_tasks.rb +238 -0
- data/packaging/rpm/internal/dummygpg +11 -0
- data/packaging/rpm/internal/exec_build +42 -0
- data/packaging/rpm/internal/get_distro_arch +14 -0
- data/packaging/rpm/internal/get_distro_id +10 -0
- data/packaging/rpm/internal/git_update +27 -0
- data/packaging/rpm/internal/inituidgid +17 -0
- data/packaging/rpm/internal/my_init +344 -0
- data/packaging/rpm/internal/python27 +3 -0
- data/packaging/rpm/internal/repo_update +46 -0
- data/packaging/rpm/internal/setuser +26 -0
- data/packaging/rpm/internal/tracking_helper +40 -0
- data/packaging/rpm/jenkins_release +99 -0
- data/packaging/rpm/lib/build_tasks_support.rb +402 -0
- data/packaging/rpm/lib/preprocessor.rb +341 -0
- data/packaging/rpm/nginx_spec/404.html +119 -0
- data/packaging/rpm/nginx_spec/50x.html +119 -0
- data/packaging/rpm/nginx_spec/index.html +116 -0
- data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +13 -0
- data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade +13 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade.8 +151 -0
- data/packaging/rpm/nginx_spec/nginx.conf +131 -0
- data/packaging/rpm/nginx_spec/nginx.init +144 -0
- data/packaging/rpm/nginx_spec/nginx.logrotate +13 -0
- data/packaging/rpm/nginx_spec/nginx.service +15 -0
- data/packaging/rpm/nginx_spec/nginx.spec.template +559 -0
- data/packaging/rpm/nginx_spec/nginx.sysconfig +4 -0
- data/packaging/rpm/nginx_spec/passenger.conf +9 -0
- data/packaging/rpm/nginx_spec/poweredby.png +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/apache-passenger.conf.in +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/config.json +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.logrotate +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.spec.template +58 -31
- data/{rpm → packaging/rpm/passenger_spec}/passenger_dynamic_thread_group.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger_tests_default_config_example.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-gcc47-include-sys_types.patch +0 -0
- data/packaging/rpm/repo_update +114 -0
- data/packaging/rpm/setup-system +60 -0
- data/packaging/rpm/shell +10 -0
- data/resources/templates/standalone/config.erb +3 -1
- data/test/config.json.rpm-automation +1 -1
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +11 -11
- data/test/cxx/ApplicationPool2/OptionsTest.cpp +5 -5
- data/test/cxx/ApplicationPool2/PoolTest.cpp +129 -89
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +15 -15
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +22 -22
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +11 -11
- data/test/cxx/ScgiRequestParserTest.cpp +75 -61
- data/test/cxx/UtilsTest.cpp +86 -85
- data/test/gdbinit.example +3 -0
- data/test/integration_tests/nginx_tests.rb +3 -3
- data/test/integration_tests/source_packaging_test.rb +3 -1
- data/test/stub/nginx/nginx.conf.erb +8 -1
- data/test/support/nginx_controller.rb +7 -7
- metadata +62 -17
- metadata.gz.asc +7 -7
- data/build/rpm.rb +0 -128
- data/dev/rpmtool +0 -21
- data/dev/test_rpm_packaging.sh +0 -28
- data/rpm/get_distro_id.py +0 -4
data/test/cxx/UtilsTest.cpp
CHANGED
@@ -18,31 +18,31 @@ namespace tut {
|
|
18
18
|
string cwd;
|
19
19
|
string oldPath;
|
20
20
|
TempDir tempDir;
|
21
|
-
|
21
|
+
|
22
22
|
UtilsTest(): tempDir("tmp.dir") {
|
23
23
|
char buffer[PATH_MAX];
|
24
24
|
cwd = getcwd(buffer, sizeof(buffer));
|
25
25
|
oldPath = getenv("PATH");
|
26
26
|
unsetenv("PASSENGER_TEMP_DIR");
|
27
27
|
}
|
28
|
-
|
28
|
+
|
29
29
|
~UtilsTest() {
|
30
30
|
setenv("PATH", oldPath.c_str(), 1);
|
31
31
|
unsetenv("PASSENGER_TEMP_DIR");
|
32
32
|
chdir(cwd.c_str());
|
33
33
|
}
|
34
|
-
|
34
|
+
|
35
35
|
void testMakeDirTreeMode(const char *name, const char *mode, mode_t expected) {
|
36
36
|
TempDir td("tmp.dir2");
|
37
37
|
struct stat buf;
|
38
38
|
mode_t allModes = S_IRWXU | S_ISUID | S_IRWXG | S_ISGID | S_IRWXO;
|
39
|
-
|
39
|
+
|
40
40
|
makeDirTree("tmp.dir2/foo", mode);
|
41
41
|
stat("tmp.dir2/foo", &buf);
|
42
42
|
ensure_equals(name, buf.st_mode & allModes, expected);
|
43
43
|
}
|
44
44
|
};
|
45
|
-
|
45
|
+
|
46
46
|
DEFINE_TEST_GROUP_WITH_LIMIT(UtilsTest, 100);
|
47
47
|
|
48
48
|
/***** Test split() *****/
|
@@ -54,7 +54,7 @@ namespace tut {
|
|
54
54
|
splitIncludeSep("", ':', output);
|
55
55
|
ensure_equals(output.size(), 0u);
|
56
56
|
}
|
57
|
-
|
57
|
+
|
58
58
|
TEST_METHOD(2) {
|
59
59
|
split("hello world", ':', output);
|
60
60
|
ensure_equals(output.size(), 1u);
|
@@ -64,7 +64,7 @@ namespace tut {
|
|
64
64
|
ensure_equals(output.size(), 1u);
|
65
65
|
ensure_equals(output[0], "hello world");
|
66
66
|
}
|
67
|
-
|
67
|
+
|
68
68
|
TEST_METHOD(3) {
|
69
69
|
split("hello world:foo bar", ':', output);
|
70
70
|
ensure_equals(output.size(), 2u);
|
@@ -76,7 +76,7 @@ namespace tut {
|
|
76
76
|
ensure_equals(output[0], "hello world:");
|
77
77
|
ensure_equals(output[1], "foo bar");
|
78
78
|
}
|
79
|
-
|
79
|
+
|
80
80
|
TEST_METHOD(4) {
|
81
81
|
split("hello world:", ':', output);
|
82
82
|
ensure_equals("(1)", output.size(), 2u);
|
@@ -87,7 +87,7 @@ namespace tut {
|
|
87
87
|
ensure_equals("(4)", output.size(), 1u);
|
88
88
|
ensure_equals("(5)", output[0], "hello world:");
|
89
89
|
}
|
90
|
-
|
90
|
+
|
91
91
|
TEST_METHOD(5) {
|
92
92
|
split(":hello world", ':', output);
|
93
93
|
ensure_equals(output.size(), 2u);
|
@@ -99,7 +99,7 @@ namespace tut {
|
|
99
99
|
ensure_equals(output[0], ":");
|
100
100
|
ensure_equals(output[1], "hello world");
|
101
101
|
}
|
102
|
-
|
102
|
+
|
103
103
|
TEST_METHOD(6) {
|
104
104
|
split("abc:def::ghi", ':', output);
|
105
105
|
ensure_equals(output.size(), 4u);
|
@@ -115,7 +115,7 @@ namespace tut {
|
|
115
115
|
ensure_equals(output[2], ":");
|
116
116
|
ensure_equals(output[3], "ghi");
|
117
117
|
}
|
118
|
-
|
118
|
+
|
119
119
|
TEST_METHOD(7) {
|
120
120
|
split("abc:::def", ':', output);
|
121
121
|
ensure_equals(output.size(), 4u);
|
@@ -131,36 +131,36 @@ namespace tut {
|
|
131
131
|
ensure_equals(output[2], ":");
|
132
132
|
ensure_equals(output[3], "def");
|
133
133
|
}
|
134
|
-
|
135
|
-
|
134
|
+
|
135
|
+
|
136
136
|
/***** Test getSystemTempDir() *****/
|
137
|
-
|
137
|
+
|
138
138
|
TEST_METHOD(11) {
|
139
139
|
// It returns "/tmp" if the PASSENGER_TEMP_DIR environment is NULL.
|
140
140
|
ensure_equals(string(getSystemTempDir()), "/tmp");
|
141
141
|
}
|
142
|
-
|
142
|
+
|
143
143
|
TEST_METHOD(12) {
|
144
144
|
// It returns "/tmp" if the PASSENGER_TEMP_DIR environment is an empty string.
|
145
145
|
setenv("PASSENGER_TEMP_DIR", "", 1);
|
146
146
|
ensure_equals(string(getSystemTempDir()), "/tmp");
|
147
147
|
}
|
148
|
-
|
148
|
+
|
149
149
|
TEST_METHOD(13) {
|
150
150
|
// It returns the value of the PASSENGER_TEMP_DIR environment if it is not NULL and not empty.
|
151
151
|
setenv("PASSENGER_TEMP_DIR", "/foo", 1);
|
152
152
|
ensure_equals(string(getSystemTempDir()), "/foo");
|
153
153
|
}
|
154
|
-
|
155
|
-
|
154
|
+
|
155
|
+
|
156
156
|
/***** Test BufferedUpload *****/
|
157
|
-
|
157
|
+
|
158
158
|
TEST_METHOD(20) {
|
159
159
|
// The resulting file handle is readable and writable.
|
160
160
|
TempDir td("utils_test.tmp");
|
161
161
|
BufferedUpload t("utils_test.tmp");
|
162
162
|
char line[30];
|
163
|
-
|
163
|
+
|
164
164
|
fprintf(t.handle, "hello world!");
|
165
165
|
fflush(t.handle);
|
166
166
|
fseek(t.handle, 0, SEEK_SET);
|
@@ -168,7 +168,7 @@ namespace tut {
|
|
168
168
|
fgets(line, sizeof(line), t.handle);
|
169
169
|
ensure_equals(string(line), "hello world!");
|
170
170
|
}
|
171
|
-
|
171
|
+
|
172
172
|
TEST_METHOD(21) {
|
173
173
|
// It immediately unlinks the temp file.
|
174
174
|
DONT_RUN_IN_VAGRANT();
|
@@ -176,9 +176,9 @@ namespace tut {
|
|
176
176
|
BufferedUpload t("utils_test.tmp");
|
177
177
|
ensure_equals(listDir("utils_test.tmp").size(), 0u);
|
178
178
|
}
|
179
|
-
|
179
|
+
|
180
180
|
/***** Test escapeForXml() *****/
|
181
|
-
|
181
|
+
|
182
182
|
TEST_METHOD(25) {
|
183
183
|
ensure_equals(escapeForXml(""), "");
|
184
184
|
ensure_equals(escapeForXml("hello world"), "hello world");
|
@@ -187,10 +187,11 @@ namespace tut {
|
|
187
187
|
ensure_equals(escapeForXml("hello\xFFworld"), "helloÿworld");
|
188
188
|
ensure_equals(escapeForXml("hello\xFF\xCCworld"), "helloÿÌworld");
|
189
189
|
ensure_equals(escapeForXml("hello\xFFworld\xCC"), "helloÿworldÌ");
|
190
|
+
ensure_equals(escapeForXml("hello\nworld"), "hello world");
|
190
191
|
}
|
191
|
-
|
192
|
+
|
192
193
|
/***** Test extractDirName() *****/
|
193
|
-
|
194
|
+
|
194
195
|
TEST_METHOD(26) {
|
195
196
|
ensure_equals("Test 1", extractDirName("/usr/lib"), "/usr");
|
196
197
|
ensure_equals("Test 2", extractDirName("/usr/lib/"), "/usr");
|
@@ -222,9 +223,9 @@ namespace tut {
|
|
222
223
|
ensure_equals("Test 12", extractDirNameStatic(".///"), ".");
|
223
224
|
ensure_equals("Test 13", extractDirNameStatic("foo//bar"), "foo");
|
224
225
|
}
|
225
|
-
|
226
|
+
|
226
227
|
/***** Test resolveSymlink() *****/
|
227
|
-
|
228
|
+
|
228
229
|
TEST_METHOD(28) {
|
229
230
|
TempDir d("tmp.symlinks");
|
230
231
|
runShellCommand("touch tmp.symlinks/foo.txt");
|
@@ -237,41 +238,41 @@ namespace tut {
|
|
237
238
|
ensure_equals(resolveSymlink("tmp.symlinks/file3"), "tmp.symlinks/file2");
|
238
239
|
ensure_equals(resolveSymlink("tmp.symlinks/absolute_symlink"), "/usr/bin");
|
239
240
|
}
|
240
|
-
|
241
|
+
|
241
242
|
/***** Test fillInMiddle() *****/
|
242
|
-
|
243
|
+
|
243
244
|
TEST_METHOD(30) {
|
244
245
|
ensure_equals(fillInMiddle(20, "server.", "123456", ".socket"), "server.123456.socket");
|
245
246
|
ensure_equals(fillInMiddle(25, "server.", "123456", ".socket"), "server.123456.socket");
|
246
247
|
ensure_equals(fillInMiddle(19, "server.", "123456", ".socket"), "server.12345.socket");
|
247
248
|
ensure_equals(fillInMiddle(16, "server.", "123456", ".socket"), "server.12.socket");
|
248
|
-
|
249
|
+
|
249
250
|
ensure_equals(fillInMiddle(10, "", "1234", ""), "1234");
|
250
251
|
ensure_equals(fillInMiddle(4, "", "1234", ""), "1234");
|
251
252
|
ensure_equals(fillInMiddle(2, "", "1234", ""), "12");
|
252
|
-
|
253
|
+
|
253
254
|
ensure_equals(fillInMiddle(20, "", "1234", ".socket"), "1234.socket");
|
254
255
|
ensure_equals(fillInMiddle(11, "", "1234", ".socket"), "1234.socket");
|
255
256
|
ensure_equals(fillInMiddle(9, "", "1234", ".socket"), "12.socket");
|
256
|
-
|
257
|
+
|
257
258
|
try {
|
258
259
|
fillInMiddle(14, "server.", "123456", ".socket");
|
259
260
|
fail();
|
260
261
|
} catch (const ArgumentException &) { }
|
261
|
-
|
262
|
+
|
262
263
|
try {
|
263
264
|
fillInMiddle(10, "server.", "123456", ".socket");
|
264
265
|
fail();
|
265
266
|
} catch (const ArgumentException &) { }
|
266
|
-
|
267
|
+
|
267
268
|
try {
|
268
269
|
fillInMiddle(10, "server.", "", ".socket");
|
269
270
|
fail();
|
270
271
|
} catch (const ArgumentException &) { }
|
271
272
|
}
|
272
|
-
|
273
|
+
|
273
274
|
/***** Test MemZeroGuard *****/
|
274
|
-
|
275
|
+
|
275
276
|
TEST_METHOD(31) {
|
276
277
|
char buf[12] = "hello world";
|
277
278
|
{
|
@@ -279,7 +280,7 @@ namespace tut {
|
|
279
280
|
}
|
280
281
|
ensure(memcmp(buf, "\0\0llo world", sizeof(buf)) == 0);
|
281
282
|
}
|
282
|
-
|
283
|
+
|
283
284
|
TEST_METHOD(32) {
|
284
285
|
string str("hello ");
|
285
286
|
{
|
@@ -288,7 +289,7 @@ namespace tut {
|
|
288
289
|
}
|
289
290
|
ensure(memcmp(str.c_str(), "\0\0\0\0\0\0\0\0\0\0\0", 11) == 0);
|
290
291
|
}
|
291
|
-
|
292
|
+
|
292
293
|
TEST_METHOD(33) {
|
293
294
|
string str("hello ");
|
294
295
|
{
|
@@ -300,9 +301,9 @@ namespace tut {
|
|
300
301
|
}
|
301
302
|
ensure(memcmp(str.c_str(), "\0\0\0\0\0\0\0\0\0\0\0", 11) == 0);
|
302
303
|
}
|
303
|
-
|
304
|
+
|
304
305
|
/***** Test parseModeString() *****/
|
305
|
-
|
306
|
+
|
306
307
|
static bool modeStringCannotBeParsed(const StaticString &modeString) {
|
307
308
|
try {
|
308
309
|
parseModeString(modeString);
|
@@ -311,7 +312,7 @@ namespace tut {
|
|
311
312
|
return true;
|
312
313
|
}
|
313
314
|
}
|
314
|
-
|
315
|
+
|
315
316
|
TEST_METHOD(36) {
|
316
317
|
ensure_equals(parseModeString(""), (mode_t) 0);
|
317
318
|
ensure_equals(parseModeString("u="), (mode_t) 0);
|
@@ -321,7 +322,7 @@ namespace tut {
|
|
321
322
|
ensure_equals(parseModeString("u=,g=,o=,u=,g="), (mode_t) 0);
|
322
323
|
ensure_equals(parseModeString("o="), (mode_t) 0);
|
323
324
|
}
|
324
|
-
|
325
|
+
|
325
326
|
TEST_METHOD(37) {
|
326
327
|
ensure_equals("(1)", parseModeString("u=rwx"), (mode_t) S_IRWXU);
|
327
328
|
ensure_equals("(2)", parseModeString("g=rwx"), (mode_t) S_IRWXG);
|
@@ -337,7 +338,7 @@ namespace tut {
|
|
337
338
|
ensure_equals("(7)", parseModeString("u=rwx,g=rwx,+t"),
|
338
339
|
(mode_t) (S_IRWXU | S_IRWXG | S_ISVTX));
|
339
340
|
}
|
340
|
-
|
341
|
+
|
341
342
|
TEST_METHOD(38) {
|
342
343
|
ensure(modeStringCannotBeParsed("0"));
|
343
344
|
ensure(modeStringCannotBeParsed("0600"));
|
@@ -347,31 +348,31 @@ namespace tut {
|
|
347
348
|
ensure(modeStringCannotBeParsed("x=rs"));
|
348
349
|
ensure(modeStringCannotBeParsed("rwxrwxrwx"));
|
349
350
|
}
|
350
|
-
|
351
|
+
|
351
352
|
/***** Test makeDirTree() *****/
|
352
|
-
|
353
|
+
|
353
354
|
TEST_METHOD(40) {
|
354
355
|
// Creating a single subdirectory works.
|
355
356
|
makeDirTree("tmp.dir/foo");
|
356
357
|
ensure_equals(getFileType("tmp.dir/foo"), FT_DIRECTORY);
|
357
358
|
}
|
358
|
-
|
359
|
+
|
359
360
|
TEST_METHOD(41) {
|
360
361
|
// Creating multiple subdirectories works.
|
361
362
|
makeDirTree("tmp.dir/foo/bar");
|
362
363
|
ensure_equals(getFileType("tmp.dir/foo"), FT_DIRECTORY);
|
363
364
|
ensure_equals(getFileType("tmp.dir/foo/bar"), FT_DIRECTORY);
|
364
365
|
}
|
365
|
-
|
366
|
+
|
366
367
|
TEST_METHOD(42) {
|
367
368
|
// It applies the permissions to all created directories.
|
368
369
|
struct stat buf, buf2;
|
369
|
-
|
370
|
+
|
370
371
|
stat("tmp.dir", &buf);
|
371
372
|
makeDirTree("tmp.dir/foo/bar", "u=rwxs,g=,o=rx");
|
372
373
|
stat("tmp.dir", &buf2);
|
373
374
|
ensure_equals(buf.st_mode, buf2.st_mode);
|
374
|
-
|
375
|
+
|
375
376
|
stat("tmp.dir/foo", &buf);
|
376
377
|
stat("tmp.dir/foo/bar", &buf2);
|
377
378
|
ensure_equals(buf.st_mode, buf2.st_mode);
|
@@ -379,7 +380,7 @@ namespace tut {
|
|
379
380
|
(mode_t) (S_IRUSR | S_IWUSR | S_IXUSR | S_ISUID |
|
380
381
|
S_IROTH | S_IXOTH));
|
381
382
|
}
|
382
|
-
|
383
|
+
|
383
384
|
TEST_METHOD(43) {
|
384
385
|
// It correctly parses the permission string.
|
385
386
|
testMakeDirTreeMode("empty 1", "", (mode_t) 0);
|
@@ -388,7 +389,7 @@ namespace tut {
|
|
388
389
|
testMakeDirTreeMode("empty 4", "o=", (mode_t) 0);
|
389
390
|
testMakeDirTreeMode("empty 5", "u=,g=", (mode_t) 0);
|
390
391
|
testMakeDirTreeMode("empty 6", "g=,o=", (mode_t) 0);
|
391
|
-
|
392
|
+
|
392
393
|
testMakeDirTreeMode("(1)", "u=rwxs,g=rwxs,o=rwx",
|
393
394
|
S_IRWXU | S_ISUID | S_IRWXG | S_ISGID | S_IRWXO);
|
394
395
|
testMakeDirTreeMode("(2)", "u=s,g=rx,o=w",
|
@@ -396,7 +397,7 @@ namespace tut {
|
|
396
397
|
testMakeDirTreeMode("(3)", "u=rwxs,g=,o=rwx",
|
397
398
|
S_IRWXU | S_ISUID | S_IRWXO);
|
398
399
|
}
|
399
|
-
|
400
|
+
|
400
401
|
TEST_METHOD(44) {
|
401
402
|
// It doesn't do anything if the directory already exists.
|
402
403
|
struct stat buf, buf2;
|
@@ -405,9 +406,9 @@ namespace tut {
|
|
405
406
|
stat("tmp.dir", &buf2);
|
406
407
|
ensure_equals(buf.st_mode, buf2.st_mode);
|
407
408
|
}
|
408
|
-
|
409
|
+
|
409
410
|
/***** Test stringToULL(), stringToUint *****/
|
410
|
-
|
411
|
+
|
411
412
|
TEST_METHOD(47) {
|
412
413
|
ensure_equals(stringToULL(""), 0ull);
|
413
414
|
ensure_equals(stringToULL("bla"), 0ull);
|
@@ -420,7 +421,7 @@ namespace tut {
|
|
420
421
|
ensure_equals(stringToULL("2937104"), 2937104ull);
|
421
422
|
ensure_equals(stringToULL("18446744073709551615"), 18446744073709551615ull);
|
422
423
|
ensure_equals(stringToULL(" 5abcdef1234"), 5ull);
|
423
|
-
|
424
|
+
|
424
425
|
ensure_equals(stringToUint(""), 0u);
|
425
426
|
ensure_equals(stringToUint("bla"), 0u);
|
426
427
|
ensure_equals(stringToUint("0"), 0u);
|
@@ -432,55 +433,55 @@ namespace tut {
|
|
432
433
|
ensure_equals(stringToUint("2937104"), 2937104u);
|
433
434
|
ensure_equals(stringToUint(" 5abcdef1234"), 5u);
|
434
435
|
}
|
435
|
-
|
436
|
+
|
436
437
|
/***** Test integerToHex() and integerToHexatri() *****/
|
437
|
-
|
438
|
+
|
438
439
|
TEST_METHOD(48) {
|
439
440
|
char buf[sizeof(int) * 2 + 1];
|
440
|
-
|
441
|
+
|
441
442
|
ensure_equals("(1)", integerToHex<int>(0x0, buf), 1u);
|
442
443
|
ensure("(1)", strcmp(buf, "0") == 0);
|
443
|
-
|
444
|
+
|
444
445
|
ensure_equals("(2)", integerToHex<int>(0x1, buf), 1u);
|
445
446
|
ensure("(2)", strcmp(buf, "1") == 0);
|
446
|
-
|
447
|
+
|
447
448
|
ensure_equals("(3)", integerToHex<int>(0x9, buf), 1u);
|
448
449
|
ensure("(3)", strcmp(buf, "9") == 0);
|
449
|
-
|
450
|
+
|
450
451
|
ensure_equals("(4)", integerToHex<int>(0xe, buf), 1u);
|
451
452
|
ensure("(4)", strcmp(buf, "e") == 0);
|
452
|
-
|
453
|
+
|
453
454
|
ensure_equals("(5)", integerToHex<unsigned int>(0xdeadbeef, buf), 8u);
|
454
455
|
ensure("(5)", strcmp(buf, "deadbeef") == 0);
|
455
|
-
|
456
|
+
|
456
457
|
ensure_equals("(6)", integerToHex<int>(0x1234f, buf), 5u);
|
457
458
|
ensure("(6)", strcmp(buf, "1234f") == 0);
|
458
|
-
|
459
|
-
|
459
|
+
|
460
|
+
|
460
461
|
ensure_equals("(7)", integerToHexatri<int>(0x0, buf), 1u);
|
461
462
|
ensure("(7)", strcmp(buf, "0") == 0);
|
462
|
-
|
463
|
+
|
463
464
|
ensure_equals("(8)", integerToHexatri<int>(0x1, buf), 1u);
|
464
465
|
ensure("(8)", strcmp(buf, "1") == 0);
|
465
|
-
|
466
|
+
|
466
467
|
ensure_equals("(9)", integerToHexatri<int>(0x9, buf), 1u);
|
467
468
|
ensure("(9)", strcmp(buf, "9") == 0);
|
468
|
-
|
469
|
+
|
469
470
|
ensure_equals("(10)", integerToHexatri<int>(0xe, buf), 1u);
|
470
471
|
ensure("(10)", strcmp(buf, "e") == 0);
|
471
|
-
|
472
|
+
|
472
473
|
ensure_equals("(11)", integerToHexatri<int>(35, buf), 1u);
|
473
474
|
ensure("(11)", strcmp(buf, "z") == 0);
|
474
|
-
|
475
|
+
|
475
476
|
ensure_equals(integerToHexatri<unsigned int>(0xdeadbeef, buf), 7u);
|
476
477
|
ensure(strcmp(buf, "1ps9wxb") == 0);
|
477
|
-
|
478
|
+
|
478
479
|
ensure_equals(integerToHexatri<int>(0x1234f, buf), 4u);
|
479
480
|
ensure(strcmp(buf, "1ljj") == 0);
|
480
481
|
}
|
481
|
-
|
482
|
+
|
482
483
|
/***** Test hexToULL(), hexToUint() and hexatriToULL() *****/
|
483
|
-
|
484
|
+
|
484
485
|
TEST_METHOD(49) {
|
485
486
|
ensure_equals(hexToULL(""), 0ull);
|
486
487
|
ensure_equals(hexToULL(" "), 0ull);
|
@@ -496,7 +497,7 @@ namespace tut {
|
|
496
497
|
ensure_equals(hexToULL("dEaDbEeF"), 3735928559ull);
|
497
498
|
ensure_equals(hexToULL("09a2s89"), 2466ull);
|
498
499
|
ensure_equals(hexToULL(" 9a2s89"), 0ull);
|
499
|
-
|
500
|
+
|
500
501
|
ensure_equals(hexToUint(""), 0u);
|
501
502
|
ensure_equals(hexToUint(" "), 0u);
|
502
503
|
ensure_equals(hexToUint("1"), 1u);
|
@@ -511,7 +512,7 @@ namespace tut {
|
|
511
512
|
ensure_equals(hexToUint("dEaDbEeF"), 3735928559u);
|
512
513
|
ensure_equals(hexToUint("09a2s89"), 2466u);
|
513
514
|
ensure_equals(hexToUint(" 9a2s89"), 0u);
|
514
|
-
|
515
|
+
|
515
516
|
ensure_equals(hexatriToULL(""), 0ull);
|
516
517
|
ensure_equals(hexatriToULL(" "), 0ull);
|
517
518
|
ensure_equals(hexatriToULL("1"), 1ull);
|
@@ -527,9 +528,9 @@ namespace tut {
|
|
527
528
|
ensure_equals(hexatriToULL("09a2s89"), 561121641ull);
|
528
529
|
ensure_equals(hexatriToULL(" 9a2s89"), 0ull);
|
529
530
|
}
|
530
|
-
|
531
|
+
|
531
532
|
/***** Test stringToLL(), stringToInt() *****/
|
532
|
-
|
533
|
+
|
533
534
|
TEST_METHOD(50) {
|
534
535
|
ensure_equals(stringToLL(""), 0ll);
|
535
536
|
ensure_equals(stringToLL("bla"), 0ll);
|
@@ -542,14 +543,14 @@ namespace tut {
|
|
542
543
|
ensure_equals(stringToLL("2937104"), 2937104ll);
|
543
544
|
ensure_equals(stringToLL("9223372036854775807"), 9223372036854775807ll);
|
544
545
|
ensure_equals(stringToLL(" 5abcdef1234"), 5ll);
|
545
|
-
|
546
|
+
|
546
547
|
ensure_equals(stringToLL("-0"), 0ll);
|
547
548
|
ensure_equals(stringToLL("-1"), -1ll);
|
548
549
|
ensure_equals(stringToLL("-010"), -10ll);
|
549
550
|
ensure_equals(stringToLL("-9876"), -9876ll);
|
550
551
|
ensure_equals(stringToLL("-9223372036854775807"), -9223372036854775807ll);
|
551
552
|
ensure_equals(stringToLL(" -5abcdef1234"), -5ll);
|
552
|
-
|
553
|
+
|
553
554
|
ensure_equals(stringToInt(""), 0);
|
554
555
|
ensure_equals(stringToInt("bla"), 0);
|
555
556
|
ensure_equals(stringToInt("0"), 0);
|
@@ -560,16 +561,16 @@ namespace tut {
|
|
560
561
|
ensure_equals(stringToInt("928"), 928);
|
561
562
|
ensure_equals(stringToInt("2937104"), 2937104);
|
562
563
|
ensure_equals(stringToInt(" 5abcdef1234"), 5);
|
563
|
-
|
564
|
+
|
564
565
|
ensure_equals(stringToInt("-0"), 0ll);
|
565
566
|
ensure_equals(stringToInt("-1"), -1ll);
|
566
567
|
ensure_equals(stringToInt("-010"), -10ll);
|
567
568
|
ensure_equals(stringToInt("-9876"), -9876);
|
568
569
|
ensure_equals(stringToInt(" -5abcdef1234"), -5);
|
569
570
|
}
|
570
|
-
|
571
|
+
|
571
572
|
/***** Test cEscapeString() *****/
|
572
|
-
|
573
|
+
|
573
574
|
TEST_METHOD(51) {
|
574
575
|
ensure_equals(cEscapeString(""), "");
|
575
576
|
ensure_equals(cEscapeString("abcdXYZ123!?"), "abcdXYZ123!?");
|
@@ -579,9 +580,9 @@ namespace tut {
|
|
579
580
|
"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t");
|
580
581
|
ensure_equals(cEscapeString("\xFF\xFE\t\xD0"), "\\xFF\\xFE\\t\\xD0");
|
581
582
|
}
|
582
|
-
|
583
|
+
|
583
584
|
/***** Test escapeHTML() *****/
|
584
|
-
|
585
|
+
|
585
586
|
TEST_METHOD(52) {
|
586
587
|
const char weird[] = "Weird \x01\x00 characters?";
|
587
588
|
ensure_equals(escapeHTML(""), "");
|
@@ -655,7 +656,7 @@ namespace tut {
|
|
655
656
|
ensure("(7)", !constantTimeCompare("ab", "cd"));
|
656
657
|
ensure("(8)", !constantTimeCompare("ab", "abc"));
|
657
658
|
ensure("(9)", !constantTimeCompare("ab", "abcd"));
|
658
|
-
|
659
|
+
|
659
660
|
ensure("(10)", !constantTimeCompare("a", ""));
|
660
661
|
ensure("(11)", !constantTimeCompare("abcd", ""));
|
661
662
|
ensure("(12)", !constantTimeCompare("cd", "ab"));
|