[PATCH v2] tests: posix: use cpu clock for sleep

Yury Khrustalev yury.khrustalev@arm.com
Thu Feb 12 09:32:32 GMT 2026


On Wed, Feb 11, 2026 at 05:52:39PM -0500, DJ Delorie wrote:
> Yury Khrustalev <yury.khrustalev@arm.com> writes:
> 
> > On some emulated targets sleep may result in inconsistent wait
> > times which will lead to the failure of the tst-chmod test.
> >
> > To account for this we use the CLOCK_PROCESS_CPUTIME_ID clock ID
> > while also consuming CPU time by repeatedly calling clock_gettime.
> 
> If all we need to do is ensure that ctime changes, could we instead call
> time(), then call sleep(1) until time() changes?

Unfortunately, this doesn't work. Emulated systems that prioritise
performance in terms of user's time lapsed have effect of sleep()
or any variant of it returning immediately (with observable effect
that the result of time() has changed correctly).

> Busy-waiting may affect how long it takes to run other tests, if "make
> -j" is used.

I'm sure the effect would be negligible, it's just one tests waiting
for a second two times. At least I didn't notice much difference
running make check with -j.

Thanks,
Yury



More information about the Libc-alpha mailing list