From 6a1a8685b7ee9fa485a796963d9b2a3430067b14 Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Tue, 2 May 2017 21:19:03 -0500
Subject: ntdll/tests: Test updating TickCount in user_shared_data.

---
 dlls/ntdll/tests/time.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c
index b684bc1980d..f90ac6ff91c 100644
--- a/dlls/ntdll/tests/time.c
+++ b/dlls/ntdll/tests/time.c
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define NONAMELESSUNION
 #include "ntdll_test.h"
+#include "ddk/wdm.h"
 
 #define TICKSPERSEC        10000000
 #define TICKSPERMSEC       10000
@@ -29,6 +29,7 @@ static VOID (WINAPI *pRtlTimeFieldsToTime)(  PTIME_FIELDS TimeFields,  PLARGE_IN
 static NTSTATUS (WINAPI *pNtQueryPerformanceCounter)( LARGE_INTEGER *counter, LARGE_INTEGER *frequency );
 static NTSTATUS (WINAPI *pRtlQueryTimeZoneInformation)( RTL_TIME_ZONE_INFORMATION *);
 static NTSTATUS (WINAPI *pRtlQueryDynamicTimeZoneInformation)( RTL_DYNAMIC_TIME_ZONE_INFORMATION *);
+static ULONG (WINAPI *pNtGetTickCount)(void);
 
 static const int MonthLengths[2][12] =
 {
@@ -153,12 +155,36 @@ static void test_RtlQueryTimeZoneInforma
        wine_dbgstr_w(tzinfo.DaylightName));
 }
 
+static void test_NtGetTickCount(void)
+{
+#ifndef _WIN64
+    KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000;
+    LONG diff;
+    int i;
+
+    if (!pNtGetTickCount)
+    {
+        win_skip("NtGetTickCount is not available\n");
+        return;
+    }
+
+    for (i = 0; i < 5; ++i)
+    {
+        diff = (user_shared_data->u.TickCountQuad * user_shared_data->TickCountMultiplier) >> 24;
+        diff = pNtGetTickCount() - diff;
+        ok(diff < 32, "NtGetTickCount - TickCountQuad too high, expected < 32 got %d\n", diff);
+        Sleep(50);
+    }
+#endif
+}
+
 START_TEST(time)
 {
     HMODULE mod = GetModuleHandleA("ntdll.dll");
     pRtlTimeToTimeFields = (void *)GetProcAddress(mod,"RtlTimeToTimeFields");
     pRtlTimeFieldsToTime = (void *)GetProcAddress(mod,"RtlTimeFieldsToTime");
     pNtQueryPerformanceCounter = (void *)GetProcAddress(mod, "NtQueryPerformanceCounter");
+    pNtGetTickCount = (void *)GetProcAddress(mod,"NtGetTickCount");
     pRtlQueryTimeZoneInformation =
         (void *)GetProcAddress(mod, "RtlQueryTimeZoneInformation");
     pRtlQueryDynamicTimeZoneInformation =
@@ -169,5 +195,6 @@ START_TEST(time)
     else
         win_skip("Required time conversion functions are not available\n");
     test_NtQueryPerformanceCounter();
+    test_NtGetTickCount();
     test_RtlQueryTimeZoneInformation();
 }
-- 
2.12.2
