Observe late mesh packets within the running event loop

This commit is contained in:
evgeny committed 2026-10-26 14:57:41 +01:00
1 parent d943c0ddca
commit 21af2e0f35
1 file changed
+15 -13
+15 -13
View File
@@ -72,6 +72,7 @@ struct mesh_ctx {
int result; /* 0=running, 1=ok, 2=fail */
int ticks;
void* timer;
uint32_t stop_dup_c; /* Снимок исходного критерия до необязательного диагностического хвоста. */
};
/* приёмник кадров (per-узел): проверка порядка seq и FIN */
@@ -160,7 +161,11 @@ static void mesh_snapshot(struct mesh_ctx* t, const char* reason) {
}
}
static void mesh_tail_stop(void* arg) { *(int*)arg = 1; }
static void mesh_tail_stop(void* arg) {
struct mesh_ctx* t = arg;
mesh_snapshot(t, "after_diagnostic_tail");
uasync_stop(t->ua);
}
static int G_PASSED = 0, G_FAILED = 0, G_TOTAL = 0;
#define TEST(n) do { G_TOTAL++; printf(" %-58s", n); fflush(stdout); } while(0)
@@ -456,8 +461,14 @@ static void mesh_tick(void* arg) {
break;
case P_DONE:
mesh_snapshot(t, "original_stop");
t->stop_dup_c = radio_dup_dropped(C, gid);
t->result = 1;
uasync_stop(t->ua);
if (getenv("UTUN_TEST_MESH_TAIL")) {
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "mesh observe tail=500ms original_ok=1 original_dupC=%u", t->stop_dup_c);
if (!uasync_set_timeout(t->ua, 5000, t, mesh_tail_stop, "mesh_diagnostic_tail")) {
DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "mesh: tail timer allocation failed"); abort();
}
} else uasync_stop(t->ua);
return;
}
@@ -531,17 +542,8 @@ int main(int argc, char** argv) {
int ok = (t.result == 1);
uint64_t gid = strtoull(CH_ID, NULL, 10);
uint32_t dup_c = radio_dup_dropped(t.inst[IDX_C], gid);
/* Диагностический хвост не меняет сохранённый результат исходной проверки. */
if (getenv("UTUN_TEST_MESH_TAIL")) {
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "mesh observe tail=500ms original_ok=%d original_dupC=%u", ok, dup_c);
int finished = 0;
void* tail = uasync_set_timeout(ua, 5000, &finished, mesh_tail_stop, "mesh_diagnostic_tail");
if (!tail) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "mesh: tail timer allocation failed"); abort(); }
while (!finished) uasync_poll(ua, 100);
mesh_snapshot(&t, "after_diagnostic_tail");
}
/* Хвост собирает поздние пакеты, но не меняет исходный результат теста. */
uint32_t dup_c = ok ? t.stop_dup_c : radio_dup_dropped(t.inst[IDX_C], gid);
if (ok && dup_c == 0) {
/* кадры не задвоились, но и дедупликация не сработала — топология не дала дублей */