2011-12-19 15:08:06 +08:00
|
|
|
#include <rtthread.h>
|
|
|
|
#include "tc_comm.h"
|
|
|
|
|
|
|
|
static rt_thread_t tid = RT_NULL;
|
|
|
|
static void sample_thread(void* parameter)
|
|
|
|
{
|
2013-12-21 12:51:52 +08:00
|
|
|
rt_kprintf("I'm sample!\n");
|
2011-12-19 15:08:06 +08:00
|
|
|
}
|
|
|
|
static void sample_thread_cleanup(struct rt_thread *p)
|
|
|
|
{
|
2013-12-21 12:51:52 +08:00
|
|
|
tid = RT_NULL;
|
|
|
|
tc_done(TC_STAT_PASSED);
|
2011-12-19 15:08:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int sample_init()
|
|
|
|
{
|
2013-12-21 12:51:52 +08:00
|
|
|
tid = rt_thread_create("t",
|
|
|
|
sample_thread, RT_NULL,
|
|
|
|
THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
|
|
|
|
if (tid != RT_NULL)
|
|
|
|
{
|
|
|
|
rt_thread_startup(tid);
|
|
|
|
tid->cleanup = sample_thread_cleanup;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
2011-12-19 15:08:06 +08:00
|
|
|
|
2013-12-21 12:51:52 +08:00
|
|
|
return 0;
|
2011-12-19 15:08:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RT_USING_TC
|
|
|
|
static void _tc_cleanup()
|
|
|
|
{
|
2013-12-21 12:51:52 +08:00
|
|
|
/* lock scheduler */
|
|
|
|
rt_enter_critical();
|
|
|
|
/* delete thread */
|
|
|
|
if (tid != RT_NULL)
|
|
|
|
{
|
|
|
|
rt_kprintf("tid1 is bad\n");
|
|
|
|
tc_stat(TC_STAT_FAILED);
|
|
|
|
}
|
|
|
|
/* unlock scheduler */
|
|
|
|
rt_exit_critical();
|
2011-12-19 15:08:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int _tc_sample()
|
|
|
|
{
|
2013-12-21 12:51:52 +08:00
|
|
|
/* set tc cleanup */
|
|
|
|
tc_cleanup(_tc_cleanup);
|
|
|
|
sample_init();
|
2011-12-19 15:08:06 +08:00
|
|
|
|
2013-12-21 12:51:52 +08:00
|
|
|
return 25;
|
2011-12-19 15:08:06 +08:00
|
|
|
}
|
|
|
|
FINSH_FUNCTION_EXPORT(_tc_sample, a thread testcase example);
|
|
|
|
#else
|
|
|
|
int rt_application_init()
|
|
|
|
{
|
2013-12-21 12:51:52 +08:00
|
|
|
sample_init();
|
2011-12-19 15:08:06 +08:00
|
|
|
|
2013-12-21 12:51:52 +08:00
|
|
|
return 0;
|
2011-12-19 15:08:06 +08:00
|
|
|
}
|
|
|
|
#endif
|