TC: more tolerate on the timeout tick in semaphore_dynamic

With system that has RT_TICK_PER_SECOND is 1000, it's easy to get one
tick error.
This commit is contained in:
Grissiom 2013-12-21 12:40:54 +08:00
parent 46f9280a9d
commit ac0e10bb83
1 changed files with 6 additions and 2 deletions

View File

@ -25,9 +25,13 @@ static void thread_entry(void* parameter)
result = rt_sem_take(sem, 10);
if (result == -RT_ETIMEOUT)
{
/* 判断是否刚好过去10个OS Tick */
if (rt_tick_get() - tick != 10)
rt_tick_t new_tick = rt_tick_get();
/* 可以有两个 tick 的误差 */
if (new_tick - tick >= 12)
{
rt_kprintf("tick error to large: expect: 10, get %d\n",
new_tick - tick);
/* 如果失败,则测试失败 */
tc_done(TC_STAT_FAILED);
rt_sem_delete(sem);