summaryrefslogtreecommitdiff
path: root/examples/kernel/tc_sample.c
diff options
context:
space:
mode:
author[email protected] <[email protected]>2011-12-19 07:08:06 +0000
committer[email protected] <[email protected]>2011-12-19 07:08:06 +0000
commitd28cdf68d923b355d144029f6aeb0aa405f3ab3f (patch)
treec7add4950886cbe726a0f43b914712fc48d0c1a4 /examples/kernel/tc_sample.c
parent212d828d3ff4dd0f57e2d2a54a9096f00eb88535 (diff)
update testcase for kernel.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1849 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/kernel/tc_sample.c')
-rw-r--r--examples/kernel/tc_sample.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/examples/kernel/tc_sample.c b/examples/kernel/tc_sample.c
new file mode 100644
index 0000000000..ea77ccda39
--- /dev/null
+++ b/examples/kernel/tc_sample.c
@@ -0,0 +1,62 @@
+#include <rtthread.h>
+#include "tc_comm.h"
+
+static rt_thread_t tid = RT_NULL;
+static void sample_thread(void* parameter)
+{
+ rt_kprintf("I'm sample!\n");
+}
+static void sample_thread_cleanup(struct rt_thread *p)
+{
+ tid = RT_NULL;
+ tc_done(TC_STAT_PASSED);
+}
+
+int sample_init()
+{
+ 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);
+
+ return 0;
+}
+
+#ifdef RT_USING_TC
+static void _tc_cleanup()
+{
+ /* 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();
+}
+
+int _tc_sample()
+{
+ /* set tc cleanup */
+ tc_cleanup(_tc_cleanup);
+ sample_init();
+
+ return 25;
+}
+FINSH_FUNCTION_EXPORT(_tc_sample, a thread testcase example);
+#else
+int rt_application_init()
+{
+ sample_init();
+
+ return 0;
+}
+#endif