Piotr Caban : msvcrt/tests: Rewrite clock() tests.

Alexandre Julliard julliard at winehq.org
Mon Nov 13 16:24:19 CST 2017


Module: wine
Branch: master
Commit: 20a11fd6ccef0bb3f96e86dc89a60e002a04b5c7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=20a11fd6ccef0bb3f96e86dc89a60e002a04b5c7

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Mon Nov 13 15:22:50 2017 +0100

msvcrt/tests: Rewrite clock() tests.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 6865e3d..bc1c6c8 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)




More information about the wine-cvs mailing list