Files
utun2/!/utun_test_hooks.c
T
Evgeny d74f76a5a0 Fix: Resolved double free in timeout_heap_pop() and test_etcp_simple_traffic bind conflict
- Fixed incorrect init_connections() call in test_etcp_simple_traffic.c (was calling server_instance instead of client_instance)
- Fixed double free in timeout_heap_pop() when handling deleted elements
- Enhanced NULL pointer safety in uasync_print_resources() by removing complex heap manipulation
- Added debug logging to timeout_heap_pop() for better error tracking

Test results: test_etcp_simple_traffic now passes without double free errors
2026-01-25 10:47:02 +03:00

30 lines
921 B
C
Executable File

#include "utun_test_hooks.h"
#include "utun_instance.h"
#include "../lib/debug_config.h"
// Add test category if not already defined
#ifndef DEBUG_CATEGORY_TEST
#define DEBUG_CATEGORY_TEST (1 << 30) // High bit for test category
#endif
// Global test hooks - NULL in production
struct utun_test_hooks* g_utun_test_hooks = NULL;
#ifdef TEST_BUILD
void utun_test_hooks_set(struct utun_test_hooks* hooks) {
if (!hooks) {
DEBUG_ERROR(DEBUG_CATEGORY_TEST, "Attempt to set NULL test hooks");
return;
}
DEBUG_INFO(DEBUG_CATEGORY_TEST, "Setting test hooks: sendto=%p, recvfrom=%p, tun_create=%p",
hooks->sendto_override, hooks->recvfrom_override, hooks->tun_create_override);
g_utun_test_hooks = hooks;
}
void utun_test_hooks_clear(void) {
DEBUG_INFO(DEBUG_CATEGORY_TEST, "Clearing test hooks (was: %p)", g_utun_test_hooks);
g_utun_test_hooks = NULL;
}
#endif