[ROSTESTS]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 20 Aug 2013 18:55:42 +0000 (18:55 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 20 Aug 2013 18:55:42 +0000 (18:55 +0000)
Fix timer tests, by Aleksander Andrejevic.
See CORE-7387 for more details, and:
http://mirrors.arcadecontrols.com/www.sysinternals.com/Information/HighResolutionTimers.html too.

svn path=/trunk/; revision=59788

rostests/apitests/ntdll/Timer.c
rostests/apitests/ntdll/testlist.c

index 1bda9d0..6bd5f1a 100644 (file)
@@ -26,8 +26,8 @@ START_TEST(TimerResolution)
                                   &CurrentResolution);
 
     /*
                                   &CurrentResolution);
 
     /*
-     * When not setting the resolution, it always
-     * returns STATUS_TIMER_RESOLUTION_NOT_SET
+     * If the timer resolution hasn't been changed for this process,
+     * it returns STATUS_TIMER_RESOLUTION_NOT_SET
      */
     ok_hex(Status, STATUS_TIMER_RESOLUTION_NOT_SET);
 
      */
     ok_hex(Status, STATUS_TIMER_RESOLUTION_NOT_SET);
 
@@ -42,6 +42,9 @@ START_TEST(TimerResolution)
     /* This function should always return STATUS_SUCCESS */
     ok_hex(Status, STATUS_SUCCESS);
 
     /* This function should always return STATUS_SUCCESS */
     ok_hex(Status, STATUS_SUCCESS);
 
+    /* The MinimumResolution should be higher than the MaximumResolution */
+    ok(MinimumResolution >= MaximumResolution, "MaximumResolution higher than MinimumResolution!");
+
     /* These two values should be the same */
     ok_hex(CurrentResolution, CurrentResolution2);
 
     /* These two values should be the same */
     ok_hex(CurrentResolution, CurrentResolution2);
 
@@ -50,17 +53,25 @@ START_TEST(TimerResolution)
      * NtSetTimerResolution will return STATUS_SUCCESS,
      * but it will not change the resolution.
      */
      * NtSetTimerResolution will return STATUS_SUCCESS,
      * but it will not change the resolution.
      */
-    Status = NtSetTimerResolution(MinimumResolution - 1,
+    Status = NtSetTimerResolution(MinimumResolution + 1,
                                   TRUE,
                                   &CurrentResolution);
     ok_hex(Status, STATUS_SUCCESS);
     printf("Current resolution: %d ; minimum resolution: %d\n", CurrentResolution, MinimumResolution);
                                   TRUE,
                                   &CurrentResolution);
     ok_hex(Status, STATUS_SUCCESS);
     printf("Current resolution: %d ; minimum resolution: %d\n", CurrentResolution, MinimumResolution);
-    ok(CurrentResolution >= MinimumResolution, "Current resolution: %d became too low! (minimum resolution: %d)\n", CurrentResolution, MinimumResolution);
+    ok(CurrentResolution <= MinimumResolution, "Current resolution: %d became too high! (minimum resolution: %d)\n", CurrentResolution, MinimumResolution);
 
 
-    Status = NtSetTimerResolution(MaximumResolution + 1,
+    Status = NtSetTimerResolution(MaximumResolution - 1,
                                   TRUE,
                                   &CurrentResolution);
     ok_hex(Status, STATUS_SUCCESS);
     printf("Current resolution: %d ; maximum resolution: %d\n", CurrentResolution, MaximumResolution);
                                   TRUE,
                                   &CurrentResolution);
     ok_hex(Status, STATUS_SUCCESS);
     printf("Current resolution: %d ; maximum resolution: %d\n", CurrentResolution, MaximumResolution);
-    ok(CurrentResolution <= MaximumResolution, "Current resolution: %d became too high! (maximum resolution: %d)\n", CurrentResolution, MaximumResolution);
+    ok(CurrentResolution >= MaximumResolution, "Current resolution: %d became too low! (maximum resolution: %d)\n", CurrentResolution, MaximumResolution);
+
+    /* Get the current timer resolution */
+    Status = NtSetTimerResolution(0,        /* Ignored */
+                                  FALSE,    /* Don't change resolution */
+                                  &CurrentResolution);
+
+    /* Since we have changed the resolution earlier, it returns STATUS_SUCCESS. */
+    ok_hex(Status, STATUS_SUCCESS);
 }
 }
index 4279fdb..115b572 100644 (file)
@@ -21,8 +21,8 @@ extern void func_RtlGetFullPathName_Ustr(void);
 extern void func_RtlGetFullPathName_UstrEx(void);
 extern void func_RtlGetLongestNtPathLength(void);
 extern void func_RtlInitializeBitMap(void);
 extern void func_RtlGetFullPathName_UstrEx(void);
 extern void func_RtlGetLongestNtPathLength(void);
 extern void func_RtlInitializeBitMap(void);
-extern void func_ZwContinue(void);
 extern void func_TimerResolution(void);
 extern void func_TimerResolution(void);
+extern void func_ZwContinue(void);
 
 const struct test winetest_testlist[] =
 {
 
 const struct test winetest_testlist[] =
 {
@@ -44,8 +44,8 @@ const struct test winetest_testlist[] =
     { "RtlGetFullPathName_UstrEx",      func_RtlGetFullPathName_UstrEx },
     { "RtlGetLongestNtPathLength",      func_RtlGetLongestNtPathLength },
     { "RtlInitializeBitMap",            func_RtlInitializeBitMap },
     { "RtlGetFullPathName_UstrEx",      func_RtlGetFullPathName_UstrEx },
     { "RtlGetLongestNtPathLength",      func_RtlGetLongestNtPathLength },
     { "RtlInitializeBitMap",            func_RtlInitializeBitMap },
-    { "ZwContinue",                     func_ZwContinue },
     { "TimerResolution",                func_TimerResolution },
     { "TimerResolution",                func_TimerResolution },
+    { "ZwContinue",                     func_ZwContinue },
 
     { 0, 0 }
 };
 
     { 0, 0 }
 };