[PATCH v1 2/2] selftests: rtc: rtctest: skip alarm test if alarm resolution is one minute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Emanuele Ghidoli <emanuele.ghidoli@xxxxxxxxxxx>

There are two types of alarm tests: one that tests alarms on minute boundaries
and another that tests alarms on second boundaries. For RTCs with one-minute
resolution, only the minute boundary test should be run. Skip the second boundary
alarm test for these RTCs.

Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@xxxxxxxxxxx>
---
 tools/testing/selftests/rtc/rtctest.c | 30 +++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
index 63ce02d1d5cc..d741a548ef76 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -82,6 +82,22 @@ static void nanosleep_with_retries(long ns)
 	}
 }
 
+static int rtc_get_features(int fd, uint64_t *features)
+{
+	struct rtc_param param = { 0 };
+	int rc;
+
+	param.param = RTC_PARAM_FEATURES;
+	param.index = 0;
+	rc = ioctl(fd, RTC_PARAM_GET, &param);
+	if (rc < 0)
+		return rc;
+
+	*features = param.uvalue;
+
+	return 0;
+}
+
 TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) {
 	int rc;
 	long iter_count = 0;
@@ -197,6 +213,13 @@ TEST_F(rtc, alarm_alm_set) {
 	fd_set readfds;
 	time_t secs, new;
 	int rc;
+	int rc_feat;
+	uint64_t rtc_feat;
+
+	rc_feat = rtc_get_features(self->fd, &rtc_feat);
+
+	if (!rc_feat && (rtc_feat & _BITUL(RTC_FEATURE_ALARM_RES_MINUTE)))
+		SKIP(return, "Skipping test since only one minute resolution alarms are supported.");
 
 	if (self->fd == -1 && errno == ENOENT)
 		SKIP(return, "Skipping test since %s does not exist", rtc_file);
@@ -255,6 +278,13 @@ TEST_F(rtc, alarm_wkalm_set) {
 	fd_set readfds;
 	time_t secs, new;
 	int rc;
+	int rc_feat;
+	uint64_t rtc_feat;
+
+	rc_feat = rtc_get_features(self->fd, &rtc_feat);
+
+	if (!rc_feat && (rtc_feat & _BITUL(RTC_FEATURE_ALARM_RES_MINUTE)))
+		SKIP(return, "Skipping test since only one minute resolution alarms are supported.");
 
 	if (self->fd == -1 && errno == ENOENT)
 		SKIP(return, "Skipping test since %s does not exist", rtc_file);
-- 
2.34.1





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux