From 94b5ccef81761b5d0a18f280b497d7f1716baa6f Mon Sep 17 00:00:00 2001 From: Myah Caron Date: Sun, 9 Aug 2020 15:41:04 +0000 Subject: [PATCH] kernelbase/tests: Add test for Sleep(1). Sleep(1) should sleep until the next kernel tick, not necessarily one millisecond. Thanks to Henri Verbeet for pointing this out. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49564 Signed-off-by: Myah Caron Signed-off-by: Alexandre Julliard --- 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 9f57cf7a952..50ce62602b0 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 <= 4.0, "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(); }