2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtQueryTimerResolution and NtSetTimerResolution.
5 * PROGRAMMER: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
8 #define WIN32_NO_STATUS
10 #include <ndk/ketypes.h>
11 #include <ndk/kefuncs.h>
15 START_TEST(TimerResolution
)
18 ULONG CurrentResolution
;
19 ULONG MinimumResolution
;
20 ULONG MaximumResolution
;
21 ULONG CurrentResolution2
;
23 /* Get the current timer resolution */
24 Status
= NtSetTimerResolution(0, /* Ignored */
25 FALSE
, /* Don't change resolution */
29 * When not setting the resolution, it always
30 * returns STATUS_TIMER_RESOLUTION_NOT_SET
32 ok_hex(Status
, STATUS_TIMER_RESOLUTION_NOT_SET
);
35 * Get the timer resolution limits and current timer resolution
36 * using a different method
38 Status
= NtQueryTimerResolution(&MinimumResolution
,
42 /* This function should always return STATUS_SUCCESS */
43 ok_hex(Status
, STATUS_SUCCESS
);
45 /* These two values should be the same */
46 ok_hex(CurrentResolution
, CurrentResolution2
);
49 * Even if you give it invalid values,
50 * NtSetTimerResolution will return STATUS_SUCCESS,
51 * but it will not change the resolution.
53 Status
= NtSetTimerResolution(MinimumResolution
- 1,
56 ok_hex(Status
, STATUS_SUCCESS
);
57 printf("Current resolution: %d ; minimum resolution: %d\n", CurrentResolution
, MinimumResolution
);
58 ok(CurrentResolution
>= MinimumResolution
, "Current resolution: %d became too low! (minimum resolution: %d)\n", CurrentResolution
, MinimumResolution
);
60 Status
= NtSetTimerResolution(MaximumResolution
+ 1,
63 ok_hex(Status
, STATUS_SUCCESS
);
64 printf("Current resolution: %d ; maximum resolution: %d\n", CurrentResolution
, MaximumResolution
);
65 ok(CurrentResolution
<= MaximumResolution
, "Current resolution: %d became too high! (maximum resolution: %d)\n", CurrentResolution
, MaximumResolution
);