From 20a11fd6ccef0bb3f96e86dc89a60e002a04b5c7 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 13 Nov 2017 15:22:50 +0100 Subject: [PATCH] msvcrt/tests: Rewrite clock() tests. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/tests/time.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c index 6865e3d2691..bc1c6c8d1ab 100644 --- a/dlls/msvcrt/tests/time.c +++ b/dlls/msvcrt/tests/time.c @@ -875,18 +875,18 @@ static void test__tzset(void) static void test_clock(void) { - static const int THRESH = 50; - clock_t s, e; - int i; - - for (i = 0; i < 10; i++) - { - s = clock(); - Sleep(1000); - e = clock(); - - ok(abs((e-s) - 1000) < THRESH, "clock off on loop %i: %i\n", i, e-s); - } + static const int THRESH = 100; + FILETIME start, cur; + int c, expect; + + ok(GetProcessTimes(GetCurrentProcess(), &start, &cur, &cur, &cur), + "GetProcessTimes failed with error: %d\n", GetLastError()); + GetSystemTimeAsFileTime(&cur); + expect = (((LONGLONG)cur.dwHighDateTime<<32)+cur.dwLowDateTime - + ((LONGLONG)start.dwHighDateTime<<32)-start.dwLowDateTime) / 10000; + + c = clock(); + ok(abs(c-expect) < THRESH, "clock() = %d, expected %d\n", c, expect); } START_TEST(time) -- 2.11.4.GIT