• 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 "hdf_io_service_if.h"
18 #include "rtc_test.h"
19 
20 using namespace testing::ext;
21 
22 class HdfRtcTest : public testing::Test {
23 public:
24     static void SetUpTestCase();
25     static void TearDownTestCase();
26     void SetUp();
27     void TearDown();
28 };
29 
SetUpTestCase()30 void HdfRtcTest::SetUpTestCase()
31 {
32     HdfTestOpenService();
33 }
34 
TearDownTestCase()35 void HdfRtcTest::TearDownTestCase()
36 {
37     HdfTestCloseService();
38 }
39 
SetUp()40 void HdfRtcTest::SetUp()
41 {
42 }
43 
TearDown()44 void HdfRtcTest::TearDown()
45 {
46 }
47 
48 /**
49   * @tc.name: testRtcReadWriteTime001
50   * @tc.desc: rtc function test
51   * @tc.type: FUNC
52   * @tc.require: AR000F868I
53   */
54 HWTEST_F(HdfRtcTest, testRtcReadWriteTime001, TestSize.Level1)
55 {
56     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_WR_TIME, -1 };
57     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
58 
59     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_WR_TIME));
60 }
61 
62 /**
63   * @tc.name: testRtcReadWriteMaxTime001
64   * @tc.desc: rtc function test
65   * @tc.type: FUNC
66   * @tc.require: AR000F868I
67   */
68 HWTEST_F(HdfRtcTest, testRtcReadWriteMaxTime001, TestSize.Level1)
69 {
70     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_WR_MAX_TIME, -1 };
71     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
72 
73     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_WR_MAX_TIME));
74 }
75 
76 /**
77   * @tc.name: testRtcReadWriteMinTime001
78   * @tc.desc: rtc function test
79   * @tc.type: FUNC
80   * @tc.require: AR000F868I
81   */
82 HWTEST_F(HdfRtcTest, testRtcReadWriteMinTime001, TestSize.Level1)
83 {
84     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_WR_MIN_TIME, -1 };
85     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
86 
87     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_WR_MIN_TIME));
88 }
89 
90 /**
91   * @tc.name: testRtcReadWriteAlarmTime001
92   * @tc.desc: rtc function test
93   * @tc.type: FUNC
94   * @tc.require: AR000F868I
95   */
96 HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmTime001, TestSize.Level1)
97 {
98     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_WR_ALARM_TIME, -1 };
99     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
100 
101     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_WR_ALARM_TIME));
102 }
103 
104 /**
105   * @tc.name: testRtcReadWriteAlarmMaxTime001
106   * @tc.desc: rtc function test
107   * @tc.type: FUNC
108   * @tc.require: AR000F868I
109   */
110 HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMaxTime001, TestSize.Level1)
111 {
112     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_WR_ALARM_MAX_TIME, -1 };
113     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
114 
115     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_WR_ALARM_MAX_TIME));
116 }
117 /**
118   * @tc.name: testRtcReadWriteAlarmMinTime001
119   * @tc.desc: rtc function test
120   * @tc.type: FUNC
121   * @tc.require: AR000F868I
122   */
123 HWTEST_F(HdfRtcTest, testRtcReadWriteAlarmMinTime001, TestSize.Level1)
124 {
125     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_WR_ALARM_MIN_TIME, -1 };
126     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
127 
128     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_WR_ALARM_MIN_TIME));
129 }
130 
131 #ifndef HDF_LITEOS_TEST
132 /**
133   * @tc.name: testRtcAlarmEnable001
134   * @tc.desc: rtc function test
135   * @tc.type: FUNC
136   * @tc.require: AR000F868I
137   */
138 HWTEST_F(HdfRtcTest, testRtcAlarmEnable001, TestSize.Level1)
139 {
140     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_ALARM_ENABLE, -1 };
141     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
142 
143     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_ALARM_ENABLE));
144 }
145 #endif
146 
147 #if defined(HDF_LITEOS_TEST)
148 
149 /**
150   * @tc.name: testRtcAlarmIrq001
151   * @tc.desc: rtc function test
152   * @tc.type: FUNC
153   * @tc.require: AR000EKRKU
154   */
155 HWTEST_F(HdfRtcTest, testRtcAlarmIrq001, TestSize.Level1)
156 {
157     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_ALARM_IRQ, -1 };
158     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
159 
160     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_ALARM_IRQ));
161 }
162 
163 /**
164   * @tc.name: testRtcRegCallback001
165   * @tc.desc: rtc function test
166   * @tc.type: FUNC
167   * @tc.require: AR000EKRKU
168   */
169 HWTEST_F(HdfRtcTest, testRtcRegCallback001, TestSize.Level1)
170 {
171     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_REGISTER_CALLBACK, -1 };
172     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
173 
174     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_REGISTER_CALLBACK));
175 }
176 
177 /**
178   * @tc.name: testRtcRegCallbackNull001
179   * @tc.desc: rtc function test
180   * @tc.type: FUNC
181   * @tc.require: AR000EKRKU
182   */
183 HWTEST_F(HdfRtcTest, testRtcRegCallbackNull001, TestSize.Level1)
184 {
185     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_REGISTER_CALLBACK_NULL, -1 };
186     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
187 
188     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_REGISTER_CALLBACK_NULL));
189 }
190 
191 /**
192   * @tc.name: testRtcFreq001
193   * @tc.desc: rtc function test
194   * @tc.type: FUNC
195   * @tc.require: AR000EKRKU
196   */
197 HWTEST_F(HdfRtcTest, testRtcFreq001, TestSize.Level1)
198 {
199     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_WR_FREQ, -1 };
200     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
201 
202     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_WR_FREQ));
203 }
204 
205 /**
206   * @tc.name: testRtcMaxFreq001
207   * @tc.desc: rtc function test
208   * @tc.type: FUNC
209   * @tc.require: AR000EKRKU
210   */
211 HWTEST_F(HdfRtcTest, testRtcMaxFreq001, TestSize.Level1)
212 {
213     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_WR_MAX_FREQ, -1 };
214     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
215 
216     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_WR_MAX_FREQ));
217 }
218 
219 /**
220   * @tc.name: testRtcMinFreq001
221   * @tc.desc: rtc function test
222   * @tc.type: FUNC
223   * @tc.require: AR000EKRKU
224   */
225 HWTEST_F(HdfRtcTest, testRtcMinFreq001, TestSize.Level1)
226 {
227     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_WR_MIN_FREQ, -1 };
228     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
229 
230     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_WR_MIN_FREQ));
231 }
232 
233 /**
234   * @tc.name: testRtcUserReg001
235   * @tc.desc: rtc function test
236   * @tc.type: FUNC
237   * @tc.require: AR000EKRKU
238   */
239 HWTEST_F(HdfRtcTest, testRtcUserReg001, TestSize.Level1)
240 {
241     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_WR_USER_REG, -1 };
242     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
243 
244     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_WR_USER_REG));
245 }
246 
247 /**
248   * @tc.name: testRtcUserRegMaxIndex001
249   * @tc.desc: rtc function test
250   * @tc.type: FUNC
251   * @tc.require: AR000EKRKU
252   */
253 HWTEST_F(HdfRtcTest, testRtcUserRegMaxIndex001, TestSize.Level1)
254 {
255     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_WR_USER_REG_MAX_INDEX, -1 };
256     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
257 
258     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_WR_USER_REG_MAX_INDEX));
259 }
260 #endif
261 /**
262   * @tc.name: testRtcReliability001
263   * @tc.desc: rtc function test
264   * @tc.type: FUNC
265   * @tc.require: AR000EKRKU
266   */
267 HWTEST_F(HdfRtcTest, testRtcReliability001, TestSize.Level1)
268 {
269     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_WR_RELIABILITY, -1 };
270     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
271 
272     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_WR_RELIABILITY));
273 }
274 
275 #if defined(HDF_LITEOS_TEST)
276 /**
277   * @tc.name: testRtcModule001
278   * @tc.desc: rtc function test
279   * @tc.type: FUNC
280   * @tc.require: AR000EKRKU
281   */
282 HWTEST_F(HdfRtcTest, testRtcModule001, TestSize.Level1)
283 {
284     struct HdfTestMsg msg = { TEST_PAL_RTC_TYPE, RTC_TEST_CMD_RTC_FUNCTION_TEST, -1 };
285     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
286 
287     EXPECT_EQ(0, RtcTestExecute(RTC_TEST_CMD_RTC_FUNCTION_TEST));
288 }
289 #endif