All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported
@ 2020-08-18  6:10 Li Wang
  2020-08-18  8:32 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2020-08-18  6:10 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Viresh Kumar<viresh.kumar@linaro.org>
Cc: Cyril Hrubis <chrubis@suse.cz>
---
 .../kernel/syscalls/clock_settime/clock_settime03.c    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime03.c b/testcases/kernel/syscalls/clock_settime/clock_settime03.c
index 5b75afbe7..250d6bcc7 100644
--- a/testcases/kernel/syscalls/clock_settime/clock_settime03.c
+++ b/testcases/kernel/syscalls/clock_settime/clock_settime03.c
@@ -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);
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported
  2020-08-18  6:10 [LTP] [PATCH] clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported Li Wang
@ 2020-08-18  8:32 ` Cyril Hrubis
  2020-08-18  9:03   ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2020-08-18  8:32 UTC (permalink / raw)
  To: ltp

Hi!
> 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.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported
  2020-08-18  8:32 ` Cyril Hrubis
@ 2020-08-18  9:03   ` Li Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2020-08-18  9:03 UTC (permalink / raw)
  To: ltp

On Tue, Aug 18, 2020 at 4:31 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > 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.
>

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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-18  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18  6:10 [LTP] [PATCH] clock_settime03: accept ENOTSUP if CLOCK_REALTIME_ALARM unsupported Li Wang
2020-08-18  8:32 ` Cyril Hrubis
2020-08-18  9:03   ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.