Browse Source

фиксы тестов (winsock)

nodeinfo-routing-update
jeka 1 month ago
parent
commit
fcdd07ba94
  1. 11
      tests/bench_uasync_timeouts.c
  2. 2
      tests/test_bgp_route_exchange.c
  3. 2
      tests/test_etcp_100_packets.c
  4. 2
      tests/test_etcp_api.c
  5. 2
      tests/test_etcp_simple_traffic.c
  6. 2
      tests/test_etcp_two_instances.c
  7. 2
      tests/test_ll_queue.c
  8. 2
      tests/test_memory_pool_and_config.c
  9. 2
      tests/test_pkt_normalizer_etcp.c
  10. 4
      tests/test_pkt_normalizer_standalone.c
  11. 2
      tests/test_routing_mesh.c
  12. 16
      tests/test_u_async_comprehensive.c
  13. 5
      tests/test_u_async_performance.c

11
tests/bench_uasync_timeouts.c

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <time.h>
#include "../lib/platform_compat.h"
#include "../lib/socket_compat.h"
#include <stdint.h>
@ -48,6 +49,8 @@ static void benchmark_without_sockets(void) {
printf("=== Test 1: Zero timeouts WITHOUT sockets ===\n\n");
socket_platform_init();
ua = uasync_create();
if (!ua) {
fprintf(stderr, "Failed to create uasync\n");
@ -103,6 +106,8 @@ static void benchmark_with_sockets(void) {
printf("=== Test 2: Zero timeouts WITH %d sockets ===\n\n", NUM_SOCKETS);
socket_platform_init();
ua = uasync_create();
if (!ua) {
fprintf(stderr, "Failed to create uasync\n");
@ -187,6 +192,8 @@ static void benchmark_with_sockets(void) {
}
int main(void) {
socket_platform_init();
double set_time_no_sockets = 0, mainloop_time_no_sockets = 0;
double set_time_with_sockets = 0, mainloop_time_with_sockets = 0;
@ -203,6 +210,8 @@ int main(void) {
printf("=== Test 1: Zero timeouts WITHOUT sockets ===\n\n");
socket_platform_init();
ua = uasync_create();
if (!ua) {
fprintf(stderr, "Failed to create uasync\n");
@ -243,6 +252,8 @@ int main(void) {
printf("=== Test 2: Zero timeouts WITH %d sockets ===\n\n", NUM_SOCKETS);
socket_platform_init();
ua = uasync_create();
if (!ua) {
fprintf(stderr, "Failed to create uasync\n");

2
tests/test_bgp_route_exchange.c

@ -35,6 +35,7 @@
#include "../src/tun_if.h"
#include "../src/secure_channel.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/debug_config.h"
#define TEST_TIMEOUT_MS 5000 // 5 seconds timeout
@ -345,6 +346,7 @@ int main() {
}
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_INFO);
debug_set_categories(DEBUG_CATEGORY_ROUTING | DEBUG_CATEGORY_ETCP | DEBUG_CATEGORY_BGP);

2
tests/test_etcp_100_packets.c

@ -20,6 +20,7 @@
#include "../src/tun_if.h"
#include "../src/secure_channel.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
#include "../lib/debug_config.h"
@ -395,6 +396,7 @@ int main() {
memset(received_packets_back, 0, sizeof(received_packets_back));
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_DEBUG);
debug_set_categories(DEBUG_CATEGORY_ETCP);

2
tests/test_etcp_api.c

@ -31,6 +31,7 @@
#include "../src/secure_channel.h"
#include "../src/pkt_normalizer.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
#include "../lib/debug_config.h"
@ -549,6 +550,7 @@ int main() {
total_bytes, (float)total_bytes / TOTAL_PACKETS / 1024);
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_WARN);
debug_set_categories(DEBUG_CATEGORY_ALL);

2
tests/test_etcp_simple_traffic.c

@ -20,6 +20,7 @@
#include "../src/tun_if.h"
#include "../src/secure_channel.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
#include "../lib/debug_config.h"
@ -361,6 +362,7 @@ int main() {
// Enable debug output - MAXIMUM DEBUGGING
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_TRACE);
debug_set_categories(DEBUG_CATEGORY_ALL);
debug_enable_function_name(1);

2
tests/test_etcp_two_instances.c

@ -20,6 +20,7 @@
#include "../src/tun_if.h"
#include "../src/secure_channel.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/debug_config.h"
#define TEST_TIMEOUT_MS 3000 // Reduced to 3 seconds for faster testing
@ -252,6 +253,7 @@ int main() {
}
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_TRACE);
debug_set_categories(DEBUG_CATEGORY_ALL);

2
tests/test_ll_queue.c

@ -12,6 +12,7 @@
#include "../lib/ll_queue.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/debug_config.h"
#include "../lib/memory_pool.h"
@ -273,6 +274,7 @@ static void test_stress(void) {
/* ------------------------------------------------------------------ */
int main(void) {
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_DEBUG);
debug_set_categories(DEBUG_CATEGORY_LL_QUEUE);

2
tests/test_memory_pool_and_config.c

@ -12,6 +12,7 @@
#include "../lib/ll_queue.h"
#include "../lib/memory_pool.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/debug_config.h"
static int test_callback_count = 0;
@ -28,6 +29,7 @@ static void test_waiter_callback(struct ll_queue* q, void* arg) {
int main() {
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_TRACE);
debug_set_categories(DEBUG_CATEGORY_ALL);

2
tests/test_pkt_normalizer_etcp.c

@ -21,6 +21,7 @@
#include "../src/secure_channel.h"
#include "../src/pkt_normalizer.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
#include "../lib/debug_config.h"
@ -522,6 +523,7 @@ int main() {
total_bytes, (float)total_bytes / TOTAL_PACKETS / 1024);
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_WARN);
// debug_set_level(DEBUG_LEVEL_DEBUG);
// debug_set_level(DEBUG_LEVEL_TRACE);

4
tests/test_pkt_normalizer_standalone.c

@ -7,6 +7,7 @@
#include "../lib/debug_config.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/ll_queue.h"
#include "../lib/memory_pool.h"
#include "../src/pkt_normalizer.h"
@ -252,7 +253,8 @@ int main() {
debug_set_level(DEBUG_LEVEL_INFO);
debug_enable_category(DEBUG_CATEGORY_ETCP);
// Initialize UASYNC
// Initialize Winsock and UASYNC
socket_platform_init();
mock_instance.ua = uasync_create();
if (!mock_instance.ua) {
printf("Failed to create UASYNC\n");

2
tests/test_routing_mesh.c

@ -20,6 +20,7 @@
#include "../src/tun_if.h"
#include "../src/secure_channel.h"
#include "../lib/u_async.h"
#include "../lib/socket_compat.h"
#include "../lib/debug_config.h"
#define TEST_TIMEOUT_MS 10000 // 10 seconds timeout
@ -339,6 +340,7 @@ int main(void) {
}
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_WARN);
ua = uasync_create();

16
tests/test_u_async_comprehensive.c

@ -8,6 +8,7 @@
#include <string.h>
#include <assert.h>
#include "../lib/platform_compat.h"
#include "../lib/socket_compat.h"
#include "u_async.h"
#include "timeout_heap.h"
@ -138,6 +139,8 @@ static void test_error_callback(void* arg) {
static void test_basic_timers(void) {
TEST_START("Basic timer functionality");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -171,6 +174,8 @@ static void test_basic_timers(void) {
static void test_timer_cancellation_races(void) {
TEST_START("Timer cancellation race conditions");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -223,6 +228,8 @@ static void test_timer_cancellation_races(void) {
static void test_immediate_timeouts(void) {
TEST_START("Immediate timeout handling");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -260,6 +267,8 @@ static void test_immediate_timeouts(void) {
static void test_memory_leak_detection(void) {
TEST_START("Memory leak detection");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -292,6 +301,8 @@ static void test_memory_leak_detection(void) {
static void test_socket_management(void) {
TEST_START("Socket management efficiency");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -339,6 +350,8 @@ static void test_socket_management(void) {
static void test_error_handling(void) {
TEST_START("Error injection and handling");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -374,6 +387,8 @@ static void test_error_handling(void) {
static void test_concurrent_operations(void) {
TEST_START("Concurrent operations stress test");
socket_platform_init();
uasync_t* ua = uasync_create();
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
@ -484,6 +499,7 @@ static void test_concurrent_operations(void) {
/* Main test runner */
int main(void) {
debug_config_init();
socket_platform_init();
debug_set_level(DEBUG_LEVEL_INFO);
debug_set_categories(DEBUG_CATEGORY_ALL);

5
tests/test_u_async_performance.c

@ -8,6 +8,7 @@
#include <string.h>
#include <stdint.h>
#include "../lib/platform_compat.h"
#include "../lib/socket_compat.h"
#include <sys/time.h>
@ -40,6 +41,8 @@ static void test_socket_callback(int fd, void* arg) {
printf("=== Socket Management Benchmark ===\n");
printf("Testing with %d sockets\n\n", num_sockets);
socket_platform_init();
uasync_t* ua = uasync_create();
if (!ua) {
printf("Failed to create uasync\n");
@ -269,6 +272,8 @@ static void benchmark_scalability(void) {
}
int main(void) {
socket_platform_init();
printf("lib Socket Management Performance Benchmark\n");
printf("================================================\n\n");

Loading…
Cancel
Save