From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: "Cyril Hrubis" <chrubis@suse.cz>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] nanosleep: Use CLOCK_MONOTONIC for elapsed time measurement
Date: Tue, 31 Mar 2026 12:20:01 +0000 [thread overview]
Message-ID: <69cbbbf2.050a0220.72fde.8c02@mx.google.com> (raw)
In-Reply-To: <acu6odZhugXeNM_C@yuki.lan>
Hi Cyril,
> Hi!
> > All nanosleep POSIX conformance tests used CLOCK_REALTIME to measure
> > elapsed sleep duration. CLOCK_REALTIME can jump due to NTP corrections,
> > VM time sync, or other wall-clock adjustments, causing sporadic test
> > failures where measured time far exceeds expected sleep duration.
> >
> > Switch to CLOCK_MONOTONIC which is immune to wall-clock changes and is
> > the correct clock for measuring elapsed durations.
>
> Unfortunately CLOCK_MONOTONIC is optional in POSIX so we have to check
> if it's present at least at compile time with something as:
>
> #if _POSIX_MONOTONIC_CLOCK
> # define TEST_CLOCK CLOCK_MONOTONIC
> #else
> # define TEST_CLOCK CLOCK_REALTIME
> #endif
good point. If it was a non-posix project it was called non-openposix :-)
Do you think that check is enough in this case? Or we should just mark
this test (if we really want to keep it 100% posix) as XFAIL ? I really
didn't see any option but introducing CLOCK_MONOTONIC checks.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-03-31 12:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 11:48 [LTP] [PATCH] nanosleep: Use CLOCK_MONOTONIC for elapsed time measurement Andrea Cervesato
2026-03-31 12:14 ` Cyril Hrubis
2026-03-31 12:20 ` Andrea Cervesato via ltp [this message]
2026-03-31 12:23 ` Cyril Hrubis
2026-03-31 12:28 ` Andrea Cervesato via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=69cbbbf2.050a0220.72fde.8c02@mx.google.com \
--to=ltp@lists.linux.it \
--cc=andrea.cervesato@suse.com \
--cc=chrubis@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox