forked from lei.chen/myxce
feat: rename delaymgr precision→precision_ms, replace sleep() with nanosleep() (P0-2b)
- Rename `precision` field to `precision_ms` in delaymgr_t struct (delay.h) - Replace `sleep(mgr->precision)` with `nanosleep()` for 10ms granularity (delay.c) - Add `#include <time.h>` to delay.c (already in delay.h) - Update delaymgr_init() to store precision_ms parameter - Update all call sites: cluster.c (2→200ms), controller/testsuite/test.c (2→2000ms), lib/testsuite/test_delay.c (1→1000ms) - Add TDD test test_delaymgr_precision_ms_field verifying field exists and stores correctly - delay_task() delay parameter remains in seconds; only sleep granularity changes
This commit is contained in:
parent
762b59c043
commit
6d4d8eb81d
5 changed files with 23 additions and 6 deletions
|
|
@ -26,7 +26,7 @@ static void test_delay1()
|
|||
int delay_period = 2;
|
||||
time_t t_start = time(NULL);
|
||||
|
||||
delaymgr_init(&mgr, 1, NULL);
|
||||
delaymgr_init(&mgr, 1000 /* precision_ms */, NULL);
|
||||
delaymgr_start(&mgr);
|
||||
delay_task(&mgr, delay_period, runcount, (delay_task_entry_fn_t)delay_work,
|
||||
&count);
|
||||
|
|
@ -48,9 +48,22 @@ static void test_delay1()
|
|||
return;
|
||||
}
|
||||
|
||||
static void test_delaymgr_precision_ms_field(void)
|
||||
{
|
||||
delaymgr_t mgr;
|
||||
memset(&mgr, 0, sizeof(mgr));
|
||||
/* precision_ms field must exist and be stored correctly */
|
||||
int rc = delaymgr_init(&mgr, 200 /* precision_ms */, NULL);
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
TEST_ASSERT_EQUAL_INT(200, mgr.precision_ms);
|
||||
delaymgr_fini(&mgr);
|
||||
printf("test_delaymgr_precision_ms_field: PASS\n");
|
||||
}
|
||||
|
||||
void test_delay(void)
|
||||
{
|
||||
printf("\n>> delay test\n\n");
|
||||
|
||||
RUN_TEST(test_delay1);
|
||||
RUN_TEST(test_delaymgr_precision_ms_field);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue