mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 07:05:56 +00:00
Add unit test for a long running timer
This commit is contained in:
parent
6ccd12b97c
commit
990c25d4f3
|
@ -203,6 +203,9 @@ typedef int ssize_t;
|
||||||
#define SSIZE_MAX INT_MAX
|
#define SSIZE_MAX INT_MAX
|
||||||
#endif /* SSIZE_MAX */
|
#endif /* SSIZE_MAX */
|
||||||
|
|
||||||
|
/* some maximum values needed in lwip code */
|
||||||
|
#define LWIP_UINT32_MAX 0xffffffff
|
||||||
|
|
||||||
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
|
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
|
||||||
* the ctype.h header. If ctype.h is available, a few character functions
|
* the ctype.h header. If ctype.h is available, a few character functions
|
||||||
* are mapped to the appropriate functions (lwip_islower, lwip_isdigit...), if
|
* are mapped to the appropriate functions (lwip_islower, lwip_isdigit...), if
|
||||||
|
|
|
@ -187,6 +187,38 @@ START_TEST(test_timers)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_long_timer)
|
||||||
|
{
|
||||||
|
LWIP_UNUSED_ARG(_i);
|
||||||
|
|
||||||
|
memset(&fired, 0, sizeof(fired));
|
||||||
|
lwip_sys_now = 0;
|
||||||
|
|
||||||
|
sys_timeout(LWIP_UINT32_MAX / 4, dummy_handler, LWIP_PTR_NUMERIC_CAST(void*, 0));
|
||||||
|
fail_unless(sys_timeouts_sleeptime() == LWIP_UINT32_MAX / 4);
|
||||||
|
|
||||||
|
sys_check_timeouts();
|
||||||
|
fail_unless(fired[0] == 0);
|
||||||
|
|
||||||
|
lwip_sys_now += LWIP_UINT32_MAX / 8;
|
||||||
|
|
||||||
|
sys_check_timeouts();
|
||||||
|
fail_unless(fired[0] == 0);
|
||||||
|
|
||||||
|
lwip_sys_now += LWIP_UINT32_MAX / 8;
|
||||||
|
|
||||||
|
sys_check_timeouts();
|
||||||
|
fail_unless(fired[0] == 0);
|
||||||
|
|
||||||
|
lwip_sys_now += 1;
|
||||||
|
|
||||||
|
sys_check_timeouts();
|
||||||
|
fail_unless(fired[0] == 1);
|
||||||
|
|
||||||
|
sys_untimeout(dummy_handler, LWIP_PTR_NUMERIC_CAST(void*, 0));
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
/** Create the suite including all tests for this module */
|
/** Create the suite including all tests for this module */
|
||||||
Suite *
|
Suite *
|
||||||
timers_suite(void)
|
timers_suite(void)
|
||||||
|
@ -194,7 +226,8 @@ timers_suite(void)
|
||||||
testfunc tests[] = {
|
testfunc tests[] = {
|
||||||
TESTFUNC(test_bug52748),
|
TESTFUNC(test_bug52748),
|
||||||
TESTFUNC(test_cyclic_timers),
|
TESTFUNC(test_cyclic_timers),
|
||||||
TESTFUNC(test_timers)
|
TESTFUNC(test_timers),
|
||||||
|
TESTFUNC(test_long_timer),
|
||||||
};
|
};
|
||||||
return create_suite("TIMERS", tests, LWIP_ARRAYSIZE(tests), timers_setup, timers_teardown);
|
return create_suite("TIMERS", tests, LWIP_ARRAYSIZE(tests), timers_setup, timers_teardown);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user