Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
6015fee5
Commit
6015fee5
authored
Jul 29, 2021
by
Francois Gouget
Committed by
Alexandre Julliard
Aug 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add some Nt{Query,Set}TimerResolution() tests.
Signed-off-by:
Francois Gouget
<
fgouget@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e9e8561f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
0 deletions
+110
-0
time.c
dlls/ntdll/tests/time.c
+110
-0
No files found.
dlls/ntdll/tests/time.c
View file @
6015fee5
...
...
@@ -216,6 +216,115 @@ static void test_RtlQueryPerformanceCounter(void)
}
#endif
#define CHECK_CURRENT_TIMER(expected) \
do { \
todo_wine ok(status == STATUS_SUCCESS, "NtSetTimerResolution failed %x\n", status); \
todo_wine ok(cur2 == (expected), "expected new timer resolution %u, got %u\n", (expected), cur2); \
min2 = min + 10; \
cur2 = min2 + 1; \
max2 = cur2 + 1; \
status = NtQueryTimerResolution(&min2, &max2, &cur2); \
todo_wine ok(status == STATUS_SUCCESS, "NtQueryTimerResolution() failed %x\n", status); \
todo_wine ok(min2 == min, "NtQueryTimerResolution() expected min=%u, got %u\n", min, min2); \
todo_wine ok(max2 == max, "NtQueryTimerResolution() expected max=%u, got %u\n", max, max2); \
todo_wine ok(cur2 == expected, "NtQueryTimerResolution() expected timer resolution %u, got %u\n", (expected), cur2); \
} while (0)
static
void
test_TimerResolution
(
void
)
{
ULONG
min
,
max
,
cur
,
min2
,
max2
,
cur2
,
set
;
NTSTATUS
status
;
status
=
NtQueryTimerResolution
(
NULL
,
&
max
,
&
cur
);
todo_wine
ok
(
status
==
STATUS_ACCESS_VIOLATION
,
"NtQueryTimerResolution(NULL,,) success
\n
"
);
status
=
NtQueryTimerResolution
(
&
min
,
NULL
,
&
cur
);
todo_wine
ok
(
status
==
STATUS_ACCESS_VIOLATION
,
"NtQueryTimerResolution(,NULL,) success
\n
"
);
status
=
NtQueryTimerResolution
(
&
min
,
&
max
,
NULL
);
todo_wine
ok
(
status
==
STATUS_ACCESS_VIOLATION
,
"NtQueryTimerResolution(,,NULL) success
\n
"
);
min
=
212121
;
cur
=
min
+
1
;
max
=
cur
+
1
;
status
=
NtQueryTimerResolution
(
&
min
,
&
max
,
&
cur
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"NtQueryTimerResolution() failed (%x)
\n
"
,
status
);
todo_wine
ok
(
min
==
156250
/* 1/64s HPET */
||
min
==
156001
/* RTC */
,
"unexpected minimum timer resolution %u
\n
"
,
min
);
ok
(
0
<
max
,
"invalid maximum timer resolution, should be 0 < %u
\n
"
,
max
);
todo_wine
ok
(
max
<=
cur
&&
cur
<=
min
,
"invalid timer resolutions, should be %u <= %u <= %u
\n
"
,
max
,
cur
,
min
);
status
=
NtSetTimerResolution
(
0
,
FALSE
,
NULL
);
todo_wine
ok
(
status
==
STATUS_ACCESS_VIOLATION
,
"NtSetTimerResolution(,,NULL) success
\n
"
);
/* Nothing happens if that pointer is not good */
status
=
NtSetTimerResolution
(
cur
-
1
,
TRUE
,
NULL
);
todo_wine
ok
(
status
==
STATUS_ACCESS_VIOLATION
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
min2
=
min
+
1
;
cur2
=
min2
+
1
;
max2
=
cur2
+
1
;
status
=
NtQueryTimerResolution
(
&
min2
,
&
max2
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"NtQueryTimerResolution() failed (%x)
\n
"
,
status
);
todo_wine
ok
(
min2
==
min
,
"NtQueryTimerResolution() expected min=%u, got %u
\n
"
,
min
,
min2
);
todo_wine
ok
(
max2
==
max
,
"NtQueryTimerResolution() expected max=%u, got %u
\n
"
,
max
,
max2
);
todo_wine
ok
(
cur2
==
cur
,
"NtQueryTimerResolution() expected timer resolution %u, got %u
\n
"
,
cur
,
cur2
);
/* 'fails' until the first valid timer resolution request */
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
0
,
FALSE
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_TIMER_RESOLUTION_NOT_SET
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
/* and returns the current timer resolution */
todo_wine
ok
(
cur2
==
cur
,
"expected requested timer resolution %u, got %u
\n
"
,
cur
,
cur2
);
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
max
-
1
,
TRUE
,
&
cur2
);
CHECK_CURRENT_TIMER
(
max
);
/* Rescinds our timer resolution request */
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
0
,
FALSE
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
/* -> the timer resolution was reset to its initial value */
todo_wine
ok
(
cur2
==
cur
,
"expected requested timer resolution %u, got %u
\n
"
,
min
,
cur2
);
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
0
,
FALSE
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_TIMER_RESOLUTION_NOT_SET
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
todo_wine
ok
(
cur2
==
cur
,
"expected requested timer resolution %u, got %u
\n
"
,
cur
,
cur2
);
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
min
+
1
,
TRUE
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
/* This works because:
* - Either cur is the minimum (15.6 ms) resolution already, i.e. the
* closest valid value 'set' is rounded to.
* - Or some other application requested a higher timer resolution, cur,
* and any attempt to lower the resolution has no effect until that
* request is rescinded (hopefully after this test is done).
*/
CHECK_CURRENT_TIMER
(
cur
);
/* The requested resolution may (win7) or may not be rounded */
cur2
=
7654321
;
set
=
max
<
cur
?
cur
-
1
:
max
;
status
=
NtSetTimerResolution
(
set
,
TRUE
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
todo_wine
ok
(
cur2
<=
set
,
"expected new timer resolution %u <= %u
\n
"
,
cur2
,
set
);
trace
(
"timer resolution: %u(max) <= %u(cur) <= %u(prev) <= %u(min)
\n
"
,
max
,
cur2
,
cur
,
min
);
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
cur
+
1
,
TRUE
,
&
cur2
);
CHECK_CURRENT_TIMER
(
cur
);
/* see min + 1 test */
/* Cleanup by rescinding the last request */
cur2
=
7654321
;
status
=
NtSetTimerResolution
(
0
,
FALSE
,
&
cur2
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"NtSetTimerResolution() failed %x
\n
"
,
status
);
todo_wine
ok
(
cur2
==
cur
,
"expected requested timer resolution %u, got %u
\n
"
,
set
,
cur2
);
}
static
void
test_RtlQueryTimeZoneInformation
(
void
)
{
RTL_DYNAMIC_TIME_ZONE_INFORMATION
tzinfo
,
tzinfo2
;
...
...
@@ -379,4 +488,5 @@ START_TEST(time)
#if defined(__i386__) || defined(__x86_64__)
test_RtlQueryPerformanceCounter
();
#endif
test_TimerResolution
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment