[test] Convert select and poll tests to using clock_gettime #26280
[test] Convert select and poll tests to using clock_gettime #26280inolen wants to merge 2 commits intoemscripten-core:mainfrom
clock_gettime #26280Conversation
| if (diff.tv_nsec < 0) { | ||
| diff.tv_nsec += 1000000000; | ||
| diff.tv_sec -= 1; | ||
| } |
There was a problem hiding this comment.
Would a negative tv_nsec here not just work in the return calculation below since + (diff.tv_nsec / 1000000) would end up substracting ?
There was a problem hiding this comment.
What do you think about this? I'd love to land this change but maybe this part is not needed?
There was a problem hiding this comment.
What do you think.. how about just:
delta_sec = end->tv_sec - begin->tv_sec,
delta_nsec = end->tv_nsec - begin->tv_nsec
return (deleta_sec * 1000) + (delta_nsec / 1000000);
I think the possible negative delta_nsec will be fine here.
4408d11 to
09ed72e
Compare
clock_gettime with
clock_gettime withclock_gettime
|
Also to note, I can't guarantee this fixes the CI issues, but it fixes these tests often failing in a comical fashion on my WSL setup. Before these changes, end would often be reported as a timestamp earlier than begin (so the delta would be negative). |
Can you confirm what you mean by |
|
I mean running the test through the python runner script on WSL. |
|
I marked the tests as flaky until this PR landed. Can you undo #26305 as part of this PR? |
CLOCK_MONOTONIC instead of gettimeofday whose implementation isn't guaranteed to be monotonic
This reverts commit 316efa4.
09ed72e to
221c465
Compare
Prefer
clock_gettimewithCLOCK_MONOTONICinstead ofgettimeofdaywhose implementation isn't guaranteed to be monotonic.