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 osSemaphoreId_t g_cmsisSemSemaph;
34
35 LITE_TEST_SUIT(Cmsis, CmsisSem, CmsisSemFuncTestSuite);
36
CmsisSemFuncTestSuiteSetUp(void)37 static BOOL CmsisSemFuncTestSuiteSetUp(void)
38 {
39 return TRUE;
40 }
41
CmsisSemFuncTestSuiteTearDown(void)42 static BOOL CmsisSemFuncTestSuiteTearDown(void)
43 {
44 return TRUE;
45 }
46
47 /**
48 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0100
49 * @tc.name : semaphore operation for creat when Semaphhore count = 1 and 0
50 * @tc.desc : [C- SOFTWARE -0200]
51 */
52 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew001, Function | MediumTest | Level1)
53 {
54 osStatus_t status;
55 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
56 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
57 (void)osSemaphoreDelete(g_cmsisSemSemaph);
58 status = osDelay(DELAY_TICKS_5);
59 ICUNIT_ASSERT_EQUAL(status, osOK, status);
60 return 0;
61 };
62
63 /**
64 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0200
65 * @tc.name : semaphore operation for creat when Semaphhore count = 10 and 1
66 * @tc.desc : [C- SOFTWARE -0200]
67 */
68 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew002, Function | MediumTest | Level1)
69 {
70 osStatus_t status;
71 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT1, NULL);
72 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
73 (void)osSemaphoreDelete(g_cmsisSemSemaph);
74 status = osDelay(DELAY_TICKS_5);
75 ICUNIT_ASSERT_EQUAL(status, osOK, status);
76 return 0;
77 };
78
79 /**
80 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0300
81 * @tc.name : semaphore operation for creat when Semaphhore count = 0 and 10
82 * @tc.desc : [C- SOFTWARE -0200]
83 */
84 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew003, Function | MediumTest | Level1)
85 {
86 osStatus_t status;
87 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT10, NULL);
88 ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
89 (void)osSemaphoreDelete(g_cmsisSemSemaph);
90 status = osDelay(DELAY_TICKS_5);
91 ICUNIT_ASSERT_EQUAL(status, osOK, status);
92 return 0;
93 };
94
95 /**
96 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0400
97 * @tc.name : semaphore operation for creat when Semaphhore count = 0 and 0
98 * @tc.desc : [C- SOFTWARE -0200]
99 */
100 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew004, Function | MediumTest | Level1)
101 {
102 osStatus_t status;
103 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT0, NULL);
104 ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
105 (void)osSemaphoreDelete(g_cmsisSemSemaph);
106 status = osDelay(DELAY_TICKS_5);
107 ICUNIT_ASSERT_EQUAL(status, osOK, status);
108 return 0;
109 };
110
111 /**
112 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0500
113 * @tc.name : semaphore operation for creat when Semaphhore count = 1 and 1
114 * @tc.desc : [C- SOFTWARE -0200]
115 */
116 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew005, Function | MediumTest | Level1)
117 {
118 osStatus_t status;
119 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
120 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
121 (void)osSemaphoreDelete(g_cmsisSemSemaph);
122 status = osDelay(DELAY_TICKS_5);
123 ICUNIT_ASSERT_EQUAL(status, osOK, status);
124 return 0;
125 };
126
127 /**
128 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0600
129 * @tc.name : semaphore operation for creat when Semaphhore count = 10 and 10
130 * @tc.desc : [C- SOFTWARE -0200]
131 */
132 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew006, Function | MediumTest | Level1)
133 {
134 osStatus_t status;
135 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT10, NULL);
136 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
137 (void)osSemaphoreDelete(g_cmsisSemSemaph);
138 status = osDelay(DELAY_TICKS_5);
139 ICUNIT_ASSERT_EQUAL(status, osOK, status);
140 return 0;
141 };
142
143 /**
144 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0700
145 * @tc.name : semaphore operation for creat when Semaphhore count = 0xFE and 0
146 * @tc.desc : [C- SOFTWARE -0200]
147 */
148 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew007, Function | MediumTest | Level1)
149 {
150 osStatus_t status;
151 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_INT0, NULL);
152 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
153 (void)osSemaphoreDelete(g_cmsisSemSemaph);
154 status = osDelay(DELAY_TICKS_5);
155 ICUNIT_ASSERT_EQUAL(status, osOK, status);
156 return 0;
157 };
158
159 /**
160 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0800
161 * @tc.name : semaphore operation for creat when Semaphhore count = 0 and 0xFE
162 * @tc.desc : [C- SOFTWARE -0200]
163 */
164 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew008, Function | MediumTest | Level1)
165 {
166 osStatus_t status;
167 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_HEX_MAX, NULL);
168 ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
169 (void)osSemaphoreDelete(g_cmsisSemSemaph);
170 status = osDelay(DELAY_TICKS_5);
171 ICUNIT_ASSERT_EQUAL(status, osOK, status);
172 return 0;
173 };
174
175 /**
176 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0900
177 * @tc.name : semaphore operation for delete
178 * @tc.desc : [C- SOFTWARE -0200]
179 */
180 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete001, Function | MediumTest | Level1)
181 {
182 osStatus_t ret;
183 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT0, NULL);
184 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
185 ret = osSemaphoreDelete(g_cmsisSemSemaph);
186 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
187 return 0;
188 };
189
190 /**
191 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1000
192 * @tc.name : semaphore delete operation twice
193 * @tc.desc : [C- SOFTWARE -0200]
194 */
195 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete002, Function | MediumTest | Level1)
196 {
197 osStatus_t ret;
198 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT0, NULL);
199 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
200
201 ret = osSemaphoreDelete(g_cmsisSemSemaph);
202 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
203
204 ret = osSemaphoreDelete(g_cmsisSemSemaph);
205 ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
206 return 0;
207 };
208
209 /**
210 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1100
211 * @tc.name : semaphore delete operation with semaphore_id = NULL
212 * @tc.desc : [C- SOFTWARE -0200]
213 */
214 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete003, Function | MediumTest | Level1)
215 {
216 osStatus_t ret = osSemaphoreDelete(NULL);
217 ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
218 return 0;
219 };
220
221 /**
222 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1200
223 * @tc.name : semaphore operation for acquire when Semaphhore count = 1 and 1
224 * @tc.desc : [C- SOFTWARE -0200]
225 */
226 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire001, Function | MediumTest | Level1)
227 {
228 osStatus_t ret;
229 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
230 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
231 ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
232 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
233
234 ret = osSemaphoreDelete(g_cmsisSemSemaph);
235 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
236 return 0;
237 };
238
239 /**
240 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1300
241 * @tc.name : semaphore operation for acquire when Semaphhore count = 1 and 0
242 * @tc.desc : [C- SOFTWARE -0200]
243 */
244 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire002, Function | MediumTest | Level1)
245 {
246 osStatus_t ret;
247 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
248 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
249 ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
250 ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
251
252 ret = osSemaphoreDelete(g_cmsisSemSemaph);
253 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
254 return 0;
255 };
256
257 /**
258 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1400
259 * @tc.name : semaphore operation for acquire when Semaphhore count = 0 and 1
260 * @tc.desc : [C- SOFTWARE -0200]
261 */
262 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire003, Function | MediumTest | Level1)
263 {
264 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT1, NULL);
265 ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
266 return 0;
267 };
268
269 /**
270 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1500
271 * @tc.name : semaphore acquire operation with semaphore_id = NULL
272 * @tc.desc : [C- SOFTWARE -0200]
273 */
274 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire004, Function | MediumTest | Level1)
275 {
276 osStatus_t ret = osSemaphoreAcquire(NULL, 0);
277 ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
278 return 0;
279 };
280
281 /**
282 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1600
283 * @tc.name : semaphore operation for release
284 * @tc.desc : [C- SOFTWARE -0200]
285 */
286 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease001, Function | MediumTest | Level1)
287 {
288 osStatus_t ret;
289 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
290 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
291
292 ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
293 ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
294
295 ret = osSemaphoreRelease(g_cmsisSemSemaph);
296 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
297
298 ret = osSemaphoreDelete(g_cmsisSemSemaph);
299 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
300 return 0;
301 };
302
303 /**
304 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1700
305 * @tc.name : semaphore release operation twice
306 * @tc.desc : [C- SOFTWARE -0200]
307 */
308 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease002, Function | MediumTest | Level1)
309 {
310 osStatus_t ret;
311 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
312 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
313
314 ret = osSemaphoreRelease(g_cmsisSemSemaph);
315 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
316 ret = osSemaphoreRelease(g_cmsisSemSemaph);
317 ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
318
319 ret = osSemaphoreDelete(g_cmsisSemSemaph);
320 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
321 return 0;
322 };
323
324 /**
325 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1800
326 * @tc.name : semaphore operation for release after semaphore acquire
327 * @tc.desc : [C- SOFTWARE -0200]
328 */
329 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease003, Function | MediumTest | Level1)
330 {
331 osStatus_t ret;
332 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
333 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
334
335 ret = osSemaphoreRelease(g_cmsisSemSemaph);
336 ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
337
338 ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
339 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
340
341 ret = osSemaphoreRelease(g_cmsisSemSemaph);
342 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
343 ret = osSemaphoreRelease(g_cmsisSemSemaph);
344 ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
345
346 ret = osSemaphoreDelete(g_cmsisSemSemaph);
347 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
348 return 0;
349 };
350
351 /**
352 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1900
353 * @tc.name : semaphore release operation with semaphore_id = NULL
354 * @tc.desc : [C- SOFTWARE -0200]
355 */
356 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease004, Function | MediumTest | Level1)
357 {
358 osStatus_t ret = osSemaphoreRelease(NULL);
359 ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
360 return 0;
361 };
362
363 /**
364 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2000
365 * @tc.name : semaphore operation for get count when Semaphhore count = 1 or 0xFE
366 * @tc.desc : [C- SOFTWARE -0200]
367 */
368 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount001, Function | MediumTest | Level1)
369 {
370 osStatus_t ret;
371 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
372 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
373 ret = osSemaphoreGetCount(g_cmsisSemSemaph);
374 ICUNIT_ASSERT_EQUAL(ret, 1, ret); /* 1, common data for test, no special meaning */
375 ret = osSemaphoreDelete(g_cmsisSemSemaph);
376 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
377
378 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_HEX_MAX, NULL);
379 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
380 ret = osSemaphoreGetCount(g_cmsisSemSemaph);
381 ICUNIT_ASSERT_EQUAL(ret, SEMAPHHORE_COUNT_HEX_MAX, ret);
382 ret = osSemaphoreDelete(g_cmsisSemSemaph);
383 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
384 return 0;
385 };
386
387 /**
388 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2100
389 * @tc.name : semaphore operation for get count when Semaphhore count = 1 or 0
390 * @tc.desc : [C- SOFTWARE -0200]
391 */
392 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount002, Function | MediumTest | Level1)
393 {
394 osStatus_t ret;
395 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
396 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
397 ret = osSemaphoreGetCount(g_cmsisSemSemaph);
398 ICUNIT_ASSERT_EQUAL(ret, 0, ret);
399 ret = osSemaphoreDelete(g_cmsisSemSemaph);
400 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
401
402 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT1, NULL);
403 ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
404 return 0;
405 };
406
407 /**
408 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2200
409 * @tc.name : semaphore operation for get count
410 * @tc.desc : [C- SOFTWARE -0200]
411 */
412 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount003, Function | MediumTest | Level1)
413 {
414 osStatus_t ret;
415 g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_HEX_MAX, NULL);
416 ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
417 ret = osSemaphoreAcquire(g_cmsisSemSemaph, osWaitForever);
418 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
419
420 ret = osSemaphoreGetCount(g_cmsisSemSemaph);
421 ICUNIT_ASSERT_EQUAL(ret, SEMAPHHORE_COUNT_HEX_MAX - 1, ret); /* 1, common data for test, no special meaning */
422 ret = osSemaphoreDelete(g_cmsisSemSemaph);
423 ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
424 return 0;
425 };
426
427 /**
428 * @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2300
429 * @tc.name : semaphore get count operation with semaphore_id = NULL
430 * @tc.desc : [C- SOFTWARE -0200]
431 */
432 LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount004, Function | MediumTest | Level1)
433 {
434 osStatus_t ret = osSemaphoreGetCount(NULL);
435 ICUNIT_ASSERT_EQUAL(ret, 0, ret);
436 return 0;
437 };
438
439 RUN_TEST_SUITE(CmsisSemFuncTestSuite);
440
CmsisSemFuncTest(void)441 void CmsisSemFuncTest(void)
442 {
443 RUN_ONE_TESTCASE(testOsSemaphoreNew001);
444 RUN_ONE_TESTCASE(testOsSemaphoreNew002);
445 RUN_ONE_TESTCASE(testOsSemaphoreNew003);
446 RUN_ONE_TESTCASE(testOsSemaphoreNew004);
447 RUN_ONE_TESTCASE(testOsSemaphoreNew005);
448 RUN_ONE_TESTCASE(testOsSemaphoreNew006);
449 RUN_ONE_TESTCASE(testOsSemaphoreNew007);
450 RUN_ONE_TESTCASE(testOsSemaphoreNew008);
451 RUN_ONE_TESTCASE(testOsSemaphoreDelete001);
452 RUN_ONE_TESTCASE(testOsSemaphoreDelete002);
453 RUN_ONE_TESTCASE(testOsSemaphoreDelete003);
454 RUN_ONE_TESTCASE(testOsSemaphoreAcquire001);
455 RUN_ONE_TESTCASE(testOsSemaphoreAcquire002);
456 RUN_ONE_TESTCASE(testOsSemaphoreAcquire003);
457 RUN_ONE_TESTCASE(testOsSemaphoreAcquire004);
458 RUN_ONE_TESTCASE(testOsSemaphoreRelease001);
459 RUN_ONE_TESTCASE(testOsSemaphoreRelease002);
460 RUN_ONE_TESTCASE(testOsSemaphoreRelease003);
461 RUN_ONE_TESTCASE(testOsSemaphoreRelease004);
462 RUN_ONE_TESTCASE(testOsSemaphoreGetCount001);
463 RUN_ONE_TESTCASE(testOsSemaphoreGetCount002);
464 RUN_ONE_TESTCASE(testOsSemaphoreGetCount003);
465 RUN_ONE_TESTCASE(testOsSemaphoreGetCount004);
466 }
467