Fix remaining Windows test build issues
- Remove sys/socket.h include from test_etcp_two_instances.c (Linux-only) - Fix test_mkdtemp buffer overflow - use memcpy instead of strncpy - Fix test_mkdtemp return value check (replace == NULL with != 0) - Add Windows socket libraries (-lws2_32 -liphlpapi) to test builds - All tests build successfully on Linux
This commit is contained in:
1 parent
4d486c7017
commit
27f2edca40
3 files changed
+12
-6
No files matched your search
+8
-1
@@ -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
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
+3
-3
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user