Windows: qualify ConfigurationAsync, MCP, Resilience, ResilienceAsync, Script, LogConfig, FunctionalCoreFormatting and SystemAsync
- AsyncWatcher: implement Windows path probing (size, mtime, type, symlink target through std::filesystem) - it was a no-op, so polling watchers never observed changes. - ConfigurationAsync test: poll until the asynchronous file event is delivered instead of assuming one poll. - SystemAsync shutdown test: skip on Windows (POSIX process helper). Windows cross build under Wine 11 (x86_64-w64-mingw32 GCC 16.2): 1178 tests, 1162 passed, 16 skipped, 0 failed.
This commit is contained in:
1 parent
c6ba2f42b5
commit
8510ea197f
4 files changed
+62
-3
No files matched your search
@@ -49,7 +49,15 @@ set(VOID_WINDOWS_MODULES
|
||||
Async
|
||||
Binary
|
||||
Configuration
|
||||
ConfigurationAsync
|
||||
Containers
|
||||
FunctionalCoreFormatting
|
||||
LogConfig
|
||||
MCP
|
||||
Resilience
|
||||
ResilienceAsync
|
||||
Script
|
||||
SystemAsync
|
||||
Core
|
||||
Crypto
|
||||
Data
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
@@ -90,7 +91,43 @@ struct PathSnapshot {
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)path;
|
||||
// Windows: the same fields through std::filesystem (no device/inode
|
||||
// identity; size, mtime and type drive change detection).
|
||||
std::error_code ec;
|
||||
const auto status = std::filesystem::symlink_status(path, ec);
|
||||
if (ec) {
|
||||
snap.sys_errno = ec.value();
|
||||
snap.permission_denied = ec == std::errc::permission_denied;
|
||||
return snap;
|
||||
}
|
||||
snap.exists = std::filesystem::exists(status);
|
||||
if (!snap.exists) {
|
||||
snap.sys_errno = ENOENT;
|
||||
return snap;
|
||||
}
|
||||
snap.is_symlink = std::filesystem::is_symlink(status);
|
||||
if (std::filesystem::is_directory(status)) {
|
||||
snap.mode = 0040755U; // S_IFDIR | 0755
|
||||
} else {
|
||||
snap.mode = 0100644U; // S_IFREG | 0644
|
||||
snap.size = std::filesystem::file_size(path, ec);
|
||||
if (ec) {
|
||||
snap.size = 0;
|
||||
ec.clear();
|
||||
}
|
||||
}
|
||||
const auto mtime = std::filesystem::last_write_time(path, ec);
|
||||
if (!ec) {
|
||||
snap.mtime_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
mtime.time_since_epoch())
|
||||
.count();
|
||||
}
|
||||
if (snap.is_symlink) {
|
||||
const auto target = std::filesystem::read_symlink(path, ec);
|
||||
if (!ec) {
|
||||
snap.symlink_target = target.string();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return snap;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdexcept>
|
||||
#include <stop_token>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace void_cfg_async_test
|
||||
@@ -316,8 +317,18 @@ Void::Testing::Test config_async_watcher_coalescing_and_prepare_external()
|
||||
Void::FileSystem::write_file(cfg_path,
|
||||
R"({"host":"watched","port":8099})")
|
||||
.has_value());
|
||||
watcher.poll_once();
|
||||
(void)exec.drain();
|
||||
// File events are asynchronous (inotify on Linux, ReadDirectoryChangesW
|
||||
// on Windows): poll until the reload is delivered.
|
||||
bool reloaded = false;
|
||||
for (int attempt = 0; attempt < 200 && !reloaded; ++attempt) {
|
||||
watcher.poll_once();
|
||||
(void)exec.drain();
|
||||
reloaded = ctrl->current().values->host == "watched";
|
||||
if (!reloaded) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{5});
|
||||
}
|
||||
}
|
||||
Void::Testing::expect(reloaded);
|
||||
Void::Testing::expect_eq(ctrl->current().values->host,
|
||||
std::string{"watched"});
|
||||
Void::Testing::expect_eq(ctrl->current().values->port, 8099);
|
||||
|
||||
@@ -125,6 +125,9 @@ public:
|
||||
|
||||
Void::Testing::Test systemasync_driver_shutdown_pending_pipe_read_retains_and_delivers_once()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Void::Testing::skip("POSIX process helper is not available on Windows");
|
||||
#endif
|
||||
ScopedTempDir dir;
|
||||
require(dir.valid());
|
||||
const auto path = dir.file("pipe_gate.bin");
|
||||
|
||||
Reference in new issue
Block a user