|
|
|
|
@ -45,7 +45,7 @@
|
|
|
|
|
#include "../lib/mem.h" |
|
|
|
|
|
|
|
|
|
#define TIMEOUT_TB 600000 |
|
|
|
|
#define SHORT_TO_TB 50000 |
|
|
|
|
#define SHORT_TO_TB 5000 /* 500мс: проверяем истечение заданного бюджета, без ожидания 5с. */ |
|
|
|
|
#define POLL_MS 5 |
|
|
|
|
|
|
|
|
|
static struct UTUN_INSTANCE *g_a = NULL, *g_b = NULL; |
|
|
|
|
@ -53,6 +53,7 @@ static struct UASYNC *ua = NULL;
|
|
|
|
|
static volatile int g_result = 0; |
|
|
|
|
static int g_phase = 0; |
|
|
|
|
static void *g_ttimer = NULL; |
|
|
|
|
static uint64_t g_timeout_started_tb; |
|
|
|
|
|
|
|
|
|
static char tdir[] = "/tmp/utun_ncd_XXXXXX"; |
|
|
|
|
static char ca[256], cb[256]; |
|
|
|
|
@ -303,6 +304,7 @@ static void t8(void* arg) {
|
|
|
|
|
memset((void*)g_tout, 0, sizeof(g_tout)); |
|
|
|
|
g_a->etcp_connect_timeout_tb = SHORT_TO_TB; |
|
|
|
|
|
|
|
|
|
g_timeout_started_tb = get_time_tb(); |
|
|
|
|
int r = node_conn_direct_open(g_a, fake_id, ncd_cb, (void*)0, &gh[0], NULL); |
|
|
|
|
fprintf(stderr, " open(unreachable) → %s\n", r == NCD_NEW ? "NCD_NEW" : "?"); |
|
|
|
|
if (r != NCD_NEW) { fail("expected NCD_NEW"); return; } |
|
|
|
|
@ -314,6 +316,14 @@ static void t9(void* arg) {
|
|
|
|
|
(void)arg; g_phase = 9; |
|
|
|
|
if (g_tout[0] == 0) { uasync_set_timeout(ua, POLL_MS, NULL, (timeout_callback_t)t9, "t9"); return; } |
|
|
|
|
if (g_up[0] > 0) { fail("up fired, expected only timeout"); return; } |
|
|
|
|
uint64_t elapsed = get_time_tb() - g_timeout_started_tb; |
|
|
|
|
if (g_tout[0] != 1 || elapsed + 10 < SHORT_TO_TB) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, "NCD test: invalid timeout calls=%d elapsed_tb=%llu budget_tb=%d", |
|
|
|
|
g_tout[0], (unsigned long long)elapsed, SHORT_TO_TB); |
|
|
|
|
g_result = 2; return; |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "NCD test: one TIMEOUT without UP elapsed_tb=%llu budget_tb=%d", |
|
|
|
|
(unsigned long long)elapsed, SHORT_TO_TB); |
|
|
|
|
fprintf(stderr, "\n=== P9: timeout_cb fired, no up ===\n"); fflush(stderr); |
|
|
|
|
node_conn_direct_close(gh[0]); gh[0] = NULL; |
|
|
|
|
uasync_call_soon(ua, NULL, t_done); |
|
|
|
|
|