Skip to contentSkip to conversation

clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported

PATCH New Li Wang 2 participants 3 messages Aug 18, 2020

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported

CLOCK_REALTIME_ALARM requires an RTC with alarm support, which may not be present on a system. In that case, the kernel will return EOPNOTSUPP, which is defined as ENOTSUP in userspace.

As CLOCK_REALTIME_ALARM is already possibly unsupported, accept that as an error besides the EINVAL code.

For issue #712:
https://github.com/linux-test-project/ltp/issues/712

Cc Viresh Kumar<[email protected]>
Cc Cyril Hrubis <[email protected]>
---
 .../kernel/syscalls/clock_settime/clock_settime03.c    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/clock_settime/clock_settime03.c +8 -2
index 5b75afbe7..250d6bcc7 100644
@@ -10,6 +10,7 @@
 #include "config.h"
 #include "tst_timer.h"
 #include "tst_safe_clocks.h"
+#include "lapi/common_timers.h"
 
 #define TIMER_DELTA	3
 #define ALLOWED_DELTA	(50 * 1000) /* 50 ms */
@@ -66,8 +67,13 @@ static void run(void)
 	SAFE_SIGPROCMASK(SIG_BLOCK, &set, NULL);
 
 	TEST(tst_syscall(__NR_timer_create, CLOCK_REALTIME_ALARM, &ev, &timer));
-	if (TST_RET != 0)
-		tst_brk(TBROK | TERRNO, "timer_create() failed");
+	if (TST_RET != 0) {
+		if (possibly_unsupported(CLOCK_REALTIME_ALARM) &&
+				(TST_ERR == EINVAL || TST_ERR == ENOTSUP))
+			tst_brk(TCONF | TTERRNO, "CLOCK_REALTIME_ALARM unsupported");
+		else
+			tst_brk(TBROK | TTERRNO, "timer_create() failed");
+	}
 
 	tst_ts_set_sec(&start, time);
 	tst_ts_set_nsec(&start, 0);
Signature · 1 line
2.21.1
#1 lore raw

PATCH 1/1 clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported

Hi!

Quoted 9 lines

CLOCK_REALTIME_ALARM requires an RTC with alarm support, which may not be present on a system. In that case, the kernel will return EOPNOTSUPP, which is defined as ENOTSUP in userspace.

As CLOCK_REALTIME_ALARM is already possibly unsupported, accept that as an error besides the EINVAL code.

For issue #712:
https://github.com/linux-test-project/ltp/issues/712

Actually I've commented on the issue, do we really need the _ALARM clock for anything? I guess that the test would work fine with old plain CLOCK_REALTIME as well.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH 1/1 clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported

Quoted 8 lines · Cyril Hrubis

Hi!

Quoted 2 lines

CLOCK_REALTIME_ALARM requires an RTC with alarm support, which may not be present on a system. In that case, the kernel will return EOPNOTSUPP,

which

Quoted 3 lines

is defined as ENOTSUP in userspace.

As CLOCK_REALTIME_ALARM is already possibly unsupported, accept that as

an

Quoted 9 lines
Quoted 4 lines

error besides the EINVAL code.

For issue #712:
https://github.com/linux-test-project/ltp/issues/712

Actually I've commented on the issue, do we really need the _ALARM clock for anything? I guess that the test would work fine with old plain CLOCK_REALTIME as well.

You're right, the CLOCK_REALTIME works fine at this point. Also as you commented, we do not suspend the OS in the middle, so I agree to use
CLOCK_REALTIME.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200818/1c0f9d8f/attachment.htm>