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>
10 #define WIN32_NO_STATUS
11 #include <ndk/ketypes.h>
12 #include <ndk/kefuncs.h>
16 START_TEST(TimerResolution
)
19 ULONG CurrentResolution
;
20 ULONG MinimumResolution
;
21 ULONG MaximumResolution
;
22 ULONG CurrentResolution2
;
24 /* Get the current timer resolution */
25 Status
= NtSetTimerResolution(0, /* Ignored */
26 FALSE
, /* Don't change resolution */
30 * If the timer resolution hasn't been changed for this process,
31 * it returns STATUS_TIMER_RESOLUTION_NOT_SET
33 ok_hex(Status
, STATUS_TIMER_RESOLUTION_NOT_SET
);
36 * Get the timer resolution limits and current timer resolution
37 * using a different method
39 Status
= NtQueryTimerResolution(&MinimumResolution
,
43 /* This function should always return STATUS_SUCCESS */
44 ok_hex(Status
, STATUS_SUCCESS
);
46 /* The MinimumResolution should be higher than the MaximumResolution */
47 ok(MinimumResolution
>= MaximumResolution
, "MaximumResolution higher than MinimumResolution!\n");
49 /* These two values should be the same */
50 ok_hex(CurrentResolution
, CurrentResolution2
);
53 * Even if you give it invalid values,
54 * NtSetTimerResolution will return STATUS_SUCCESS,
55 * but it will not change the resolution.
57 Status
= NtSetTimerResolution(MinimumResolution
+ 1,
60 ok_hex(Status
, STATUS_SUCCESS
);
61 printf("Current resolution: %lu ; minimum resolution: %lu\n", CurrentResolution
, MinimumResolution
);
62 ok(CurrentResolution
<= MinimumResolution
, "Current resolution: %lu became too high! (minimum resolution: %lu)\n", CurrentResolution
, MinimumResolution
);
64 Status
= NtSetTimerResolution(MaximumResolution
- 1,
67 ok_hex(Status
, STATUS_SUCCESS
);
68 printf("Current resolution: %lu ; maximum resolution: %lu\n", CurrentResolution
, MaximumResolution
);
69 ok(CurrentResolution
>= MaximumResolution
, "Current resolution: %lu became too low! (maximum resolution: %lu)\n", CurrentResolution
, MaximumResolution
);
71 /* Get the current timer resolution */
72 Status
= NtSetTimerResolution(0, /* Ignored */
73 FALSE
, /* Don't change resolution */
76 /* Since we have changed the resolution earlier, it returns STATUS_SUCCESS. */
77 ok_hex(Status
, STATUS_SUCCESS
);
79 /* Get the current timer resolution again */
80 Status
= NtSetTimerResolution(0, /* Ignored */
81 FALSE
, /* Don't change resolution */
84 /* The resolution is not changed now, so it should return STATUS_TIMER_RESOLUTION_NOT_SET */
85 ok_hex(Status
, STATUS_TIMER_RESOLUTION_NOT_SET
);