Sleep(1) does not sleep for a millisecond, but rather a kernel tick.
Thanks to Henri Verbeet for pointing this out.
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=49564 Signed-off-by: Myah Caron qsniyg@protonmail.com --- I've tested it under Windows 10, but when testing shortly after the machine booted, it appears to sleep for ~1.6ms on average (rather than ~16ms). I'm not sure what is the reason, but my guess is that the kernel tick was possibly shorter when it booted?
dlls/kernelbase/tests/sync.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/dlls/kernelbase/tests/sync.c b/dlls/kernelbase/tests/sync.c index 9f57cf7a95..f89e93261b 100644 --- a/dlls/kernelbase/tests/sync.c +++ b/dlls/kernelbase/tests/sync.c @@ -172,6 +172,31 @@ static void test_WaitOnAddress(void) ok(!address, "got unexpected value %s\n", wine_dbgstr_longlong(address)); }
+static void test_Sleep(void) +{ + LARGE_INTEGER frequency; + LARGE_INTEGER t1, t2; + double elapsed_time; + BOOL ret; + int i; + + ret = QueryPerformanceFrequency(&frequency); + ok(ret, "QueryPerformanceFrequency failed\n"); + + ret = QueryPerformanceCounter(&t1); + ok(ret, "QueryPerformanceCounter failed\n"); + + for (i = 0; i < 100; i++) { + Sleep(1); + } + + ret = QueryPerformanceCounter(&t2); + ok(ret, "QueryPerformanceCounter failed\n"); + + elapsed_time = (t2.QuadPart - t1.QuadPart) / (double)frequency.QuadPart; + todo_wine ok(elapsed_time >= 1.5 && elapsed_time <= 2.1, "got %f\n", elapsed_time); +} + START_TEST(sync) { HMODULE hmod; @@ -186,4 +211,5 @@ START_TEST(sync) pWakeByAddressSingle = (void *)GetProcAddress(hmod, "WakeByAddressSingle");
test_WaitOnAddress(); + test_Sleep(); } -- 2.27.0
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76717
Your paranoid android.
=== w864 (64 bit report) ===
kernelbase: sync.c:197: Test failed: got 2.294550