Lines Matching +full:self +full:- +full:test
1 // SPDX-License-Identifier: GPL-2.0
3 * Real Time Clock Driver Test Program
33 self->fd = open(rtc_file, O_RDONLY); in FIXTURE_SETUP()
37 close(self->fd); in FIXTURE_TEARDOWN()
44 if (self->fd == -1 && errno == ENOENT) in TEST_F()
45 SKIP(return, "Skipping test since %s does not exist", rtc_file); in TEST_F()
46 ASSERT_NE(-1, self->fd); in TEST_F()
49 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); in TEST_F()
50 ASSERT_NE(-1, rc); in TEST_F()
60 .tm_sec = rtc_time->tm_sec, in rtc_time_to_timestamp()
61 .tm_min = rtc_time->tm_min, in rtc_time_to_timestamp()
62 .tm_hour = rtc_time->tm_hour, in rtc_time_to_timestamp()
63 .tm_mday = rtc_time->tm_mday, in rtc_time_to_timestamp()
64 .tm_mon = rtc_time->tm_mon, in rtc_time_to_timestamp()
65 .tm_year = rtc_time->tm_year, in rtc_time_to_timestamp()
91 if (self->fd == -1 && errno == ENOENT)
92 SKIP(return, "Skipping test since %s does not exist", rtc_file);
93 ASSERT_NE(-1, self->fd);
98 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
99 ASSERT_NE(-1, rc);
106 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
107 ASSERT_NE(-1, rc);
129 if (self->fd == -1 && errno == ENOENT)
130 SKIP(return, "Skipping test since %s does not exist", rtc_file);
131 ASSERT_NE(-1, self->fd);
134 rc = ioctl(self->fd, RTC_UIE_ON, 0);
135 if (rc == -1) {
143 rc = read(self->fd, &data, sizeof(data));
144 ASSERT_NE(-1, rc);
150 rc = ioctl(self->fd, RTC_UIE_OFF, 0);
151 ASSERT_NE(-1, rc);
158 if (self->fd == -1 && errno == ENOENT) in TEST_F()
159 SKIP(return, "Skipping test since %s does not exist", rtc_file); in TEST_F()
160 ASSERT_NE(-1, self->fd); in TEST_F()
163 rc = ioctl(self->fd, RTC_UIE_ON, 0); in TEST_F()
164 if (rc == -1) { in TEST_F()
175 FD_SET(self->fd, &readfds); in TEST_F()
177 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); in TEST_F()
178 ASSERT_NE(-1, rc); in TEST_F()
182 rc = read(self->fd, &data, sizeof(unsigned long)); in TEST_F()
183 ASSERT_NE(-1, rc); in TEST_F()
189 rc = ioctl(self->fd, RTC_UIE_OFF, 0); in TEST_F()
190 ASSERT_NE(-1, rc); in TEST_F()
201 if (self->fd == -1 && errno == ENOENT) in TEST_F()
202 SKIP(return, "Skipping test since %s does not exist", rtc_file); in TEST_F()
203 ASSERT_NE(-1, self->fd); in TEST_F()
205 rc = ioctl(self->fd, RTC_RD_TIME, &tm); in TEST_F()
206 ASSERT_NE(-1, rc); in TEST_F()
211 rc = ioctl(self->fd, RTC_ALM_SET, &tm); in TEST_F()
212 if (rc == -1) { in TEST_F()
218 rc = ioctl(self->fd, RTC_ALM_READ, &tm); in TEST_F()
219 ASSERT_NE(-1, rc); in TEST_F()
225 rc = ioctl(self->fd, RTC_AIE_ON, 0); in TEST_F()
226 ASSERT_NE(-1, rc); in TEST_F()
229 FD_SET(self->fd, &readfds); in TEST_F()
231 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); in TEST_F()
232 ASSERT_NE(-1, rc); in TEST_F()
236 rc = ioctl(self->fd, RTC_AIE_OFF, 0); in TEST_F()
237 ASSERT_NE(-1, rc); in TEST_F()
239 rc = read(self->fd, &data, sizeof(unsigned long)); in TEST_F()
240 ASSERT_NE(-1, rc); in TEST_F()
243 rc = ioctl(self->fd, RTC_RD_TIME, &tm); in TEST_F()
244 ASSERT_NE(-1, rc); in TEST_F()
259 if (self->fd == -1 && errno == ENOENT) in TEST_F()
260 SKIP(return, "Skipping test since %s does not exist", rtc_file); in TEST_F()
261 ASSERT_NE(-1, self->fd); in TEST_F()
263 rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time); in TEST_F()
264 ASSERT_NE(-1, rc); in TEST_F()
271 rc = ioctl(self->fd, RTC_WKALM_SET, &alarm); in TEST_F()
272 if (rc == -1) { in TEST_F()
278 rc = ioctl(self->fd, RTC_WKALM_RD, &alarm); in TEST_F()
279 ASSERT_NE(-1, rc); in TEST_F()
287 FD_SET(self->fd, &readfds); in TEST_F()
289 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); in TEST_F()
290 ASSERT_NE(-1, rc); in TEST_F()
293 rc = read(self->fd, &data, sizeof(unsigned long)); in TEST_F()
294 ASSERT_NE(-1, rc); in TEST_F()
296 rc = ioctl(self->fd, RTC_RD_TIME, &tm); in TEST_F()
297 ASSERT_NE(-1, rc); in TEST_F()
311 if (self->fd == -1 && errno == ENOENT)
312 SKIP(return, "Skipping test since %s does not exist", rtc_file);
313 ASSERT_NE(-1, self->fd);
315 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
316 ASSERT_NE(-1, rc);
318 secs = timegm((struct tm *)&tm) + 60 - tm.tm_sec;
321 rc = ioctl(self->fd, RTC_ALM_SET, &tm);
322 if (rc == -1) {
328 rc = ioctl(self->fd, RTC_ALM_READ, &tm);
329 ASSERT_NE(-1, rc);
335 rc = ioctl(self->fd, RTC_AIE_ON, 0);
336 ASSERT_NE(-1, rc);
339 FD_SET(self->fd, &readfds);
341 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
342 ASSERT_NE(-1, rc);
346 rc = ioctl(self->fd, RTC_AIE_OFF, 0);
347 ASSERT_NE(-1, rc);
349 rc = read(self->fd, &data, sizeof(unsigned long));
350 ASSERT_NE(-1, rc);
353 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
354 ASSERT_NE(-1, rc);
369 if (self->fd == -1 && errno == ENOENT)
370 SKIP(return, "Skipping test since %s does not exist", rtc_file);
371 ASSERT_NE(-1, self->fd);
373 rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
374 ASSERT_NE(-1, rc);
376 secs = timegm((struct tm *)&alarm.time) + 60 - alarm.time.tm_sec;
381 rc = ioctl(self->fd, RTC_WKALM_SET, &alarm);
382 if (rc == -1) {
388 rc = ioctl(self->fd, RTC_WKALM_RD, &alarm);
389 ASSERT_NE(-1, rc);
397 FD_SET(self->fd, &readfds);
399 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
400 ASSERT_NE(-1, rc);
403 rc = read(self->fd, &data, sizeof(unsigned long));
404 ASSERT_NE(-1, rc);
406 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
407 ASSERT_NE(-1, rc);
415 int ret = -1; in main()
428 /* Run the test if rtc_file is accessible */ in main()
432 ksft_exit_skip("[SKIP]: Cannot access rtc file %s - Exiting\n", in main()