Add name parameter to uasync_set_timeout for timer identification in dumps
This commit is contained in:
1 parent
3c0b5f501a
commit
d74ab1c1c6
28 files changed
+102
-93
No files matched your search
@@ -58,7 +58,7 @@ static void benchmark_without_sockets(void) {
|
||||
// Set 100 zero timeouts
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < NUM_TIMEOUTS; i++) {
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback);
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback, "bench0");
|
||||
if (!timeout_ids[i]) {
|
||||
fprintf(stderr, "Failed to set timeout at iteration %d\n", i);
|
||||
uasync_destroy(ua, 0);
|
||||
@@ -147,7 +147,7 @@ static void benchmark_with_sockets(void) {
|
||||
// Set 100 zero timeouts WITH sockets already open
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < NUM_TIMEOUTS; i++) {
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback);
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback, "bench0");
|
||||
if (!timeout_ids[i]) {
|
||||
fprintf(stderr, "Failed to set timeout at iteration %d\n", i);
|
||||
for (int j = 0; j < NUM_SOCKETS; j++) {
|
||||
@@ -215,7 +215,7 @@ int main(void) {
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < NUM_TIMEOUTS; i++) {
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback);
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback, "bench0");
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
set_time_no_sockets = measure_time_diff(&start, &end);
|
||||
@@ -266,7 +266,7 @@ int main(void) {
|
||||
// Set timeouts WITH sockets open
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < NUM_TIMEOUTS; i++) {
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback);
|
||||
timeout_ids[i] = uasync_set_timeout(ua, 0, (void*)(uintptr_t)(i + 1), timeout_callback, "bench0");
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
set_time_with_sockets = measure_time_diff(&start, &end);
|
||||
|
||||
@@ -102,9 +102,9 @@ static void test_basic_timers(void) {
|
||||
ctx.timeout_ms = 10; // Non-zero to avoid immediate timeout counting
|
||||
|
||||
/* Set multiple timers with different timeouts */
|
||||
void* timer1 = uasync_set_timeout(ua, 10, &ctx, test_timer_callback); /* 1ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 20, &ctx, test_timer_callback); /* 2ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 30, &ctx, test_timer_callback); /* 3ms */
|
||||
void* timer1 = uasync_set_timeout(ua, 10, &ctx, test_timer_callback, "test_t1"); /* 1ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 20, &ctx, test_timer_callback, "test_t2"); /* 2ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 30, &ctx, test_timer_callback, "test_t3"); /* 3ms */
|
||||
|
||||
ASSERT_NOT_NULL(timer1, "Failed to set timer 1");
|
||||
ASSERT_NOT_NULL(timer2, "Failed to set timer 2");
|
||||
@@ -136,9 +136,9 @@ static void test_timer_cancellation_races(void) {
|
||||
ctx.timeout_ms = 5; // Non-zero to avoid immediate timeout counting
|
||||
|
||||
/* Create timers that will be cancelled at different stages */
|
||||
void* timer1 = uasync_set_timeout(ua, 5, &ctx, test_timer_callback); /* 0.5ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 50, &ctx, test_timer_callback); /* 5ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 100, &ctx, test_timer_callback); /* 10ms */
|
||||
void* timer1 = uasync_set_timeout(ua, 5, &ctx, test_timer_callback, "test_t1"); /* 0.5ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 50, &ctx, test_timer_callback, "test_t2"); /* 5ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 100, &ctx, test_timer_callback, "test_t3"); /* 10ms */
|
||||
|
||||
ASSERT_NOT_NULL(timer1, "Failed to set timer 1");
|
||||
ASSERT_NOT_NULL(timer2, "Failed to set timer 2");
|
||||
@@ -192,7 +192,7 @@ static void test_immediate_timeouts(void) {
|
||||
|
||||
/* Set multiple immediate timeouts (0ms) */
|
||||
for (int i = 0; i < 5; i++) {
|
||||
void* timer = uasync_set_timeout(ua, 0, &ctx, test_timer_callback);
|
||||
void* timer = uasync_set_timeout(ua, 0, &ctx, test_timer_callback, "test_imm");
|
||||
ASSERT_NOT_NULL(timer, "Failed to set immediate timer");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ int main() {
|
||||
test_context_t ctx1 = {.timeout_ms = 10};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
uasync_set_timeout(ua1, 10 + i*10, &ctx1, test_timer_callback);
|
||||
uasync_set_timeout(ua1, 10 + i*10, &ctx1, test_timer_callback, "test_d1");
|
||||
}
|
||||
|
||||
int polls = 0;
|
||||
@@ -55,7 +55,7 @@ int main() {
|
||||
test_context_t ctx2 = {.timeout_ms = 0};
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
uasync_set_timeout(ua2, 0, &ctx2, test_timer_callback);
|
||||
uasync_set_timeout(ua2, 0, &ctx2, test_timer_callback, "test_d2");
|
||||
}
|
||||
|
||||
printf("Before poll: ctx2.callback_count = %d, immediate_timeouts = %d\n", ctx2.callback_count, test_stats.immediate_timeouts);
|
||||
@@ -73,7 +73,7 @@ int main() {
|
||||
test_context_t ctx3 = {.timeout_ms = 0};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
uasync_set_timeout(ua3, 0, &ctx3, test_timer_callback);
|
||||
uasync_set_timeout(ua3, 0, &ctx3, test_timer_callback, "test_d3");
|
||||
}
|
||||
|
||||
uasync_poll(ua3, 1);
|
||||
|
||||
@@ -284,7 +284,7 @@ static void monitor_connections(void* arg) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "=== Connection established! Waiting for BGP exchange... ===");
|
||||
test_phase = 1;
|
||||
// Schedule next check after BGP exchange time
|
||||
monitor_timeout_id = uasync_set_timeout(ua, BGP_EXCHANGE_WAIT_MS, NULL, monitor_connections);
|
||||
monitor_timeout_id = uasync_set_timeout(ua, BGP_EXCHANGE_WAIT_MS, NULL, monitor_connections, "test_monitor");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -317,7 +317,7 @@ static void monitor_connections(void* arg) {
|
||||
|
||||
// Schedule next check
|
||||
if (test_phase < 3) {
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections);
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections, "test_monitor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ int main() {
|
||||
|
||||
// Start monitoring
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Starting connection monitoring...");
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections);
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout);
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections, "test_monitor");
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout, "test_timeout");
|
||||
|
||||
// Main event loop - use uasync timers only, no artificial timing
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Running event loop...");
|
||||
|
||||
@@ -114,7 +114,7 @@ static void send_timer_callback(void* arg) {
|
||||
st->next_seq++;
|
||||
|
||||
/* Перезапускаем таймер на следующую отправку (10 timebase = 1ms) */
|
||||
st->send_timer = uasync_set_timeout(st->ua, 10, st, send_timer_callback);
|
||||
st->send_timer = uasync_set_timeout(st->ua, 10, st, send_timer_callback, "test_dummynet");
|
||||
}
|
||||
|
||||
/* Burst отправка - все пакеты сразу */
|
||||
@@ -259,7 +259,7 @@ static int run_scenario(const char* name,
|
||||
printf("Sending %d packets (fast)...\n", PKT_COUNT);
|
||||
|
||||
/* Запускаем таймер отправки с интервалом 1 timebase (0.1ms) */
|
||||
st.send_timer = uasync_set_timeout(st.ua, 1, &st, send_timer_callback);
|
||||
st.send_timer = uasync_set_timeout(st.ua, 1, &st, send_timer_callback, "test_dummynet");
|
||||
|
||||
/* Умное ожидание завершения: ранний выход при готовности + watchdog */
|
||||
uint64_t start_time = get_time_us();
|
||||
|
||||
@@ -361,7 +361,7 @@ static void monitor_and_send(void* arg) {
|
||||
}
|
||||
|
||||
if (!test_completed) {
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send, "test_monitor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,8 +419,8 @@ int main() {
|
||||
printf("✅ Client ready\n\n");
|
||||
|
||||
printf("Sending %d packets in each direction (max queue size: %d)...\n", TOTAL_PACKETS, MAX_QUEUE_SIZE);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send);
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send, "test_monitor");
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout, "test_timeout");
|
||||
|
||||
while (!test_completed) {
|
||||
uasync_poll(ua, 100);
|
||||
|
||||
@@ -437,7 +437,7 @@ static void monitor_and_send(void* arg) {
|
||||
connection_delay++;
|
||||
if (connection_delay < 50) { // Ждем 50 циклов (~500ms)
|
||||
if (!test_completed) {
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send, "test_monitor");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ static void monitor_and_send(void* arg) {
|
||||
}
|
||||
|
||||
if (!test_completed) {
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send, "test_monitor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,8 +586,8 @@ int main() {
|
||||
DATA_PACKET_ID, (void*)server_recv_callback, (void*)client_recv_callback);
|
||||
|
||||
printf("Sending %d packets in each direction via etcp_send...\n", TOTAL_PACKETS);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 1000, NULL, monitor_and_send);
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS*10, NULL, test_timeout);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 1000, NULL, monitor_and_send, "test_monitor");
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS*10, NULL, test_timeout, "test_timeout");
|
||||
|
||||
while (!test_completed) {
|
||||
uasync_poll(ua, 100); // 100ms timeout to allow timer processing
|
||||
|
||||
@@ -94,7 +94,7 @@ static void send_pkt(void* arg) {
|
||||
|
||||
/* Schedule next packet with 5ms delay for rate limiting (~200 pkt/sec)
|
||||
* Note: uasync_set_timeout uses 0.1ms units, so 50 = 5ms */
|
||||
uasync_set_timeout(ua, 50, NULL, send_pkt);
|
||||
uasync_set_timeout(ua, 50, NULL, send_pkt, "test_dnet");
|
||||
}
|
||||
|
||||
static struct UTUN_INSTANCE* create_instance(struct UASYNC* u, uint64_t node_id,
|
||||
|
||||
@@ -169,8 +169,8 @@ int main(void) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "Client init_connections failed with code %d", ret);
|
||||
goto cleanup;
|
||||
}
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections);
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout);
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections, "test_monitor");
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout, "test_timeout");
|
||||
while (!test_completed) {
|
||||
uasync_poll(ua, 10);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ static void monitor_and_send(void* arg) {
|
||||
|
||||
// Schedule next check
|
||||
if (!test_completed) {
|
||||
void* new_timeout = uasync_set_timeout(server_instance->ua, 100, NULL, monitor_and_send);
|
||||
void* new_timeout = uasync_set_timeout(server_instance->ua, 100, NULL, monitor_and_send, "test_monitor");
|
||||
if (!new_timeout) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "monitor_and_send: Failed to set timeout - uasync_set_timeout returned NULL");
|
||||
printf("[ERROR] Failed to set timeout in monitor_and_send\n");
|
||||
@@ -472,8 +472,8 @@ int main() {
|
||||
|
||||
// Start monitoring and packet transmission
|
||||
printf("Starting packet transmission test...\n");
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send);
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send, "test_monitor");
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout, "test_timeout");
|
||||
|
||||
// Main event loop
|
||||
printf("Running event loop...\n\n");
|
||||
|
||||
@@ -231,7 +231,7 @@ static void monitor_connections(void* arg) {
|
||||
uasync_cancel_timeout(ua, monitor_timeout_id);
|
||||
monitor_timeout_id = NULL;
|
||||
}
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 200, NULL, monitor_connections);
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 200, NULL, monitor_connections, "test_monitor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,8 +341,8 @@ int main() {
|
||||
|
||||
// Start monitoring
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Starting connection monitoring...\n");
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections);
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout);
|
||||
monitor_timeout_id = uasync_set_timeout(ua, 100, NULL, monitor_connections, "test_monitor");
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, test_timeout, "test_timeout");
|
||||
|
||||
// Main event loop
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Running event loop...\n\n");
|
||||
|
||||
@@ -223,7 +223,7 @@ int main(void) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS * 10, NULL, test_timeout_cb);
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS * 10, NULL, test_timeout_cb, "test_nat");
|
||||
|
||||
// 1. Wait for links C1->S and C2->S to initialize
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Waiting for ETCP links to initialize...");
|
||||
|
||||
@@ -482,7 +482,7 @@ static void monitor_and_send(void* arg) {
|
||||
}
|
||||
|
||||
if (!test_completed) {
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 10, NULL, monitor_and_send, "test_monitor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,8 +550,8 @@ int main() {
|
||||
printf("Client created\n\n");
|
||||
|
||||
printf("Sending %d packets in each direction via normalizer...\n", TOTAL_PACKETS);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send);
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS*10, NULL, test_timeout);
|
||||
packet_timeout_id = uasync_set_timeout(ua, 500, NULL, monitor_and_send, "test_monitor");
|
||||
void* global_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS*10, NULL, test_timeout, "test_timeout");
|
||||
|
||||
while (!test_completed) {
|
||||
uasync_poll(ua, 100); // 100ms timeout to allow timer processing
|
||||
|
||||
@@ -159,7 +159,7 @@ static void monitor(void* arg) {
|
||||
}
|
||||
|
||||
// Schedule next check
|
||||
uasync_set_timeout(mock_instance.ua, 10, NULL, monitor);
|
||||
uasync_set_timeout(mock_instance.ua, 10, NULL, monitor, "test_monitor");
|
||||
}
|
||||
|
||||
// Timeout handler
|
||||
@@ -298,8 +298,8 @@ int main() {
|
||||
printf("Normalizer created (frag_size=%d)\n\n", pn->frag_size);
|
||||
|
||||
// Set up monitoring and timeout FIRST (before sending)
|
||||
uasync_set_timeout(mock_instance.ua, 10, NULL, monitor);
|
||||
uasync_set_timeout(mock_instance.ua, TEST_TIMEOUT_MS, NULL, test_timeout);
|
||||
uasync_set_timeout(mock_instance.ua, 10, NULL, monitor, "test_monitor");
|
||||
uasync_set_timeout(mock_instance.ua, TEST_TIMEOUT_MS, NULL, test_timeout, "test_timeout");
|
||||
|
||||
// Give uasync a chance to process any pending callbacks
|
||||
uasync_poll(mock_instance.ua, 1);
|
||||
|
||||
@@ -221,7 +221,7 @@ int main(void) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS * 10, NULL, test_timeout_cb);
|
||||
test_timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS * 10, NULL, test_timeout_cb, "test_route_ping");
|
||||
|
||||
// 1. Wait for links A->B and B->C to initialize
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Waiting for ETCP links to initialize...");
|
||||
|
||||
@@ -105,7 +105,7 @@ static void check_mesh_state(void* arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
timeout_id = uasync_set_timeout(ua, 500, NULL, check_mesh_state);
|
||||
timeout_id = uasync_set_timeout(ua, 500, NULL, check_mesh_state, "test_mesh");
|
||||
}
|
||||
|
||||
static void timeout_handler(void* arg) {
|
||||
|
||||
@@ -147,9 +147,9 @@ static void test_basic_timers(void) {
|
||||
ctx.expected_count = 3;
|
||||
|
||||
/* Set multiple timers with different timeouts */
|
||||
void* timer1 = uasync_set_timeout(ua, 10, &ctx, test_timer_callback); /* 1ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 20, &ctx, test_timer_callback); /* 2ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 30, &ctx, test_timer_callback); /* 3ms */
|
||||
void* timer1 = uasync_set_timeout(ua, 10, &ctx, test_timer_callback, "test_t1"); /* 1ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 20, &ctx, test_timer_callback, "test_t2"); /* 2ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 30, &ctx, test_timer_callback, "test_t3"); /* 3ms */
|
||||
|
||||
ASSERT_NOT_NULL(timer1, "Failed to set timer 1");
|
||||
ASSERT_NOT_NULL(timer2, "Failed to set timer 2");
|
||||
@@ -181,9 +181,9 @@ static void test_timer_cancellation_races(void) {
|
||||
ctx.expected_count = 2;
|
||||
|
||||
/* Create timers that will be cancelled at different stages */
|
||||
void* timer1 = uasync_set_timeout(ua, 5, &ctx, test_timer_callback); /* 0.5ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 50, &ctx, test_timer_callback); /* 5ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 100, &ctx, test_timer_callback); /* 10ms */
|
||||
void* timer1 = uasync_set_timeout(ua, 5, &ctx, test_timer_callback, "test_t1"); /* 0.5ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 50, &ctx, test_timer_callback, "test_t2"); /* 5ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 100, &ctx, test_timer_callback, "test_t3"); /* 10ms */
|
||||
|
||||
ASSERT_NOT_NULL(timer1, "Failed to set timer 1");
|
||||
ASSERT_NOT_NULL(timer2, "Failed to set timer 2");
|
||||
@@ -238,7 +238,7 @@ static void test_immediate_timeouts(void) {
|
||||
|
||||
/* Set multiple immediate timeouts (0ms) */
|
||||
for (int i = 0; i < 5; i++) {
|
||||
void* timer = uasync_set_timeout(ua, 0, &ctx, test_timer_callback);
|
||||
void* timer = uasync_set_timeout(ua, 0, &ctx, test_timer_callback, "test_imm");
|
||||
ASSERT_NOT_NULL(timer, "Failed to set immediate timer");
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ static void test_memory_leak_detection(void) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
test_context_t timer_ctx = {0};
|
||||
timer_ctx.timeout_ms = 100; // Set proper timeout to avoid immediate timeout
|
||||
void* timer = uasync_set_timeout(ua, 100, &timer_ctx, test_timer_callback);
|
||||
void* timer = uasync_set_timeout(ua, 100, &timer_ctx, test_timer_callback, "test_cancel");
|
||||
ASSERT_NOT_NULL(timer, "Failed to set timer");
|
||||
|
||||
/* Cancel some, leave others to timeout */
|
||||
@@ -350,7 +350,7 @@ static void test_error_handling(void) {
|
||||
ASSERT_NOT_NULL(ua, "Failed to create uasync instance");
|
||||
|
||||
/* Test invalid parameters */
|
||||
void* null_timer = uasync_set_timeout(NULL, 10, NULL, NULL);
|
||||
void* null_timer = uasync_set_timeout(NULL, 10, NULL, NULL, "test_null");
|
||||
ASSERT_NULL(null_timer, "Should fail with NULL uasync");
|
||||
|
||||
err_t cancel_result = uasync_cancel_timeout(NULL, NULL);
|
||||
@@ -364,7 +364,7 @@ static void test_error_handling(void) {
|
||||
test_context_t ctx = {0};
|
||||
ctx.callback_arg = -1; /* Error injection flag */
|
||||
|
||||
void* error_timer = uasync_set_timeout(ua, 5, &ctx, test_error_callback);
|
||||
void* error_timer = uasync_set_timeout(ua, 5, &ctx, test_error_callback, "test_err");
|
||||
ASSERT_NOT_NULL(error_timer, "Failed to set error timer");
|
||||
|
||||
uasync_poll(ua, 10);
|
||||
@@ -434,7 +434,7 @@ static void test_concurrent_operations(void) {
|
||||
individual_ctx->timeout_ms = (i + 1) * 5; // Different timeouts: 5, 10, 15, ..., 50ms
|
||||
individual_ctx->callback_arg = 0;
|
||||
|
||||
timers[i] = uasync_set_timeout(ua, (i + 1) * 5, individual_ctx, test_timer_callback);
|
||||
timers[i] = uasync_set_timeout(ua, (i + 1) * 5, individual_ctx, test_timer_callback, "test_stress");
|
||||
ASSERT_NOT_NULL(timers[i], "Failed to set timer");
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ static void timer_callback(void* arg) {
|
||||
new_ctx->stop_flag = ctx->stop_flag;
|
||||
new_ctx->ua = ctx->ua;
|
||||
|
||||
void* new_timer = uasync_set_timeout(ctx->ua, random_delay, new_ctx, timer_callback);
|
||||
void* new_timer = uasync_set_timeout(ctx->ua, random_delay, new_ctx, timer_callback, "test_timer");
|
||||
if (new_timer) {
|
||||
ctx->timer_data[ctx->timer_number].timer_id = new_timer;
|
||||
} else {
|
||||
@@ -122,7 +122,7 @@ int main(void) {
|
||||
ctx->ua = ua;
|
||||
|
||||
int random_delay = rand() % 101; /* 0-100 (0-10ms) */
|
||||
void* timer_id = uasync_set_timeout(ua, random_delay, ctx, timer_callback);
|
||||
void* timer_id = uasync_set_timeout(ua, random_delay, ctx, timer_callback, "test_timer");
|
||||
|
||||
if (!timer_id) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_TEST, "Failed to set timer %d", i);
|
||||
@@ -152,7 +152,7 @@ int main(void) {
|
||||
stop_ctx->stop_flag = &stop_flag;
|
||||
stop_ctx->ua = ua;
|
||||
|
||||
void* stop_timer = uasync_set_timeout(ua, STOP_TIMEOUT_TB, stop_ctx, stop_callback);
|
||||
void* stop_timer = uasync_set_timeout(ua, STOP_TIMEOUT_TB, stop_ctx, stop_callback, "test_stop");
|
||||
if (!stop_timer) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_TEST, "Failed to set stop timer");
|
||||
u_free(stop_ctx);
|
||||
|
||||
+4
-4
@@ -89,9 +89,9 @@ static void test_basic_timers(void) {
|
||||
ctx.timeout_ms = 10; // Non-zero timeout
|
||||
|
||||
/* Set multiple timers with different timeouts */
|
||||
void* timer1 = uasync_set_timeout(ua, 10, &ctx, test_timer_callback); /* 1ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 20, &ctx, test_timer_callback); /* 2ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 30, &ctx, test_timer_callback); /* 3ms */
|
||||
void* timer1 = uasync_set_timeout(ua, 10, &ctx, test_timer_callback, "test_t1"); /* 1ms */
|
||||
void* timer2 = uasync_set_timeout(ua, 20, &ctx, test_timer_callback, "test_t2"); /* 2ms */
|
||||
void* timer3 = uasync_set_timeout(ua, 30, &ctx, test_timer_callback, "test_t3"); /* 3ms */
|
||||
|
||||
ASSERT_NOT_NULL(timer1, "Failed to set timer 1");
|
||||
ASSERT_NOT_NULL(timer2, "Failed to set timer 2");
|
||||
@@ -124,7 +124,7 @@ static void test_immediate_timeouts(void) {
|
||||
|
||||
/* Set multiple immediate timeouts (0ms) */
|
||||
for (int i = 0; i < 5; i++) {
|
||||
void* timer = uasync_set_timeout(ua, 0, &ctx, test_timer_callback);
|
||||
void* timer = uasync_set_timeout(ua, 0, &ctx, test_timer_callback, "test_imm");
|
||||
ASSERT_NOT_NULL(timer, "Failed to set immediate timer");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user