1
0

thread_tc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-09.01 yangjie the firet version
  9. * 2021-10.11 mazhiyuan add idle, yield, suspend, control, priority, delay_until
  10. */
  11. #define __RT_IPC_SOURCE__ /* include internal API for utest */
  12. #include <rtthread.h>
  13. #include <stdlib.h>
  14. #include "utest.h"
  15. #define THREAD_STACK_SIZE UTEST_THR_STACK_SIZE
  16. #define THREAD_TIMESLICE 10
  17. rt_align(RT_ALIGN_SIZE)
  18. static char thread2_stack[UTEST_THR_STACK_SIZE];
  19. static struct rt_thread thread2;
  20. #ifdef RT_USING_HEAP
  21. static rt_thread_t tid1 = RT_NULL;
  22. static rt_thread_t tid3 = RT_NULL;
  23. static rt_thread_t tid4 = RT_NULL;
  24. static rt_thread_t tid5 = RT_NULL;
  25. static rt_thread_t tid6 = RT_NULL;
  26. static rt_thread_t tid7 = RT_NULL;
  27. #endif /* RT_USING_HEAP */
  28. static volatile rt_uint32_t tid3_delay_pass_flag = 0;
  29. static volatile rt_uint32_t tid3_finish_flag = 0;
  30. static volatile rt_uint32_t tid4_finish_flag = 0;
  31. static volatile rt_uint32_t tid6_finish_flag = 0;
  32. static volatile rt_uint32_t thread5_source = 0;
  33. #ifndef RT_USING_SMP
  34. static volatile rt_uint32_t thread_yield_flag = 0;
  35. #endif
  36. static volatile rt_uint32_t entry_idle_hook_times = 0;
  37. static rt_thread_t __current_thread;
  38. static rt_uint8_t change_priority;
  39. static volatile rt_uint32_t count = 0;
  40. void thread1_entry(void *param)
  41. {
  42. while (1);
  43. }
  44. static void test_dynamic_thread(void)
  45. {
  46. rt_err_t ret_startup = -RT_ERROR;
  47. rt_err_t ret_delete = -RT_ERROR;
  48. tid1 = rt_thread_create("thread1",
  49. thread1_entry,
  50. (void *)1,
  51. THREAD_STACK_SIZE,
  52. UTEST_THR_PRIORITY + 1,
  53. THREAD_TIMESLICE - 5);
  54. if (tid1 == RT_NULL)
  55. {
  56. uassert_false(tid1 == RT_NULL);
  57. goto __exit;
  58. }
  59. ret_startup = rt_thread_startup(tid1);
  60. if (ret_startup != RT_EOK)
  61. {
  62. uassert_false(ret_startup != RT_EOK);
  63. goto __exit;
  64. }
  65. ret_delete = rt_thread_delete(tid1);
  66. if (ret_delete != RT_EOK)
  67. {
  68. uassert_false(ret_delete != RT_EOK);
  69. goto __exit;
  70. }
  71. uassert_true(tid1 != RT_NULL && ret_startup == RT_EOK && ret_delete == RT_EOK);
  72. __exit:
  73. if (tid1 != RT_NULL && ret_delete != RT_EOK)
  74. {
  75. rt_thread_delete(tid1);
  76. }
  77. return;
  78. }
  79. void thread2_entry(void *param)
  80. {
  81. while (1);
  82. }
  83. static void test_static_thread(void)
  84. {
  85. rt_err_t ret_init = -RT_ERROR;
  86. rt_err_t ret_startup = -RT_ERROR;
  87. rt_err_t ret_detach = -RT_ERROR;
  88. ret_init = rt_thread_init(&thread2,
  89. "thread2",
  90. thread2_entry,
  91. (void *)2,
  92. &thread2_stack[0],
  93. sizeof(thread2_stack),
  94. UTEST_THR_PRIORITY + 1,
  95. THREAD_TIMESLICE);
  96. if (ret_init != RT_EOK)
  97. {
  98. uassert_false(ret_init != RT_EOK);
  99. goto __exit;
  100. }
  101. ret_startup = rt_thread_startup(&thread2);
  102. if (ret_startup != RT_EOK)
  103. {
  104. uassert_false(ret_startup != RT_EOK);
  105. goto __exit;
  106. }
  107. ret_detach = rt_thread_detach(&thread2);
  108. if (ret_detach != RT_EOK)
  109. {
  110. uassert_false(ret_detach != RT_EOK);
  111. goto __exit;
  112. }
  113. uassert_true(ret_init == RT_EOK && ret_startup == RT_EOK && ret_detach == RT_EOK);
  114. __exit:
  115. if (ret_init == RT_EOK && ret_detach != RT_EOK)
  116. {
  117. rt_thread_detach(&thread2);
  118. }
  119. return;
  120. }
  121. static void thread3_entry(void *parameter)
  122. {
  123. rt_tick_t tick, latency_tick;
  124. tick = rt_tick_get();
  125. rt_thread_delay(15);
  126. latency_tick = rt_tick_get() - tick;
  127. if (latency_tick > 16 || latency_tick < 15)
  128. {
  129. tid3_finish_flag = 1;
  130. tid3_delay_pass_flag = 0;
  131. return;
  132. }
  133. tid3_delay_pass_flag = 1;
  134. tid3_finish_flag = 1;
  135. }
  136. static void test_thread_delay(void)
  137. {
  138. rt_err_t ret_startup = -RT_ERROR;
  139. tid3 = rt_thread_create("thread3",
  140. thread3_entry,
  141. RT_NULL,
  142. THREAD_STACK_SIZE,
  143. UTEST_THR_PRIORITY - 1,
  144. THREAD_TIMESLICE);
  145. if (tid3 == RT_NULL)
  146. {
  147. LOG_E("rt_thread_create failed!");
  148. uassert_false(tid3 == RT_NULL);
  149. goto __exit;
  150. }
  151. ret_startup = rt_thread_startup(tid3);
  152. if (ret_startup != RT_EOK)
  153. {
  154. LOG_E("rt_thread_startup failed!");
  155. uassert_false(1);
  156. goto __exit;
  157. }
  158. while (tid3_finish_flag != 1);
  159. uassert_true(tid3_delay_pass_flag == 1);
  160. __exit:
  161. return;
  162. }
  163. static void idle_hook(void)
  164. {
  165. entry_idle_hook_times ++;
  166. }
  167. static void thread4_entry(void *parameter)
  168. {
  169. rt_uint32_t delay_times = 5;
  170. while (delay_times --)
  171. {
  172. rt_thread_mdelay(300);
  173. }
  174. rt_thread_idle_delhook(idle_hook);
  175. tid4_finish_flag = 1;
  176. }
  177. static void test_idle_hook(void)
  178. {
  179. rt_err_t ret_startup = -RT_ERROR;
  180. rt_thread_idle_sethook(idle_hook);
  181. tid4 = rt_thread_create("thread4",
  182. thread4_entry,
  183. RT_NULL,
  184. THREAD_STACK_SIZE,
  185. UTEST_THR_PRIORITY - 1,
  186. THREAD_TIMESLICE);
  187. if (tid4 == RT_NULL)
  188. {
  189. LOG_E("rt_thread_create failed!");
  190. uassert_false(tid4 == RT_NULL);
  191. goto __exit;
  192. }
  193. ret_startup = rt_thread_startup(tid4);
  194. if (ret_startup != RT_EOK)
  195. {
  196. LOG_E("rt_thread_startup failed!");
  197. uassert_false(1);
  198. goto __exit;
  199. }
  200. while (tid4_finish_flag != 1)
  201. {
  202. rt_thread_mdelay(200);
  203. }
  204. uassert_true(entry_idle_hook_times > 0);
  205. __exit:
  206. return;
  207. }
  208. static void thread5_entry(void *parameter)
  209. {
  210. while (1)
  211. {
  212. thread5_source ++;
  213. rt_thread_delay(5);
  214. if (thread5_source == 5)
  215. {
  216. rt_thread_yield();
  217. }
  218. }
  219. }
  220. static void thread6_entry(void *parameter)
  221. {
  222. while (++ thread5_source <= 9);
  223. tid6_finish_flag = 1;
  224. }
  225. static void test_thread_yield(void)
  226. {
  227. rt_err_t ret_startup = -RT_ERROR;
  228. thread5_source = 0;
  229. tid5 = rt_thread_create("thread5",
  230. thread5_entry,
  231. RT_NULL,
  232. THREAD_STACK_SIZE,
  233. UTEST_THR_PRIORITY - 1,
  234. THREAD_TIMESLICE);
  235. if (tid5 == RT_NULL)
  236. {
  237. LOG_E("rt_thread_create failed!");
  238. uassert_false(tid5 == RT_NULL);
  239. goto __exit;
  240. }
  241. ret_startup = rt_thread_startup(tid5);
  242. if (ret_startup != RT_EOK)
  243. {
  244. LOG_E("rt_thread_startup failed!");
  245. uassert_false(1);
  246. goto __exit;
  247. }
  248. tid6 = rt_thread_create("thread6",
  249. thread6_entry,
  250. RT_NULL,
  251. THREAD_STACK_SIZE,
  252. UTEST_THR_PRIORITY - 1,
  253. THREAD_TIMESLICE);
  254. if (tid6 == RT_NULL)
  255. {
  256. LOG_E("rt_thread_create failed!");
  257. uassert_false(tid6 == RT_NULL);
  258. goto __exit;
  259. }
  260. ret_startup = rt_thread_startup(tid6);
  261. if (ret_startup != RT_EOK)
  262. {
  263. LOG_E("rt_thread_startup failed!");
  264. uassert_false(1);
  265. goto __exit;
  266. }
  267. while (tid6_finish_flag != 1);
  268. uassert_true(thread5_source == 10);
  269. __exit:
  270. if (tid5 != RT_NULL)
  271. {
  272. rt_thread_delete(tid5);
  273. }
  274. return;
  275. }
  276. static void thread7_entry(void *parameter)
  277. {
  278. while (1);
  279. }
  280. static void test_thread_control(void)
  281. {
  282. rt_err_t ret_control = -RT_ERROR;
  283. rt_err_t rst_delete = -RT_ERROR;
  284. rt_sched_lock_level_t slvl;
  285. tid7 = rt_thread_create("thread7",
  286. thread7_entry,
  287. RT_NULL,
  288. THREAD_STACK_SIZE,
  289. UTEST_THR_PRIORITY + 1,
  290. THREAD_TIMESLICE);
  291. if (tid7 == RT_NULL)
  292. {
  293. LOG_E("rt_thread_create failed!");
  294. uassert_false(tid7 == RT_NULL);
  295. goto __exit;
  296. }
  297. ret_control = rt_thread_control(tid7, RT_THREAD_CTRL_STARTUP, RT_NULL);
  298. if (ret_control != RT_EOK)
  299. {
  300. LOG_E("rt_thread_control failed!");
  301. uassert_false(1);
  302. goto __exit;
  303. }
  304. rt_thread_mdelay(200);
  305. rt_thread_control(tid7, RT_THREAD_CTRL_CHANGE_PRIORITY, &change_priority);
  306. rt_sched_lock(&slvl);
  307. if (rt_sched_thread_get_curr_prio(tid7) != change_priority)
  308. {
  309. LOG_E("rt_thread_control failed!");
  310. uassert_false(1);
  311. rt_sched_unlock(slvl);
  312. goto __exit;
  313. }
  314. rt_sched_unlock(slvl);
  315. rst_delete = rt_thread_control(tid7, RT_THREAD_CTRL_CLOSE, RT_NULL);
  316. if (rst_delete != RT_EOK)
  317. {
  318. LOG_E("rt_thread_control failed!");
  319. uassert_false(rst_delete != RT_EOK);
  320. goto __exit;
  321. }
  322. uassert_true(1);
  323. __exit:
  324. if (tid7 != RT_NULL && rst_delete != RT_EOK)
  325. {
  326. rt_thread_delete(tid7);
  327. }
  328. return;
  329. }
  330. static void thread8_entry(void *parameter)
  331. {
  332. for (; count < 10; count ++);
  333. }
  334. static void test_thread_priority(void)
  335. {
  336. rt_err_t ret_startup = -RT_ERROR;
  337. rt_thread_t tid8 = RT_NULL;
  338. tid8 = rt_thread_create("thread8",
  339. thread8_entry,
  340. RT_NULL,
  341. THREAD_STACK_SIZE,
  342. UTEST_THR_PRIORITY - 1,
  343. THREAD_TIMESLICE);
  344. if (tid8 == RT_NULL)
  345. {
  346. LOG_E("rt_thread_create failed!");
  347. uassert_false(tid8 == RT_NULL);
  348. return;
  349. }
  350. count = 0;
  351. ret_startup = rt_thread_startup(tid8);
  352. if (ret_startup != RT_EOK)
  353. {
  354. uassert_false(ret_startup != RT_EOK);
  355. return ;
  356. }
  357. uassert_true(count == 10);
  358. return;
  359. }
  360. static void test_delay_until(void)
  361. {
  362. rt_tick_t tick;
  363. rt_tick_t check_tick = 0;
  364. rt_tick_t delta = 0;
  365. tick = rt_tick_get();
  366. check_tick = tick;
  367. rt_thread_delay_until(&tick, 100);
  368. delta = rt_tick_get() - check_tick;
  369. rt_kprintf("delta[100] -> %d\n", delta);
  370. uassert_int_equal(delta, 100);
  371. check_tick = tick;
  372. rt_thread_delay(2);
  373. rt_thread_delay_until(&tick, 200);
  374. delta = rt_tick_get() - check_tick;
  375. rt_kprintf("delta[200] -> %d\n", delta);
  376. uassert_int_equal(delta, 200);
  377. check_tick = tick;
  378. rt_thread_delay(2);
  379. rt_thread_delay_until(&tick, 300);
  380. delta = rt_tick_get() - check_tick;
  381. rt_kprintf("delta[300] -> %d\n", delta);
  382. uassert_int_equal(delta, 300);
  383. check_tick = tick;
  384. rt_thread_delay(2);
  385. rt_thread_delay_until(&tick, 100);
  386. delta = rt_tick_get() - check_tick;
  387. uassert_int_equal(delta, 100);
  388. check_tick = tick;
  389. rt_thread_delay(2);
  390. rt_thread_delay_until(&tick, 50);
  391. delta = rt_tick_get() - check_tick;
  392. rt_kprintf("delta[50] -> %d\n", delta);
  393. uassert_int_equal(delta, 50);
  394. check_tick = tick;
  395. rt_thread_delay(2);
  396. rt_thread_delay_until(&tick, 20);
  397. delta = rt_tick_get() - check_tick;
  398. rt_kprintf("delta[20] -> %d\n", delta);
  399. uassert_int_equal(delta, 20);
  400. /**
  401. * the rt_kprints above can take few ticks to complete, maybe more than 10
  402. */
  403. tick = rt_tick_get();
  404. check_tick = tick;
  405. rt_thread_delay(2);
  406. rt_thread_delay_until(&tick, 10);
  407. delta = rt_tick_get() - check_tick;
  408. rt_kprintf("delta[10] -> %d\n", delta);
  409. uassert_int_equal(delta, 10);
  410. }
  411. static rt_thread_t tidA, tidB1, tidB2;
  412. static uint32_t timeslice_cntA, timeslice_cntB1, timeslice_cntB2;
  413. static void test_timeslice_threadA_entry(void *parameter)
  414. {
  415. while (1)
  416. {
  417. rt_thread_delay(2);
  418. timeslice_cntA++;
  419. if (timeslice_cntA > 10) return;
  420. }
  421. }
  422. static void test_timeslice_threadB1_entry(void *parameter)
  423. {
  424. while (1)
  425. {
  426. timeslice_cntB1++;
  427. if (timeslice_cntA > 10) return;
  428. }
  429. }
  430. static void test_timeslice_threadB2_entry(void *parameter)
  431. {
  432. while (1)
  433. {
  434. timeslice_cntB2++;
  435. if (timeslice_cntA > 10) return;
  436. }
  437. }
  438. void test_timeslice(void)
  439. {
  440. rt_err_t ret_startup = -RT_ERROR;
  441. uint32_t diff;
  442. timeslice_cntA = 0;
  443. timeslice_cntB1 = 0;
  444. timeslice_cntB2 = 0;
  445. tidA = rt_thread_create("timeslice", test_timeslice_threadA_entry, RT_NULL,
  446. 2048, UTEST_THR_PRIORITY + 1, 10);
  447. if (!tidA)
  448. {
  449. LOG_E("rt_thread_create failed!");
  450. return;
  451. }
  452. rt_thread_control(tidA, RT_THREAD_CTRL_BIND_CPU, (void *)1);
  453. ret_startup = rt_thread_startup(tidA);
  454. if (ret_startup != RT_EOK)
  455. {
  456. LOG_E("rt_thread_startup failed!");
  457. uassert_false(1);
  458. return ;
  459. }
  460. tidB1 = rt_thread_create("timeslice", test_timeslice_threadB1_entry, RT_NULL,
  461. 2048, UTEST_THR_PRIORITY + 2, 2);
  462. if (!tidB1)
  463. {
  464. LOG_E("rt_thread_create failed!");
  465. return;
  466. }
  467. rt_thread_control(tidB1, RT_THREAD_CTRL_BIND_CPU, (void *)1);
  468. ret_startup = rt_thread_startup(tidB1);
  469. if (ret_startup != RT_EOK)
  470. {
  471. LOG_E("rt_thread_startup failed!");
  472. uassert_false(1);
  473. return ;
  474. }
  475. tidB2 = rt_thread_create("timeslice", test_timeslice_threadB2_entry, RT_NULL,
  476. 2048, UTEST_THR_PRIORITY + 2, 2);
  477. if (!tidB2)
  478. {
  479. LOG_E("rt_thread_create failed!");
  480. return;
  481. }
  482. rt_thread_control(tidB2, RT_THREAD_CTRL_BIND_CPU, (void *)1);
  483. ret_startup = rt_thread_startup(tidB2);
  484. if (ret_startup != RT_EOK)
  485. {
  486. LOG_E("rt_thread_startup failed!");
  487. uassert_false(1);
  488. return ;
  489. }
  490. do{
  491. rt_thread_delay(2 * 20);
  492. }while(timeslice_cntA <= 10);
  493. rt_kprintf("A:%d,B1:%d,B2:%d\n", timeslice_cntA, timeslice_cntB1, timeslice_cntB2);
  494. diff = abs(timeslice_cntB1 - timeslice_cntB2);
  495. uassert_true(diff * 100 / timeslice_cntB1 < 30);
  496. uassert_true(timeslice_cntA == 11);
  497. }
  498. #ifndef RT_USING_SMP
  499. static volatile rt_uint32_t yield_count;
  500. static void test_thread_yield_inc_entry(void *parameter)
  501. {
  502. rt_uint32_t loop = 0;
  503. while (1)
  504. {
  505. if (loop++ > 10001)
  506. break;
  507. yield_count++;
  508. rt_thread_yield();
  509. }
  510. }
  511. static void test_thread_yield_entry(void *parameter)
  512. {
  513. rt_err_t ret_startup = -RT_ERROR;
  514. rt_thread_t tid;
  515. rt_uint32_t loop = 0;
  516. rt_uint32_t count_before;
  517. tid = rt_thread_create("inc", test_thread_yield_inc_entry, RT_NULL,
  518. 2048, 1, 10);
  519. if (!tid)
  520. {
  521. LOG_E("rt_thread_create failed!");
  522. return;
  523. }
  524. ret_startup = rt_thread_startup(tid);
  525. if (ret_startup != RT_EOK)
  526. {
  527. LOG_E("rt_thread_startup failed!");
  528. uassert_false(1);
  529. return ;
  530. }
  531. while (1)
  532. {
  533. if (loop++ > 10000)
  534. break;
  535. count_before = yield_count;
  536. rt_thread_yield();
  537. if (yield_count == count_before)
  538. {
  539. LOG_E("yield error!");
  540. return;
  541. }
  542. }
  543. thread_yield_flag = 1;
  544. }
  545. void test_thread_yield_nosmp(void)
  546. {
  547. rt_err_t ret_startup = -RT_ERROR;
  548. rt_thread_t tid;
  549. yield_count = 0;
  550. tid = rt_thread_create("chkcnt", test_thread_yield_entry, RT_NULL,
  551. 2048, 1, 10);
  552. if (!tid)
  553. {
  554. LOG_E("rt_thread_create failed!");
  555. return;
  556. }
  557. ret_startup = rt_thread_startup(tid);
  558. if (ret_startup != RT_EOK)
  559. {
  560. LOG_E("rt_thread_startup failed!");
  561. uassert_false(1);
  562. return ;
  563. }
  564. uassert_true(thread_yield_flag == 1);
  565. }
  566. // static rt_uint32_t thread9_count = 0;
  567. // static void thread9_entry(void *parameter)
  568. // {
  569. // while (1)
  570. // {
  571. // thread9_count ++;
  572. // }
  573. // }
  574. // static void test_thread_suspend(void)
  575. // {
  576. // static rt_thread_t tid;
  577. // rt_err_t ret_startup = -RT_ERROR;
  578. // uint32_t count_before_suspend, count_before_resume, count_after_resume;
  579. // tid = rt_thread_create("thread9",
  580. // thread9_entry,
  581. // RT_NULL,
  582. // THREAD_STACK_SIZE,
  583. // UTEST_THR_PRIORITY + 1,
  584. // THREAD_TIMESLICE);
  585. // if (tid == RT_NULL)
  586. // {
  587. // LOG_E("rt_thread_create failed!");
  588. // uassert_false(tid4 == RT_NULL);
  589. // goto __exit;
  590. // }
  591. // ret_startup = rt_thread_startup(tid);
  592. // if (ret_startup != RT_EOK)
  593. // {
  594. // LOG_E("rt_thread_startup failed!");
  595. // uassert_false(1);
  596. // goto __exit;
  597. // }
  598. // rt_thread_delay(5);
  599. // rt_thread_suspend(tid);
  600. // count_before_suspend = thread9_count;
  601. // uassert_true(count_before_suspend != 0);
  602. // rt_thread_delay(5);
  603. // count_before_resume = thread9_count;
  604. // uassert_true(count_before_suspend == count_before_resume);
  605. // rt_thread_resume(tid);
  606. // rt_thread_delay(5);
  607. // count_after_resume = thread9_count;
  608. // uassert_true(count_after_resume != count_before_resume);
  609. // __exit:
  610. // if (tid != RT_NULL)
  611. // {
  612. // rt_thread_delete(tid);
  613. // }
  614. // return;
  615. // }
  616. #endif
  617. static rt_err_t utest_tc_init(void)
  618. {
  619. __current_thread = rt_thread_self();
  620. change_priority = UTEST_THR_PRIORITY + 5;
  621. tid3_delay_pass_flag = 0;
  622. tid3_finish_flag = 0;
  623. tid4_finish_flag = 0;
  624. tid6_finish_flag = 0;
  625. entry_idle_hook_times = 0;
  626. count = 0;
  627. return RT_EOK;
  628. }
  629. static rt_err_t utest_tc_cleanup(void)
  630. {
  631. return RT_EOK;
  632. }
  633. static void testcase(void)
  634. {
  635. /* init, detach */
  636. UTEST_UNIT_RUN(test_static_thread);
  637. /* create, delete */
  638. UTEST_UNIT_RUN(test_dynamic_thread);
  639. /* delay */
  640. UTEST_UNIT_RUN(test_thread_delay);
  641. /* idle_sethook, idle_delhook */
  642. UTEST_UNIT_RUN(test_idle_hook);
  643. /* yield */
  644. UTEST_UNIT_RUN(test_thread_yield);
  645. #ifndef RT_USING_SMP
  646. /* yield_nosmp */
  647. UTEST_UNIT_RUN(test_thread_yield_nosmp);
  648. /* suspend, resume */
  649. // UTEST_UNIT_RUN(test_thread_suspend);
  650. #endif
  651. /* control */
  652. UTEST_UNIT_RUN(test_thread_control);
  653. UTEST_UNIT_RUN(test_thread_priority);
  654. /* delay_until */
  655. UTEST_UNIT_RUN(test_delay_until);
  656. /* timeslice */
  657. // UTEST_UNIT_RUN(test_timeslice); /* Can not running in Github Action QEMU */
  658. }
  659. UTEST_TC_EXPORT(testcase, "testcases.kernel.thread_tc", utest_tc_init, utest_tc_cleanup, 1000);
  660. /********************* end of file ************************/