Huw Davies : kernel32/tests: Add a test for GetTickCount().

Alexandre Julliard julliard at winehq.org
Fri Jun 14 16:52:17 CDT 2019


Module: wine
Branch: master
Commit: 2706b94dd011b08113f541fe123c251ffd751734
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2706b94dd011b08113f541fe123c251ffd751734

Author: Huw Davies <huw at codeweavers.com>
Date:   Fri Jun 14 11:50:30 2019 +0100

kernel32/tests: Add a test for GetTickCount().

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/time.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/dlls/kernel32/tests/time.c b/dlls/kernel32/tests/time.c
index 536f233..5faabd3 100644
--- a/dlls/kernel32/tests/time.c
+++ b/dlls/kernel32/tests/time.c
@@ -32,6 +32,7 @@ static int (WINAPI *pGetCalendarInfoW)(LCID,CALID,CALTYPE,LPWSTR,int,LPDWORD);
 static DWORD (WINAPI *pGetDynamicTimeZoneInformation)(DYNAMIC_TIME_ZONE_INFORMATION*);
 static void (WINAPI *pGetSystemTimePreciseAsFileTime)(LPFILETIME);
 static BOOL (WINAPI *pGetTimeZoneInformationForYear)(USHORT, PDYNAMIC_TIME_ZONE_INFORMATION, LPTIME_ZONE_INFORMATION);
+static ULONG (WINAPI *pNtGetTickCount)(void);
 
 #define SECSPERMIN         60
 #define SECSPERDAY        86400
@@ -1004,9 +1005,32 @@ static void test_GetTimeZoneInformationForYear(void)
        "GetTimeZoneInformationForYear err %u\n", GetLastError());
 }
 
+static void test_GetTickCount(void)
+{
+    DWORD t1, t2, t3;
+    int i = 0;
+
+    if (!pNtGetTickCount)
+    {
+        win_skip("NtGetTickCount not implemented\n");
+        return;
+    }
+
+    do
+    {
+        t1 = pNtGetTickCount();
+        t2 = GetTickCount();
+        t3 = pNtGetTickCount();
+    } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */
+
+    ok(t1 <= t2, "out of order %d %d\n", t1, t2);
+    ok(t2 <= t3, "out of order %d %d\n", t2, t3);
+}
+
 START_TEST(time)
 {
     HMODULE hKernel = GetModuleHandleA("kernel32");
+    HMODULE hntdll = GetModuleHandleA("ntdll");
     pTzSpecificLocalTimeToSystemTime = (void *)GetProcAddress(hKernel, "TzSpecificLocalTimeToSystemTime");
     pSystemTimeToTzSpecificLocalTime = (void *)GetProcAddress( hKernel, "SystemTimeToTzSpecificLocalTime");
     pGetSystemTimes = (void *)GetProcAddress( hKernel, "GetSystemTimes");
@@ -1015,6 +1039,7 @@ START_TEST(time)
     pGetDynamicTimeZoneInformation = (void *)GetProcAddress(hKernel, "GetDynamicTimeZoneInformation");
     pGetSystemTimePreciseAsFileTime = (void *)GetProcAddress(hKernel, "GetSystemTimePreciseAsFileTime");
     pGetTimeZoneInformationForYear = (void *)GetProcAddress(hKernel, "GetTimeZoneInformationForYear");
+    pNtGetTickCount = (void *)GetProcAddress(hntdll, "NtGetTickCount");
 
     test_conversions();
     test_invalid_arg();
@@ -1029,4 +1054,5 @@ START_TEST(time)
     test_GetSystemTimeAsFileTime();
     test_GetSystemTimePreciseAsFileTime();
     test_GetTimeZoneInformationForYear();
+    test_GetTickCount();
 }




More information about the wine-cvs mailing list