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