From 15e580aeaa0afabc8ca9f22b5d13801fb1243878 Mon Sep 17 00:00:00 2001 From: gxu Date: Sat, 18 Oct 2025 13:43:11 +0800 Subject: [PATCH 1/9] Add test preset for Visual Studio to detect test cases Signed-off-by: gxu --- CMakePresets.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index 9cf29c49..dd5858ce 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -116,6 +116,18 @@ "lhs": "${hostSystemName}", "rhs": "Linux" } + }, + { + "name": "windows-x64", + "configurePreset": "windows-x64", + "output": { + "outputOnFailure": true + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } } ] } From 3c43a268e4b074d5c3581973e43a75fba68cf7d4 Mon Sep 17 00:00:00 2001 From: gxu Date: Sat, 18 Oct 2025 13:44:38 +0800 Subject: [PATCH 2/9] Fix Build Errors on Windows Signed-off-by: gxu --- scaler/io/ymq/timed_queue.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scaler/io/ymq/timed_queue.h b/scaler/io/ymq/timed_queue.h index 6f1c5e35..a323e291 100644 --- a/scaler/io/ymq/timed_queue.h +++ b/scaler/io/ymq/timed_queue.h @@ -199,10 +199,10 @@ class TimedQueue { } } - Identifier push(Timestamp timestamp, Callback cb) + Configuration::ExecutionCancellationIdentifier push(Timestamp timestamp, Configuration::TimedQueueCallback cb) { auto ts = convertToLARGE_INTEGER(timestamp); - if (pq.empty() || timestamp < std::get<0>(pq.top())) { + if (pq.empty() || timestamp < pq.top().timestamp) { SetWaitableTimer( _timerFd, (LARGE_INTEGER*)&ts, @@ -218,16 +218,16 @@ class TimedQueue { return _currentId++; } - void cancelExecution(Identifier id) { _cancelledFunctions.insert(id); } + void cancelExecution(Configuration::ExecutionCancellationIdentifier id) { _cancelledFunctions.insert(id); } - std::vector dequeue() + std::vector dequeue() { - std::vector callbacks; + std::vector callbacks; Timestamp now; while (pq.size()) { - if (std::get<0>(pq.top()) < now) { - auto [ts, cb, id] = std::move(const_cast(pq.top())); + if (pq.top().timestamp < now) { + auto [ts, cb, id] = std::move(const_cast::reference>(pq.top())); pq.pop(); auto cancelled = _cancelledFunctions.find(id); if (cancelled != _cancelledFunctions.end()) { @@ -240,7 +240,7 @@ class TimedQueue { } if (!pq.empty()) { - auto nextTs = std::get<0>(pq.top()); + auto nextTs = pq.top().timestamp; auto ts = convertToLARGE_INTEGER(nextTs); SetWaitableTimer( _timerFd, @@ -258,9 +258,9 @@ class TimedQueue { private: HANDLE _timerFd; - Identifier _currentId; - PriorityQueue pq; - std::set _cancelledFunctions; + Configuration::ExecutionCancellationIdentifier _currentId; + std::priority_queue pq; + std::set _cancelledFunctions; }; #endif // _WIN32 From 2b0a0d2bc608075ff5f8d3918c3d6d779c781a8b Mon Sep 17 00:00:00 2001 From: gxu Date: Sat, 18 Oct 2025 13:45:58 +0800 Subject: [PATCH 3/9] Improve add_test_executable for Windows Signed-off-by: gxu --- tests/CMakeLists.txt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3fe97551..48cb56a9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,11 +20,10 @@ function(add_test_executable test_name source_file) target_include_directories(${test_name} PRIVATE ${CMAKE_BINARY_DIR}) - target_link_libraries(${test_name} PRIVATE - $<$:-Wl,-Bstatic> - object_storage_server_objs - ymq_objs + target_link_libraries(${test_name} PRIVATE $<$:-Wl,-Bdynamic> + $<$>:object_storage_server_objs> + ymq_objs CapnProto::capnp CapnProto::kj GTest::gtest_main @@ -32,6 +31,17 @@ function(add_test_executable test_name source_file) ) add_test(NAME ${test_name} COMMAND ${test_name}) + + # Post build: We need to copy if dll is not present, otherwise the test program won't find gtest.dll + # See https://stackoverflow.com/questions/69978314/cmake-with-gtest-on-windows-build-starts-test-but-shared-libs-cannot-be-found + if (WIN32) + add_custom_command(TARGET ${test_name} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + COMMAND_EXPAND_LISTS + ) + endif() endfunction() if(LINUX OR APPLE) From 7d03cbe1e9a6194a4217770cc55a090635a85e2e Mon Sep 17 00:00:00 2001 From: gxu Date: Sat, 18 Oct 2025 13:48:23 +0800 Subject: [PATCH 4/9] Remove redundant test directory Signed-off-by: gxu --- tests/CMakeLists.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 48cb56a9..dd5a8457 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,10 +44,6 @@ function(add_test_executable test_name source_file) endif() endfunction() -if(LINUX OR APPLE) - # Add the directory for the C++ tests. - add_subdirectory(cpp) +# Add the directory for the C++ tests. +add_subdirectory(cpp) - # Add the new directory for io tests. - add_subdirectory(io/ymq) -endif() From 8ec56dd4554b34bb2e7bd2018848e2297f96a018 Mon Sep 17 00:00:00 2001 From: gxu Date: Sat, 18 Oct 2025 13:49:42 +0800 Subject: [PATCH 5/9] Migrate and fixup logging test for Windows Signed-off-by: gxu --- tests/cpp/CMakeLists.txt | 7 +++++-- tests/cpp/ymq/CMakeLists.txt | 11 ++++++++++- .../test_logging.cpp => cpp/ymq/test_ymq_logging.cpp} | 4 ++++ tests/io/ymq/CMakeLists.txt | 1 - 4 files changed, 19 insertions(+), 4 deletions(-) rename tests/{io/ymq/test_logging.cpp => cpp/ymq/test_ymq_logging.cpp} (99%) delete mode 100644 tests/io/ymq/CMakeLists.txt diff --git a/tests/cpp/CMakeLists.txt b/tests/cpp/CMakeLists.txt index 6b6a872c..20d0ab8e 100644 --- a/tests/cpp/CMakeLists.txt +++ b/tests/cpp/CMakeLists.txt @@ -1,3 +1,6 @@ # this fetches Google Test, so it must be included first. -add_subdirectory(object_storage) -add_subdirectory(ymq) \ No newline at end of file +if(LINUX OR APPLE) + add_subdirectory(object_storage) +endif() + +add_subdirectory(ymq) diff --git a/tests/cpp/ymq/CMakeLists.txt b/tests/cpp/ymq/CMakeLists.txt index 86689d1d..f3608fdb 100644 --- a/tests/cpp/ymq/CMakeLists.txt +++ b/tests/cpp/ymq/CMakeLists.txt @@ -1 +1,10 @@ -add_test_executable(test_ymq test_ymq.cpp) +# We do NOT merge this two files into one for now because it's likely easier to have another test named test_windows_ymq +# Currently it does not support APPLE, nor does it support WIN32 +if(LINUX) + add_test_executable(test_ymq test_ymq.cpp) +endif() + +# Later if we decide to promote ymq logging module to a global one, rename this file to +# test_logging and move it to another directory +# Logging test is cross platformed, as it appears +add_test_executable(test_ymq_logging test_ymq_logging.cpp) diff --git a/tests/io/ymq/test_logging.cpp b/tests/cpp/ymq/test_ymq_logging.cpp similarity index 99% rename from tests/io/ymq/test_logging.cpp rename to tests/cpp/ymq/test_ymq_logging.cpp index 839bde65..c194f8d5 100644 --- a/tests/io/ymq/test_logging.cpp +++ b/tests/cpp/ymq/test_ymq_logging.cpp @@ -10,6 +10,10 @@ #include "scaler/io/ymq/logging.h" +#ifdef max +#undef max +#endif + // Test fixture for direct unit testing of the log() function's formatting class LoggingUnitTest: public ::testing::Test { protected: diff --git a/tests/io/ymq/CMakeLists.txt b/tests/io/ymq/CMakeLists.txt deleted file mode 100644 index e1001a1f..00000000 --- a/tests/io/ymq/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_test_executable(test_logging test_logging.cpp) \ No newline at end of file From e366afde7ab4f122d9e7a7c780735356d35ab664 Mon Sep 17 00:00:00 2001 From: gxu Date: Sat, 18 Oct 2025 13:44:08 +0800 Subject: [PATCH 6/9] Tmp fix bad logic on Windows Signed-off-by: gxu --- scaler/io/ymq/message_connection_tcp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scaler/io/ymq/message_connection_tcp.cpp b/scaler/io/ymq/message_connection_tcp.cpp index d09f2757..7f36a505 100644 --- a/scaler/io/ymq/message_connection_tcp.cpp +++ b/scaler/io/ymq/message_connection_tcp.cpp @@ -121,6 +121,7 @@ void MessageConnectionTCP::onCreated() if (lastError == ERROR_IO_PENDING) { return; } + unrecoverableError({ Error::ErrorCode::CoreBug, "Originated from", @@ -352,6 +353,10 @@ void MessageConnectionTCP::onRead() } #ifdef _WIN32 + // TODO: This need rewrite to better logic + if (!_connFd) { + return; + } const bool ok = ReadFile((HANDLE)(SOCKET)_connFd, nullptr, 0, nullptr, this->_eventManager.get()); if (ok) { onRead(); From 1162632e6316b76468c88d0800c902f4a898447c Mon Sep 17 00:00:00 2001 From: gxu Date: Sun, 19 Oct 2025 09:07:35 +0800 Subject: [PATCH 7/9] revert not build test_ymq on Windows Signed-off-by: gxu --- tests/cpp/ymq/CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/cpp/ymq/CMakeLists.txt b/tests/cpp/ymq/CMakeLists.txt index f3608fdb..5f9ada56 100644 --- a/tests/cpp/ymq/CMakeLists.txt +++ b/tests/cpp/ymq/CMakeLists.txt @@ -1,10 +1,3 @@ -# We do NOT merge this two files into one for now because it's likely easier to have another test named test_windows_ymq -# Currently it does not support APPLE, nor does it support WIN32 -if(LINUX) - add_test_executable(test_ymq test_ymq.cpp) -endif() +add_test_executable(test_ymq test_ymq.cpp) -# Later if we decide to promote ymq logging module to a global one, rename this file to -# test_logging and move it to another directory -# Logging test is cross platformed, as it appears add_test_executable(test_ymq_logging test_ymq_logging.cpp) From dc238069de91a2182fd64326868b18606803be81 Mon Sep 17 00:00:00 2001 From: gxu Date: Sun, 19 Oct 2025 11:08:39 +0800 Subject: [PATCH 8/9] Bump Version Number Signed-off-by: gxu --- scaler/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaler/version.txt b/scaler/version.txt index bece0d34..ea90c617 100644 --- a/scaler/version.txt +++ b/scaler/version.txt @@ -1 +1 @@ -1.12.18 +1.12.19 From f259c59655e3323f8495001e809406cd242a0a2c Mon Sep 17 00:00:00 2001 From: gxu Date: Sun, 19 Oct 2025 11:54:54 +0800 Subject: [PATCH 9/9] Remove dynamic link flag Signed-off-by: gxu --- tests/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dd5a8457..e8b99d8b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,7 +21,6 @@ function(add_test_executable test_name source_file) target_include_directories(${test_name} PRIVATE ${CMAKE_BINARY_DIR}) target_link_libraries(${test_name} PRIVATE - $<$:-Wl,-Bdynamic> $<$>:object_storage_server_objs> ymq_objs CapnProto::capnp