thread_tc.c 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <cmsis_rtthread.h>
  2. #include "utest.h"
  3. #define THREAD_STACK_SIZE 2048
  4. #define THREAD_TIMESLICE 10
  5. static osThreadId_t __current_thread;
  6. static osThreadId_t tid1 = RT_NULL;
  7. void thread1_entry(void *param)
  8. {
  9. }
  10. static void test_thread_create(void)
  11. {
  12. osThreadAttr_t thread1_attr;
  13. const char th1_name[5] = "th1";
  14. rt_memset((void *)&thread1_attr, 0, sizeof(thread1_attr));
  15. thread1_attr.name = th1_name;
  16. thread1_attr.stack_size = THREAD_STACK_SIZE;
  17. thread1_attr.priority = osThreadGetPriority(__current_thread) + 1;
  18. tid1 = osThreadNew(thread1_entry, (void *)1, &thread1_attr);
  19. uassert_true(tid1 != RT_NULL);
  20. return;
  21. }
  22. static rt_err_t utest_tc_init(void){
  23. __current_thread = osThreadGetId();
  24. return RT_EOK;
  25. }
  26. static rt_err_t utest_tc_cleanup(void){
  27. return RT_EOK;
  28. }
  29. static void testcase(void){
  30. UTEST_UNIT_RUN(test_thread_create)
  31. }
  32. UTEST_TC_EXPORT(testcase, "testcases.cmsis_os.kernel.thread_tc", utest_tc_init, utest_tc_cleanup, 1000);