[PATCH v2] tests: posix: use cpu clock for sleep
DJ Delorie
dj@redhat.com
Wed Feb 11 22:52:39 GMT 2026
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? You don't actually need
to sleep for exactly a second, you just need to sleep "long enough".
You could even use usleep(100) to avoid sleeping for the whole second if
not needed.
Busy-waiting may affect how long it takes to run other tests, if "make
-j" is used.
More information about the Libc-alpha
mailing list