Streamline hardening helpers and expand coverage
This commit is contained in:
+14
-8
@@ -31,10 +31,11 @@ RENDER(Request& context)
|
||||
bool write_ok = socket_write(sockfd, "GET /tests/index.uce HTTP/1.0\r\nHost: uce.openfu.com\r\n\r\n");
|
||||
String response = socket_read(sockfd, 4096, 2);
|
||||
socket_close(sockfd);
|
||||
bool has_nul = response.find(String("\0", 1)) != String::npos;
|
||||
mark(
|
||||
"socket_connect() / socket_write() / socket_read()",
|
||||
(write_ok && response.find("200 OK") != String::npos) ? "pass" : "fail",
|
||||
response.substr(0, response.length() > 220 ? 220 : response.length())
|
||||
(write_ok && response.find("200 OK") != String::npos && !has_nul) ? "pass" : "fail",
|
||||
response.substr(0, response.length() > 220 ? 220 : response.length()) + (has_nul ? " [unexpected NUL]" : "")
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -50,17 +51,22 @@ RENDER(Request& context)
|
||||
bool write_ok = socket_write(custom_http_sockfd, "GET /custom-test?alpha=1 HTTP/1.0\r\nHost: localhost\r\n\r\n");
|
||||
String response = socket_read(custom_http_sockfd, 4096, 2);
|
||||
socket_close(custom_http_sockfd);
|
||||
server_stop("site-tests-http");
|
||||
bool stopped = server_stop("site-tests-http");
|
||||
usleep(200000);
|
||||
u64 stopped_sockfd = socket_connect("127.0.0.1", 19091);
|
||||
bool listener_closed = stopped_sockfd == 0;
|
||||
if(stopped_sockfd != 0)
|
||||
socket_close(stopped_sockfd);
|
||||
mark(
|
||||
"server_start_http() / SERVE_HTTP:named",
|
||||
(custom_http_pid != 0 && write_ok && response.find("custom-http-named") != String::npos && response.find("query=alpha=1") != String::npos) ? "pass" : "fail",
|
||||
response.substr(0, response.length() > 260 ? 260 : response.length())
|
||||
"server_start_http() / SERVE_HTTP:named / server_stop()",
|
||||
(custom_http_pid != 0 && write_ok && response.find("custom-http-named") != String::npos && response.find("query=alpha=1") != String::npos && stopped && listener_closed) ? "pass" : "fail",
|
||||
response.substr(0, response.length() > 260 ? 260 : response.length()) + " stopped=" + (stopped ? "true" : "false") + " listener_closed=" + (listener_closed ? "true" : "false")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
server_stop("site-tests-http");
|
||||
mark("server_start_http() / SERVE_HTTP:named", "fail", "socket_connect(127.0.0.1, 19091) returned 0; pid=" + std::to_string(custom_http_pid));
|
||||
bool stopped = server_stop("site-tests-http");
|
||||
mark("server_start_http() / SERVE_HTTP:named / server_stop()", "fail", "socket_connect(127.0.0.1, 19091) returned 0; pid=" + std::to_string(custom_http_pid) + " stopped=" + (stopped ? "true" : "false"));
|
||||
}
|
||||
|
||||
u64 memfd = memcache_connect();
|
||||
|
||||
Reference in New Issue
Block a user