lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240624102354.894871-3-ghidoliemanuele@gmail.com>
Date: Mon, 24 Jun 2024 12:23:54 +0200
From: Emanuele Ghidoli <ghidoliemanuele@...il.com>
To: alexandre.belloni@...tlin.com,
	linux-kernel@...r.kernel.org,
	linux-rtc@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	shuah@...nel.org
Cc: Emanuele Ghidoli <emanuele.ghidoli@...adex.com>,
	jjang@...dia.com,
	kobak@...dia.com,
	mochs@...dia.com
Subject: [PATCH v1 2/2] selftests: rtc: rtctest: skip alarm test if alarm resolution is one minute

From: Emanuele Ghidoli <emanuele.ghidoli@...adex.com>

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@...adex.com>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ