Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftest: rtc: skip some tests if the alarm only supports minutes

There are alarms which have only minute-granularity. The RTC core
already has a flag to describe them. Use this flag to skip tests which
require the alarm to support seconds.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20250218101548.6514-1-wsa+renesas@sang-engineering.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Wolfram Sang and committed by
Alexandre Belloni
0cd73ab4 c2004b6e

+14 -5
+14 -5
tools/testing/selftests/rtc/rtctest.c
··· 29 29 RTC_ALARM_UNKNOWN, 30 30 RTC_ALARM_ENABLED, 31 31 RTC_ALARM_DISABLED, 32 + RTC_ALARM_RES_MINUTE, 32 33 }; 33 34 34 35 FIXTURE(rtc) { ··· 89 88 } 90 89 } 91 90 92 - static enum rtc_alarm_state get_rtc_alarm_state(int fd) 91 + static enum rtc_alarm_state get_rtc_alarm_state(int fd, int need_seconds) 93 92 { 94 93 struct rtc_param param = { 0 }; 95 94 int rc; ··· 103 102 104 103 if ((param.uvalue & _BITUL(RTC_FEATURE_ALARM)) == 0) 105 104 return RTC_ALARM_DISABLED; 105 + 106 + /* Check if alarm has desired granularity */ 107 + if (need_seconds && (param.uvalue & _BITUL(RTC_FEATURE_ALARM_RES_MINUTE))) 108 + return RTC_ALARM_RES_MINUTE; 106 109 107 110 return RTC_ALARM_ENABLED; 108 111 } ··· 232 227 SKIP(return, "Skipping test since %s does not exist", rtc_file); 233 228 ASSERT_NE(-1, self->fd); 234 229 235 - alarm_state = get_rtc_alarm_state(self->fd); 230 + alarm_state = get_rtc_alarm_state(self->fd, 1); 236 231 if (alarm_state == RTC_ALARM_DISABLED) 237 232 SKIP(return, "Skipping test since alarms are not supported."); 233 + if (alarm_state == RTC_ALARM_RES_MINUTE) 234 + SKIP(return, "Skipping test since alarms has only minute granularity."); 238 235 239 236 rc = ioctl(self->fd, RTC_RD_TIME, &tm); 240 237 ASSERT_NE(-1, rc); ··· 302 295 SKIP(return, "Skipping test since %s does not exist", rtc_file); 303 296 ASSERT_NE(-1, self->fd); 304 297 305 - alarm_state = get_rtc_alarm_state(self->fd); 298 + alarm_state = get_rtc_alarm_state(self->fd, 1); 306 299 if (alarm_state == RTC_ALARM_DISABLED) 307 300 SKIP(return, "Skipping test since alarms are not supported."); 301 + if (alarm_state == RTC_ALARM_RES_MINUTE) 302 + SKIP(return, "Skipping test since alarms has only minute granularity."); 308 303 309 304 rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time); 310 305 ASSERT_NE(-1, rc); ··· 366 357 SKIP(return, "Skipping test since %s does not exist", rtc_file); 367 358 ASSERT_NE(-1, self->fd); 368 359 369 - alarm_state = get_rtc_alarm_state(self->fd); 360 + alarm_state = get_rtc_alarm_state(self->fd, 0); 370 361 if (alarm_state == RTC_ALARM_DISABLED) 371 362 SKIP(return, "Skipping test since alarms are not supported."); 372 363 ··· 434 425 SKIP(return, "Skipping test since %s does not exist", rtc_file); 435 426 ASSERT_NE(-1, self->fd); 436 427 437 - alarm_state = get_rtc_alarm_state(self->fd); 428 + alarm_state = get_rtc_alarm_state(self->fd, 0); 438 429 if (alarm_state == RTC_ALARM_DISABLED) 439 430 SKIP(return, "Skipping test since alarms are not supported."); 440 431