1
2 /*
3 * Copyright (c) 2022 Huawei Device Co., Ltd.
4 *
5 * HDF is dual licensed: you can use it either under the terms of
6 * the GPL, or the BSD license, at your option.
7 * See the LICENSE file in the root of this repository for complete details.
8 */
9
10 #include <cstdint>
11 #include <cstdio>
12 #include <cstdlib>
13 #include <fcntl.h>
14 #include <gtest/gtest.h>
15 #include <string>
16 #include <unistd.h>
17 #include "hdf_uhdf_test.h"
18 #include "timer_test.h"
19 #include "hdf_io_service_if.h"
20
21 using namespace testing::ext;
22
23 class HdfLiteTimerTest : public testing::Test {
24 public:
25 static void SetUpTestCase();
26 static void TearDownTestCase();
27 void SetUp();
28 void TearDown();
29 };
30
SetUpTestCase()31 void HdfLiteTimerTest::SetUpTestCase()
32 {
33 HdfTestOpenService();
34 }
35
TearDownTestCase()36 void HdfLiteTimerTest::TearDownTestCase()
37 {
38 HdfTestCloseService();
39 }
40
SetUp()41 void HdfLiteTimerTest::SetUp()
42 {
43 }
44
TearDown()45 void HdfLiteTimerTest::TearDown()
46 {
47 }
48 /**
49 * @tc.name: TimerTestSet001
50 * @tc.desc: timer set test
51 * @tc.type: FUNC
52 * @tc.require: NA
53 */
54 HWTEST_F(HdfLiteTimerTest, TimerTestSet001, TestSize.Level1)
55 {
56 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_TEST_SET, -1};
57 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
58 EXPECT_EQ(0, TimerTestExecute(TIMER_TEST_SET));
59 }
60
61 /**
62 * @tc.name: TimerTestSetOnce001
63 * @tc.desc: timer set once test
64 * @tc.type: FUNC
65 * @tc.require: NA
66 */
67 HWTEST_F(HdfLiteTimerTest, TimerTestSetOnce001, TestSize.Level1)
68 {
69 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_TEST_SETONCE, -1};
70 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
71 EXPECT_EQ(0, TimerTestExecute(TIMER_TEST_SETONCE));
72 }
73
74 /**
75 * @tc.name: TimerTestGet001
76 * @tc.desc: timer get test
77 * @tc.type: FUNC
78 * @tc.require: NA
79 */
80 HWTEST_F(HdfLiteTimerTest, TimerTestGet001, TestSize.Level1)
81 {
82 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_TEST_GET, -1};
83 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
84 EXPECT_EQ(0, TimerTestExecute(TIMER_TEST_GET));
85 }
86
87 /**
88 * @tc.name: TimerTestStart001
89 * @tc.desc: timer start test
90 * @tc.type: FUNC
91 * @tc.require: NA
92 */
93 HWTEST_F(HdfLiteTimerTest, TimerTestStart001, TestSize.Level1)
94 {
95 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_TEST_START, -1};
96 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
97 EXPECT_EQ(0, TimerTestExecute(TIMER_TEST_START));
98 }
99
100 /**
101 * @tc.name: TimerTestStop001
102 * @tc.desc: timer stop test
103 * @tc.type: FUNC
104 * @tc.require: NA
105 */
106 HWTEST_F(HdfLiteTimerTest, TimerTestStop001, TestSize.Level1)
107 {
108 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_TEST_STOP, -1};
109 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
110 EXPECT_EQ(0, TimerTestExecute(TIMER_TEST_STOP));
111 }
112
113 /**
114 * @tc.name: TimerTestMultiThread001
115 * @tc.desc: timer multi thread test
116 * @tc.type: FUNC
117 * @tc.require: NA
118 */
119 HWTEST_F(HdfLiteTimerTest, TimerTestMultiThread001, TestSize.Level1)
120 {
121 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_MULTI_THREAD_TEST, -1};
122 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
123 EXPECT_EQ(0, TimerTestExecute(TIMER_MULTI_THREAD_TEST));
124 }
125
126 /**
127 * @tc.name: TimerTestReliability001
128 * @tc.desc: timer reliability test
129 * @tc.type: FUNC
130 * @tc.require: NA
131 */
132 HWTEST_F(HdfLiteTimerTest, TimerTestReliability001, TestSize.Level1)
133 {
134 struct HdfTestMsg msg = {TEST_PAL_TIMER_TYPE, TIMER_RELIABILITY_TEST, -1};
135 EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
136 EXPECT_EQ(0, TimerTestExecute(TIMER_RELIABILITY_TEST));
137 }
138
139 /**
140 * @tc.name: TimerTestIfPerformance001
141 * @tc.desc: timer user if performance test
142 * @tc.type: FUNC
143 * @tc.require: NA
144 */
145 HWTEST_F(HdfLiteTimerTest, TimerTestIfPerformance001, TestSize.Level1)
146 {
147 EXPECT_EQ(0, TimerTestExecute(TIMER_IF_PERFORMANCE_TEST));
148 }
149