Fix Windows test failures: proper WSAPoll error handling and FD_SETSIZE check
This commit is contained in:
1 parent
7e30aa6347
commit
d74937e754
5 files changed
+77
-78
No files matched your search
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def find_c_h_files(dirs):
|
||||
files = []
|
||||
for d in dirs:
|
||||
for root, _, filenames in os.walk(d):
|
||||
for fname in filenames:
|
||||
if fname.endswith('.c') or fname.endswith('.h'):
|
||||
files.append(os.path.join(root, fname))
|
||||
return sorted(files)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python gen_filelist.py <dir1> [dir2] ...")
|
||||
sys.exit(1)
|
||||
dirs = sys.argv[1:]
|
||||
files = find_c_h_files(dirs)
|
||||
with open('filelist.txt', 'w') as f:
|
||||
for file in files:
|
||||
f.write(file + '\n')
|
||||
print(f"Generated filelist.txt with {len(files)} files.")
|
||||
+5
-1
@@ -438,7 +438,11 @@ err_t uasync_cancel_timeout(struct UASYNC* ua, void* t_id) {
|
||||
|
||||
// Instance version
|
||||
void* uasync_add_socket(struct UASYNC* ua, int fd, socket_callback_t read_cbk, socket_callback_t write_cbk, socket_callback_t except_cbk, void* user_data) {
|
||||
if (!ua || fd < 0 || fd >= FD_SETSIZE) return NULL; // Bounds check
|
||||
if (!ua || fd < 0) return NULL;
|
||||
// FD_SETSIZE check only for POSIX systems - Windows sockets can have any value
|
||||
#ifndef _WIN32
|
||||
if (fd >= FD_SETSIZE) return NULL;
|
||||
#endif
|
||||
|
||||
int index = socket_array_add(ua->sockets, fd, read_cbk, write_cbk, except_cbk, user_data);
|
||||
if (index < 0) return NULL;
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
ar: модификатор «u» игнорируется, так как по умолчанию используется «D» (смотрите «U»)
|
||||
utun_instance.c: In function ‘utun_instance_destroy’:
|
||||
utun_instance.c:98:17: warning: implicit declaration of function ‘conn_destroy’; did you mean ‘uasync_destroy’? [-Wimplicit-function-declaration]
|
||||
98 | conn_destroy(instance->connections[i]);
|
||||
| ^~~~~~~~~~~~
|
||||
| uasync_destroy
|
||||
utun_instance.c: In function ‘tun_read_callback’:
|
||||
utun_instance.c:237:21: warning: implicit declaration of function ‘conn_send’ [-Wimplicit-function-declaration]
|
||||
237 | if (conn_send(route.next_hop, buffer, nread) < 0) {
|
||||
| ^~~~~~~~~
|
||||
utun_instance.c: In function ‘utun_instance_unregister_sockets’:
|
||||
utun_instance.c:276:57: warning: passing argument 2 of ‘uasync_remove_socket’ makes pointer from integer without a cast [-Wint-conversion]
|
||||
276 | uasync_remove_socket(instance->ua, instance->tun.fd);
|
||||
| ~~~~~~~~~~~~~^~~
|
||||
| |
|
||||
| int
|
||||
In file included from utun_instance.c:8:
|
||||
../lib/u_async.h:35:48: note: expected ‘void *’ but argument is of type ‘int’
|
||||
35 | err_t uasync_remove_socket(uasync_t* ua, void* s_id);
|
||||
| ~~~~~~^~~~
|
||||
etcp_connections.c: In function ‘etcp_link_send_init’:
|
||||
etcp_connections.c:223:5: warning: implicit declaration of function ‘sc_get_public_key’; did you mean ‘sc_set_peer_public_key’? [-Wimplicit-function-declaration]
|
||||
223 | sc_get_public_key(sc, pubkey);
|
||||
| ^~~~~~~~~~~~~~~~~
|
||||
| sc_set_peer_public_key
|
||||
etcp_connections.c: In function ‘init_connections’:
|
||||
etcp_connections.c:432:29: warning: initialization of ‘struct config *’ from incompatible pointer type ‘struct utun_config *’ [-Wincompatible-pointer-types]
|
||||
432 | struct config* config = instance->config;
|
||||
| ^~~~~~~~
|
||||
etcp_connections.c:433:42: error: invalid use of undefined type ‘struct config’
|
||||
433 | instance->connections = calloc(config->server_count, sizeof(conn_handle_t*));
|
||||
| ^~
|
||||
etcp_connections.c:438:31: error: invalid use of undefined type ‘struct config’
|
||||
438 | for (int i = 0; i < config->server_count; i++) {
|
||||
| ^~
|
||||
etcp_connections.c:439:47: error: invalid use of undefined type ‘struct config’
|
||||
439 | struct server_config* server = &config->servers[i];
|
||||
| ^~
|
||||
etcp_connections.c:442:30: warning: implicit declaration of function ‘parse_ip_port’ [-Wimplicit-function-declaration]
|
||||
442 | uint16_t bind_port = parse_ip_port(server->addr, bind_ip_str, sizeof(bind_ip_str));
|
||||
| ^~~~~~~~~~~~~
|
||||
etcp_connections.c:485:43: warning: assignment to ‘struct ETCP_SOCKET *’ from incompatible pointer type ‘struct ETCP_CONNECTIONS *’ [-Wincompatible-pointer-types]
|
||||
485 | instance->first_listen_socket = conns;
|
||||
| ^
|
||||
etcp_connections.c:489:35: error: invalid use of undefined type ‘struct config’
|
||||
489 | for (int j = 0; j < config->client_count; j++) {
|
||||
| ^~
|
||||
etcp_connections.c:490:51: error: invalid use of undefined type ‘struct config’
|
||||
490 | struct client_config* client = &config->clients[j];
|
||||
| ^~
|
||||
make[2]: *** [Makefile:626: utun-etcp_connections.o] Ошибка 1
|
||||
make[1]: *** [Makefile:433: all-recursive] Ошибка 1
|
||||
make: *** [Makefile:353: all] Ошибка 2
|
||||
@@ -0,0 +1,63 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo Running all tests...
|
||||
echo.
|
||||
|
||||
set passed=0
|
||||
set failed=0
|
||||
set skipped=0
|
||||
set total=0
|
||||
|
||||
for %%t in (
|
||||
test_etcp_crypto
|
||||
test_crypto
|
||||
test_etcp_two_instances
|
||||
test_etcp_simple_traffic
|
||||
test_etcp_minimal
|
||||
test_etcp_100_packets
|
||||
test_pkt_normalizer_etcp
|
||||
test_pkt_normalizer_standalone
|
||||
test_etcp_api
|
||||
test_ll_queue
|
||||
test_ecc_encrypt
|
||||
test_intensive_memory_pool
|
||||
test_memory_pool_and_config
|
||||
test_packet_dump
|
||||
test_u_async_comprehensive
|
||||
test_u_async_performance
|
||||
test_debug_categories
|
||||
test_config_debug
|
||||
test_route_lib
|
||||
test_bgp_route_exchange
|
||||
test_routing_mesh
|
||||
bench_timeout_heap
|
||||
bench_uasync_timeouts
|
||||
) do (
|
||||
set /a total+=1
|
||||
if exist "tests\%%t.exe" (
|
||||
echo [RUN] %%t
|
||||
tests\%%t.exe > tests\%%t.log 2>&1
|
||||
if !errorlevel! equ 0 (
|
||||
echo [PASS] %%t
|
||||
set /a passed+=1
|
||||
) else (
|
||||
echo [FAIL] %%t
|
||||
set /a failed+=1
|
||||
echo Failed test log for %%t:
|
||||
type tests\%%t.log
|
||||
echo.
|
||||
)
|
||||
) else (
|
||||
echo [SKIP] %%t (not built)
|
||||
set /a skipped+=1
|
||||
)
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ==========================================
|
||||
echo Test Results: %passed% passed, %failed% failed, %skipped% skipped (%total% total)
|
||||
echo ==========================================
|
||||
|
||||
if %failed% gtr 0 exit /b 1
|
||||
exit /b 0
|
||||
@@ -15,6 +15,7 @@
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/socket_compat.h"
|
||||
#include "../src/config_parser.h"
|
||||
|
||||
// Temp config file path
|
||||
@@ -69,9 +70,16 @@ static void cleanup_temp_config(void) {
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Initialize socket platform (required for getaddrinfo on Windows)
|
||||
if (socket_platform_init() != 0) {
|
||||
fprintf(stderr, "Failed to initialize socket platform\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create temp config file first
|
||||
if (create_temp_config() != 0) {
|
||||
fprintf(stderr, "Failed to create temporary config file\n");
|
||||
socket_platform_cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -124,5 +132,6 @@ int main() {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "=== Тест завершен ===");
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "Проверьте файл /tmp/utun_debug.log для записанных сообщений");
|
||||
|
||||
socket_platform_cleanup();
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user