1 /*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "xts_cmsis.h"
32
33 UINT32 g_threadCount;
34 UINT16 g_cmsisTestTaskCount;
35 UINT16 g_getStackSizeExit;
36 UINT16 g_threadCreateExit;
37 UINT16 g_threadCreateExit1;
38 UINT16 g_getNameExit;
39 UINT16 g_getStackSpaceExit;
40 osThreadId_t g_puwTaskID01;
41 osThreadId_t g_puwTaskID02;
42 osPriority_t g_threadPriority;
43
44 LITE_TEST_SUIT(Cmsis, Cmsistask, CmsisTaskFuncTestSuite);
45
CmsisTaskFuncTestSuiteSetUp(void)46 static BOOL CmsisTaskFuncTestSuiteSetUp(void)
47 {
48 return TRUE;
49 }
50
CmsisTaskFuncTestSuiteTearDown(void)51 static BOOL CmsisTaskFuncTestSuiteTearDown(void)
52 {
53 return TRUE;
54 }
55
CmsisThreadCreatFunc(void const *argument)56 static void CmsisThreadCreatFunc(void const *argument)
57 {
58 (void)argument;
59 g_threadCreateExit = TESTCOUNT_NUM_1;
60 osThreadExit();
61 }
62
CmsisThreadCreat002Func001(void const *argument)63 static void CmsisThreadCreat002Func001(void const *argument)
64 {
65 (void)argument;
66 g_cmsisTestTaskCount++;
67 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
68 g_threadCreateExit = TESTCOUNT_NUM_1;
69 osThreadExit();
70 }
71
CmsisThreadCreat002Func002(void const *argument)72 static void CmsisThreadCreat002Func002(void const *argument)
73 {
74 (void)argument;
75 g_cmsisTestTaskCount++;
76 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
77 osThreadExit();
78 }
79
CmsisThreadCreat003Func001(void const *argument)80 static void CmsisThreadCreat003Func001(void const *argument)
81 {
82 (void)argument;
83 osStatus_t status;
84 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, 0, g_cmsisTestTaskCount);
85 g_cmsisTestTaskCount++;
86 status = osDelay(DELAY_TICKS_5);
87 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
88 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
89 g_cmsisTestTaskCount++;
90 g_threadCreateExit = TESTCOUNT_NUM_1;
91 osThreadExit();
92 }
93
CmsisThreadCreat003Func002(void const *argument)94 static void CmsisThreadCreat003Func002(void const *argument)
95 {
96 (void)argument;
97 osStatus_t status;
98 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
99 g_cmsisTestTaskCount++;
100 status = osDelay(DELAY_TICKS_5);
101 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
102 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_4, g_cmsisTestTaskCount);
103 g_cmsisTestTaskCount++;
104 osThreadExit();
105 }
106
CmsisThreadCreat004Func002(void const *argument)107 static void CmsisThreadCreat004Func002(void const *argument)
108 {
109 (void)argument;
110 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
111 g_cmsisTestTaskCount++;
112 osThreadExit();
113 }
114
CmsisThreadCreat004Func001(void const *argument)115 static void CmsisThreadCreat004Func001(void const *argument)
116 {
117 (void)argument;
118 osThreadId_t osId;
119 osThreadAttr_t osAttr;
120 osAttr.name = "test";
121 osAttr.attr_bits = 0U;
122 osAttr.cb_mem = NULL;
123 osAttr.cb_size = 0U;
124 osAttr.stack_mem = NULL;
125 osAttr.stack_size = TEST_TASK_STACK_SIZE;
126 osAttr.priority = osPriorityAboveNormal1;
127 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, 0, g_cmsisTestTaskCount);
128 g_cmsisTestTaskCount++;
129 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat004Func002, NULL, &osAttr);
130 ICUNIT_ASSERT_NOT_EQUAL_VOID(osId, NULL, osId);
131 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
132 g_cmsisTestTaskCount++;
133 g_threadCreateExit = TESTCOUNT_NUM_1;
134 osThreadExit();
135 }
136
KeepRunByTick(UINT32 tick)137 static void KeepRunByTick(UINT32 tick)
138 {
139 UINT32 tickA = osKernelGetTickCount();
140 UINT32 runned = 0;
141 UINT32 tickB = 0;
142 while (runned < tick) {
143 tickB = osKernelGetTickCount();
144 if (tickB >= tickA) {
145 runned = tickB - tickA;
146 } else {
147 runned = tickB + (MAX_UINT32 - tickA);
148 }
149 }
150 return;
151 }
152
WaitThreadExit(osThreadId_t id, UINT16 const *exitFlag)153 static void WaitThreadExit(osThreadId_t id, UINT16 const *exitFlag)
154 {
155 osStatus_t status;
156 (void)osThreadSetPriority(id, PRIORITY_COUNT_MIN_1);
157 while (*exitFlag != TESTCOUNT_NUM_1) {
158 status = osDelay(DELAY_TICKS_10);
159 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
160 }
161 }
162
CmsisThreadCreat005Func001(void const *argument)163 static void CmsisThreadCreat005Func001(void const *argument)
164 {
165 (void)argument;
166 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
167 while (g_cmsisTestTaskCount < TESTCOUNT_NUM_2) {
168 KeepRunByTick(DELAY_TICKS_10);
169 }
170 g_cmsisTestTaskCount++;
171 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
172 g_threadCreateExit = TESTCOUNT_NUM_1;
173 osThreadExit();
174 }
175
CmsisThreadGetIDFunc001(void const *argument)176 static void CmsisThreadGetIDFunc001(void const *argument)
177 {
178 (void)argument;
179 g_puwTaskID01 = osThreadGetId();
180 ICUNIT_ASSERT_NOT_EQUAL_VOID(g_puwTaskID01, NULL, g_puwTaskID01);
181 g_threadCreateExit = TESTCOUNT_NUM_1;
182 osThreadExit();
183 }
184
CmsisThreadGetNameFunc001(void const *argument)185 static void CmsisThreadGetNameFunc001(void const *argument)
186 {
187 (void)argument;
188 osThreadAttr_t attr;
189 g_puwTaskID01 = osThreadGetId();
190 attr.name = osThreadGetName(g_puwTaskID01);
191 ICUNIT_ASSERT_STRING_EQUAL_VOID(attr.name, "testThreadGetName", attr.name);
192 g_getNameExit = TESTCOUNT_NUM_1;
193 osThreadExit();
194 }
195
CmsisThreadGetStateFunc001(void const *argument)196 static void CmsisThreadGetStateFunc001(void const *argument)
197 {
198 (void)argument;
199 osThreadState_t state = osThreadGetState(g_puwTaskID01);
200 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadBlocked, state);
201
202 g_puwTaskID02 = osThreadGetId();
203 state = osThreadGetState(g_puwTaskID02);
204 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadRunning, state);
205 g_threadCreateExit1 = TESTCOUNT_NUM_1;
206 osThreadExit();
207 }
208
CmsisThreadGetStateFunc002(void const *argument)209 static void CmsisThreadGetStateFunc002(void const *argument)
210 {
211 (void)argument;
212 osThreadState_t state = osThreadGetState(g_puwTaskID01);
213 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadReady, state);
214
215 g_puwTaskID02 = osThreadGetId();
216 state = osThreadGetState(g_puwTaskID02);
217 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadRunning, state);
218 g_threadCreateExit = TESTCOUNT_NUM_1;
219 osThreadExit();
220 }
221
CmsisThreadSuspendFunc001(void const *argument)222 static void CmsisThreadSuspendFunc001(void const *argument)
223 {
224 (void)argument;
225 osStatus_t status;
226 g_puwTaskID01 = osThreadGetId();
227 status = osThreadSuspend(g_puwTaskID01);
228 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
229 g_threadCreateExit = TESTCOUNT_NUM_1;
230 osThreadExit();
231 }
232
CmsisThreadGetStackSizeFunc001(void const *argument)233 static void CmsisThreadGetStackSizeFunc001(void const *argument)
234 {
235 (void)argument;
236 osThreadAttr_t attr;
237 g_puwTaskID01 = osThreadGetId();
238 attr.stack_size = osThreadGetStackSize(g_puwTaskID01);
239 ICUNIT_ASSERT_EQUAL_VOID(attr.stack_size, TEST_TASK_STACK_SIZE, attr.stack_size);
240 g_getStackSizeExit = TESTCOUNT_NUM_1;
241 osThreadExit();
242 }
243
CmsisThreadGetStackSpaceFunc001(void const *argument)244 static void CmsisThreadGetStackSpaceFunc001(void const *argument)
245 {
246 (void)argument;
247 UINT32 uwCount;
248 g_puwTaskID01 = osThreadGetId();
249 uwCount = osThreadGetStackSpace(g_puwTaskID01);
250 ICUNIT_ASSERT_WITHIN_EQUAL_VOID(uwCount, 0, INT_MAX, uwCount);
251 g_getStackSpaceExit = TESTCOUNT_NUM_1;
252 osThreadExit();
253 }
254
CmsisThreadYieldFunc002(void const *argument)255 static void CmsisThreadYieldFunc002(void const *argument)
256 {
257 (void)argument;
258 osThreadState_t state = osThreadGetState(g_puwTaskID01);
259 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadReady, state);
260 g_cmsisTestTaskCount++;
261 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
262 g_threadCreateExit = TESTCOUNT_NUM_1;
263 osThreadExit();
264 }
265
CmsisThreadYieldFunc001(void const *argument)266 static void CmsisThreadYieldFunc001(void const *argument)
267 {
268 (void)argument;
269 osStatus_t status;
270 osThreadId_t osId;
271 osThreadState_t state;
272 osThreadAttr_t osAttr;
273 osAttr.name = "test";
274 osAttr.attr_bits = 0U;
275 osAttr.cb_mem = NULL;
276 osAttr.cb_size = 0U;
277 osAttr.stack_mem = NULL;
278 osAttr.stack_size = TEST_TASK_STACK_SIZE;
279 osAttr.priority = g_threadPriority;
280 g_threadCreateExit = 0;
281 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
282 g_puwTaskID01 = osThreadGetId();
283 osId = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc002, NULL, &osAttr);
284 ICUNIT_ASSERT_NOT_EQUAL_VOID(osId, NULL, osId);
285 state = osThreadGetState(g_puwTaskID01);
286 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadRunning, state);
287 status = osThreadYield();
288 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
289 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
290 g_threadCreateExit1 = TESTCOUNT_NUM_1;
291 WaitThreadExit(osId, &g_threadCreateExit);
292 osThreadExit();
293 }
294
CmsisThreadYieldFunc003(void const *argument)295 static void CmsisThreadYieldFunc003(void const *argument)
296 {
297 (void)argument;
298 osStatus_t status;
299 osThreadId_t osId;
300 osThreadState_t state;
301 osThreadAttr_t osAttr;
302 osAttr.name = "test";
303 osAttr.attr_bits = 0U;
304 osAttr.cb_mem = NULL;
305 osAttr.cb_size = 0U;
306 osAttr.stack_mem = NULL;
307 osAttr.stack_size = TEST_TASK_STACK_SIZE;
308 osAttr.priority = osPriorityNormal7;
309 g_puwTaskID01 = osThreadGetId();
310 g_threadCreateExit = 0;
311 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
312 ICUNIT_ASSERT_NOT_EQUAL_VOID(osId, NULL, osId);
313 state = osThreadGetState(g_puwTaskID01);
314 ICUNIT_ASSERT_EQUAL_VOID(state, osThreadRunning, state);
315 status = osThreadYield();
316 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
317 WaitThreadExit(osId, &g_threadCreateExit);
318 g_threadCreateExit1 = TESTCOUNT_NUM_1;
319 osThreadExit();
320 }
321
CmsisThreadResumeFunc002(void const *argument)322 static void CmsisThreadResumeFunc002(void const *argument)
323 {
324 (void)argument;
325 osStatus_t status;
326 g_cmsisTestTaskCount++;
327 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
328 status = osThreadResume(g_puwTaskID01);
329 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
330 status = osDelay(DELAY_TICKS_5);
331 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
332 osThreadExit();
333 }
334
CmsisThreadResumeFunc001(void const *argument)335 static void CmsisThreadResumeFunc001(void const *argument)
336 {
337 (void)argument;
338 osStatus_t status;
339 osThreadId_t osId;
340 osThreadAttr_t osAttr;
341 osAttr.name = "test";
342 osAttr.attr_bits = 0U;
343 osAttr.cb_mem = NULL;
344 osAttr.cb_size = 0U;
345 osAttr.stack_mem = NULL;
346 osAttr.stack_size = TEST_TASK_STACK_SIZE;
347 osAttr.priority = osPriorityAboveNormal;
348 g_puwTaskID01 = osThreadGetId();
349 osId = osThreadNew((osThreadFunc_t)CmsisThreadResumeFunc002, NULL, &osAttr);
350 ICUNIT_ASSERT_NOT_EQUAL_VOID(osId, NULL, osId);
351 status = osThreadSuspend(g_puwTaskID01);
352 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
353 g_cmsisTestTaskCount++;
354 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
355 g_threadCreateExit1 = TESTCOUNT_NUM_1;
356 osThreadExit();
357 }
358
CmsisThreadTerminateFunc001(void const *argument)359 static void CmsisThreadTerminateFunc001(void const *argument)
360 {
361 (void)argument;
362 osStatus_t status;
363 g_puwTaskID01 = osThreadGetId();
364 status = osThreadTerminate(g_puwTaskID01);
365 ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
366 g_cmsisTestTaskCount++;
367 ICUNIT_ASSERT_EQUAL_VOID(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
368 osThreadExit();
369 }
370
CmsisThreadGetCountFunc002(void const *argument)371 static void CmsisThreadGetCountFunc002(void const *argument)
372 {
373 (void)argument;
374 UINT32 uwRet = osThreadGetCount();
375 ICUNIT_ASSERT_WITHIN_EQUAL_VOID(uwRet, 0, INT_MAX, uwRet);
376 osThreadExit();
377 }
378
CmsisThreadGetCountFunc001(void const *argument)379 static void CmsisThreadGetCountFunc001(void const *argument)
380 {
381 (void)argument;
382 osThreadId_t osId;
383 osThreadAttr_t osAttr;
384 osAttr.name = "test";
385 osAttr.attr_bits = 0U;
386 osAttr.cb_mem = NULL;
387 osAttr.cb_size = 0U;
388 osAttr.stack_mem = NULL;
389 osAttr.stack_size = TEST_TASK_STACK_SIZE;
390 osAttr.priority = osPriorityAboveNormal;
391 osId = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc002, NULL, &osAttr);
392 ICUNIT_ASSERT_NOT_EQUAL_VOID(osId, NULL, osId);
393 g_threadCreateExit1 = TESTCOUNT_NUM_1;
394 osThreadExit();
395 }
396
CmsisThreadGetCountFunc003(void const *argument)397 static void CmsisThreadGetCountFunc003(void const *argument)
398 {
399 (void)argument;
400 UINT32 uwRet = osThreadGetCount();
401 ICUNIT_ASSERT_EQUAL_VOID(uwRet, g_threadCount + 1, uwRet);
402 g_threadCreateExit1 = TESTCOUNT_NUM_1;
403 osThreadExit();
404 }
405
CmsisOSKernelLockFunc002(void const *arg)406 static void CmsisOSKernelLockFunc002(void const *arg)
407 {
408 (void)arg;
409 g_cmsisTestTaskCount++;
410 osThreadExit();
411 }
412
413 /**
414 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0040
415 * @tc.name : thread operation for creat fail with invalid parameter
416 * @tc.desc : [C- SOFTWARE -0200]
417 */
418 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew001, Function | MediumTest | Level1)
419 {
420 osThreadId_t osId;
421 osThreadAttr_t osAttr;
422 osStatus_t status;
423 osAttr.name = "test";
424 osAttr.attr_bits = 0U;
425 osAttr.cb_mem = NULL;
426 osAttr.cb_size = 0U;
427 osAttr.stack_mem = NULL;
428 osAttr.stack_size = TEST_TASK_STACK_SIZE;
429 osAttr.priority = osPriorityNormal;
430 g_threadCreateExit = 0;
431 status = osDelay(DELAY_TICKS_5);
432 ICUNIT_ASSERT_EQUAL(status, osOK, status);
433 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, NULL);
434 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
435 osId = osThreadNew(NULL, NULL, NULL);
436 ICUNIT_ASSERT_EQUAL(osId, NULL, osId);
437 osId = osThreadNew(NULL, NULL, &osAttr);
438 ICUNIT_ASSERT_EQUAL(osId, NULL, osId);
439 status = osDelay(DELAY_TICKS_5);
440 ICUNIT_ASSERT_EQUAL(status, osOK, status);
441 WaitThreadExit(osId, &g_threadCreateExit);
442 return 0;
443 };
444
445 /**
446 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0080
447 * @tc.name : thread operation for creat success
448 * @tc.desc : [C- SOFTWARE -0200]
449 */
450 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew002, Function | MediumTest | Level1)
451 {
452 osThreadId_t osId;
453 osThreadAttr_t osAttr;
454 osStatus_t status;
455 osAttr.name = "test";
456 osAttr.attr_bits = 0U;
457 osAttr.cb_mem = NULL;
458 osAttr.cb_size = 0U;
459 osAttr.stack_mem = NULL;
460 osAttr.stack_size = TEST_TASK_STACK_SIZE;
461 osAttr.priority = osPriorityLow1;
462 g_cmsisTestTaskCount = 0;
463 g_threadCreateExit = 0;
464 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat002Func001, NULL, &osAttr);
465 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
466 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, 0, g_cmsisTestTaskCount);
467 g_cmsisTestTaskCount++;
468 osAttr.priority = osPriorityAboveNormal;
469 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat002Func002, NULL, &osAttr);
470 status = osDelay(DELAY_TICKS_5);
471 ICUNIT_ASSERT_EQUAL(status, osOK, status);
472 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
473 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
474 WaitThreadExit(osId, &g_threadCreateExit);
475 return 0;
476 };
477
478 /**
479 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0120
480 * @tc.name : thread operation for delay scheduler
481 * @tc.desc : [C- SOFTWARE -0200]
482 */
483 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew003, Function | MediumTest | Level1)
484 {
485 osThreadId_t osId;
486 osStatus_t status;
487 osThreadAttr_t osAttr;
488 osThreadAttr_t osAttr1;
489 g_cmsisTestTaskCount = 0;
490 osAttr.name = "test";
491 osAttr.attr_bits = 0U;
492 osAttr.cb_mem = NULL;
493 osAttr.cb_size = 0U;
494 osAttr.stack_mem = NULL;
495 osAttr.stack_size = TEST_TASK_STACK_SIZE;
496 osAttr.priority = osPriorityAboveNormal;
497 g_threadCreateExit = 0;
498 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat003Func001, NULL, &osAttr);
499 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
500 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
501 g_cmsisTestTaskCount++;
502 osAttr1.name = "test1";
503 osAttr1.attr_bits = 0U;
504 osAttr1.cb_mem = NULL;
505 osAttr1.cb_size = 0U;
506 osAttr1.stack_mem = NULL;
507 osAttr1.stack_size = TEST_TASK_STACK_SIZE;
508 osAttr1.priority = osPriorityAboveNormal;
509 status = osDelay(DELAY_TICKS_1);
510 ICUNIT_ASSERT_EQUAL(status, osOK, status);
511 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat003Func002, NULL, &osAttr1);
512 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
513 status = osDelay(DELAY_TICKS_5);
514 ICUNIT_ASSERT_EQUAL(status, osOK, status);
515 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_5, g_cmsisTestTaskCount);
516 WaitThreadExit(osId, &g_threadCreateExit);
517 return 0;
518 };
519
520 /**
521 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0160
522 * @tc.name : thread operation for nesting schedule
523 * @tc.desc : [C- SOFTWARE -0200]
524 */
525 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew004, Function | MediumTest | Level1)
526 {
527 osThreadId_t osId;
528 osStatus_t status;
529 osThreadAttr_t osAttr;
530 osAttr.name = "test";
531 osAttr.attr_bits = 0U;
532 osAttr.cb_mem = NULL;
533 osAttr.cb_size = 0U;
534 osAttr.stack_mem = NULL;
535 osAttr.stack_size = TEST_TASK_STACK_SIZE;
536 g_cmsisTestTaskCount = 0;
537 osAttr.priority = osPriorityAboveNormal;
538 g_threadCreateExit = 0;
539 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat004Func001, NULL, &osAttr);
540 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
541 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
542 status = osDelay(DELAY_TICKS_5);
543 ICUNIT_ASSERT_EQUAL(status, osOK, status);
544 WaitThreadExit(osId, &g_threadCreateExit);
545 return 0;
546 };
547
548 /**
549 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0200
550 * @tc.name : thread operation for cycle schdule
551 * @tc.desc : [C- SOFTWARE -0200]
552 */
553 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew005, Function | MediumTest | Level1)
554 {
555 osThreadId_t osId;
556 osStatus_t status;
557 osThreadAttr_t osAttr;
558 osAttr.name = "test";
559 osAttr.attr_bits = 0U;
560 osAttr.cb_mem = NULL;
561 osAttr.cb_size = 0U;
562 osAttr.stack_mem = NULL;
563 osAttr.stack_size = TEST_TASK_STACK_SIZE;
564 osAttr.priority = osPriorityLow1;
565 g_cmsisTestTaskCount = 0;
566 g_cmsisTestTaskCount++;
567 g_threadCreateExit = 0;
568 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreat005Func001, NULL, &osAttr);
569 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
570 status = osDelay(DELAY_TICKS_1);
571 ICUNIT_ASSERT_EQUAL(status, osOK, status);
572 g_cmsisTestTaskCount++;
573 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
574 status = osDelay(DELAY_TICKS_5);
575 ICUNIT_ASSERT_EQUAL(status, osOK, status);
576 while (g_cmsisTestTaskCount != TESTCOUNT_NUM_3) {
577 KeepRunByTick(DELAY_TICKS_10);
578 }
579 WaitThreadExit(osId, &g_threadCreateExit);
580 return 0;
581 };
582
583 /**
584 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0240
585 * @tc.name : thread operation for creat fail when priority = osPriorityNone
586 * @tc.desc : [C- SOFTWARE -0200]
587 */
588 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew006, Function | MediumTest | Level1)
589 {
590 osThreadAttr_t osAttr;
591 osThreadId_t id;
592 osAttr.name = "test";
593 osAttr.attr_bits = 0U;
594 osAttr.cb_mem = NULL;
595 osAttr.cb_size = 0U;
596 osAttr.stack_mem = NULL;
597 osAttr.stack_size = TEST_TASK_STACK_SIZE;
598 osAttr.priority = osPriorityNone;
599 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
600 ICUNIT_ASSERT_EQUAL(id, NULL, id);
601
602 osAttr.priority = osPriorityIdle;
603 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
604 ICUNIT_ASSERT_EQUAL(id, NULL, id);
605
606 osAttr.priority = PRIORITY_COUNT_NOT_MIN;
607 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
608 ICUNIT_ASSERT_EQUAL(id, NULL, id);
609
610 osAttr.priority = osPriorityAboveNormal2;
611 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
612 ICUNIT_ASSERT_EQUAL(id, NULL, id);
613
614 osAttr.priority = osPriorityHigh;
615 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
616 ICUNIT_ASSERT_EQUAL(id, NULL, id);
617
618 osAttr.priority = osPriorityHigh7;
619 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
620 ICUNIT_ASSERT_EQUAL(id, NULL, id);
621
622 osAttr.priority = osPriorityRealtime;
623 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
624 ICUNIT_ASSERT_EQUAL(id, NULL, id);
625
626 osAttr.priority = osPriorityRealtime7;
627 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
628 ICUNIT_ASSERT_EQUAL(id, NULL, id);
629
630 osAttr.priority = osPriorityISR;
631 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
632 ICUNIT_ASSERT_EQUAL(id, NULL, id);
633
634 osAttr.priority = osPriorityError;
635 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
636 ICUNIT_ASSERT_EQUAL(id, NULL, id);
637
638 osAttr.priority = osPriorityReserved;
639 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
640 ICUNIT_ASSERT_EQUAL(id, NULL, id);
641 return 0;
642 };
643
644 /**
645 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_0360
646 * @tc.name : thread operation for creat success when priority = osPriorityLow1
647 * @tc.desc : [C- SOFTWARE -0200]
648 */
649 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew007, Function | MediumTest | Level1)
650 {
651 osThreadAttr_t osAttr;
652 osThreadId_t id;
653 osAttr.name = "test";
654 osAttr.attr_bits = 0U;
655 osAttr.cb_mem = NULL;
656 osAttr.cb_size = 0U;
657 osAttr.stack_mem = NULL;
658 osAttr.stack_size = TEST_TASK_STACK_SIZE;
659 osAttr.priority = osPriorityLow1;
660 g_threadCreateExit = 0;
661 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
662 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
663
664 osAttr.priority = osPriorityLow7;
665 g_threadCreateExit = 0;
666 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
667 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
668
669 osAttr.priority = osPriorityBelowNormal;
670 g_threadCreateExit = 0;
671 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
672 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
673
674 osAttr.priority = osPriorityBelowNormal7;
675 g_threadCreateExit = 0;
676 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
677 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
678
679 osAttr.priority = osPriorityNormal;
680 g_threadCreateExit = 0;
681 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
682 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
683
684 osAttr.priority = osPriorityNormal7;
685 g_threadCreateExit = 0;
686 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
687 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
688
689 osAttr.priority = osPriorityAboveNormal;
690 g_threadCreateExit = 0;
691 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
692 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
693
694 osAttr.priority = osPriorityAboveNormal1;
695 g_threadCreateExit = 0;
696 id = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, &osAttr);
697 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
698 WaitThreadExit(id, &g_threadCreateExit);
699 return 0;
700 };
701
702 /**
703 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1000
704 * @tc.name : thread creat operation with func = NULL
705 * @tc.desc : [C- SOFTWARE -0200]
706 */
707 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew008, Function | MediumTest | Level1)
708 {
709 osThreadAttr_t osAttr;
710 osThreadId_t osId;
711 osAttr.name = "test";
712 osAttr.attr_bits = 0U;
713 osAttr.cb_mem = NULL;
714 osAttr.cb_size = 0U;
715 osAttr.stack_mem = NULL;
716 osAttr.stack_size = TEST_TASK_STACK_SIZE;
717 osAttr.priority = osPriorityNormal;
718 osId = osThreadNew(NULL, NULL, &osAttr);
719 ICUNIT_ASSERT_EQUAL(osId, NULL, osId);
720 return 0;
721 };
722
723 /**
724 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1040
725 * @tc.name : thread creat operation with attr = NULL
726 * @tc.desc : [C- SOFTWARE -0200]
727 */
728 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew009, Function | MediumTest | Level1)
729 {
730 osThreadId_t osId;
731 g_threadCreateExit = 0;
732 osId = osThreadNew((osThreadFunc_t)CmsisThreadCreatFunc, NULL, NULL);
733 ICUNIT_ASSERT_NOT_EQUAL(osId, NULL, osId);
734 WaitThreadExit(osId, &g_threadCreateExit);
735 return 0;
736 };
737
738 /**
739 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1160
740 * @tc.name : thread operation for suspend when priority = osPriorityLow1
741 * @tc.desc : [C- SOFTWARE -0200]
742 */
743 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadSuspend001, Function | MediumTest | Level1)
744 {
745 osThreadId_t id;
746 osStatus_t status;
747 osStatus_t uwRet;
748 osThreadAttr_t attr;
749 osThreadState_t state;
750 g_cmsisTestTaskCount = 0;
751 attr.name = "test";
752 attr.attr_bits = 0U;
753 attr.cb_mem = NULL;
754 attr.cb_size = 0U;
755 attr.stack_mem = NULL;
756 attr.stack_size = TEST_TASK_STACK_SIZE;
757 attr.priority = osPriorityLow1;
758 g_threadCreateExit = 0;
759 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
760 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
761 status = osDelay(DELAY_TICKS_5);
762 ICUNIT_ASSERT_EQUAL(status, osOK, status);
763 state = osThreadGetState(g_puwTaskID01);
764 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
765 uwRet = osThreadResume(g_puwTaskID01);
766 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
767
768 attr.priority = osPriorityNormal;
769 g_threadCreateExit = 0;
770 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
771 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
772 status = osDelay(DELAY_TICKS_5);
773 ICUNIT_ASSERT_EQUAL(status, osOK, status);
774 state = osThreadGetState(g_puwTaskID01);
775 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
776 uwRet = osThreadResume(g_puwTaskID01);
777 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
778 WaitThreadExit(id, &g_threadCreateExit);
779 return 0;
780 };
781
782 /**
783 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1200
784 * @tc.name : thread operation for get current ID
785 * @tc.desc : [C- SOFTWARE -0200]
786 */
787 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetId001, Function | MediumTest | Level1)
788 {
789 osStatus_t status;
790 g_puwTaskID01 = osThreadGetId();
791 ICUNIT_ASSERT_NOT_EQUAL(g_puwTaskID01, NULL, g_puwTaskID01);
792 status = osDelay(DELAY_TICKS_5);
793 ICUNIT_ASSERT_EQUAL(status, osOK, status);
794 return 0;
795 };
796
797 /**
798 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1240
799 * @tc.name : thread operation for get ID when priority = osPriorityLow1
800 * @tc.desc : [C- SOFTWARE -0200]
801 */
802 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetId002, Function | MediumTest | Level1)
803 {
804 osThreadId_t id;
805 osThreadAttr_t attr;
806 osStatus_t status;
807 attr.name = "test";
808 attr.attr_bits = 0U;
809 attr.cb_mem = NULL;
810 attr.cb_size = 0U;
811 attr.stack_mem = NULL;
812 attr.stack_size = TEST_TASK_STACK_SIZE;
813 attr.priority = osPriorityLow1;
814 g_threadCreateExit = 0;
815 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
816 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
817 status = osDelay(DELAY_TICKS_5);
818 ICUNIT_ASSERT_EQUAL(status, osOK, status);
819 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
820
821 attr.priority = osPriorityLow7;
822 g_threadCreateExit = 0;
823 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
824 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
825 status = osDelay(DELAY_TICKS_5);
826 ICUNIT_ASSERT_EQUAL(status, osOK, status);
827 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
828
829 attr.priority = osPriorityBelowNormal;
830 g_threadCreateExit = 0;
831 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
832 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
833 status = osDelay(DELAY_TICKS_5);
834 ICUNIT_ASSERT_EQUAL(status, osOK, status);
835 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
836
837 attr.priority = osPriorityBelowNormal7;
838 g_threadCreateExit = 0;
839 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
840 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
841 status = osDelay(DELAY_TICKS_5);
842 ICUNIT_ASSERT_EQUAL(status, osOK, status);
843 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
844
845 attr.priority = osPriorityNormal;
846 g_threadCreateExit = 0;
847 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
848 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
849 status = osDelay(DELAY_TICKS_5);
850 ICUNIT_ASSERT_EQUAL(status, osOK, status);
851 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
852 WaitThreadExit(id, &g_threadCreateExit);
853 return 0;
854 };
855
856 /**
857 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1440
858 * @tc.name : thread operation for get ID when priority = osPriorityNormal7
859 * @tc.desc : [C- SOFTWARE -0200]
860 */
861 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetId003, Function | MediumTest | Level1)
862 {
863 osThreadId_t id;
864 osThreadAttr_t attr;
865
866 attr.name = "test";
867 attr.attr_bits = 0U;
868 attr.cb_mem = NULL;
869 attr.cb_size = 0U;
870 attr.stack_mem = NULL;
871 attr.stack_size = TEST_TASK_STACK_SIZE;
872 attr.priority = osPriorityNormal7;
873 g_threadCreateExit = 0;
874 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
875 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
876 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
877
878 attr.priority = osPriorityAboveNormal;
879 g_threadCreateExit = 0;
880 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
881 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
882 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
883
884 attr.priority = osPriorityAboveNormal1;
885 g_threadCreateExit = 0;
886 id = osThreadNew((osThreadFunc_t)CmsisThreadGetIDFunc001, NULL, &attr);
887 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
888 ICUNIT_ASSERT_EQUAL((uintptr_t)id, (uintptr_t)g_puwTaskID01, (uintptr_t)id);
889 WaitThreadExit(id, &g_threadCreateExit);
890 return 0;
891 };
892
893 /**
894 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1560
895 * @tc.name : thread operation for get ID then exit thread
896 * @tc.desc : [C- SOFTWARE -0200]
897 */
898 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetId004, Function | MediumTest | Level1)
899 {
900 g_puwTaskID01 = osThreadGetId();
901 ICUNIT_ASSERT_NOT_EQUAL(g_puwTaskID01, NULL, g_puwTaskID01);
902 return 0;
903 };
904
905 /**
906 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1640
907 * @tc.name : thread operation for get stack space
908 * @tc.desc : [C- SOFTWARE -0200]
909 */
910 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSpace001, Function | MediumTest | Level1)
911 {
912 UINT32 uwCount;
913 g_cmsisTestTaskCount = 0;
914 g_puwTaskID01 = osThreadGetId();
915 uwCount = osThreadGetStackSpace(g_puwTaskID01);
916 ICUNIT_ASSERT_WITHIN_EQUAL(uwCount, 0, INT_MAX, uwCount);
917 return 0;
918 };
919
920 /**
921 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1680
922 * @tc.name : thread operation for yield when priority = osPriorityLow1
923 * @tc.desc : [C- SOFTWARE -0200]
924 */
925 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield001, Function | MediumTest | Level1)
926 {
927 osThreadId_t id;
928 osStatus_t status;
929 osThreadAttr_t attr;
930 g_threadPriority = osPriorityLow1;
931 attr.name = "test";
932 attr.attr_bits = 0U;
933 attr.cb_mem = NULL;
934 attr.cb_size = 0U;
935 attr.stack_mem = NULL;
936 attr.stack_size = TEST_TASK_STACK_SIZE;
937 attr.priority = g_threadPriority;
938 g_cmsisTestTaskCount = 0;
939 g_cmsisTestTaskCount++;
940 g_threadCreateExit1 = 0;
941 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
942 status = osDelay(DELAY_TICKS_5);
943 ICUNIT_ASSERT_EQUAL(status, osOK, status);
944 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
945 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
946 WaitThreadExit(id, &g_threadCreateExit1);
947 return 0;
948 };
949
950 /**
951 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1720
952 * @tc.name : thread operation for yield when priority = osPriorityLow7
953 * @tc.desc : [C- SOFTWARE -0200]
954 */
955 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield002, Function | MediumTest | Level1)
956 {
957 osThreadId_t id;
958 osStatus_t status;
959 osThreadAttr_t attr;
960 g_threadPriority = osPriorityLow7;
961 attr.name = "test";
962 attr.attr_bits = 0U;
963 attr.cb_mem = NULL;
964 attr.cb_size = 0U;
965 attr.stack_mem = NULL;
966 attr.stack_size = TEST_TASK_STACK_SIZE;
967 attr.priority = g_threadPriority;
968 g_cmsisTestTaskCount = 0;
969 g_cmsisTestTaskCount++;
970 g_threadCreateExit1 = 0;
971 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
972 status = osDelay(DELAY_TICKS_5);
973 ICUNIT_ASSERT_EQUAL(status, osOK, status);
974 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
975 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
976 WaitThreadExit(id, &g_threadCreateExit1);
977 return 0;
978 };
979
980 /**
981 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1760
982 * @tc.name : thread operation for yield when priority = osPriorityBelowNormal
983 * @tc.desc : [C- SOFTWARE -0200]
984 */
985 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield003, Function | MediumTest | Level1)
986 {
987 osThreadId_t id;
988 osStatus_t status;
989 osThreadAttr_t attr;
990 g_threadPriority = osPriorityBelowNormal;
991 attr.name = "test";
992 attr.attr_bits = 0U;
993 attr.cb_mem = NULL;
994 attr.cb_size = 0U;
995 attr.stack_mem = NULL;
996 attr.stack_size = TEST_TASK_STACK_SIZE;
997 attr.priority = g_threadPriority;
998 g_cmsisTestTaskCount = 0;
999 g_cmsisTestTaskCount++;
1000 g_threadCreateExit1 = 0;
1001 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
1002 status = osDelay(DELAY_TICKS_5);
1003 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1004 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
1005 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1006 WaitThreadExit(id, &g_threadCreateExit1);
1007 return 0;
1008 };
1009
1010 /**
1011 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1800
1012 * @tc.name : thread operation for yield when priority = osPriorityBelowNormal7
1013 * @tc.desc : [C- SOFTWARE -0200]
1014 */
1015 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield004, Function | MediumTest | Level1)
1016 {
1017 osThreadId_t id;
1018 osStatus_t status;
1019 osThreadAttr_t attr;
1020 g_threadPriority = osPriorityBelowNormal7;
1021 attr.name = "test";
1022 attr.attr_bits = 0U;
1023 attr.cb_mem = NULL;
1024 attr.cb_size = 0U;
1025 attr.stack_mem = NULL;
1026 attr.stack_size = TEST_TASK_STACK_SIZE;
1027 attr.priority = g_threadPriority;
1028 g_cmsisTestTaskCount = 0;
1029 g_cmsisTestTaskCount++;
1030 g_threadCreateExit1 = 0;
1031 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
1032 status = osDelay(DELAY_TICKS_5);
1033 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1034 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
1035 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1036 WaitThreadExit(id, &g_threadCreateExit1);
1037 return 0;
1038 };
1039
1040 /**
1041 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1840
1042 * @tc.name : thread operation for yield when priority = osPriorityNormal
1043 * @tc.desc : [C- SOFTWARE -0200]
1044 */
1045 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield005, Function | MediumTest | Level1)
1046 {
1047 osThreadId_t id;
1048 osStatus_t status;
1049 osThreadAttr_t attr;
1050 g_threadPriority = osPriorityNormal;
1051 attr.name = "test";
1052 attr.attr_bits = 0U;
1053 attr.cb_mem = NULL;
1054 attr.cb_size = 0U;
1055 attr.stack_mem = NULL;
1056 attr.stack_size = TEST_TASK_STACK_SIZE;
1057 attr.priority = g_threadPriority;
1058 g_cmsisTestTaskCount = 0;
1059 g_cmsisTestTaskCount++;
1060 g_threadCreateExit1 = 0;
1061 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
1062 status = osDelay(DELAY_TICKS_5);
1063 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1064 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
1065 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1066 WaitThreadExit(id, &g_threadCreateExit1);
1067 return 0;
1068 };
1069
1070 /**
1071 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1880
1072 * @tc.name : thread operation for yield when priority = osPriorityNormal7
1073 * @tc.desc : [C- SOFTWARE -0200]
1074 */
1075 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield006, Function | MediumTest | Level1)
1076 {
1077 osThreadId_t id;
1078 osThreadAttr_t attr;
1079 g_threadPriority = osPriorityNormal7;
1080 attr.name = "test";
1081 attr.attr_bits = 0U;
1082 attr.cb_mem = NULL;
1083 attr.cb_size = 0U;
1084 attr.stack_mem = NULL;
1085 attr.stack_size = TEST_TASK_STACK_SIZE;
1086 attr.priority = g_threadPriority;
1087 g_cmsisTestTaskCount = 0;
1088 g_cmsisTestTaskCount++;
1089 g_threadCreateExit1 = 0;
1090 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
1091 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
1092 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1093 WaitThreadExit(id, &g_threadCreateExit1);
1094 return 0;
1095 };
1096
1097 /**
1098 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1920
1099 * @tc.name : thread operation for yield when priority = osPriorityAboveNormal
1100 * @tc.desc : [C- SOFTWARE -0200]
1101 */
1102 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield007, Function | MediumTest | Level1)
1103 {
1104 osThreadId_t id;
1105 osThreadAttr_t attr;
1106 g_threadPriority = osPriorityAboveNormal;
1107 attr.name = "test";
1108 attr.attr_bits = 0U;
1109 attr.cb_mem = NULL;
1110 attr.cb_size = 0U;
1111 attr.stack_mem = NULL;
1112 attr.stack_size = TEST_TASK_STACK_SIZE;
1113 attr.priority = g_threadPriority;
1114 g_cmsisTestTaskCount = 0;
1115 g_cmsisTestTaskCount++;
1116 g_threadCreateExit1 = 0;
1117 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
1118 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
1119 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1120 WaitThreadExit(id, &g_threadCreateExit1);
1121 return 0;
1122 };
1123
1124 /**
1125 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_1960
1126 * @tc.name : thread operation for yield when priority = osPriorityAboveNormal1
1127 * @tc.desc : [C- SOFTWARE -0200]
1128 */
1129 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield008, Function | MediumTest | Level1)
1130 {
1131 osThreadId_t id;
1132 osThreadAttr_t attr;
1133 g_threadPriority = osPriorityAboveNormal1;
1134 attr.name = "test";
1135 attr.attr_bits = 0U;
1136 attr.cb_mem = NULL;
1137 attr.cb_size = 0U;
1138 attr.stack_mem = NULL;
1139 attr.stack_size = TEST_TASK_STACK_SIZE;
1140 attr.priority = g_threadPriority;
1141 g_cmsisTestTaskCount = 0;
1142 g_cmsisTestTaskCount++;
1143 g_threadCreateExit1 = 0;
1144 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc001, NULL, &attr);
1145 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_2, g_cmsisTestTaskCount);
1146 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1147 WaitThreadExit(id, &g_threadCreateExit1);
1148 return 0;
1149 };
1150
1151 /**
1152 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2000
1153 * @tc.name : thread yield operation for thread with different priority
1154 * @tc.desc : [C- SOFTWARE -0200]
1155 */
1156 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadYield009, Function | MediumTest | Level1)
1157 {
1158 osThreadId_t id;
1159 osThreadAttr_t attr;
1160 attr.name = "test";
1161 attr.attr_bits = 0U;
1162 attr.cb_mem = NULL;
1163 attr.cb_size = 0U;
1164 attr.stack_mem = NULL;
1165 attr.stack_size = TEST_TASK_STACK_SIZE;
1166 attr.priority = osPriorityAboveNormal;
1167 g_threadCreateExit1 = 0;
1168 id = osThreadNew((osThreadFunc_t)CmsisThreadYieldFunc003, NULL, &attr);
1169 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1170 WaitThreadExit(id, &g_threadCreateExit1);
1171 return 0;
1172 };
1173
1174 /**
1175 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2040
1176 * @tc.name : thread operation for resume
1177 * @tc.desc : [C- SOFTWARE -0200]
1178 */
1179 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadResume001, Function | MediumTest | Level1)
1180 {
1181 osThreadId_t id;
1182 osThreadAttr_t attr;
1183 attr.name = "test";
1184 attr.attr_bits = 0U;
1185 attr.cb_mem = NULL;
1186 attr.cb_size = 0U;
1187 attr.stack_mem = NULL;
1188 attr.stack_size = TEST_TASK_STACK_SIZE;
1189 attr.priority = osPriorityAboveNormal;
1190 g_cmsisTestTaskCount = 0;
1191 g_cmsisTestTaskCount++;
1192 id = osThreadNew((osThreadFunc_t)CmsisThreadResumeFunc001, NULL, &attr);
1193 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_3, g_cmsisTestTaskCount);
1194 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1195 return 0;
1196 };
1197
1198 /**
1199 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2120
1200 * @tc.name : get thread count with callback function when priority = osPriorityAboveNormal
1201 * @tc.desc : [C- SOFTWARE -0200]
1202 */
1203 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetCount001, Function | MediumTest | Level1)
1204 {
1205 osThreadId_t id;
1206 osThreadAttr_t attr;
1207 attr.name = "test";
1208 attr.attr_bits = 0U;
1209 attr.cb_mem = NULL;
1210 attr.cb_size = 0U;
1211 attr.stack_mem = NULL;
1212 attr.stack_size = TEST_TASK_STACK_SIZE;
1213 attr.priority = osPriorityAboveNormal;
1214 g_threadCreateExit1 = 0;
1215 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc001, NULL, &attr);
1216 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1217 WaitThreadExit(id, &g_threadCreateExit1);
1218 return 0;
1219 };
1220
1221 /**
1222 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2160
1223 * @tc.name : thread operation for current count
1224 * @tc.desc : [C- SOFTWARE -0200]
1225 */
1226 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetCount002, Function | MediumTest | Level1)
1227 {
1228 UINT32 uwRet = osThreadGetCount();
1229 ICUNIT_ASSERT_WITHIN_EQUAL(uwRet, 0, INT_MAX, uwRet);
1230 return 0;
1231 };
1232
1233 /**
1234 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2200
1235 * @tc.name : get thread count when priority = osPriorityLow1
1236 * @tc.desc : [C- SOFTWARE -0200]
1237 */
1238 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetCount003, Function | MediumTest | Level1)
1239 {
1240 osThreadId_t id;
1241 osStatus_t status;
1242 osThreadAttr_t attr;
1243 attr.name = "test";
1244 attr.attr_bits = 0U;
1245 attr.cb_mem = NULL;
1246 attr.cb_size = 0U;
1247 attr.stack_mem = NULL;
1248 attr.stack_size = TEST_TASK_STACK_SIZE;
1249 attr.priority = osPriorityLow1;
1250 g_threadCreateExit1 = 0;
1251 g_threadCount = osThreadGetCount();
1252 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1253 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1254 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1255 status = osDelay(DELAY_TICKS_5);
1256 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1257
1258 attr.priority = osPriorityLow7;
1259 g_threadCreateExit1 = 0;
1260 g_threadCount = osThreadGetCount();
1261 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1262 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1263 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1264 status = osDelay(DELAY_TICKS_5);
1265 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1266
1267 attr.priority = osPriorityBelowNormal;
1268 g_threadCreateExit1 = 0;
1269 g_threadCount = osThreadGetCount();
1270 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1271 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1272 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1273 status = osDelay(DELAY_TICKS_5);
1274 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1275
1276 attr.priority = osPriorityBelowNormal7;
1277 g_threadCreateExit1 = 0;
1278 g_threadCount = osThreadGetCount();
1279 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1280 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1281 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1282 status = osDelay(DELAY_TICKS_5);
1283 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1284 WaitThreadExit(id, &g_threadCreateExit1);
1285 return 0;
1286 };
1287
1288 /**
1289 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2360
1290 * @tc.name : get thread count when priority = osPriorityNormal
1291 * @tc.desc : [C- SOFTWARE -0200]
1292 */
1293 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetCount004, Function | MediumTest | Level1)
1294 {
1295 osThreadId_t id;
1296 osStatus_t status;
1297 osThreadAttr_t attr;
1298 attr.name = "test";
1299 attr.attr_bits = 0U;
1300 attr.cb_mem = NULL;
1301 attr.cb_size = 0U;
1302 attr.stack_mem = NULL;
1303 attr.stack_size = TEST_TASK_STACK_SIZE;
1304 attr.priority = osPriorityNormal;
1305 g_threadCreateExit1 = 0;
1306 g_threadCount = osThreadGetCount();
1307 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1308 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1309 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1310 status = osDelay(DELAY_TICKS_5);
1311 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1312
1313 attr.priority = osPriorityNormal7;
1314 g_threadCreateExit1 = 0;
1315 g_threadCount = osThreadGetCount();
1316 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1317 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1318 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1319
1320 attr.priority = osPriorityAboveNormal;
1321 g_threadCreateExit1 = 0;
1322 g_threadCount = osThreadGetCount();
1323 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1324 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1325 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1326
1327 attr.priority = osPriorityAboveNormal1;
1328 g_threadCreateExit1 = 0;
1329 g_threadCount = osThreadGetCount();
1330 ICUNIT_ASSERT_WITHIN_EQUAL(g_threadCount, 0, INT_MAX, g_threadCount);
1331 id = osThreadNew((osThreadFunc_t)CmsisThreadGetCountFunc003, NULL, &attr);
1332 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1333 WaitThreadExit(id, &g_threadCreateExit1);
1334 return 0;
1335 };
1336
1337 /**
1338 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2520
1339 * @tc.name : thread operation for get name input exception
1340 * @tc.desc : [C- SOFTWARE -0200]
1341 */
1342 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetName002, Function | MediumTest | Level1)
1343 {
1344 osThreadAttr_t attr;
1345 attr.name = osThreadGetName(NULL);
1346 ICUNIT_ASSERT_EQUAL(attr.name, NULL, attr.name);
1347 return 0;
1348 };
1349
1350 /**
1351 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2560
1352 * @tc.name : thread operation for get name when priority = osPriorityLow1
1353 * @tc.desc : [C- SOFTWARE -0200]
1354 */
1355 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetName001, Function | MediumTest | Level1)
1356 {
1357 osThreadId_t id;
1358 osThreadAttr_t attr;
1359 osStatus_t status;
1360 attr.name = "testThreadGetName";
1361 attr.attr_bits = 0U;
1362 attr.cb_mem = NULL;
1363 attr.cb_size = 0U;
1364 attr.stack_mem = NULL;
1365 attr.stack_size = TEST_TASK_STACK_SIZE;
1366 attr.priority = osPriorityLow1;
1367 g_getNameExit = 0;
1368 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1369 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1370 status = osDelay(DELAY_TICKS_5);
1371 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1372
1373 attr.priority = osPriorityLow7;
1374 g_getNameExit = 0;
1375 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1376 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1377 status = osDelay(DELAY_TICKS_5);
1378 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1379
1380 attr.priority = osPriorityBelowNormal;
1381 g_getNameExit = 0;
1382 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1383 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1384 status = osDelay(DELAY_TICKS_5);
1385 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1386
1387 attr.priority = osPriorityBelowNormal7;
1388 g_getNameExit = 0;
1389 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1390 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1391 status = osDelay(DELAY_TICKS_5);
1392 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1393
1394 attr.priority = osPriorityNormal;
1395 g_cmsisTestTaskCount = 0;
1396 g_getNameExit = 0;
1397 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1398 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1399 status = osDelay(DELAY_TICKS_5);
1400 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1401 WaitThreadExit(id, &g_getNameExit);
1402 return 0;
1403 };
1404
1405 /**
1406 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2720
1407 * @tc.name : thread operation for get name when priority = osPriorityNormal7
1408 * @tc.desc : [C- SOFTWARE -0200]
1409 */
1410 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetName003, Function | MediumTest | Level1)
1411 {
1412 osThreadId_t id;
1413 osThreadAttr_t attr;
1414 attr.name = "testThreadGetName";
1415 attr.attr_bits = 0U;
1416 attr.cb_mem = NULL;
1417 attr.cb_size = 0U;
1418 attr.stack_mem = NULL;
1419 attr.stack_size = TEST_TASK_STACK_SIZE;
1420 attr.priority = osPriorityNormal7;
1421 g_getNameExit = 0;
1422 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1423 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1424
1425 attr.priority = osPriorityAboveNormal;
1426 g_getNameExit = 0;
1427 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1428 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1429
1430 attr.priority = osPriorityAboveNormal1;
1431 g_getNameExit = 0;
1432 id = osThreadNew((osThreadFunc_t)CmsisThreadGetNameFunc001, NULL, &attr);
1433 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1434 WaitThreadExit(id, &g_getNameExit);
1435 return 0;
1436 };
1437
1438 /**
1439 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2840
1440 * @tc.name : thread operation for get name
1441 * @tc.desc : [C- SOFTWARE -0200]
1442 */
1443 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetName010, Function | MediumTest | Level1)
1444 {
1445 osThreadAttr_t attr;
1446 g_puwTaskID01 = osThreadGetId();
1447 attr.name = osThreadGetName(g_puwTaskID01);
1448 ICUNIT_ASSERT_NOT_EQUAL(attr.name, NULL, attr.name);
1449 return 0;
1450 };
1451
1452 /**
1453 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2880
1454 * @tc.name : thread operation for get state input exception
1455 * @tc.desc : [C- SOFTWARE -0200]
1456 */
1457 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetState001, Function | MediumTest | Level1)
1458 {
1459 osStatus_t uwRet = osThreadGetState(NULL);
1460 ICUNIT_ASSERT_EQUAL(uwRet, osThreadError, uwRet);
1461 return 0;
1462 };
1463
1464 /**
1465 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_2920
1466 * @tc.name : thread operation for get state when priority = osPriorityLow1
1467 * @tc.desc : [C- SOFTWARE -0200]
1468 */
1469 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetState002, Function | MediumTest | Level1)
1470 {
1471 osThreadId_t id;
1472 osThreadAttr_t attr;
1473 osStatus_t status;
1474 attr.name = "test";
1475 attr.attr_bits = 0U;
1476 attr.cb_mem = NULL;
1477 attr.cb_size = 0U;
1478 attr.stack_mem = NULL;
1479 attr.stack_size = TEST_TASK_STACK_SIZE;
1480 attr.priority = osPriorityLow1;
1481 g_threadCreateExit1 = 0;
1482 g_puwTaskID01 = osThreadGetId();
1483 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc001, NULL, &attr);
1484 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1485 status = osDelay(DELAY_TICKS_5);
1486 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1487 WaitThreadExit(id, &g_threadCreateExit1);
1488
1489 attr.priority = PRIORITY_COUNT_MIN_1;
1490 g_threadCreateExit1 = 0;
1491 g_puwTaskID01 = osThreadGetId();
1492 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc001, NULL, &attr);
1493 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1494 status = osDelay(DELAY_TICKS_5);
1495 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1496 WaitThreadExit(id, &g_threadCreateExit1);
1497
1498 attr.priority = PRIORITY_COUNT_MIN_2;
1499 g_threadCreateExit1 = 0;
1500 g_puwTaskID01 = osThreadGetId();
1501 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc001, NULL, &attr);
1502 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1503 status = osDelay(DELAY_TICKS_5);
1504 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1505
1506 attr.priority = PRIORITY_COUNT_MIN_3;
1507 g_threadCreateExit1 = 0;
1508 g_puwTaskID01 = osThreadGetId();
1509 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc001, NULL, &attr);
1510 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1511 status = osDelay(DELAY_TICKS_5);
1512 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1513
1514 attr.priority = PRIORITY_COUNT_MIN_4;
1515 g_threadCreateExit1 = 0;
1516 g_puwTaskID01 = osThreadGetId();
1517 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc001, NULL, &attr);
1518 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1519 status = osDelay(DELAY_TICKS_5);
1520 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1521 WaitThreadExit(id, &g_threadCreateExit1);
1522 return 0;
1523 };
1524
1525 /**
1526 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3120
1527 * @tc.name : thread operation for get state when priority = osPriorityNormal7
1528 * @tc.desc : [C- SOFTWARE -0200]
1529 */
1530 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetState003, Function | MediumTest | Level1)
1531 {
1532 osThreadId_t id;
1533 osThreadAttr_t attr;
1534 osStatus_t status;
1535 attr.name = "test";
1536 attr.attr_bits = 0U;
1537 attr.cb_mem = NULL;
1538 attr.cb_size = 0U;
1539 attr.stack_mem = NULL;
1540 attr.stack_size = TEST_TASK_STACK_SIZE;
1541 attr.priority = osPriorityNormal7;
1542 g_threadCreateExit = 0;
1543 g_puwTaskID01 = osThreadGetId();
1544 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc002, NULL, &attr);
1545 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1546 status = osDelay(DELAY_TICKS_5);
1547 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1548
1549 attr.priority = osPriorityAboveNormal1;
1550 g_threadCreateExit = 0;
1551 g_puwTaskID01 = osThreadGetId();
1552 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc002, NULL, &attr);
1553 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1554 status = osDelay(DELAY_TICKS_5);
1555 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1556
1557 attr.priority = osPriorityAboveNormal;
1558 g_threadCreateExit = 0;
1559 g_puwTaskID01 = osThreadGetId();
1560 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStateFunc002, NULL, &attr);
1561 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1562 status = osDelay(DELAY_TICKS_5);
1563 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1564 WaitThreadExit(id, &g_threadCreateExit);
1565 return 0;
1566 };
1567
1568 /**
1569 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3200
1570 * @tc.name : thread operation for get current state
1571 * @tc.desc : [C- SOFTWARE -0200]
1572 */
1573 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetState004, Function | MediumTest | Level1)
1574 {
1575 osThreadState_t state;
1576 g_puwTaskID01 = osThreadGetId();
1577 state = osThreadGetState(g_puwTaskID01);
1578 ICUNIT_ASSERT_EQUAL(state, osThreadRunning, state);
1579 return 0;
1580 };
1581
1582 /**
1583 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3240
1584 * @tc.name : thread operation for suspend input exception
1585 * @tc.desc : [C- SOFTWARE -0200]
1586 */
1587 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadSuspend002, Function | MediumTest | Level1)
1588 {
1589 osStatus_t uwRet = osThreadSuspend(NULL);
1590 ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
1591 return 0;
1592 };
1593
1594 /**
1595 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3280
1596 * @tc.name : thread operation for suspend when priority = osPriorityLow7
1597 * @tc.desc : [C- SOFTWARE -0200]
1598 */
1599 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadSuspend003, Function | MediumTest | Level1)
1600 {
1601 osThreadId_t id;
1602 osStatus_t status;
1603 osStatus_t uwRet;
1604 osThreadAttr_t attr;
1605 osThreadState_t state;
1606 g_cmsisTestTaskCount = 0;
1607 attr.name = "test";
1608 attr.attr_bits = 0U;
1609 attr.cb_mem = NULL;
1610 attr.cb_size = 0U;
1611 attr.stack_mem = NULL;
1612 attr.stack_size = TEST_TASK_STACK_SIZE;
1613 attr.priority = osPriorityLow7;
1614 g_threadCreateExit = 0;
1615 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
1616 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1617 status = osDelay(DELAY_TICKS_5);
1618 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1619 state = osThreadGetState(g_puwTaskID01);
1620 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
1621 uwRet = osThreadResume(g_puwTaskID01);
1622 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1623
1624 attr.priority = osPriorityBelowNormal;
1625 g_threadCreateExit = 0;
1626 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
1627 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1628 status = osDelay(DELAY_TICKS_5);
1629 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1630 state = osThreadGetState(g_puwTaskID01);
1631 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
1632 uwRet = osThreadResume(g_puwTaskID01);
1633 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1634
1635 attr.priority = osPriorityBelowNormal7;
1636 g_threadCreateExit = 0;
1637 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
1638 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1639 status = osDelay(DELAY_TICKS_5);
1640 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1641 state = osThreadGetState(g_puwTaskID01);
1642 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
1643 uwRet = osThreadResume(g_puwTaskID01);
1644 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1645
1646 WaitThreadExit(id, &g_threadCreateExit);
1647 return 0;
1648 };
1649
1650 /**
1651 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3440
1652 * @tc.name : thread operation for suspend when priority = osPriorityNormal7
1653 * @tc.desc : [C- SOFTWARE -0200]
1654 */
1655 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadSuspend004, Function | MediumTest | Level1)
1656 {
1657 osThreadId_t id;
1658 osStatus_t uwRet;
1659 osThreadAttr_t attr;
1660 osThreadState_t state;
1661 g_cmsisTestTaskCount = 0;
1662 attr.name = "test";
1663 attr.attr_bits = 0U;
1664 attr.cb_mem = NULL;
1665 attr.cb_size = 0U;
1666 attr.stack_mem = NULL;
1667 attr.stack_size = TEST_TASK_STACK_SIZE;
1668 attr.priority = osPriorityNormal7;
1669 g_threadCreateExit = 0;
1670 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
1671 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1672 state = osThreadGetState(g_puwTaskID01);
1673 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
1674 uwRet = osThreadResume(g_puwTaskID01);
1675 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1676
1677 attr.priority = osPriorityAboveNormal;
1678 g_threadCreateExit = 0;
1679 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
1680 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1681 state = osThreadGetState(g_puwTaskID01);
1682 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
1683 uwRet = osThreadResume(g_puwTaskID01);
1684 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1685
1686 attr.priority = osPriorityAboveNormal1;
1687 g_threadCreateExit = 0;
1688 id = osThreadNew((osThreadFunc_t)CmsisThreadSuspendFunc001, NULL, &attr);
1689 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1690 state = osThreadGetState(g_puwTaskID01);
1691 ICUNIT_ASSERT_EQUAL(state, osThreadBlocked, state);
1692 uwRet = osThreadResume(g_puwTaskID01);
1693 ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1694 WaitThreadExit(id, &g_threadCreateExit);
1695 return 0;
1696 };
1697
1698 /**
1699 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3560
1700 * @tc.name : thread operation for get stack size input exception
1701 * @tc.desc : [C- SOFTWARE -0200]
1702 */
1703 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSize001, Function | MediumTest | Level1)
1704 {
1705 UINT32 uwRet = osThreadGetStackSize(NULL);
1706 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
1707 return 0;
1708 };
1709
1710 /**
1711 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3600
1712 * @tc.name : thread operation for get stack size when priority = osPriorityLow1
1713 * @tc.desc : [C- SOFTWARE -0200]
1714 */
1715 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSize002, Function | MediumTest | Level1)
1716 {
1717 osThreadId_t id;
1718 osThreadAttr_t attr;
1719 attr.name = "test";
1720 attr.attr_bits = 0U;
1721 attr.cb_mem = NULL;
1722 attr.cb_size = 0U;
1723 attr.stack_mem = NULL;
1724 attr.stack_size = TEST_TASK_STACK_SIZE;
1725 attr.priority = osPriorityLow1;
1726 g_getStackSizeExit = 0;
1727 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1728 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1729
1730 attr.priority = osPriorityLow7;
1731 g_getStackSizeExit = 0;
1732 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1733 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1734
1735 attr.priority = osPriorityBelowNormal;
1736 g_getStackSizeExit = 0;
1737 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1738 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1739
1740 attr.priority = osPriorityBelowNormal7;
1741 g_getStackSizeExit = 0;
1742 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1743 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1744
1745 attr.priority = osPriorityNormal;
1746 g_getStackSizeExit = 0;
1747 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1748 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1749
1750 attr.priority = osPriorityNormal7;
1751 g_getStackSizeExit = 0;
1752 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1753 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1754
1755 attr.priority = osPriorityAboveNormal;
1756 g_getStackSizeExit = 0;
1757 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1758 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1759
1760 attr.priority = osPriorityAboveNormal1;
1761 g_getStackSizeExit = 0;
1762 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSizeFunc001, NULL, &attr);
1763 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1764 WaitThreadExit(id, &g_getStackSizeExit);
1765 return 0;
1766 };
1767
1768 /**
1769 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3880
1770 * @tc.name : thread operation for get stack size
1771 * @tc.desc : [C- SOFTWARE -0200]
1772 */
1773 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSize003, Function | MediumTest | Level1)
1774 {
1775 osThreadAttr_t attr;
1776 g_puwTaskID01 = osThreadGetId();
1777 attr.stack_size = osThreadGetStackSize(g_puwTaskID01);
1778 ICUNIT_ASSERT_WITHIN_EQUAL(attr.stack_size, 0, INT_MAX, attr.stack_size);
1779 return 0;
1780 };
1781
1782 /**
1783 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3920
1784 * @tc.name : thread operation for get stack space input exception
1785 * @tc.desc : [C- SOFTWARE -0200]
1786 */
1787 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSpace002, Function | MediumTest | Level1)
1788 {
1789 UINT32 uwRet = osThreadGetStackSpace(NULL);
1790 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
1791 return 0;
1792 };
1793
1794 /**
1795 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_3960
1796 * @tc.name : thread operation for get stack space when priority = osPriorityLow1
1797 * @tc.desc : [C- SOFTWARE -0200]
1798 */
1799 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSpace003, Function | MediumTest | Level1)
1800 {
1801 osThreadId_t id;
1802 osThreadAttr_t attr;
1803 osStatus_t status;
1804 attr.name = "test";
1805 attr.attr_bits = 0U;
1806 attr.cb_mem = NULL;
1807 attr.cb_size = 0U;
1808 attr.stack_mem = NULL;
1809 attr.stack_size = TEST_TASK_STACK_SIZE;
1810 attr.priority = osPriorityLow1;
1811 g_getStackSpaceExit = 0;
1812 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1813 status = osDelay(DELAY_TICKS_5);
1814 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1815 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1816
1817 attr.priority = osPriorityLow7;
1818 g_getStackSpaceExit = 0;
1819 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1820 status = osDelay(DELAY_TICKS_5);
1821 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1822 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1823
1824 attr.priority = osPriorityBelowNormal;
1825 g_getStackSpaceExit = 0;
1826 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1827 status = osDelay(DELAY_TICKS_5);
1828 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1829 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1830
1831 attr.priority = osPriorityBelowNormal7;
1832 g_getStackSpaceExit = 0;
1833 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1834 status = osDelay(DELAY_TICKS_5);
1835 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1836 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1837
1838 attr.priority = osPriorityNormal;
1839 g_getStackSpaceExit = 0;
1840 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1841 status = osDelay(DELAY_TICKS_5);
1842 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1843 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1844 WaitThreadExit(id, &g_getStackSpaceExit);
1845 return 0;
1846 };
1847
1848 /**
1849 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4160
1850 * @tc.name : thread operation for get stack space when priority = osPriorityNormal7
1851 * @tc.desc : [C- SOFTWARE -0200]
1852 */
1853 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadGetStackSpace004, Function | MediumTest | Level1)
1854 {
1855 osThreadId_t id;
1856 osThreadAttr_t attr;
1857 osStatus_t status;
1858 attr.name = "test";
1859 attr.attr_bits = 0U;
1860 attr.cb_mem = NULL;
1861 attr.cb_size = 0U;
1862 attr.stack_mem = NULL;
1863 attr.stack_size = TEST_TASK_STACK_SIZE;
1864 attr.priority = osPriorityNormal7;
1865 g_getStackSpaceExit = 0;
1866 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1867 status = osDelay(DELAY_TICKS_5);
1868 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1869 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1870
1871 attr.priority = osPriorityAboveNormal;
1872 g_getStackSpaceExit = 0;
1873 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1874 status = osDelay(DELAY_TICKS_5);
1875 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1876 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1877
1878 attr.priority = osPriorityAboveNormal1;
1879 g_getStackSpaceExit = 0;
1880 id = osThreadNew((osThreadFunc_t)CmsisThreadGetStackSpaceFunc001, NULL, &attr);
1881 status = osDelay(DELAY_TICKS_5);
1882 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1883 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1884 WaitThreadExit(id, &g_getStackSpaceExit);
1885 return 0;
1886 };
1887
1888 /**
1889 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4280
1890 * @tc.name : thread operation for resume input exception with NULL parameter
1891 * @tc.desc : [C- SOFTWARE -0200]
1892 */
1893 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadResume002, Function | MediumTest | Level1)
1894 {
1895 UINT32 uwRet = osThreadResume(NULL);
1896 ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
1897
1898 g_puwTaskID01 = osThreadGetId();
1899 uwRet = osThreadResume(g_puwTaskID01);
1900 ICUNIT_ASSERT_EQUAL(uwRet, osErrorResource, uwRet);
1901 return 0;
1902 };
1903
1904 /**
1905 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4360
1906 * @tc.name : thread operation for terminate input exception
1907 * @tc.desc : [C- SOFTWARE -0200]
1908 */
1909 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadTerminate001, Function | MediumTest | Level1)
1910 {
1911 UINT32 uwRet = osThreadTerminate(NULL);
1912 ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
1913 return 0;
1914 };
1915
1916 /**
1917 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4400
1918 * @tc.name : thread operation for terminate when priority = osPriorityLow7
1919 * @tc.desc : [C- SOFTWARE -0200]
1920 */
1921 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadTerminate002, Function | MediumTest | Level1)
1922 {
1923 osThreadId_t id;
1924 osThreadAttr_t attr;
1925 osStatus_t status;
1926 attr.name = "test";
1927 attr.attr_bits = 0U;
1928 attr.cb_mem = NULL;
1929 attr.cb_size = 0U;
1930 attr.stack_mem = NULL;
1931 attr.stack_size = TEST_TASK_STACK_SIZE;
1932 attr.priority = osPriorityLow7;
1933 g_cmsisTestTaskCount = 0;
1934 g_cmsisTestTaskCount++;
1935 g_threadCreateExit1 = 0;
1936 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
1937 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1938 status = osDelay(DELAY_TICKS_5);
1939 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1940 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
1941
1942 attr.priority = osPriorityBelowNormal;
1943 g_cmsisTestTaskCount = 0;
1944 g_cmsisTestTaskCount++;
1945 g_threadCreateExit1 = 0;
1946 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
1947 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1948 status = osDelay(DELAY_TICKS_5);
1949 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1950 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
1951
1952 attr.priority = osPriorityBelowNormal7;
1953 g_cmsisTestTaskCount = 0;
1954 g_cmsisTestTaskCount++;
1955 g_threadCreateExit1 = 0;
1956 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
1957 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1958 status = osDelay(DELAY_TICKS_5);
1959 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1960 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
1961
1962 attr.priority = osPriorityNormal;
1963 g_cmsisTestTaskCount = 0;
1964 g_cmsisTestTaskCount++;
1965 g_threadCreateExit1 = 0;
1966 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
1967 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1968 status = osDelay(DELAY_TICKS_5);
1969 ICUNIT_ASSERT_EQUAL(status, osOK, status);
1970 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
1971 return 0;
1972 };
1973
1974 /**
1975 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4560
1976 * @tc.name : thread operation for terminate when priority = osPriorityNormal7
1977 * @tc.desc : [C- SOFTWARE -0200]
1978 */
1979 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadTerminate003, Function | MediumTest | Level1)
1980 {
1981 osThreadId_t id;
1982 osThreadAttr_t attr;
1983 osStatus_t status;
1984 attr.name = "test";
1985 attr.attr_bits = 0U;
1986 attr.cb_mem = NULL;
1987 attr.cb_size = 0U;
1988 attr.stack_mem = NULL;
1989 attr.stack_size = TEST_TASK_STACK_SIZE;
1990 attr.priority = osPriorityNormal7;
1991 g_cmsisTestTaskCount = 0;
1992 g_cmsisTestTaskCount++;
1993 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
1994 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1995 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
1996
1997 attr.priority = osPriorityAboveNormal;
1998 g_cmsisTestTaskCount = 0;
1999 g_cmsisTestTaskCount++;
2000 g_threadCreateExit1 = 0;
2001 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
2002 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
2003 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
2004
2005 attr.priority = osPriorityAboveNormal1;
2006 g_cmsisTestTaskCount = 0;
2007 g_cmsisTestTaskCount++;
2008 g_threadCreateExit1 = 0;
2009 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
2010 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
2011 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
2012
2013 attr.priority = osPriorityLow1;
2014 g_cmsisTestTaskCount = 0;
2015 g_cmsisTestTaskCount++;
2016 id = osThreadNew((osThreadFunc_t)CmsisThreadTerminateFunc001, NULL, &attr);
2017 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
2018 status = osDelay(DELAY_TICKS_5);
2019 ICUNIT_ASSERT_EQUAL(status, osOK, status);
2020 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
2021 return 0;
2022 };
2023
2024 /**
2025 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4680
2026 * @tc.name : kernel operation for get info
2027 * @tc.desc : [C- SOFTWARE -0200]
2028 */
2029 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelGetInfo001, Function | MediumTest | Level1)
2030 {
2031 CHAR infobuf[100]; /* 100, common data for test, no special meaning */
2032 osVersion_t osv;
2033 osStatus_t status = osKernelGetInfo(&osv, infobuf, sizeof(infobuf));
2034 ICUNIT_ASSERT_EQUAL(status, osOK, status);
2035 return 0;
2036 };
2037
2038 /**
2039 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4720
2040 * @tc.name : kernel operation for get state
2041 * @tc.desc : [C- SOFTWARE -0200]
2042 */
2043 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelGetState001, Function | MediumTest | Level1)
2044 {
2045 osKernelState_t uwRet = osKernelGetState();
2046 ICUNIT_ASSERT_EQUAL(uwRet, osKernelRunning, uwRet);
2047 return 0;
2048 };
2049
2050 /**
2051 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4760
2052 * @tc.name : kernel operation for get state after kernel lock
2053 * @tc.desc : [C- SOFTWARE -0200]
2054 */
2055 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelGetState002, Function | MediumTest | Level1)
2056 {
2057 osKernelLock();
2058 osKernelState_t uwRet;
2059 uwRet = osKernelGetState();
2060 ICUNIT_ASSERT_EQUAL(uwRet, osKernelLocked, uwRet);
2061 osKernelUnlock();
2062 return 0;
2063 };
2064
2065 /**
2066 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4800
2067 * @tc.name : kernel lock operation twice
2068 * @tc.desc : [C- SOFTWARE -0200]
2069 */
2070 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelLock001, Function | MediumTest | Level1)
2071 {
2072 UINT32 uwRet = osKernelLock();
2073 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2074 uwRet = osKernelLock();
2075 ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet);
2076 osKernelUnlock();
2077 return 0;
2078 };
2079
2080 /**
2081 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4840
2082 * @tc.name : kernel operation for lock
2083 * @tc.desc : [C- SOFTWARE -0200]
2084
2085 */
2086 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelLock002, Function | MediumTest | Level1)
2087 {
2088 UINT32 uwRet;
2089 osThreadId_t id;
2090 osThreadAttr_t attr;
2091 g_cmsisTestTaskCount = 0;
2092 attr.name = "test";
2093 attr.attr_bits = 0U;
2094 attr.cb_mem = NULL;
2095 attr.cb_size = 0U;
2096 attr.stack_mem = NULL;
2097 attr.stack_size = TEST_TASK_STACK_SIZE;
2098 attr.priority = osPriorityAboveNormal;
2099
2100 uwRet = osKernelLock();
2101 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2102 id = osThreadNew((osThreadFunc_t)CmsisOSKernelLockFunc002, NULL, &attr);
2103 ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
2104 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, 0, g_cmsisTestTaskCount);
2105 uwRet = osKernelUnlock();
2106 ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet);
2107 ICUNIT_ASSERT_EQUAL(g_cmsisTestTaskCount, TESTCOUNT_NUM_1, g_cmsisTestTaskCount);
2108 return 0;
2109 };
2110
2111 /**
2112 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4880
2113 * @tc.name : kernel operation for unlock
2114 * @tc.desc : [C- SOFTWARE -0200]
2115 */
2116 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelUnLock001, Function | MediumTest | Level1)
2117 {
2118 UINT32 uwRet = osKernelUnlock();
2119 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2120 return 0;
2121 };
2122
2123 /**
2124 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4920
2125 * @tc.name : kernel operation for unlock after kernel lock
2126 * @tc.desc : [C- SOFTWARE -0200]
2127 */
2128 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelUnLock002, Function | MediumTest | Level1)
2129 {
2130 UINT32 uwRet;
2131 (void)osKernelLock();
2132 uwRet = osKernelUnlock();
2133 ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
2134 uwRet = osKernelUnlock();
2135 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2136 return 0;
2137 };
2138
2139 /**
2140 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_4960
2141 * @tc.name : kernel operation for unlock after kernel lock twice
2142 * @tc.desc : [C- SOFTWARE -0200]
2143 */
2144 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelUnLock003, Function | MediumTest | Level1)
2145 {
2146 UINT32 uwRet;
2147 (void)osKernelLock();
2148 (void)osKernelLock();
2149 uwRet = osKernelUnlock();
2150 ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
2151 uwRet = osKernelUnlock();
2152 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2153 return 0;
2154 };
2155
2156 /**
2157 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_5000
2158 * @tc.name : kernel operation for restore lock after kernel lock
2159 * @tc.desc : [C- SOFTWARE -0200]
2160 */
2161 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelRestoreLock001, Function | MediumTest | Level1)
2162 {
2163 UINT32 uwRet;
2164 (void)osKernelLock();
2165 uwRet = osKernelRestoreLock(0);
2166 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2167 uwRet = osKernelUnlock();
2168 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2169 return 0;
2170 };
2171
2172 /**
2173 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_5040
2174 * @tc.name : kernel operation for restore lock after kernel lock twice
2175 * @tc.desc : [C- SOFTWARE -0200]
2176 */
2177 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelRestoreLock002, Function | MediumTest | Level1)
2178 {
2179 UINT32 uwRet;
2180 (void)osKernelLock();
2181 (void)osKernelLock();
2182 uwRet = osKernelRestoreLock(0);
2183 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2184 uwRet = osKernelUnlock();
2185 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2186 return 0;
2187 };
2188
2189 /**
2190 * @tc.number : SUB_KERNEL_CMSIS_TASK_OPERATION_5080
2191 * @tc.name : kernel operation for restore lock
2192 * @tc.desc : [C- SOFTWARE -0200]
2193 */
2194 LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsKernelRestoreLock003, Function | MediumTest | Level1)
2195 {
2196 UINT32 uwRet = osKernelUnlock();
2197 ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
2198 uwRet = osKernelRestoreLock(1); /* 1, common data for test, no special meaning */
2199 ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
2200 uwRet = osKernelUnlock();
2201 ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
2202 return 0;
2203 };
2204
2205 RUN_TEST_SUITE(CmsisTaskFuncTestSuite);
2206
CmsisTaskFuncTest(void)2207 void CmsisTaskFuncTest(void)
2208 {
2209 RUN_ONE_TESTCASE(testOsThreadNew001);
2210 RUN_ONE_TESTCASE(testOsThreadNew002);
2211 RUN_ONE_TESTCASE(testOsThreadNew003);
2212 RUN_ONE_TESTCASE(testOsThreadNew004);
2213 RUN_ONE_TESTCASE(testOsThreadNew005);
2214 RUN_ONE_TESTCASE(testOsThreadNew006);
2215 RUN_ONE_TESTCASE(testOsThreadNew007);
2216 RUN_ONE_TESTCASE(testOsThreadNew008);
2217 RUN_ONE_TESTCASE(testOsThreadNew009);
2218 RUN_ONE_TESTCASE(testOsThreadGetName001);
2219 RUN_ONE_TESTCASE(testOsThreadGetName002);
2220 RUN_ONE_TESTCASE(testOsThreadGetName003);
2221 RUN_ONE_TESTCASE(testOsThreadGetState001);
2222 RUN_ONE_TESTCASE(testOsThreadGetState002);
2223 RUN_ONE_TESTCASE(testOsThreadGetState003);
2224 RUN_ONE_TESTCASE(testOsThreadGetState004);
2225 RUN_ONE_TESTCASE(testOsThreadSuspend001);
2226 RUN_ONE_TESTCASE(testOsThreadSuspend002);
2227 RUN_ONE_TESTCASE(testOsThreadSuspend003);
2228 RUN_ONE_TESTCASE(testOsThreadSuspend004);
2229 RUN_ONE_TESTCASE(testOsThreadGetId001);
2230 RUN_ONE_TESTCASE(testOsThreadGetId002);
2231 RUN_ONE_TESTCASE(testOsThreadGetId003);
2232 RUN_ONE_TESTCASE(testOsThreadGetId004);
2233 RUN_ONE_TESTCASE(testOsThreadGetStackSize001);
2234 RUN_ONE_TESTCASE(testOsThreadGetStackSize002);
2235 RUN_ONE_TESTCASE(testOsThreadGetStackSize003);
2236 RUN_ONE_TESTCASE(testOsThreadGetStackSpace001);
2237 RUN_ONE_TESTCASE(testOsThreadGetStackSpace002);
2238 RUN_ONE_TESTCASE(testOsThreadGetStackSpace003);
2239 RUN_ONE_TESTCASE(testOsThreadGetStackSpace004);
2240 RUN_ONE_TESTCASE(testOsThreadYield001);
2241 RUN_ONE_TESTCASE(testOsThreadYield002);
2242 RUN_ONE_TESTCASE(testOsThreadYield003);
2243 RUN_ONE_TESTCASE(testOsThreadYield004);
2244 RUN_ONE_TESTCASE(testOsThreadYield005);
2245 RUN_ONE_TESTCASE(testOsThreadYield006);
2246 RUN_ONE_TESTCASE(testOsThreadYield007);
2247 RUN_ONE_TESTCASE(testOsThreadYield008);
2248 RUN_ONE_TESTCASE(testOsThreadYield009);
2249 RUN_ONE_TESTCASE(testOsThreadResume001);
2250 RUN_ONE_TESTCASE(testOsThreadResume002);
2251 CmsisTaskFuncTest1();
2252 }
2253
CmsisTaskFuncTest1(void)2254 void CmsisTaskFuncTest1(void)
2255 {
2256 RUN_ONE_TESTCASE(testOsThreadTerminate001);
2257 RUN_ONE_TESTCASE(testOsThreadTerminate002);
2258 RUN_ONE_TESTCASE(testOsThreadTerminate003);
2259 RUN_ONE_TESTCASE(testOsThreadGetCount001);
2260 RUN_ONE_TESTCASE(testOsThreadGetCount002);
2261 RUN_ONE_TESTCASE(testOsThreadGetCount003);
2262 RUN_ONE_TESTCASE(testOsThreadGetCount004);
2263
2264 RUN_ONE_TESTCASE(testOsKernelGetInfo001);
2265 RUN_ONE_TESTCASE(testOsKernelGetState001);
2266 RUN_ONE_TESTCASE(testOsKernelGetState002);
2267 RUN_ONE_TESTCASE(testOsKernelLock001);
2268 RUN_ONE_TESTCASE(testOsKernelLock002);
2269 RUN_ONE_TESTCASE(testOsKernelUnLock001);
2270 RUN_ONE_TESTCASE(testOsKernelUnLock002);
2271 RUN_ONE_TESTCASE(testOsKernelUnLock003);
2272 RUN_ONE_TESTCASE(testOsKernelRestoreLock001);
2273 RUN_ONE_TESTCASE(testOsKernelRestoreLock002);
2274 RUN_ONE_TESTCASE(testOsKernelRestoreLock003);
2275 }