ReactOS 0.4.15-dev-7842-g558ab78
Timer.c File Reference
#include "precomp.h"
Include dependency graph for Timer.c:

Go to the source code of this file.

Functions

 START_TEST (TimerResolution)
 

Function Documentation

◆ START_TEST()

START_TEST ( TimerResolution  )

Definition at line 10 of file Timer.c.

11{
13 ULONG CurrentResolution;
14 ULONG MinimumResolution;
15 ULONG MaximumResolution;
16 ULONG CurrentResolution2;
17
18 /* Get the current timer resolution */
19 Status = NtSetTimerResolution(0, /* Ignored */
20 FALSE, /* Don't change resolution */
21 &CurrentResolution);
22
23 /*
24 * If the timer resolution hasn't been changed for this process,
25 * it returns STATUS_TIMER_RESOLUTION_NOT_SET
26 */
28
29 /*
30 * Get the timer resolution limits and current timer resolution
31 * using a different method
32 */
33 Status = NtQueryTimerResolution(&MinimumResolution,
34 &MaximumResolution,
35 &CurrentResolution2);
36
37 /* This function should always return STATUS_SUCCESS */
39
40 /* The MinimumResolution should be higher than the MaximumResolution */
41 ok(MinimumResolution >= MaximumResolution, "MaximumResolution higher than MinimumResolution!\n");
42
43 /* These two values should be the same */
44 ok_hex(CurrentResolution, CurrentResolution2);
45
46 /*
47 * Even if you give it invalid values,
48 * NtSetTimerResolution will return STATUS_SUCCESS,
49 * but it will not change the resolution.
50 */
51 Status = NtSetTimerResolution(MinimumResolution + 1,
52 TRUE,
53 &CurrentResolution);
55 printf("Current resolution: %lu ; minimum resolution: %lu\n", CurrentResolution, MinimumResolution);
56 ok(CurrentResolution <= MinimumResolution, "Current resolution: %lu became too high! (minimum resolution: %lu)\n", CurrentResolution, MinimumResolution);
57
58 Status = NtSetTimerResolution(MaximumResolution - 1,
59 TRUE,
60 &CurrentResolution);
62 printf("Current resolution: %lu ; maximum resolution: %lu\n", CurrentResolution, MaximumResolution);
63#if 0 // Why? This doesn't hold true on Windows Server 2003.
64 ok(abs((LONG)MaximumResolution - (LONG)CurrentResolution) < 200, "Current resolution: %lu became too low! (maximum resolution: %lu)\n", CurrentResolution, MaximumResolution);
65#endif
66
67 /* Get the current timer resolution */
68 Status = NtSetTimerResolution(0, /* Ignored */
69 FALSE, /* Don't change resolution */
70 &CurrentResolution);
71
72 /* Since we have changed the resolution earlier, it returns STATUS_SUCCESS. */
74
75 /* Get the current timer resolution again */
76 Status = NtSetTimerResolution(0, /* Ignored */
77 FALSE, /* Don't change resolution */
78 &CurrentResolution);
79
80 /* The resolution is not changed now, so it should return STATUS_TIMER_RESOLUTION_NOT_SET */
82}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define abs(i)
Definition: fconv.c:206
#define printf
Definition: freeldr.h:93
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG ActualResolution)
Definition: time.c:547
NTSTATUS NTAPI NtSetTimerResolution(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution)
Definition: time.c:598
#define STATUS_TIMER_RESOLUTION_NOT_SET
Definition: ntstatus.h:713
long LONG
Definition: pedump.c:60
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59