Tests: build the pure-C ABI plugin fixtures on Windows

The V1 fixture gets a small pthread/nanosleep shim over
_beginthreadex and CRITICAL_SECTION, so the C ABI hardening suite
runs on Windows too (+5 tests). The fixture block is no longer
gated to non-Windows.
This commit is contained in:
faumaray committed 2026-12-06 16:54:41 +03:00
1 parent 7cddcf15ea
commit 7d9884d86b
4 files changed
+92 -9

No files matched your search

+4 -4
View File
@@ -109,7 +109,7 @@ recognized and configured like Linux; musl-specific behaviour (subprocess
| Language | C++26, reflection `yes` |
| Runtime | Wine 11.0 (`wine64`), no native Windows runner available |
| Modules | all modules under `src/` (`VOID_WINDOWS_MODULES` in `cmake/Targets.cmake`) |
| Observed | configure, compile, `cmake --install`, consume (`TargetProfile.exe` linked); each module's suite is verified under Wine before it is allowlisted. Full allowlisted set in one Debug shared binary (MinGW-w64 GCC 16.2.0) under Wine 11: **2003 tests, 1988 passed, 15 skipped, 0 failed** |
| Observed | configure, compile, `cmake --install`, consume (`TargetProfile.exe` linked); each module's suite is verified under Wine before it is allowlisted. Full allowlisted set in one Debug shared binary (MinGW-w64 GCC 16.2.0) under Wine 11: **2008 tests, 1993 passed, 15 skipped, 0 failed** |
Notes from the runtime run:
@@ -150,9 +150,9 @@ Notes from the runtime run:
libsodium, and `ShortUrlRemote` links the Windows `Net` client/server.
- Plugin hot-reload and discovery tests run on Windows: a new generation is
loaded from a fresh copy while the old DLL stays mapped, and the plugin file
is retired by rename instead of in-place replacement. The C ABI plugin
fixtures remain POSIX-only, and the reload-under-load stress test is still
gated.
is retired by rename instead of in-place replacement. The pure-C ABI fixture
suite also runs there (the V1 fixture carries a small pthread shim), and the
reload-under-load stress test is still gated.
- `Observability` links after replacing the namespace-scope
`inline thread_local` hook stack with a function-local `thread_local`
accessor (MinGW emitted duplicate TLS init functions).
+2 -4
View File
@@ -327,9 +327,8 @@ if(TARGET VoidTests AND TARGET Void::Plugin)
add_dependencies(VoidTests VoidServicePluginV1 VoidServicePluginV2)
endif()
# The pure-C ABI fixtures use pthreads/nanosleep; they are POSIX-only for
# now (the C++ plugin fixtures above still cover Plugin on Windows).
if(NOT WIN32)
# The pure-C ABI fixtures build on every platform (the V1 fixture carries
# a small pthread shim for Windows); they are loaded through the C ABI.
enable_language(C)
function(_void_add_cabi_fixture target_name source_file)
add_library(${target_name} SHARED "${CMAKE_CURRENT_SOURCE_DIR}/plugins/${source_file}")
@@ -385,5 +384,4 @@ if(TARGET VoidTests AND TARGET Void::Plugin)
"VOID_CABI_CYC_A_PATH=\"$<TARGET_FILE:VoidCAbiCycA>\""
"VOID_CABI_CYC_B_PATH=\"$<TARGET_FILE:VoidCAbiCycB>\""
)
endif() # NOT WIN32
endif()
+86
View File
@@ -2,7 +2,12 @@
#include <Void/Plugin/CAbi.h>
#if defined(_WIN32)
#include <process.h>
#include <windows.h>
#else
#include <pthread.h>
#endif
#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
@@ -10,6 +15,87 @@
#include <string.h>
#include <time.h>
#if defined(_WIN32)
// Minimal pthread/nanosleep surface for the fixture: one worker thread per
// operation and a CRITICAL_SECTION for the operation table.
typedef HANDLE pthread_t;
typedef CRITICAL_SECTION pthread_mutex_t;
typedef struct {
void* (*fn)(void*);
void* arg;
} void_thread_start;
static unsigned __stdcall void_thread_trampoline(void* raw)
{
void_thread_start* start = (void_thread_start*)raw;
void* (*fn)(void*) = start->fn;
void* arg = start->arg;
free(start);
return (unsigned)(uintptr_t)fn(arg);
}
static int pthread_mutex_init(pthread_mutex_t* mutex, const void* attr)
{
(void)attr;
InitializeCriticalSection(mutex);
return 0;
}
static void pthread_mutex_destroy(pthread_mutex_t* mutex)
{
DeleteCriticalSection(mutex);
}
static void pthread_mutex_lock(pthread_mutex_t* mutex)
{
EnterCriticalSection(mutex);
}
static void pthread_mutex_unlock(pthread_mutex_t* mutex)
{
LeaveCriticalSection(mutex);
}
static int pthread_create(pthread_t* thread, const void* attr,
void* (*fn)(void*), void* arg)
{
(void)attr;
void_thread_start* start = (void_thread_start*)malloc(sizeof(*start));
if (start == NULL) {
return -1;
}
start->fn = fn;
start->arg = arg;
const uintptr_t handle = _beginthreadex(NULL, 0, void_thread_trampoline,
start, 0, NULL);
if (handle == 0) {
free(start);
return -1;
}
*thread = (HANDLE)handle;
return 0;
}
static int pthread_join(pthread_t thread, void** result)
{
WaitForSingleObject(thread, INFINITE);
CloseHandle(thread);
if (result != NULL) {
*result = NULL;
}
return 0;
}
static void nanosleep(const struct timespec* request,
struct timespec* remaining)
{
(void)remaining;
Sleep((DWORD)(request->tv_sec * 1000 +
request->tv_nsec / 1000000));
}
#endif
typedef struct cabi_calc_v1 {
uint32_t (*version)(void_module_handle* h);
int32_t (*accumulate)(void_module_handle* h, int32_t delta);
@@ -1,7 +1,6 @@
#include <Void/Plugin/CAbi.h>
#include <Void/Plugin/CAbiAdapter.hpp>
#include <Void/Plugin/Host.hpp>
// @requires-posix: C ABI plugin fixtures use pthreads/nanosleep.
#include <Void/Plugin/Manager.hpp>
#include <Void/System/TempDir.hpp>
#include <Void/Testing/Assert.hpp>