[glibc] rt: skip nanosleep interval and abs test for low precision clocks
Mark Wielaard via Glibc-cvs <[email protected]> Tue, 4 Aug 2026 07:32:43 +0000 (GMT)
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c89d20dd5264957490edef3b7f6151e51c359d10 commit c89d20dd5264957490edef3b7f6151e51c359d10 Author: Mark Wielaard <[email protected]> Date: Tue Jan 14 01:30:40 2025 +0100 rt: skip nanosleep interval and abs test for low precision clocks If a clock doesn't have enough precision to check the sleep resolution (quantum.tv_nsec > TEST_NSEC / 10) then record the quantum.tv_nsec, but skip the interval_test and abs_test for that clock. Reviewed-by: Adhemerval Zanella <[email protected]> Tested-by: Magnus Lindholm <[email protected]> Diff: --- rt/tst-clock_nanosleep2.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/rt/tst-clock_nanosleep2.c b/rt/tst-clock_nanosleep2.c index 0a34a273e8..18df0c2c8e 100644 --- a/rt/tst-clock_nanosleep2.c +++ b/rt/tst-clock_nanosleep2.c @@ -87,9 +87,14 @@ test_interval_1 (const char *n_clock, clockid_t t_clock) /* Arbitrary to ensure our time period is sufficiently bigger than the time step. */ TEST_VERIFY (clock_getres (t_clock, &quantum) == 0); - printf("Clock quantum: %lld ns, test time: %lld ns\n", + printf("%s quantum: %lld ns, test time: %lld ns\n", n_clock, (long long int) quantum.tv_nsec, (long long int) TEST_NSEC); - TEST_VERIFY (quantum.tv_nsec <= TEST_NSEC / 10); + if (quantum.tv_nsec > TEST_NSEC / 10) + { + printf ("SKIPPING test_interval for clock %s, not enough precision\n", + n_clock); + return; + } min_slept = TEST_NSEC; @@ -125,9 +130,14 @@ test_abs_1 (const char *n_clock, clockid_t t_clock) /* Arbitrary to ensure our time period is sufficiently bigger than the time step. */ TEST_VERIFY (clock_getres (t_clock, &quantum) == 0); - printf("Clock quantum: %lld ns, test time: %lld ns\n", + printf("%s quantum: %lld ns, test time: %lld ns\n", n_clock, (long long int) quantum.tv_nsec, (long long int) TEST_NSEC); - TEST_VERIFY (quantum.tv_nsec <= TEST_NSEC / 10); + if (quantum.tv_nsec > TEST_NSEC / 10) + { + printf ("SKIPPING test_abs for clock %s, not enough precision\n", + n_clock); + return; + } me_sleep = make_timespec (0, TEST_NSEC);