1 /*
2 * Copyright (c) 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 <gtest/gtest.h>
10 #include "hdf_io_service.h"
11 #include "hdf_pm_driver_test.h"
12
13 using namespace testing::ext;
14
15 class HdfPmTest : public testing::Test {
16 public:
17 static void SetUpTestCase();
18 static void TearDownTestCase();
19 void SetUp();
20 void TearDown();
21 static struct HdfIoService *ioService;
22 };
23
24 struct HdfIoService *HdfPmTest::ioService = nullptr;
25
SetUpTestCase()26 void HdfPmTest::SetUpTestCase()
27 {
28 ioService = HdfIoServiceBind("pm_ut_service");
29 ASSERT_TRUE(ioService != nullptr);
30 ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_BEGEN, nullptr, nullptr);
31 }
32
TearDownTestCase()33 void HdfPmTest::TearDownTestCase()
34 {
35 ASSERT_TRUE(ioService != nullptr);
36 ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_END, nullptr, nullptr);
37 HdfIoServiceRecycle(ioService);
38 }
39
SetUp()40 void HdfPmTest::SetUp()
41 {
42 }
43
TearDown()44 void HdfPmTest::TearDown()
45 {
46 }
47
48 /**
49 * @tc.name: HdfPmTestOneDriverOnce
50 * @tc.desc: test one driver
51 * @tc.type: FUNC
52 * @tc.require: SR000GGTQF
53 */
54 HWTEST_F(HdfPmTest, HdfPmTestOneDriverOnce, TestSize.Level3)
55 {
56 ASSERT_TRUE(ioService != nullptr);
57
58 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_ONCE, nullptr, nullptr);
59 EXPECT_TRUE(ret == HDF_SUCCESS);
60 }
61
62 /**
63 * @tc.name: HdfPmTestOneDriverTwice
64 * @tc.desc: test one driver
65 * @tc.type: FUNC
66 * @tc.require: SR000GGTQF
67 */
68 HWTEST_F(HdfPmTest, HdfPmTestOneDriverTwice, TestSize.Level3)
69 {
70 ASSERT_TRUE(ioService != nullptr);
71
72 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_TWICE, nullptr, nullptr);
73 EXPECT_TRUE(ret == HDF_SUCCESS);
74 }
75
76 /**
77 * @tc.name: HdfPmTestOneDriverTen
78 * @tc.desc: test one driver
79 * @tc.type: FUNC
80 * @tc.require: SR000GGTQF
81 */
82 HWTEST_F(HdfPmTest, HdfPmTestOneDriverTen, TestSize.Level3)
83 {
84 ASSERT_TRUE(ioService != nullptr);
85
86 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_TEN, nullptr, nullptr);
87 EXPECT_TRUE(ret == HDF_SUCCESS);
88 }
89
90 /**
91 * @tc.name: HdfPmTestOneDriverHundred
92 * @tc.desc: test one driver
93 * @tc.type: FUNC
94 * @tc.require: SR000GGTQF
95 */
96 HWTEST_F(HdfPmTest, HdfPmTestOneDriverHundred, TestSize.Level3)
97 {
98 ASSERT_TRUE(ioService != nullptr);
99
100 int32_t ret = ioService->dispatcher->Dispatch(
101 &ioService->object, HDF_PM_TEST_ONE_DRIVER_HUNDRED, nullptr, nullptr);
102 EXPECT_TRUE(ret == HDF_SUCCESS);
103 }
104
105 /**
106 * @tc.name: HdfPmTestOneDriverThousand
107 * @tc.desc: test one driver
108 * @tc.type: FUNC
109 * @tc.require: SR000GGTQF
110 */
111 HWTEST_F(HdfPmTest, HdfPmTestOneDriverThousand, TestSize.Level3)
112 {
113 ASSERT_TRUE(ioService != nullptr);
114
115 int32_t ret = ioService->dispatcher->Dispatch(
116 &ioService->object, HDF_PM_TEST_ONE_DRIVER_THOUSAND, nullptr, nullptr);
117 EXPECT_TRUE(ret == HDF_SUCCESS);
118 }
119
120 /**
121 * @tc.name: HdfPmTestTwoDriverOnce
122 * @tc.desc: test two drivers
123 * @tc.type: FUNC
124 * @tc.require: SR000GGTQF
125 */
126 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverOnce, TestSize.Level3)
127 {
128 ASSERT_TRUE(ioService != nullptr);
129
130 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_ONCE, nullptr, nullptr);
131 EXPECT_TRUE(ret == HDF_SUCCESS);
132 }
133
134 /**
135 * @tc.name: HdfPmTestTwoDriverTwice
136 * @tc.desc: test two drivers
137 * @tc.type: FUNC
138 * @tc.require: SR000GGTQF
139 */
140 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverTwice, TestSize.Level3)
141 {
142 ASSERT_TRUE(ioService != nullptr);
143
144 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_TWICE, nullptr, nullptr);
145 EXPECT_TRUE(ret == HDF_SUCCESS);
146 }
147
148 /**
149 * @tc.name: HdfPmTestTwoDriverTen
150 * @tc.desc: test two drivers
151 * @tc.type: FUNC
152 * @tc.require: SR000GGTQF
153 */
154 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverTen, TestSize.Level3)
155 {
156 ASSERT_TRUE(ioService != nullptr);
157
158 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_TEN, nullptr, nullptr);
159 EXPECT_TRUE(ret == HDF_SUCCESS);
160 }
161
162 /**
163 * @tc.name: HdfPmTestTwoDriverHundred
164 * @tc.desc: test two drivers
165 * @tc.type: FUNC
166 * @tc.require: SR000GGTQF
167 */
168 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverHundred, TestSize.Level3)
169 {
170 ASSERT_TRUE(ioService != nullptr);
171
172 int32_t ret = ioService->dispatcher->Dispatch(
173 &ioService->object, HDF_PM_TEST_TWO_DRIVER_HUNDRED, nullptr, nullptr);
174 EXPECT_TRUE(ret == HDF_SUCCESS);
175 }
176
177 /**
178 * @tc.name: HdfPmTestTwoDriverThousand
179 * @tc.desc: test two drivers
180 * @tc.type: FUNC
181 * @tc.require: SR000GGTQF
182 */
183 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverThousand, TestSize.Level3)
184 {
185 ASSERT_TRUE(ioService != nullptr);
186
187 int32_t ret = ioService->dispatcher->Dispatch(
188 &ioService->object, HDF_PM_TEST_TWO_DRIVER_THOUSAND, nullptr, nullptr);
189 EXPECT_TRUE(ret == HDF_SUCCESS);
190 }
191
192 /**
193 * @tc.name: HdfPmTestThreeDriverOnce
194 * @tc.desc: test three drivers
195 * @tc.type: FUNC
196 * @tc.require: SR000GGTQF
197 */
198 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverOnce, TestSize.Level3)
199 {
200 ASSERT_TRUE(ioService != nullptr);
201
202 int32_t ret = ioService->dispatcher->Dispatch(
203 &ioService->object, HDF_PM_TEST_THREE_DRIVER_ONCE, nullptr, nullptr);
204 EXPECT_TRUE(ret == HDF_SUCCESS);
205 }
206
207 /**
208 * @tc.name: HdfPmTestThreeDriverTwice
209 * @tc.desc: test three drivers
210 * @tc.type: FUNC
211 * @tc.require: SR000GGTQF
212 */
213 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverTwice, TestSize.Level3)
214 {
215 ASSERT_TRUE(ioService != nullptr);
216
217 int32_t ret = ioService->dispatcher->Dispatch(
218 &ioService->object, HDF_PM_TEST_THREE_DRIVER_TWICE, nullptr, nullptr);
219 EXPECT_TRUE(ret == HDF_SUCCESS);
220 }
221
222 /**
223 * @tc.name: HdfPmTestThreeDriverTen
224 * @tc.desc: test three drivers
225 * @tc.type: FUNC
226 * @tc.require: SR000GGTQF
227 */
228 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverTen, TestSize.Level3)
229 {
230 ASSERT_TRUE(ioService != nullptr);
231
232 int32_t ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_TEN, nullptr, nullptr);
233 EXPECT_TRUE(ret == HDF_SUCCESS);
234 }
235
236 /**
237 * @tc.name: HdfPmTestThreeDriverHundred
238 * @tc.desc: test three drivers
239 * @tc.type: FUNC
240 * @tc.require: SR000GGTQF
241 */
242 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverHundred, TestSize.Level3)
243 {
244 ASSERT_TRUE(ioService != nullptr);
245
246 int32_t ret = ioService->dispatcher->Dispatch(
247 &ioService->object, HDF_PM_TEST_THREE_DRIVER_HUNDRED, nullptr, nullptr);
248 EXPECT_TRUE(ret == HDF_SUCCESS);
249 }
250
251 /**
252 * @tc.name: HdfPmTestThreeDriverThousand
253 * @tc.desc: test three drivers
254 * @tc.type: FUNC
255 * @tc.require: SR000GGTQF
256 */
257 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverThousand, TestSize.Level3)
258 {
259 ASSERT_TRUE(ioService != nullptr);
260
261 int32_t ret = ioService->dispatcher->Dispatch(
262 &ioService->object, HDF_PM_TEST_THREE_DRIVER_THOUSAND, nullptr, nullptr);
263 EXPECT_TRUE(ret == HDF_SUCCESS);
264 }
265
266 /**
267 * @tc.name: HdfPmTestThreeDriverSeqHundred
268 * @tc.desc: test three drivers
269 * @tc.type: FUNC
270 * @tc.require: SR000GGTQF
271 */
272 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverSeqHundred, TestSize.Level3)
273 {
274 ASSERT_TRUE(ioService != nullptr);
275
276 int32_t ret = ioService->dispatcher->Dispatch(
277 &ioService->object, HDF_PM_TEST_THREE_DRIVER_SEQ_HUNDRED, nullptr, nullptr);
278 EXPECT_TRUE(ret == HDF_SUCCESS);
279 }
280
281 /**
282 * @tc.name: HdfPmTestThreeDriverHundredWithSync
283 * @tc.desc: test three drivers
284 * @tc.type: FUNC
285 * @tc.require: SR000GGTQF
286 */
287 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverHundredWithSync, TestSize.Level3)
288 {
289 ASSERT_TRUE(ioService != nullptr);
290
291 int32_t ret = ioService->dispatcher->Dispatch(
292 &ioService->object, HDF_PM_TEST_THREE_DRIVER_HUNDRED_WITH_SYNC, nullptr, nullptr);
293 EXPECT_TRUE(ret == HDF_SUCCESS);
294 }
295