Windows: full module parity and runtime-qualified test suite
- Net/IO: Winsock sockets (UdpSocket, TlsClientStream, WebSocketClient), HttpServer port with a loopback wake socket replacing eventfd, and the select-based IO backend built on Windows (ws2_32). - Net: implement StaticFileResolver::open_safe and OpenedStaticFile on Windows (reparse-point rejection plus canonical containment check on the opened handle) and widen native handles to intptr_t. - Plugin: hot reload works on Windows by loading a fresh copy while the old DLL stays mapped; enable the reload, discovery and FSM service reload tests and retire the plugin file by rename instead of replacement. - Update: activation pointer as a directory junction on Windows. - Stacktrace: portable path comparison for wide native strings. - Docs/targets: every module allowlisted on Windows; record the Wine run (2000 tests, 1977 passed, 23 skipped, 0 failed). - CMake: add -Wa,-mbig-obj for GNU MinGW targets (COFF section limit). - Async: fix the FuturePool stopped-after-close test to wait for the executor to release its admission slot instead of racing it. Windows and Linux suites both pass: Windows 2000/1977/23 skips/0 failed, Linux 2027/2023/4 skips/0 failed.
This commit is contained in:
1 parent
1b1947340f
commit
b3c959b920
32 files changed
+1836
-401
No files matched your search
@@ -9,10 +9,57 @@
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <process.h>
|
||||
#ifndef MSG_NOSIGNAL
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
inline int test_close_socket(int fd) noexcept
|
||||
{
|
||||
return ::closesocket(static_cast<SOCKET>(fd));
|
||||
}
|
||||
inline int test_last_socket_error() noexcept
|
||||
{
|
||||
return ::WSAGetLastError();
|
||||
}
|
||||
inline bool test_interrupted(int code) noexcept
|
||||
{
|
||||
return code == WSAEINTR;
|
||||
}
|
||||
inline int test_getpid() noexcept
|
||||
{
|
||||
return ::_getpid();
|
||||
}
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
inline int test_close_socket(int fd) noexcept
|
||||
{
|
||||
return ::close(fd);
|
||||
}
|
||||
inline int test_last_socket_error() noexcept
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
inline bool test_interrupted(int code) noexcept
|
||||
{
|
||||
return code == EINTR;
|
||||
}
|
||||
inline int test_getpid() noexcept
|
||||
{
|
||||
return ::getpid();
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
@@ -29,7 +76,7 @@ namespace Void::Testing::NetSupport
|
||||
{
|
||||
static unsigned counter = 0;
|
||||
auto path = std::filesystem::temp_directory_path() /
|
||||
(std::string{prefix} + std::to_string(::getpid()) + "_" +
|
||||
(std::string{prefix} + std::to_string(test_getpid()) + "_" +
|
||||
std::to_string(counter++));
|
||||
std::filesystem::create_directories(path);
|
||||
return path;
|
||||
@@ -97,12 +144,12 @@ namespace Void::Testing::NetSupport
|
||||
|
||||
const auto cert_path = dir / (std::string{"cert_"} + tag + ".pem");
|
||||
const auto key_path = dir / (std::string{"key_"} + tag + ".pem");
|
||||
FILE* cf = std::fopen(cert_path.c_str(), "wb");
|
||||
FILE* cf = std::fopen(cert_path.string().c_str(), "wb");
|
||||
Void::Testing::require(cf != nullptr);
|
||||
Void::Testing::require(PEM_write_X509(cf, cert.get()) == 1);
|
||||
std::fclose(cf);
|
||||
|
||||
FILE* kf = std::fopen(key_path.c_str(), "wb");
|
||||
FILE* kf = std::fopen(key_path.string().c_str(), "wb");
|
||||
Void::Testing::require(kf != nullptr);
|
||||
Void::Testing::require(PEM_write_PrivateKey(
|
||||
kf, pkey.get(), nullptr, nullptr, 0,
|
||||
@@ -121,7 +168,8 @@ namespace Void::Testing::NetSupport
|
||||
fd = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
Void::Testing::require(fd >= 0);
|
||||
int yes = 1;
|
||||
::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes,
|
||||
::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
reinterpret_cast<const char*>(&yes),
|
||||
sizeof(yes));
|
||||
sockaddr_in address{};
|
||||
address.sin_family = AF_INET;
|
||||
@@ -144,23 +192,23 @@ namespace Void::Testing::NetSupport
|
||||
~LoopbackListener()
|
||||
{
|
||||
if (fd >= 0) {
|
||||
::close(fd);
|
||||
(void)test_close_socket(fd);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] int accept_one() const
|
||||
{
|
||||
return ::accept(fd, nullptr, nullptr);
|
||||
return static_cast<int>(::accept(fd, nullptr, nullptr));
|
||||
}
|
||||
};
|
||||
|
||||
inline bool write_all(int fd, std::string_view data)
|
||||
{
|
||||
while (!data.empty()) {
|
||||
const ssize_t written =
|
||||
const std::ptrdiff_t written =
|
||||
::send(fd, data.data(), data.size(), MSG_NOSIGNAL);
|
||||
if (written <= 0) {
|
||||
if (written < 0 && errno == EINTR) {
|
||||
if (written < 0 && test_interrupted(test_last_socket_error())) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
@@ -178,7 +226,7 @@ namespace Void::Testing::NetSupport
|
||||
while (buffer.find(delimiter) == std::string::npos &&
|
||||
buffer.size() <= max_bytes) {
|
||||
char chunk[1024];
|
||||
const ssize_t count = ::recv(fd, chunk, sizeof(chunk), 0);
|
||||
const std::ptrdiff_t count = ::recv(fd, chunk, sizeof(chunk), 0);
|
||||
if (count <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user