diff --git a/tests/Makefile.am b/tests/Makefile.am index 2941b34..59e5504 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -76,7 +76,14 @@ ETCP_FULL_OBJS = \ $(ETCP_CORE_OBJS) # Common libraries (libuasync.a from lib directory) -COMMON_LIBS = $(top_builddir)/lib/libuasync.a -lpthread +COMMON_LIBS = $(top_builddir)/lib/libuasync.a -lpthread $(WIN_LIBS) + +# Windows-specific libraries +if OS_WINDOWS +WIN_LIBS = -lws2_32 -liphlpapi +else +WIN_LIBS = +endif # Crypto libraries (conditional) if USE_OPENSSL diff --git a/tests/test_etcp_two_instances.c b/tests/test_etcp_two_instances.c index 8a4225c..4f742ca 100644 --- a/tests/test_etcp_two_instances.c +++ b/tests/test_etcp_two_instances.c @@ -11,7 +11,6 @@ #endif #include #include -#include #include "../src/etcp.h" #include "../src/etcp_connections.h" @@ -71,7 +70,7 @@ static const char* client_config_content = // Create temp config files static int create_temp_configs(void) { - if (test_mkdtemp(temp_dir) == NULL) { + if (test_mkdtemp(temp_dir) != 0) { fprintf(stderr, "Failed to create temp directory\n"); return -1; } diff --git a/tests/test_utils.h b/tests/test_utils.h index df50010..1d45c35 100644 --- a/tests/test_utils.h +++ b/tests/test_utils.h @@ -20,7 +20,6 @@ static char test_temp_dir[MAX_PATH]; // Cross-platform mkdtemp for Windows static inline int test_mkdtemp(char *template_str) { - (void)template_str; // Not used on Windows, we generate our own path char tmp_path[MAX_PATH]; GetTempPathA(MAX_PATH, tmp_path); @@ -31,9 +30,10 @@ static inline int test_mkdtemp(char *template_str) { snprintf(test_temp_dir, sizeof(test_temp_dir), "%s\\utun_test_%08x", tmp_path, (unsigned int)rand()); if (_mkdir(test_temp_dir) == 0) { - // Copy path back to caller's buffer + // Copy path back to caller's buffer if provided if (template_str) { - strncpy(template_str, test_temp_dir, MAX_PATH); + size_t len = strlen(test_temp_dir); + memcpy(template_str, test_temp_dir, len + 1); // Include null terminator } return 0; // Success }