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 osThreadId_t g_priTaskID01;
34 osPriority_t g_setPriority;
35 UINT16 g_threadCreateExit2;
36 UINT16 g_threadCreateExit3;
37 
38 LITE_TEST_SUIT(Cmsis, Cmsistask, CmsisTaskPriFuncTestSuite);
39 
CmsisTaskPriFuncTestSuiteSetUp(void)40 static BOOL CmsisTaskPriFuncTestSuiteSetUp(void)
41 {
42     return TRUE;
43 }
44 
CmsisTaskPriFuncTestSuiteTearDown(void)45 static BOOL CmsisTaskPriFuncTestSuiteTearDown(void)
46 {
47     return TRUE;
48 }
49 
WaitThreadExit(osThreadId_t id, UINT16 const *exitFlag)50 static void WaitThreadExit(osThreadId_t id, UINT16 const *exitFlag)
51 {
52     osStatus_t status;
53     (void)osThreadSetPriority(id, PRIORITY_COUNT_MIN_1);
54     while (*exitFlag != TESTCOUNT_NUM_1) {
55         status = osDelay(DELAY_TICKS_5);
56         ICUNIT_ASSERT_EQUAL(status, osOK, status);
57     }
58 }
CmsisThreadGetPriorityFunc001(void const *argument)59 static void CmsisThreadGetPriorityFunc001(void const *argument)
60 {
61     (void)argument;
62     osThreadAttr_t attr;
63 
64     g_priTaskID01 = osThreadGetId();
65     attr.priority = osThreadGetPriority(g_priTaskID01);
66     ICUNIT_ASSERT_EQUAL(attr.priority, g_setPriority, attr.priority);
67     g_threadCreateExit2 = TESTCOUNT_NUM_1;
68     osThreadExit();
69 }
70 
CmsisThreadSetPriorityFunc001(void const *argument)71 static void CmsisThreadSetPriorityFunc001(void const *argument)
72 {
73     (void)argument;
74     osThreadAttr_t attr;
75     UINT32 uwRet;
76     g_priTaskID01 = osThreadGetId();
77     uwRet = osThreadSetPriority(g_priTaskID01, g_setPriority);
78     ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
79     attr.priority = osThreadGetPriority(g_priTaskID01);
80     ICUNIT_ASSERT_EQUAL(attr.priority, g_setPriority, attr.priority);
81     g_threadCreateExit2 = TESTCOUNT_NUM_1;
82     osThreadExit();
83 }
84 
CmsisThreadSetPriorityFunc002(void const *argument)85 static void CmsisThreadSetPriorityFunc002(void const *argument)
86 {
87     (void)argument;
88     UINT32 uwRet;
89     g_priTaskID01 = osThreadGetId();
90     uwRet = osThreadSetPriority(g_priTaskID01, g_setPriority);
91     ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
92     g_threadCreateExit2 = TESTCOUNT_NUM_1;
93     osThreadExit();
94 }
95 
96 /**
97  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5120
98  * @tc.name      : thread operation for get priority when Priority = osPriorityLow1
99  * @tc.desc      : [C- SOFTWARE -0200]
100  */
101 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority001, Function | MediumTest | Level1)
102 {
103     osThreadId_t id;
104     osStatus_t status;
105     osThreadAttr_t attr;
106     g_setPriority = osPriorityLow1;
107     attr.name = "test";
108     attr.attr_bits = 0U;
109     attr.cb_mem = NULL;
110     attr.cb_size = 0U;
111     attr.stack_mem = NULL;
112     attr.stack_size = TEST_TASK_STACK_SIZE;
113     attr.priority = g_setPriority;
114     g_threadCreateExit2 = 0;
115     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
116     status = osDelay(DELAY_TICKS_5);
117     ICUNIT_ASSERT_EQUAL(status, osOK, status);
118     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
119     WaitThreadExit(id, &g_threadCreateExit2);
120     return 0;
121 };
122 
123 /**
124  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5160
125  * @tc.name      : thread operation for get priority input exception
126  * @tc.desc      : [C- SOFTWARE -0200]
127  */
128 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority002, Function | MediumTest | Level1)
129 {
130     UINT32 uwRet = osThreadGetPriority(NULL);
131     ICUNIT_ASSERT_EQUAL(uwRet, osPriorityError, uwRet);
132     return 0;
133 };
134 
135 /**
136  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5200
137  * @tc.name      : thread operation for get current priority
138  * @tc.desc      : [C- SOFTWARE -0200]
139  */
140 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority003, Function | MediumTest | Level1)
141 {
142     UINT32 uwRet;
143     g_priTaskID01 = osThreadGetId();
144     uwRet = osThreadGetPriority(g_priTaskID01);
145     ICUNIT_ASSERT_EQUAL(uwRet, osPriorityLow1, uwRet);
146     return 0;
147 };
148 
149 /**
150  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5240
151  * @tc.name      : thread operation for get priority when Priority = osPriorityLow7
152  * @tc.desc      : [C- SOFTWARE -0200]
153  */
154 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority004, Function | MediumTest | Level1)
155 {
156     osThreadId_t id;
157     osStatus_t status;
158     osThreadAttr_t attr;
159     g_setPriority = osPriorityLow7;
160     attr.name = "test";
161     attr.attr_bits = 0U;
162     attr.cb_mem = NULL;
163     attr.cb_size = 0U;
164     attr.stack_mem = NULL;
165     attr.stack_size = TEST_TASK_STACK_SIZE;
166     attr.priority = g_setPriority;
167     g_threadCreateExit2 = 0;
168     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
169     status = osDelay(DELAY_TICKS_5);
170     ICUNIT_ASSERT_EQUAL(status, osOK, status);
171     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
172     WaitThreadExit(id, &g_threadCreateExit2);
173     return 0;
174 };
175 
176 /**
177  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5280
178  * @tc.name      : thread operation for get priority when Priority = osPriorityBelowNormal
179  * @tc.desc      : [C- SOFTWARE -0200]
180  */
181 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority005, Function | MediumTest | Level1)
182 {
183     osThreadId_t id;
184     osStatus_t status;
185     osThreadAttr_t attr;
186     g_setPriority = osPriorityBelowNormal;
187     attr.name = "test";
188     attr.attr_bits = 0U;
189     attr.cb_mem = NULL;
190     attr.cb_size = 0U;
191     attr.stack_mem = NULL;
192     attr.stack_size = TEST_TASK_STACK_SIZE;
193     attr.priority = g_setPriority;
194     g_threadCreateExit2 = 0;
195     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
196     status = osDelay(DELAY_TICKS_5);
197     ICUNIT_ASSERT_EQUAL(status, osOK, status);
198     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
199     WaitThreadExit(id, &g_threadCreateExit2);
200     return 0;
201 };
202 
203 /**
204  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5320
205  * @tc.name      : thread operation for get priority when Priority = osPriorityBelowNormal7
206  * @tc.desc      : [C- SOFTWARE -0200]
207  */
208 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority006, Function | MediumTest | Level1)
209 {
210     osThreadId_t id;
211     osStatus_t status;
212     osThreadAttr_t attr;
213     g_setPriority = osPriorityBelowNormal7;
214     attr.name = "test";
215     attr.attr_bits = 0U;
216     attr.cb_mem = NULL;
217     attr.cb_size = 0U;
218     attr.stack_mem = NULL;
219     attr.stack_size = TEST_TASK_STACK_SIZE;
220     attr.priority = g_setPriority;
221     g_threadCreateExit2 = 0;
222     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
223     status = osDelay(DELAY_TICKS_5);
224     ICUNIT_ASSERT_EQUAL(status, osOK, status);
225     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
226     WaitThreadExit(id, &g_threadCreateExit2);
227     return 0;
228 };
229 
230 /**
231  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5360
232  * @tc.name      : thread operation for get priority when Priority = osPriorityNormal
233  * @tc.desc      : [C- SOFTWARE -0200]
234  */
235 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority007, Function | MediumTest | Level1)
236 {
237     osThreadId_t id;
238     osStatus_t status;
239     osThreadAttr_t attr;
240     g_setPriority = osPriorityNormal;
241     attr.name = "test";
242     attr.attr_bits = 0U;
243     attr.cb_mem = NULL;
244     attr.cb_size = 0U;
245     attr.stack_mem = NULL;
246     attr.stack_size = TEST_TASK_STACK_SIZE;
247     attr.priority = g_setPriority;
248     g_threadCreateExit2 = 0;
249     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
250     status = osDelay(DELAY_TICKS_5);
251     ICUNIT_ASSERT_EQUAL(status, osOK, status);
252     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
253     WaitThreadExit(id, &g_threadCreateExit2);
254     return 0;
255 };
256 
257 /**
258  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5400
259  * @tc.name      : thread operation for get priority when Priority = osPriorityNormal7
260  * @tc.desc      : [C- SOFTWARE -0200]
261  */
262 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority008, Function | MediumTest | Level1)
263 {
264     osThreadId_t id;
265     osThreadAttr_t attr;
266     g_setPriority = osPriorityNormal7;
267     attr.name = "test";
268     attr.attr_bits = 0U;
269     attr.cb_mem = NULL;
270     attr.cb_size = 0U;
271     attr.stack_mem = NULL;
272     attr.stack_size = TEST_TASK_STACK_SIZE;
273     attr.priority = g_setPriority;
274     g_threadCreateExit2 = 0;
275     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
276     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
277     WaitThreadExit(id, &g_threadCreateExit2);
278     return 0;
279 };
280 
281 /**
282  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5440
283  * @tc.name      : thread operation for get priority when Priority = osPriorityAboveNormal
284  * @tc.desc      : [C- SOFTWARE -0200]
285  */
286 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority009, Function | MediumTest | Level1)
287 {
288     osThreadId_t id;
289     osThreadAttr_t attr;
290     g_setPriority = osPriorityAboveNormal;
291     attr.name = "test";
292     attr.attr_bits = 0U;
293     attr.cb_mem = NULL;
294     attr.cb_size = 0U;
295     attr.stack_mem = NULL;
296     attr.stack_size = TEST_TASK_STACK_SIZE;
297     attr.priority = g_setPriority;
298     g_threadCreateExit2 = 0;
299     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
300     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
301     WaitThreadExit(id, &g_threadCreateExit2);
302     return 0;
303 };
304 
305 /**
306  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5480
307  * @tc.name      : thread operation for get priority when Priority = osPriorityAboveNormal1
308  * @tc.desc      : [C- SOFTWARE -0200]
309  */
310 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadGetPriority010, Function | MediumTest | Level1)
311 {
312     osThreadId_t id;
313     osThreadAttr_t attr;
314     g_setPriority = osPriorityAboveNormal1;
315     attr.name = "test";
316     attr.attr_bits = 0U;
317     attr.cb_mem = NULL;
318     attr.cb_size = 0U;
319     attr.stack_mem = NULL;
320     attr.stack_size = TEST_TASK_STACK_SIZE;
321     attr.priority = g_setPriority;
322     g_threadCreateExit2 = 0;
323     id = osThreadNew((osThreadFunc_t)CmsisThreadGetPriorityFunc001, NULL, &attr);
324     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
325     WaitThreadExit(id, &g_threadCreateExit2);
326     return 0;
327 };
328 
329 /**
330  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5520
331  * @tc.name      : thread operation for set priority input1 exception
332  * @tc.desc      : [C- SOFTWARE -0200]
333  */
334 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority001, Function | MediumTest | Level1)
335 {
336     UINT32 uwRet = osThreadSetPriority(NULL, osPriorityNormal);
337     ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
338     return 0;
339 };
340 
341 /**
342  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5560
343  * @tc.name      : thread operation for set priority input2 exception
344  * @tc.desc      : [C- SOFTWARE -0200]
345  */
346 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority002, Function | MediumTest | Level1)
347 {
348     UINT32 uwRet;
349     g_priTaskID01 =  osThreadGetId();
350     uwRet = osThreadSetPriority(g_priTaskID01, osPriorityNone);
351     ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
352     return 0;
353 };
354 
355 /**
356  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5600
357  * @tc.name      : set invalid priority when curPriority = osPriorityLow1 and setPriority = osPriorityNone
358  * @tc.desc      : [C- SOFTWARE -0200]
359  */
360 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority003, Function | MediumTest | Level1)
361 {
362     osThreadId_t id;
363     osStatus_t status;
364     osThreadAttr_t attr;
365     attr.name = "test";
366     attr.attr_bits = 0U;
367     attr.cb_mem = NULL;
368     attr.cb_size = 0U;
369     attr.stack_mem = NULL;
370     attr.stack_size = TEST_TASK_STACK_SIZE;
371     attr.priority = osPriorityLow1;
372 
373     g_setPriority = osPriorityNone;
374     g_threadCreateExit2 = 0;
375     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
376     status = osDelay(DELAY_TICKS_5);
377     ICUNIT_ASSERT_EQUAL(status, osOK, status);
378     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
379 
380     g_setPriority = osPriorityIdle;
381     g_threadCreateExit2 = 0;
382     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
383     status = osDelay(DELAY_TICKS_5);
384     ICUNIT_ASSERT_EQUAL(status, osOK, status);
385     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
386 
387     g_setPriority = PRIORITY_COUNT_NOT_MIN;
388     g_threadCreateExit2 = 0;
389     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
390     status = osDelay(DELAY_TICKS_5);
391     ICUNIT_ASSERT_EQUAL(status, osOK, status);
392     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
393 
394     g_setPriority = osPriorityAboveNormal7;
395     g_threadCreateExit2 = 0;
396     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
397     status = osDelay(DELAY_TICKS_5);
398     ICUNIT_ASSERT_EQUAL(status, osOK, status);
399     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
400 
401     g_setPriority = osPriorityHigh;
402     g_threadCreateExit2 = 0;
403     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
404     status = osDelay(DELAY_TICKS_5);
405     ICUNIT_ASSERT_EQUAL(status, osOK, status);
406     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
407 
408     g_setPriority = osPriorityHigh7;
409     g_threadCreateExit2 = 0;
410     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
411     status = osDelay(DELAY_TICKS_5);
412     ICUNIT_ASSERT_EQUAL(status, osOK, status);
413     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
414     WaitThreadExit(id, &g_threadCreateExit2);
415     return 0;
416 };
417 
418 /**
419  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5720
420  * @tc.name      : set priority when curPriority = osPriorityLow1
421  * @tc.desc      : [C- SOFTWARE -0200]
422  */
423 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority004, Function | MediumTest | Level1)
424 {
425     osThreadId_t id;
426     osStatus_t status;
427     osThreadAttr_t attr;
428     attr.name = "test";
429     attr.attr_bits = 0U;
430     attr.cb_mem = NULL;
431     attr.cb_size = 0U;
432     attr.stack_mem = NULL;
433     attr.stack_size = TEST_TASK_STACK_SIZE;
434     attr.priority = PRIORITY_COUNT_MIN_1;
435     g_setPriority = PRIORITY_COUNT_MIN_1;
436     g_threadCreateExit2 = 0;
437     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
438     status = osDelay(DELAY_TICKS_5);
439     ICUNIT_ASSERT_EQUAL(status, osOK, status);
440     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
441     WaitThreadExit(id, &g_threadCreateExit2);
442 
443     g_setPriority = osPriorityLow7;
444     g_threadCreateExit2 = 0;
445     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
446     status = osDelay(DELAY_TICKS_5);
447     ICUNIT_ASSERT_EQUAL(status, osOK, status);
448     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
449     WaitThreadExit(id, &g_threadCreateExit2);
450 
451     g_setPriority = osPriorityBelowNormal;
452     g_threadCreateExit2 = 0;
453     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
454     status = osDelay(DELAY_TICKS_5);
455     ICUNIT_ASSERT_EQUAL(status, osOK, status);
456     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
457 
458     g_setPriority = osPriorityBelowNormal7;
459     g_threadCreateExit2 = 0;
460     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
461     status = osDelay(DELAY_TICKS_5);
462     ICUNIT_ASSERT_EQUAL(status, osOK, status);
463     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
464 
465     WaitThreadExit(id, &g_threadCreateExit2);
466     return 0;
467 };
468 
469 /**
470  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_5720
471  * @tc.name      : set priority when curPriority = osPriorityLow1
472  * @tc.desc      : [C- SOFTWARE -0200]
473  */
474 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority016, Function | MediumTest | Level1)
475 {
476     osThreadId_t id;
477     osStatus_t status;
478     osThreadAttr_t attr;
479     attr.name = "test";
480     attr.attr_bits = 0U;
481     attr.cb_mem = NULL;
482     attr.cb_size = 0U;
483     attr.stack_mem = NULL;
484     attr.stack_size = TEST_TASK_STACK_SIZE;
485     attr.priority = PRIORITY_COUNT_MIN_1;
486 
487     g_setPriority = osPriorityNormal;
488     g_threadCreateExit2 = 0;
489     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
490     status = osDelay(DELAY_TICKS_5);
491     ICUNIT_ASSERT_EQUAL(status, osOK, status);
492     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
493 
494     g_setPriority = osPriorityNormal7;
495     g_threadCreateExit2 = 0;
496     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
497     status = osDelay(DELAY_TICKS_5);
498     ICUNIT_ASSERT_EQUAL(status, osOK, status);
499     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
500 
501     g_setPriority = osPriorityAboveNormal;
502     g_threadCreateExit2 = 0;
503     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
504     status = osDelay(DELAY_TICKS_5);
505     ICUNIT_ASSERT_EQUAL(status, osOK, status);
506     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
507 
508     g_setPriority = osPriorityAboveNormal1;
509     g_threadCreateExit2 = 0;
510     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
511     status = osDelay(DELAY_TICKS_5);
512     ICUNIT_ASSERT_EQUAL(status, osOK, status);
513     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
514     WaitThreadExit(id, &g_threadCreateExit2);
515     return 0;
516 };
517 
518 /**
519  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_6040
520  * @tc.name      : set invalid priority when curPriority = osPriorityLow1 and setPriority = osPriorityAboveNormal7
521  * @tc.desc      : [C- SOFTWARE -0200]
522  */
523 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority005, Function | MediumTest | Level1)
524 {
525     osThreadId_t id;
526     osStatus_t status;
527     osThreadAttr_t attr;
528     attr.name = "test";
529     attr.attr_bits = 0U;
530     attr.cb_mem = NULL;
531     attr.cb_size = 0U;
532     attr.stack_mem = NULL;
533     attr.stack_size = TEST_TASK_STACK_SIZE;
534     attr.priority = osPriorityLow1;
535 
536     g_setPriority = osPriorityRealtime;
537     g_threadCreateExit2 = 0;
538     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
539     status = osDelay(DELAY_TICKS_5);
540     ICUNIT_ASSERT_EQUAL(status, osOK, status);
541     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
542 
543     g_setPriority = osPriorityRealtime7;
544     g_threadCreateExit2 = 0;
545     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
546     status = osDelay(DELAY_TICKS_5);
547     ICUNIT_ASSERT_EQUAL(status, osOK, status);
548     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
549 
550     g_setPriority = osPriorityISR;
551     g_threadCreateExit2 = 0;
552     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
553     status = osDelay(DELAY_TICKS_5);
554     ICUNIT_ASSERT_EQUAL(status, osOK, status);
555     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
556 
557     g_setPriority = osPriorityError;
558     g_threadCreateExit2 = 0;
559     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
560     status = osDelay(DELAY_TICKS_5);
561     ICUNIT_ASSERT_EQUAL(status, osOK, status);
562     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
563 
564     g_setPriority = osPriorityReserved;
565     g_threadCreateExit2 = 0;
566     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
567     status = osDelay(DELAY_TICKS_5);
568     ICUNIT_ASSERT_EQUAL(status, osOK, status);
569     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
570     WaitThreadExit(id, &g_threadCreateExit2);
571     return 0;
572 };
573 
574 /**
575  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_6360
576  * @tc.name      : set invalid priority when curPriority = osPriorityNormal and setPriority = osPriorityNone
577  * @tc.desc      : [C- SOFTWARE -0200]
578  */
579 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority006, Function | MediumTest | Level1)
580 {
581     osThreadId_t id;
582     osStatus_t status;
583     osThreadAttr_t attr;
584     attr.name = "test";
585     attr.attr_bits = 0U;
586     attr.cb_mem = NULL;
587     attr.cb_size = 0U;
588     attr.stack_mem = NULL;
589     attr.stack_size = TEST_TASK_STACK_SIZE;
590     attr.priority = osPriorityNormal;
591     g_setPriority = osPriorityNone;
592     g_threadCreateExit2 = 0;
593     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
594     status = osDelay(DELAY_TICKS_5);
595     ICUNIT_ASSERT_EQUAL(status, osOK, status);
596     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
597 
598     g_setPriority = osPriorityIdle;
599     g_threadCreateExit2 = 0;
600     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
601     status = osDelay(DELAY_TICKS_5);
602     ICUNIT_ASSERT_EQUAL(status, osOK, status);
603     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
604 
605     g_setPriority = PRIORITY_COUNT_NOT_MIN;
606     g_threadCreateExit2 = 0;
607     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
608     status = osDelay(DELAY_TICKS_5);
609     ICUNIT_ASSERT_EQUAL(status, osOK, status);
610     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
611 
612     WaitThreadExit(id, &g_threadCreateExit2);
613     return 0;
614 };
615 
616 /**
617  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_6480
618  * @tc.name      : set priority when curPriority = osPriorityNormal and setPriority = osPriorityLow1
619  * @tc.desc      : [C- SOFTWARE -0200]
620  */
621 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority007, Function | MediumTest | Level1)
622 {
623     osThreadId_t id;
624     osStatus_t status;
625     osThreadAttr_t attr;
626     attr.name = "test";
627     attr.attr_bits = 0U;
628     attr.cb_mem = NULL;
629     attr.cb_size = 0U;
630     attr.stack_mem = NULL;
631     attr.stack_size = TEST_TASK_STACK_SIZE;
632     attr.priority = osPriorityNormal;
633     g_setPriority = osPriorityLow1;
634     g_threadCreateExit2 = 0;
635     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
636     status = osDelay(DELAY_TICKS_5);
637     ICUNIT_ASSERT_EQUAL(status, osOK, status);
638     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
639 
640     g_setPriority = osPriorityLow7;
641     g_threadCreateExit2 = 0;
642     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
643     status = osDelay(DELAY_TICKS_5);
644     ICUNIT_ASSERT_EQUAL(status, osOK, status);
645     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
646 
647     g_setPriority = osPriorityBelowNormal;
648     g_threadCreateExit2 = 0;
649     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
650     status = osDelay(DELAY_TICKS_5);
651     ICUNIT_ASSERT_EQUAL(status, osOK, status);
652     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
653 
654     g_setPriority = osPriorityBelowNormal7;
655     g_threadCreateExit2 = 0;
656     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
657     status = osDelay(DELAY_TICKS_5);
658     ICUNIT_ASSERT_EQUAL(status, osOK, status);
659     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
660 
661     g_setPriority = osPriorityNormal;
662     g_threadCreateExit2 = 0;
663     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
664     status = osDelay(DELAY_TICKS_5);
665     ICUNIT_ASSERT_EQUAL(status, osOK, status);
666     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
667     WaitThreadExit(id, &g_threadCreateExit2);
668     return 0;
669 };
670 
671 /**
672  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_6680
673  * @tc.name      : set priority when curPriority = osPriorityNormal and setPriority = osPriorityNormal7
674  * @tc.desc      : [C- SOFTWARE -0200]
675  */
676 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority008, Function | MediumTest | Level1)
677 {
678     osThreadId_t id;
679     osStatus_t status;
680     osThreadAttr_t attr;
681     attr.name = "test";
682     attr.attr_bits = 0U;
683     attr.cb_mem = NULL;
684     attr.cb_size = 0U;
685     attr.stack_mem = NULL;
686     attr.stack_size = TEST_TASK_STACK_SIZE;
687     attr.priority = osPriorityNormal;
688     g_setPriority = osPriorityNormal7;
689     g_threadCreateExit2 = 0;
690     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
691     status = osDelay(DELAY_TICKS_5);
692     ICUNIT_ASSERT_EQUAL(status, osOK, status);
693     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
694 
695     g_setPriority = osPriorityAboveNormal;
696     g_threadCreateExit2 = 0;
697     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
698     status = osDelay(DELAY_TICKS_5);
699     ICUNIT_ASSERT_EQUAL(status, osOK, status);
700     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
701 
702     g_setPriority = osPriorityAboveNormal1;
703     g_threadCreateExit2 = 0;
704     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
705     status = osDelay(DELAY_TICKS_5);
706     ICUNIT_ASSERT_EQUAL(status, osOK, status);
707     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
708 
709     WaitThreadExit(id, &g_threadCreateExit2);
710     return 0;
711 };
712 
713 /**
714  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_6800
715  * @tc.name      : set invalid priority when curPriority = osPriorityNormal and setPriority = osPriorityAboveNormal2
716  * @tc.desc      : [C- SOFTWARE -0200]
717  */
718 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority009, Function | MediumTest | Level1)
719 {
720     osThreadId_t id;
721     osStatus_t status;
722     osThreadAttr_t attr;
723     attr.name = "test";
724     attr.attr_bits = 0U;
725     attr.cb_mem = NULL;
726     attr.cb_size = 0U;
727     attr.stack_mem = NULL;
728     attr.stack_size = TEST_TASK_STACK_SIZE;
729     attr.priority = osPriorityNormal;
730     g_setPriority = osPriorityAboveNormal2;
731     g_threadCreateExit2 = 0;
732     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
733     status = osDelay(DELAY_TICKS_5);
734     ICUNIT_ASSERT_EQUAL(status, osOK, status);
735     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
736 
737     g_setPriority = osPriorityHigh;
738     g_threadCreateExit2 = 0;
739     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
740     status = osDelay(DELAY_TICKS_5);
741     ICUNIT_ASSERT_EQUAL(status, osOK, status);
742     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
743 
744     g_setPriority = osPriorityHigh7;
745     g_threadCreateExit2 = 0;
746     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
747     status = osDelay(DELAY_TICKS_5);
748     ICUNIT_ASSERT_EQUAL(status, osOK, status);
749     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
750 
751     g_setPriority = osPriorityRealtime;
752     g_threadCreateExit2 = 0;
753     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
754     status = osDelay(DELAY_TICKS_5);
755     ICUNIT_ASSERT_EQUAL(status, osOK, status);
756     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
757 
758     g_setPriority = osPriorityRealtime7;
759     g_threadCreateExit2 = 0;
760     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
761     status = osDelay(DELAY_TICKS_5);
762     ICUNIT_ASSERT_EQUAL(status, osOK, status);
763     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
764 
765     g_setPriority = osPriorityISR;
766     g_threadCreateExit2 = 0;
767     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
768     status = osDelay(DELAY_TICKS_5);
769     ICUNIT_ASSERT_EQUAL(status, osOK, status);
770     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
771 
772     WaitThreadExit(id, &g_threadCreateExit2);
773     return 0;
774 };
775 
776 /**
777  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7040
778  * @tc.name      : set invalid priority when curPriority = osPriorityNormal and setPriority = osPriorityError
779  * @tc.desc      : [C- SOFTWARE -0200]
780  */
781 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority010, Function | MediumTest | Level1)
782 {
783     osThreadId_t id;
784     osStatus_t status;
785     osThreadAttr_t attr;
786     attr.name = "test";
787     attr.attr_bits = 0U;
788     attr.cb_mem = NULL;
789     attr.cb_size = 0U;
790     attr.stack_mem = NULL;
791     attr.stack_size = TEST_TASK_STACK_SIZE;
792     attr.priority = osPriorityNormal;
793     g_setPriority = osPriorityError;
794     g_threadCreateExit2 = 0;
795     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
796     status = osDelay(DELAY_TICKS_5);
797     ICUNIT_ASSERT_EQUAL(status, osOK, status);
798     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
799 
800     g_setPriority = osPriorityReserved;
801     g_threadCreateExit2 = 0;
802     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
803     status = osDelay(DELAY_TICKS_5);
804     ICUNIT_ASSERT_EQUAL(status, osOK, status);
805     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
806 
807     WaitThreadExit(id, &g_threadCreateExit2);
808     return 0;
809 };
810 
811 /**
812  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7120
813  * @tc.name      : set invalid priority when curPriority = osPriorityAboveNormal1 and setPriority = osPriorityNone
814  * @tc.desc      : [C- SOFTWARE -0200]
815  */
816 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority011, Function | MediumTest | Level1)
817 {
818     osThreadId_t id;
819     osStatus_t status;
820     osThreadAttr_t attr;
821     attr.name = "test";
822     attr.attr_bits = 0U;
823     attr.cb_mem = NULL;
824     attr.cb_size = 0U;
825     attr.stack_mem = NULL;
826     attr.stack_size = TEST_TASK_STACK_SIZE;
827     attr.priority = osPriorityAboveNormal1;
828     g_setPriority = osPriorityNone;
829     g_threadCreateExit2 = 0;
830     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
831     status = osDelay(DELAY_TICKS_5);
832     ICUNIT_ASSERT_EQUAL(status, osOK, status);
833     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
834 
835     g_setPriority = osPriorityIdle;
836     g_threadCreateExit2 = 0;
837     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
838     status = osDelay(DELAY_TICKS_5);
839     ICUNIT_ASSERT_EQUAL(status, osOK, status);
840     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
841 
842     g_setPriority = PRIORITY_COUNT_NOT_MIN;
843     g_threadCreateExit2 = 0;
844     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
845     status = osDelay(DELAY_TICKS_5);
846     ICUNIT_ASSERT_EQUAL(status, osOK, status);
847     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
848 
849     WaitThreadExit(id, &g_threadCreateExit2);
850     return 0;
851 };
852 
853 /**
854  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7240
855  * @tc.name      : set priority when curPriority = osPriorityAboveNormal1 and setPriority = osPriorityLow1
856  * @tc.desc      : [C- SOFTWARE -0200]
857  */
858 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority012, Function | MediumTest | Level1)
859 {
860     osThreadId_t id;
861     osStatus_t status;
862     osThreadAttr_t attr;
863     attr.name = "test";
864     attr.attr_bits = 0U;
865     attr.cb_mem = NULL;
866     attr.cb_size = 0U;
867     attr.stack_mem = NULL;
868     attr.stack_size = TEST_TASK_STACK_SIZE;
869     attr.priority = osPriorityAboveNormal1;
870     g_setPriority = osPriorityLow1;
871     g_threadCreateExit2 = 0;
872     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
873     status = osDelay(DELAY_TICKS_5);
874     ICUNIT_ASSERT_EQUAL(status, osOK, status);
875     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
876 
877     g_setPriority = osPriorityLow7;
878     g_threadCreateExit2 = 0;
879     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
880     status = osDelay(DELAY_TICKS_5);
881     ICUNIT_ASSERT_EQUAL(status, osOK, status);
882     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
883 
884     g_setPriority = osPriorityBelowNormal;
885     g_threadCreateExit2 = 0;
886     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
887     status = osDelay(DELAY_TICKS_5);
888     ICUNIT_ASSERT_EQUAL(status, osOK, status);
889     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
890 
891     g_setPriority = osPriorityBelowNormal7;
892     g_threadCreateExit2 = 0;
893     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
894     status = osDelay(DELAY_TICKS_5);
895     ICUNIT_ASSERT_EQUAL(status, osOK, status);
896     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
897 
898     g_setPriority = osPriorityNormal;
899     g_threadCreateExit2 = 0;
900     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
901     status = osDelay(DELAY_TICKS_5);
902     ICUNIT_ASSERT_EQUAL(status, osOK, status);
903     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
904 
905     g_setPriority = osPriorityNormal7;
906     g_threadCreateExit2 = 0;
907     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
908     status = osDelay(DELAY_TICKS_5);
909     ICUNIT_ASSERT_EQUAL(status, osOK, status);
910     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
911 
912     WaitThreadExit(id, &g_threadCreateExit2);
913     return 0;
914 };
915 
916 /**
917  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7480
918  * @tc.name      : set priority when curPriority = osPriorityAboveNormal1 and setPriority = osPriorityAboveNormal
919  * @tc.desc      : [C- SOFTWARE -0200]
920  */
921 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority013, Function | MediumTest | Level1)
922 {
923     osThreadId_t id;
924     osStatus_t status;
925     osThreadAttr_t attr;
926     attr.name = "test";
927     attr.attr_bits = 0U;
928     attr.cb_mem = NULL;
929     attr.cb_size = 0U;
930     attr.stack_mem = NULL;
931     attr.stack_size = TEST_TASK_STACK_SIZE;
932     attr.priority = osPriorityAboveNormal1;
933     g_setPriority = osPriorityAboveNormal;
934     g_threadCreateExit2 = 0;
935     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
936     status = osDelay(DELAY_TICKS_5);
937     ICUNIT_ASSERT_EQUAL(status, osOK, status);
938     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
939 
940     g_setPriority = osPriorityAboveNormal1;
941     g_threadCreateExit2 = 0;
942     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc001, NULL, &attr);
943     status = osDelay(DELAY_TICKS_5);
944     ICUNIT_ASSERT_EQUAL(status, osOK, status);
945     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
946 
947     WaitThreadExit(id, &g_threadCreateExit2);
948     return 0;
949 };
950 
951 /**
952  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7560
953  * @tc.name      : set invalid priority when curPriority = PriorityAboveNormal6 and setPriority = PriorityAboveNormal7
954  * @tc.desc      : [C- SOFTWARE -0200]
955  */
956 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority014, Function | MediumTest | Level1)
957 {
958     osThreadId_t id;
959     osStatus_t status;
960     osThreadAttr_t attr;
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 = osPriorityAboveNormal1;
968     g_setPriority = osPriorityAboveNormal7;
969     g_threadCreateExit2 = 0;
970     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
971     status = osDelay(DELAY_TICKS_5);
972     ICUNIT_ASSERT_EQUAL(status, osOK, status);
973     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
974 
975     g_setPriority = osPriorityHigh;
976     g_threadCreateExit2 = 0;
977     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
978     status = osDelay(DELAY_TICKS_5);
979     ICUNIT_ASSERT_EQUAL(status, osOK, status);
980     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
981 
982     g_setPriority = osPriorityHigh7;
983     g_threadCreateExit2 = 0;
984     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
985     status = osDelay(DELAY_TICKS_5);
986     ICUNIT_ASSERT_EQUAL(status, osOK, status);
987     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
988 
989     g_setPriority = osPriorityRealtime;
990     g_threadCreateExit2 = 0;
991     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
992     status = osDelay(DELAY_TICKS_5);
993     ICUNIT_ASSERT_EQUAL(status, osOK, status);
994     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
995 
996     g_setPriority = osPriorityRealtime7;
997     g_threadCreateExit2 = 0;
998     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
999     status = osDelay(DELAY_TICKS_5);
1000     ICUNIT_ASSERT_EQUAL(status, osOK, status);
1001     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1002 
1003     WaitThreadExit(id, &g_threadCreateExit2);
1004     return 0;
1005 };
1006 
1007 /**
1008  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7760
1009  * @tc.name      : set invalid priority when curPriority = osPriorityAboveNormal1 and setPriority = osPriorityISR
1010  * @tc.desc      : [C- SOFTWARE -0200]
1011  */
1012 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsThreadSetPriority015, Function | MediumTest | Level1)
1013 {
1014     osThreadId_t id;
1015     osStatus_t status;
1016     osThreadAttr_t attr;
1017     attr.name = "test";
1018     attr.attr_bits = 0U;
1019     attr.cb_mem = NULL;
1020     attr.cb_size = 0U;
1021     attr.stack_mem = NULL;
1022     attr.stack_size = TEST_TASK_STACK_SIZE;
1023     attr.priority = osPriorityAboveNormal1;
1024     g_setPriority = osPriorityISR;
1025     g_threadCreateExit2 = 0;
1026     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
1027     status = osDelay(DELAY_TICKS_5);
1028     ICUNIT_ASSERT_EQUAL(status, osOK, status);
1029     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1030 
1031     g_setPriority = osPriorityError;
1032     g_threadCreateExit2 = 0;
1033     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
1034     status = osDelay(DELAY_TICKS_5);
1035     ICUNIT_ASSERT_EQUAL(status, osOK, status);
1036     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1037 
1038     g_setPriority = osPriorityReserved;
1039     g_threadCreateExit2 = 0;
1040     id = osThreadNew((osThreadFunc_t)CmsisThreadSetPriorityFunc002, NULL, &attr);
1041     status = osDelay(DELAY_TICKS_5);
1042     ICUNIT_ASSERT_EQUAL(status, osOK, status);
1043     ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
1044     WaitThreadExit(id, &g_threadCreateExit2);
1045     return 0;
1046 };
1047 
1048 /**
1049  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7880
1050  * @tc.name      : delay operation for 5 ticks
1051  * @tc.desc      : [C- SOFTWARE -0200]
1052 
1053  */
1054 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsDelay, Function | MediumTest | Level1)
1055 {
1056     UINT32 uwRet = osDelay(DELAY_TICKS_5);
1057     ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1058     uwRet = osDelay(0);
1059     ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
1060     return 0;
1061 };
1062 
1063 /**
1064  * @tc.number    : SUB_KERNEL_CMSIS_TASK_OPERATION_7960
1065  * @tc.name      : delay until operation
1066  * @tc.desc      : [C- SOFTWARE -0200]
1067 
1068  */
1069 LITE_TEST_CASE(CmsisTaskPriFuncTestSuite, testOsDelayUntil, Function | MediumTest | Level1)
1070 {
1071     UINT32 uwRet;
1072     UINT32 uwTickCnt;
1073     UINT32 uwUntilTickCnt;
1074     uwTickCnt = osKernelGetTickCount();
1075     uwUntilTickCnt = uwTickCnt + DELAY_TICKS_5;
1076     uwRet = osDelayUntil(uwUntilTickCnt);
1077     ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
1078 
1079     uwRet = osDelayUntil(DELAY_TICKS_1);
1080     ICUNIT_ASSERT_EQUAL(uwRet, osError, uwRet);
1081 
1082     uwTickCnt = osKernelGetTickCount();
1083     uwUntilTickCnt = uwTickCnt - DELAY_TICKS_5;
1084     uwRet = osDelayUntil(uwUntilTickCnt);
1085     ICUNIT_ASSERT_EQUAL(uwRet, osError, uwRet);
1086     return 0;
1087 };
1088 
1089 RUN_TEST_SUITE(CmsisTaskPriFuncTestSuite);
1090 
CmsisTaskPriFuncTest(void)1091 void CmsisTaskPriFuncTest(void)
1092 {
1093     RUN_ONE_TESTCASE(testOsThreadGetPriority001);
1094     RUN_ONE_TESTCASE(testOsThreadGetPriority002);
1095     RUN_ONE_TESTCASE(testOsThreadGetPriority003);
1096     RUN_ONE_TESTCASE(testOsThreadGetPriority004);
1097     RUN_ONE_TESTCASE(testOsThreadGetPriority005);
1098     RUN_ONE_TESTCASE(testOsThreadGetPriority006);
1099     RUN_ONE_TESTCASE(testOsThreadGetPriority007);
1100     RUN_ONE_TESTCASE(testOsThreadGetPriority008);
1101     RUN_ONE_TESTCASE(testOsThreadGetPriority009);
1102     RUN_ONE_TESTCASE(testOsThreadGetPriority010);
1103     RUN_ONE_TESTCASE(testOsThreadSetPriority001);
1104     RUN_ONE_TESTCASE(testOsThreadSetPriority002);
1105     RUN_ONE_TESTCASE(testOsThreadSetPriority003);
1106     RUN_ONE_TESTCASE(testOsThreadSetPriority004);
1107     RUN_ONE_TESTCASE(testOsThreadSetPriority005);
1108     RUN_ONE_TESTCASE(testOsThreadSetPriority006);
1109     RUN_ONE_TESTCASE(testOsThreadSetPriority007);
1110     RUN_ONE_TESTCASE(testOsThreadSetPriority008);
1111     RUN_ONE_TESTCASE(testOsThreadSetPriority009);
1112     RUN_ONE_TESTCASE(testOsThreadSetPriority010);
1113     RUN_ONE_TESTCASE(testOsThreadSetPriority011);
1114     RUN_ONE_TESTCASE(testOsThreadSetPriority012);
1115     RUN_ONE_TESTCASE(testOsThreadSetPriority013);
1116     RUN_ONE_TESTCASE(testOsThreadSetPriority014);
1117     RUN_ONE_TESTCASE(testOsThreadSetPriority015);
1118     RUN_ONE_TESTCASE(testOsThreadSetPriority016);
1119     RUN_ONE_TESTCASE(testOsDelay);
1120     RUN_ONE_TESTCASE(testOsDelayUntil);
1121 }