• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = NULL;
25 
SetUpTestCase()26 void HdfPmTest::SetUpTestCase()
27 {
28     ioService = HdfIoServiceBind("pm_test_service");
29     ASSERT_TRUE(ioService != NULL);
30     ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_BEGEN, NULL, NULL);
31 }
32 
TearDownTestCase()33 void HdfPmTest::TearDownTestCase()
34 {
35     ASSERT_TRUE(ioService != NULL);
36     ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_END, NULL, NULL);
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     int32_t ret = HDF_FAILURE;
57 
58     ASSERT_TRUE(ioService != NULL);
59 
60     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_ONCE, NULL, NULL);
61     EXPECT_TRUE(ret == HDF_SUCCESS);
62 }
63 
64 /**
65   * @tc.name: HdfPmTestOneDriverTwice
66   * @tc.desc: test one driver
67   * @tc.type: FUNC
68   * @tc.require: SR000GGTQF
69   */
70 HWTEST_F(HdfPmTest, HdfPmTestOneDriverTwice, TestSize.Level3)
71 {
72     int32_t ret = HDF_FAILURE;
73 
74     ASSERT_TRUE(ioService != NULL);
75 
76     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_TWICE, NULL, NULL);
77     EXPECT_TRUE(ret == HDF_SUCCESS);
78 }
79 
80 /**
81   * @tc.name: HdfPmTestOneDriverTen
82   * @tc.desc: test one driver
83   * @tc.type: FUNC
84   * @tc.require: SR000GGTQF
85   */
86 HWTEST_F(HdfPmTest, HdfPmTestOneDriverTen, TestSize.Level3)
87 {
88     int32_t ret = HDF_FAILURE;
89 
90     ASSERT_TRUE(ioService != NULL);
91 
92     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_TEN, NULL, NULL);
93     EXPECT_TRUE(ret == HDF_SUCCESS);
94 }
95 
96 /**
97   * @tc.name: HdfPmTestOneDriverHundred
98   * @tc.desc: test one driver
99   * @tc.type: FUNC
100   * @tc.require: SR000GGTQF
101   */
102 HWTEST_F(HdfPmTest, HdfPmTestOneDriverHundred, TestSize.Level3)
103 {
104     int32_t ret = HDF_FAILURE;
105 
106     ASSERT_TRUE(ioService != NULL);
107 
108     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_HUNDRED, NULL, NULL);
109     EXPECT_TRUE(ret == HDF_SUCCESS);
110 }
111 
112 /**
113   * @tc.name: HdfPmTestOneDriverThousand
114   * @tc.desc: test one driver
115   * @tc.type: FUNC
116   * @tc.require: SR000GGTQF
117   */
118 HWTEST_F(HdfPmTest, HdfPmTestOneDriverThousand, TestSize.Level3)
119 {
120     int32_t ret = HDF_FAILURE;
121 
122     ASSERT_TRUE(ioService != NULL);
123 
124     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_ONE_DRIVER_THOUSAND, NULL, NULL);
125     EXPECT_TRUE(ret == HDF_SUCCESS);
126 }
127 
128 /**
129   * @tc.name: HdfPmTestTwoDriverOnce
130   * @tc.desc: test two drivers
131   * @tc.type: FUNC
132   * @tc.require: SR000GGTQF
133   */
134 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverOnce, TestSize.Level3)
135 {
136     int32_t ret = HDF_FAILURE;
137 
138     ASSERT_TRUE(ioService != NULL);
139 
140     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_ONCE, NULL, NULL);
141     EXPECT_TRUE(ret == HDF_SUCCESS);
142 }
143 
144 /**
145   * @tc.name: HdfPmTestTwoDriverTwice
146   * @tc.desc: test two drivers
147   * @tc.type: FUNC
148   * @tc.require: SR000GGTQF
149   */
150 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverTwice, TestSize.Level3)
151 {
152     int32_t ret = HDF_FAILURE;
153 
154     ASSERT_TRUE(ioService != NULL);
155 
156     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_TWICE, NULL, NULL);
157     EXPECT_TRUE(ret == HDF_SUCCESS);
158 }
159 
160 /**
161   * @tc.name: HdfPmTestTwoDriverTen
162   * @tc.desc: test two drivers
163   * @tc.type: FUNC
164   * @tc.require: SR000GGTQF
165   */
166 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverTen, TestSize.Level3)
167 {
168     int32_t ret = HDF_FAILURE;
169 
170     ASSERT_TRUE(ioService != NULL);
171 
172     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_TEN, NULL, NULL);
173     EXPECT_TRUE(ret == HDF_SUCCESS);
174 }
175 
176 /**
177   * @tc.name: HdfPmTestTwoDriverHundred
178   * @tc.desc: test two drivers
179   * @tc.type: FUNC
180   * @tc.require: SR000GGTQF
181   */
182 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverHundred, TestSize.Level3)
183 {
184     int32_t ret = HDF_FAILURE;
185 
186     ASSERT_TRUE(ioService != NULL);
187 
188     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_HUNDRED, NULL, NULL);
189     EXPECT_TRUE(ret == HDF_SUCCESS);
190 }
191 
192 /**
193   * @tc.name: HdfPmTestTwoDriverThousand
194   * @tc.desc: test two drivers
195   * @tc.type: FUNC
196   * @tc.require: SR000GGTQF
197   */
198 HWTEST_F(HdfPmTest, HdfPmTestTwoDriverThousand, TestSize.Level3)
199 {
200     int32_t ret = HDF_FAILURE;
201 
202     ASSERT_TRUE(ioService != NULL);
203 
204     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_TWO_DRIVER_THOUSAND, NULL, NULL);
205     EXPECT_TRUE(ret == HDF_SUCCESS);
206 }
207 
208 /**
209   * @tc.name: HdfPmTestThreeDriverOnce
210   * @tc.desc: test three drivers
211   * @tc.type: FUNC
212   * @tc.require: SR000GGTQF
213   */
214 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverOnce, TestSize.Level3)
215 {
216     int32_t ret = HDF_FAILURE;
217 
218     ASSERT_TRUE(ioService != NULL);
219 
220     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_ONCE, NULL, NULL);
221     EXPECT_TRUE(ret == HDF_SUCCESS);
222 }
223 
224 /**
225   * @tc.name: HdfPmTestThreeDriverTwice
226   * @tc.desc: test three drivers
227   * @tc.type: FUNC
228   * @tc.require: SR000GGTQF
229   */
230 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverTwice, TestSize.Level3)
231 {
232     int32_t ret = HDF_FAILURE;
233 
234     ASSERT_TRUE(ioService != NULL);
235 
236     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_TWICE, NULL, NULL);
237     EXPECT_TRUE(ret == HDF_SUCCESS);
238 }
239 
240 /**
241   * @tc.name: HdfPmTestThreeDriverTen
242   * @tc.desc: test three drivers
243   * @tc.type: FUNC
244   * @tc.require: SR000GGTQF
245   */
246 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverTen, TestSize.Level3)
247 {
248     int32_t ret = HDF_FAILURE;
249 
250     ASSERT_TRUE(ioService != NULL);
251 
252     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_TEN, NULL, NULL);
253     EXPECT_TRUE(ret == HDF_SUCCESS);
254 }
255 
256 /**
257   * @tc.name: HdfPmTestThreeDriverHundred
258   * @tc.desc: test three drivers
259   * @tc.type: FUNC
260   * @tc.require: SR000GGTQF
261   */
262 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverHundred, TestSize.Level3)
263 {
264     int32_t ret = HDF_FAILURE;
265 
266     ASSERT_TRUE(ioService != NULL);
267 
268     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_HUNDRED, NULL, NULL);
269     EXPECT_TRUE(ret == HDF_SUCCESS);
270 }
271 
272 /**
273   * @tc.name: HdfPmTestThreeDriverThousand
274   * @tc.desc: test three drivers
275   * @tc.type: FUNC
276   * @tc.require: SR000GGTQF
277   */
278 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverThousand, TestSize.Level3)
279 {
280     int32_t ret = HDF_FAILURE;
281 
282     ASSERT_TRUE(ioService != NULL);
283 
284     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_THOUSAND, NULL, NULL);
285     EXPECT_TRUE(ret == HDF_SUCCESS);
286 }
287 
288 /**
289   * @tc.name: HdfPmTestThreeDriverSeqHundred
290   * @tc.desc: test three drivers
291   * @tc.type: FUNC
292   * @tc.require: SR000GGTQF
293   */
294 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverSeqHundred, TestSize.Level3)
295 {
296     int32_t ret = HDF_FAILURE;
297 
298     ASSERT_TRUE(ioService != NULL);
299 
300     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_SEQ_HUNDRED, NULL, NULL);
301     EXPECT_TRUE(ret == HDF_SUCCESS);
302 }
303 
304 /**
305   * @tc.name: HdfPmTestThreeDriverHundredWithSync
306   * @tc.desc: test three drivers
307   * @tc.type: FUNC
308   * @tc.require: SR000GGTQF
309   */
310 HWTEST_F(HdfPmTest, HdfPmTestThreeDriverHundredWithSync, TestSize.Level3)
311 {
312     int32_t ret = HDF_FAILURE;
313 
314     ASSERT_TRUE(ioService != NULL);
315 
316     ret = ioService->dispatcher->Dispatch(&ioService->object, HDF_PM_TEST_THREE_DRIVER_HUNDRED_WITH_SYNC, NULL, NULL);
317     EXPECT_TRUE(ret == HDF_SUCCESS);
318 }
319