1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include <cstdint>
10 #include <cstdio>
11 #include <cstdlib>
12 #include <fcntl.h>
13 #include <string>
14 #include <unistd.h>
15 #include <gtest/gtest.h>
16 #include "hdf_uhdf_test.h"
17 #include "osal_get_case_test.h"
18 #include "osal_test_case_def.h"
19
HdfOsalUserEntry(enum HdfOsalTestCaseCmd cmd)20 int32_t HdfOsalUserEntry(enum HdfOsalTestCaseCmd cmd)
21 {
22 int32_t result = 0;
23 if (cmd < OSAL_TEST_MAX) {
24 if (cmd == OSAL_TEST_START) {
25 result = OsaTestBegin();
26 } else if (cmd == OSAL_TEST_END) {
27 result = OsaTestEnd();
28 } else if (cmd == OSAL_TEST_ALL) {
29 result = OsaTestALLResult();
30 } else {
31 result = OsalGetTestResult(cmd);
32 }
33 } else {
34 return -1;
35 }
36
37 printf("HdfTestUser:osal test result[%d-%d]", result, cmd);
38
39 return result;
40 }
41
42 using namespace testing::ext;
43
44 #define OSAL_TEST_FUNC_DEFINE(subCmd) do { \
45 printf("OSAL test enter cmd:%d\n\r", subCmd); \
46 EXPECT_EQ(0, HdfOsalUserEntry(subCmd)); \
47 } while (0)
48
49 class OsalTest : public testing::Test {
50 public:
51 static void SetUpTestCase();
52 static void TearDownTestCase();
53 void SetUp();
54 void TearDown();
55 private:
56 static const int OSAL_TEST_TIME = 30;
57 static const int OSAL_WAIT_END_TIME = 5;
58 };
59
SetUpTestCase()60 void OsalTest::SetUpTestCase()
61 {
62 OSAL_TEST_FUNC_DEFINE(OSAL_TEST_START);
63 sleep(OSAL_TEST_TIME);
64 OSAL_TEST_FUNC_DEFINE(OSAL_TEST_END);
65 sleep(OSAL_WAIT_END_TIME);
66 }
67
TearDownTestCase()68 void OsalTest::TearDownTestCase()
69 {
70 }
71
SetUp()72 void OsalTest::SetUp()
73 {
74 }
75
TearDown()76 void OsalTest::TearDown()
77 {
78 }
79
80 /**
81 * @tc.name: OsalGetMutex001
82 * @tc.desc: mutex function test
83 * @tc.type: FUNC
84 * @tc.require: AR000F868U
85 */
86 HWTEST_F(OsalTest, OsalGetMutex001, TestSize.Level3)
87 {
88 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_CREATE);
89 }
90
91 /**
92 * @tc.name: OsalGetMutex002
93 * @tc.desc: mutex function test
94 * @tc.type: FUNC
95 * @tc.require: AR000F868U
96 */
97 HWTEST_F(OsalTest, OsalGetMutex002, TestSize.Level3)
98 {
99 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_LOCK_TIMEOUT);
100 }
101
102 /**
103 * @tc.name: OsalGetMutex003
104 * @tc.desc: mutex function test
105 * @tc.type: FUNC
106 * @tc.require: AR000F868U
107 */
108 HWTEST_F(OsalTest, OsalGetMutex003, TestSize.Level3)
109 {
110 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_UNLOCK);
111 }
112
113 /**
114 * @tc.name: OsalGetMutex004
115 * @tc.desc: mutex function test
116 * @tc.type: FUNC
117 * @tc.require: AR000F868U
118 */
119 HWTEST_F(OsalTest, OsalGetMutex004, TestSize.Level3)
120 {
121 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_LOCK_FOREVER);
122 }
123
124 /**
125 * @tc.name: OsalGetMutex005
126 * @tc.desc: mutex function test
127 * @tc.type: FUNC
128 * @tc.require: AR000F868U
129 */
130 HWTEST_F(OsalTest, OsalGetMutex005, TestSize.Level3)
131 {
132 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_DESTROY);
133 }
134
135 /**
136 * @tc.name: OsalGetMutex006
137 * @tc.desc: mutex function test
138 * @tc.type: FUNC
139 * @tc.require: AR000F868U
140 */
141 HWTEST_F(OsalTest, OsalGetMutex006, TestSize.Level3)
142 {
143 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_VISIT_DESTROY);
144 }
145
146 /**
147 * @tc.name: OsalGetMutex007
148 * @tc.desc: mutex function test
149 * @tc.type: FUNC
150 * @tc.require: AR000F868U
151 */
152 HWTEST_F(OsalTest, OsalGetMutex007, TestSize.Level3)
153 {
154 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_STRESS_TEST);
155 }
156
157 /**
158 * @tc.name: OsalGetMutex008
159 * @tc.desc: mutex function test
160 * @tc.type: FUNC
161 * @tc.require: AR000F868U
162 */
163 HWTEST_F(OsalTest, OsalGetMutex008, TestSize.Level3)
164 {
165 OSAL_TEST_FUNC_DEFINE(OSAL_MUTEX_OTHER);
166 }
167
168 /**
169 * @tc.name: OsalGetSpin001
170 * @tc.desc: Spin function test
171 * @tc.type: FUNC
172 * @tc.require: AR000F8690
173 */
174 HWTEST_F(OsalTest, OsalGetSpin001, TestSize.Level3)
175 {
176 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_CREATE);
177 }
178
179 /**
180 * @tc.name: OsalGetSpin002
181 * @tc.desc: Spin function test
182 * @tc.type: FUNC
183 * @tc.require: AR000F8690
184 */
185 HWTEST_F(OsalTest, OsalGetSpin002, TestSize.Level3)
186 {
187 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_LOCK);
188 }
189
190 /**
191 * @tc.name: OsalGetSpin003
192 * @tc.desc: Spin function test
193 * @tc.type: FUNC
194 * @tc.require: AR000F8690
195 */
196 HWTEST_F(OsalTest, OsalGetSpin003, TestSize.Level3)
197 {
198 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_UNLOCK);
199 }
200
201 /**
202 * @tc.name: OsalGetSpin004
203 * @tc.desc: Spin function test
204 * @tc.type: FUNC
205 * @tc.require: AR000F8690
206 */
207 HWTEST_F(OsalTest, OsalGetSpin004, TestSize.Level3)
208 {
209 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_LOCK_IRQ);
210 }
211
212 /**
213 * @tc.name: OsalGetSpin005
214 * @tc.desc: Spin function test
215 * @tc.type: FUNC
216 * @tc.require: AR000F8690
217 */
218 HWTEST_F(OsalTest, OsalGetSpin005, TestSize.Level3)
219 {
220 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_UNLOCK_IRQ);
221 }
222
223 /**
224 * @tc.name: OsalGetSpin006
225 * @tc.desc: Spin function test
226 * @tc.type: FUNC
227 * @tc.require: AR000F8690
228 */
229 HWTEST_F(OsalTest, OsalGetSpin006, TestSize.Level3)
230 {
231 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_LOCK_IRQ_SAVE);
232 }
233
234 /**
235 * @tc.name: OsalGetSpin007
236 * @tc.desc: Spin function test
237 * @tc.type: FUNC
238 * @tc.require: AR000F8690
239 */
240 HWTEST_F(OsalTest, OsalGetSpin007, TestSize.Level3)
241 {
242 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_UNLOCK_IRQ_RESTORE);
243 }
244
245 /**
246 * @tc.name: OsalGetSpin008
247 * @tc.desc: Spin function test
248 * @tc.type: FUNC
249 * @tc.require: AR000F8690
250 */
251 HWTEST_F(OsalTest, OsalGetSpin008, TestSize.Level3)
252 {
253 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_DESTROY);
254 }
255
256 /**
257 * @tc.name: OsalGetSpin009
258 * @tc.desc: Spin function test
259 * @tc.type: FUNC
260 * @tc.require: AR000F8690
261 */
262 HWTEST_F(OsalTest, OsalGetSpin009, TestSize.Level3)
263 {
264 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_LOCK_AFTER_DESTROY);
265 }
266
267 /**
268 * @tc.name: OsalGetSpin010
269 * @tc.desc: LOG function test
270 * @tc.type: FUNC
271 * @tc.require: AR000F8695
272 */
273 HWTEST_F(OsalTest, OsalGetSpin010, TestSize.Level3)
274 {
275 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_STRESS_TEST);
276 }
277
278 /**
279 * @tc.name: OsalGetSpin011
280 * @tc.desc: LOG function test
281 * @tc.type: FUNC
282 * @tc.require: AR000F8695
283 */
284 HWTEST_F(OsalTest, OsalGetSpin011, TestSize.Level3)
285 {
286 OSAL_TEST_FUNC_DEFINE(OSAL_SPIN_OTHER);
287 }
288
289 /**
290 * @tc.name: OsalGetTime001
291 * @tc.desc: time function test
292 * @tc.type: FUNC
293 * @tc.require: AR000F8696
294 */
295 HWTEST_F(OsalTest, OsalGetTime001, TestSize.Level3)
296 {
297 OSAL_TEST_FUNC_DEFINE(OSAL_TIME_SLEEP);
298 }
299 /**
300 * @tc.name: OsalGetTime002
301 * @tc.desc: time function test
302 * @tc.type: FUNC
303 * @tc.require: AR000F8696
304 */
305 HWTEST_F(OsalTest, OsalGetTime002, TestSize.Level3)
306 {
307 OSAL_TEST_FUNC_DEFINE(OSAL_TIME_MSLEEP);
308 }
309 /**
310 * @tc.name: OsalGetTime003
311 * @tc.desc: time function test
312 * @tc.type: FUNC
313 * @tc.require: AR000F8696
314 */
315 HWTEST_F(OsalTest, OsalGetTime003, TestSize.Level3)
316 {
317 OSAL_TEST_FUNC_DEFINE(OSAL_TIME_USLEEP);
318 }
319 /**
320 * @tc.name: OsalGetTime004
321 * @tc.desc: time function test
322 * @tc.type: FUNC
323 * @tc.require: AR000F8696
324 */
325 HWTEST_F(OsalTest, OsalGetTime004, TestSize.Level3)
326 {
327 OSAL_TEST_FUNC_DEFINE(OSAL_TIME_GETTIME);
328 }
329 /**
330 * @tc.name: OsalGetTime005
331 * @tc.desc: time function test
332 * @tc.type: FUNC
333 * @tc.require: AR000F8696
334 */
335 HWTEST_F(OsalTest, OsalGetTime005, TestSize.Level3)
336 {
337 OSAL_TEST_FUNC_DEFINE(OSAL_TIME_DIFFTIME);
338 }
339
340 /**
341 * @tc.name: OsalGetThread001
342 * @tc.desc: thread function test
343 * @tc.type: FUNC
344 * @tc.require: AR000F868S
345 */
346 HWTEST_F(OsalTest, OsalGetThread001, TestSize.Level3)
347 {
348 OSAL_TEST_FUNC_DEFINE(OSAL_THREAD_CREATE);
349 }
350 /**
351 * @tc.name: OsalGetThread002
352 * @tc.desc: thread function test
353 * @tc.type: FUNC
354 * @tc.require: AR000F868S
355 */
356 HWTEST_F(OsalTest, OsalGetThread002, TestSize.Level3)
357 {
358 OSAL_TEST_FUNC_DEFINE(OSAL_THREAD_PARA_CHECK);
359 }
360 /**
361 * @tc.name: OsalGetThread003
362 * @tc.desc: thread function test
363 * @tc.type: FUNC
364 * @tc.require: AR000F868S
365 */
366 HWTEST_F(OsalTest, OsalGetThread003, TestSize.Level3)
367 {
368 OSAL_TEST_FUNC_DEFINE(OSAL_THREAD_RUN_CHECK);
369 }
370
371 /**
372 * @tc.name: OsalGetMemory001
373 * @tc.desc: memory function test
374 * @tc.type: FUNC
375 * @tc.require: AR000F868R
376 */
377 HWTEST_F(OsalTest, OsalGetMemory001, TestSize.Level3)
378 {
379 OSAL_TEST_FUNC_DEFINE(OSAL_MALLOC_BIG);
380 }
381 /**
382 * @tc.name: OsalGetMemory002
383 * @tc.desc: memory function test
384 * @tc.type: FUNC
385 * @tc.require: AR000F868R
386 */
387 HWTEST_F(OsalTest, OsalGetMemory002, TestSize.Level3)
388 {
389 OSAL_TEST_FUNC_DEFINE(OSAL_MALLOC_SMALL);
390 }
391 /**
392 * @tc.name: OsalGetMemory003
393 * @tc.desc: memory function test
394 * @tc.type: FUNC
395 * @tc.require: AR000F868R
396 */
397 HWTEST_F(OsalTest, OsalGetMemory003, TestSize.Level3)
398 {
399 OSAL_TEST_FUNC_DEFINE(OSAL_MALLOC_BIG_STRESS);
400 }
401 /**
402 * @tc.name: OsalGetMemory004
403 * @tc.desc: memory function test
404 * @tc.type: FUNC
405 * @tc.require: AR000F868R
406 */
407 HWTEST_F(OsalTest, OsalGetMemory004, TestSize.Level3)
408 {
409 OSAL_TEST_FUNC_DEFINE(OSAL_MALLOC_SMALL_STRESS);
410 }
411
412 /**
413 * @tc.name: OsalGetList001
414 * @tc.desc: list function test
415 * @tc.type: FUNC
416 * @tc.require: SR000F868P
417 */
418 HWTEST_F(OsalTest, OsalGetList001, TestSize.Level3)
419 {
420 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_INIT);
421 }
422 /**
423 * @tc.name: OsalGetList002
424 * @tc.desc: list function test
425 * @tc.type: FUNC
426 * @tc.require: SR000F868P
427 */
428 HWTEST_F(OsalTest, OsalGetList002, TestSize.Level3)
429 {
430 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_EMPTY);
431 }
432 /**
433 * @tc.name: OsalGetList003
434 * @tc.desc: list function test
435 * @tc.type: FUNC
436 * @tc.require: SR000F868P
437 */
438 HWTEST_F(OsalTest, OsalGetList003, TestSize.Level3)
439 {
440 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_COUNT_CHECK);
441 }
442 /**
443 * @tc.name: OsalGetList004
444 * @tc.desc: list function test
445 * @tc.type: FUNC
446 * @tc.require: SR000F868P
447 */
448 HWTEST_F(OsalTest, OsalGetList004, TestSize.Level3)
449 {
450 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_TAIL);
451 }
452 /**
453 * @tc.name: OsalGetList005
454 * @tc.desc: list function test
455 * @tc.type: FUNC
456 * @tc.require: SR000F868P
457 */
458 HWTEST_F(OsalTest, OsalGetList005, TestSize.Level3)
459 {
460 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_HEAD);
461 }
462 /**
463 * @tc.name: OsalGetList006
464 * @tc.desc: list function test
465 * @tc.type: FUNC
466 * @tc.require: SR000F868P
467 */
468 HWTEST_F(OsalTest, OsalGetList006, TestSize.Level3)
469 {
470 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_REMOVE);
471 }
472 /**
473 * @tc.name: OsalGetList007
474 * @tc.desc: list function test
475 * @tc.type: FUNC
476 * @tc.require: SR000F868P
477 */
478 HWTEST_F(OsalTest, OsalGetList007, TestSize.Level3)
479 {
480 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_TRAVERSAL);
481 }
482 /**
483 * @tc.name: OsalGetList008
484 * @tc.desc: list function test
485 * @tc.type: FUNC
486 * @tc.require: SR000F868P
487 */
488 HWTEST_F(OsalTest, OsalGetList008, TestSize.Level3)
489 {
490 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_TRAVERSAL_REMOVE);
491 }
492 /**
493 * @tc.name: OsalGetList009
494 * @tc.desc: list function test
495 * @tc.type: FUNC
496 * @tc.require: SR000F868P
497 */
498 HWTEST_F(OsalTest, OsalGetList009, TestSize.Level3)
499 {
500 OSAL_TEST_FUNC_DEFINE(OSAL_LIST_STRESS);
501 }
502
503 /**
504 * @tc.name: OsalGetSem001
505 * @tc.desc: sem function test
506 * @tc.type: FUNC
507 * @tc.require: AR000F868V
508 */
509 HWTEST_F(OsalTest, OsalGetSem001, TestSize.Level3)
510 {
511 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_CREATE);
512 }
513 /**
514 * @tc.name: OsalGetSem002
515 * @tc.desc: sem function test
516 * @tc.type: FUNC
517 * @tc.require: AR000F868V
518 */
519 HWTEST_F(OsalTest, OsalGetSem002, TestSize.Level3)
520 {
521 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_POST);
522 }
523 /**
524 * @tc.name: OsalGetSem003
525 * @tc.desc: sem function test
526 * @tc.type: FUNC
527 * @tc.require: AR000F868V
528 */
529 HWTEST_F(OsalTest, OsalGetSem003, TestSize.Level3)
530 {
531 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_POST_RESULT);
532 }
533 /**
534 * @tc.name: OsalGetSem004
535 * @tc.desc: sem function test
536 * @tc.type: FUNC
537 * @tc.require: AR000F868V
538 */
539 HWTEST_F(OsalTest, OsalGetSem004, TestSize.Level3)
540 {
541 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_WAIT_TIMEOUT);
542 }
543 /**
544 * @tc.name: OsalGetSem005
545 * @tc.desc: sem function test
546 * @tc.type: FUNC
547 * @tc.require: AR000F868V
548 */
549 HWTEST_F(OsalTest, OsalGetSem005, TestSize.Level3)
550 {
551 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_WAIT_FOREVER);
552 }
553 /**
554 * @tc.name: OsalGetSem006
555 * @tc.desc: sem function test
556 * @tc.type: FUNC
557 * @tc.require: AR000F868V
558 */
559 HWTEST_F(OsalTest, OsalGetSem006, TestSize.Level3)
560 {
561 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_DESTROY);
562 }
563 /**
564 * @tc.name: OsalGetSem007
565 * @tc.desc: sem function test
566 * @tc.type: FUNC
567 * @tc.require: AR000F868V
568 */
569 HWTEST_F(OsalTest, OsalGetSem007, TestSize.Level3)
570 {
571 OSAL_TEST_FUNC_DEFINE(OSAL_SEM_VISIT_AFTER_DESTROY);
572 }
573
574 /**
575 * @tc.name: OsalGetAll001
576 * @tc.desc: all function test
577 * @tc.type: FUNC
578 * @tc.require: SR000F868P
579 */
580 HWTEST_F(OsalTest, OsalGetAll001, TestSize.Level3)
581 {
582 OSAL_TEST_FUNC_DEFINE(OSAL_TEST_ALL);
583 }
584