Windows: portability fixes for IPC, SystemAsync and MCP tests
- IPC: map poll() onto WSAPoll and link ws2_32 on Windows (the module's remaining POSIX socket surface still needs a dedicated port). - SystemAsync: define the non-ANSI SIGTERM/SIGKILL values the Windows process backend interprets itself. - MCP tests: stdio transport cases skip on Windows instead of being compiled out (the scanner cannot evaluate #if guards). - SystemAsync tests: mark the POSIX process-helper suite with @requires-posix. Refs #65
This commit is contained in:
1 parent
ea285d1c65
commit
c6ba2f42b5
6 files changed
+34
-2
No files matched your search
@@ -1,12 +1,24 @@
|
|||||||
#include <Void/IPC/Transport.hpp>
|
#include <Void/IPC/Transport.hpp>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
// MinGW's winsock2.h defines struct pollfd and the POLL* flags; WSAPoll is
|
||||||
|
// the Windows equivalent of poll(2).
|
||||||
|
inline int poll(struct pollfd* descriptors,
|
||||||
|
unsigned long count,
|
||||||
|
int timeout)
|
||||||
|
{
|
||||||
|
return ::WSAPoll(descriptors, count, timeout);
|
||||||
|
}
|
||||||
|
#else
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
void_add_module(IPC
|
void_add_module(IPC
|
||||||
INTERNAL_DEPS Core Functional Memory Time Binary Async IO Resilience
|
INTERNAL_DEPS Core Functional Memory Time Binary Async IO Resilience
|
||||||
|
DEPS_WIN32 ws2_32
|
||||||
)
|
)
|
||||||
@@ -5,6 +5,15 @@
|
|||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
// MinGW's <signal.h> only defines the ANSI signals; the Windows process
|
||||||
|
// backend interprets these values itself.
|
||||||
|
#ifndef SIGTERM
|
||||||
|
#define SIGTERM 15
|
||||||
|
#endif
|
||||||
|
#ifndef SIGKILL
|
||||||
|
#define SIGKILL 9
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|||||||
@@ -292,9 +292,11 @@ Void::Testing::Test mcp_line_framer_bounds_and_crlf()
|
|||||||
std::string{"first\nsecond"});
|
std::string{"first\nsecond"});
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
Void::Testing::Test mcp_stdio_framing_dispatch_and_parse_error()
|
Void::Testing::Test mcp_stdio_framing_dispatch_and_parse_error()
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
Void::Testing::skip("POSIX pipe-based stdio transport");
|
||||||
|
#else
|
||||||
int input[2]{};
|
int input[2]{};
|
||||||
int output[2]{};
|
int output[2]{};
|
||||||
Void::Testing::require(::pipe(input) == 0);
|
Void::Testing::require(::pipe(input) == 0);
|
||||||
@@ -344,10 +346,14 @@ Void::Testing::Test mcp_stdio_framing_dispatch_and_parse_error()
|
|||||||
Void::Testing::require(error_response->error.has_value());
|
Void::Testing::require(error_response->error.has_value());
|
||||||
Void::Testing::expect_eq(error_response->error->code,
|
Void::Testing::expect_eq(error_response->error->code,
|
||||||
std::int32_t{-32700});
|
std::int32_t{-32700});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Void::Testing::Test mcp_stdio_cancellation_and_slow_reader()
|
Void::Testing::Test mcp_stdio_cancellation_and_slow_reader()
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
Void::Testing::skip("POSIX pipe-based stdio transport");
|
||||||
|
#else
|
||||||
// Cancellation while waiting on an empty, non-blocking input pipe.
|
// Cancellation while waiting on an empty, non-blocking input pipe.
|
||||||
{
|
{
|
||||||
int input[2]{};
|
int input[2]{};
|
||||||
@@ -408,8 +414,8 @@ Void::Testing::Test mcp_stdio_cancellation_and_slow_reader()
|
|||||||
::close(output[0]);
|
::close(output[0]);
|
||||||
::close(output[1]);
|
::close(output[1]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
Void::Testing::Test mcp_legacy_session_fixtures()
|
Void::Testing::Test mcp_legacy_session_fixtures()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @requires-posix: drives the POSIX process helper and descriptor semantics.
|
||||||
#include <Void/Async/Executor.hpp>
|
#include <Void/Async/Executor.hpp>
|
||||||
#include <Void/Async/TaskScope.hpp>
|
#include <Void/Async/TaskScope.hpp>
|
||||||
#include <Void/IO/Driver.hpp>
|
#include <Void/IO/Driver.hpp>
|
||||||
|
|||||||
@@ -224,6 +224,9 @@ Void::Testing::Test systemasync_driver_shutdown_pending_pipe_read_retains_and_de
|
|||||||
|
|
||||||
// Unblock file worker and kill child -> Driver shutdown completes and delivers once.
|
// Unblock file worker and kill child -> Driver shutdown completes and delivers once.
|
||||||
sys.gate.open();
|
sys.gate.open();
|
||||||
|
#ifndef SIGKILL
|
||||||
|
#define SIGKILL 9
|
||||||
|
#endif
|
||||||
(void)child.child().send_signal(SIGKILL);
|
(void)child.child().send_signal(SIGKILL);
|
||||||
auto rep2 = drv.shutdown(
|
auto rep2 = drv.shutdown(
|
||||||
Void::Async::OperationOptions{
|
Void::Async::OperationOptions{
|
||||||
|
|||||||
Reference in new issue
Block a user