diff options
| author | Bernard Xiong <[email protected]> | 2013-12-19 23:50:39 -0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2013-12-19 23:50:39 -0800 |
| commit | ca270a46678b8de14fc23b2851ef84d265f29268 (patch) | |
| tree | b1829cf86c9a86912047202b584cba18141e94a9 | |
| parent | 52db5cfbe035c5751c178626afe7f8be7743d35e (diff) | |
| parent | 9a679cc7d88dec363a53594cf54aaea4d088e631 (diff) | |
Merge pull request #213 from grissiom/more-tc
More tc
| -rw-r--r-- | examples/kernel/tc_comm.c | 9 | ||||
| -rw-r--r-- | examples/kernel/thread_delete.c | 14 |
2 files changed, 15 insertions, 8 deletions
diff --git a/examples/kernel/tc_comm.c b/examples/kernel/tc_comm.c index 7804701284..ac4b36d8be 100644 --- a/examples/kernel/tc_comm.c +++ b/examples/kernel/tc_comm.c @@ -52,6 +52,15 @@ void tc_thread_entry(void* parameter) _tc_cleanup = RT_NULL; } + if (_tc_stat & TC_STAT_RUNNING) + { + rt_kprintf("TestCase[%s] exit with stat TC_STAT_RUNNING." + " Please fix the TC.\n", + _tc_current); + /* If the TC forgot to clear the flag, we do it. */ + _tc_stat &= ~TC_STAT_RUNNING; + } + if (_tc_stat & TC_STAT_FAILED) rt_kprintf("TestCase[%s] failed\n", _tc_current); else diff --git a/examples/kernel/thread_delete.c b/examples/kernel/thread_delete.c index 6bae53994e..69d5ab8ebc 100644 --- a/examples/kernel/thread_delete.c +++ b/examples/kernel/thread_delete.c @@ -41,7 +41,7 @@ static void thread2_entry(void* parameter) /* 线程2拥有较高的优先级,以抢占线程1而获得执行 */ /* 线程2启动后先睡眠10个OS Tick */ - rt_thread_delay(10); + rt_thread_delay(RT_TICK_PER_SECOND); /* * 线程2唤醒后直接删除线程1,删除线程1后,线程1自动脱离就绪线程 @@ -53,7 +53,7 @@ static void thread2_entry(void* parameter) * 线程2继续休眠10个OS Tick然后退出,线程2休眠后应切换到idle线程 * idle线程将执行真正的线程1控制块和线程栈的删除 */ - rt_thread_delay(10); + rt_thread_delay(RT_TICK_PER_SECOND); } static void thread2_cleanup(struct rt_thread *tid) @@ -100,7 +100,7 @@ int thread_delete_init() else tc_stat(TC_STAT_END | TC_STAT_FAILED); - return 0; + return 10 * RT_TICK_PER_SECOND; } #ifdef RT_USING_TC @@ -112,12 +112,12 @@ static void _tc_cleanup() /* delete thread */ if (tid1 != RT_NULL) { - rt_kprintf("tid1 is bad\n"); + rt_kprintf("tid1 is %p, should be NULL\n", tid1); tc_stat(TC_STAT_FAILED); } if (tid2 != RT_NULL) { - rt_kprintf("tid2 is bad\n"); + rt_kprintf("tid2 is %p, should be NULL\n", tid2); tc_stat(TC_STAT_FAILED); } @@ -129,9 +129,7 @@ int _tc_thread_delete() { /* set tc cleanup */ tc_cleanup(_tc_cleanup); - thread_delete_init(); - - return 27; + return thread_delete_init(); } FINSH_FUNCTION_EXPORT(_tc_thread_delete, a thread delete example); #else |
