From cc9d03297177eb8504c7353db673b9dc6f64ea07 Mon Sep 17 00:00:00 2001 From: Michael Grunder Date: Thu, 2 Apr 2020 22:41:34 -0700 Subject: Win32 tests and timeout fix (#776) Unit tests in Windows and a Windows timeout fix This commit gets our unit tests compiling and running on Windows as well as removes a duplicated `timeval` -> `DWORD` conversion logic in sockcompat.c There are minor differences in behavior between Linux and Windows to note: 1. In Windows, opening a non-existent hangs forever in WSAPoll whereas it correctly returns with a "Connection refused" error on Linux. For that reason, I simply skip this test in Windows. It may be related to this known issue: https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ 2. Timeouts are handled slightly differently in Windows and Linux. In Linux, we intentionally set REDIS_ERR_IO for connection timeouts whereas in Windows we set REDIS_ERR_TIMEOUT. It may be prudent to fix this discrepancy although there are almost certainly users relying on the current behavior. --- CMakeLists.txt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 564c138..48e5920 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,17 +33,10 @@ SET(hiredis_sources sockcompat.c alloc.c) -IF(WIN32) - SET(hiredis_sources - ${hiredis_sources} - hiredis.def - ) -ENDIF() - ADD_LIBRARY(hiredis SHARED ${hiredis_sources}) SET_TARGET_PROPERTIES(hiredis - PROPERTIES + PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE VERSION "${HIREDIS_SONAME}") IF(WIN32 OR MINGW) TARGET_LINK_LIBRARIES(hiredis PRIVATE ws2_32) @@ -87,7 +80,7 @@ IF(ENABLE_SSL) DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ENDIF() -IF(NOT (DISABLE_TESTS OR (WIN32 OR MINGW))) +IF(NOT DISABLE_TESTS) ENABLE_TESTING() ADD_EXECUTABLE(hiredis-test test.c) TARGET_LINK_LIBRARIES(hiredis-test hiredis) -- cgit v1.2.3