Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
c2daea89
Commit
c2daea89
authored
Jan 16, 2021
by
Daniel Lehman
Committed by
Alexandre Julliard
Jan 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add tests for semaphores.
Signed-off-by:
Daniel Lehman
<
dlehman25@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ae7d8131
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
om.c
dlls/ntdll/tests/om.c
+79
-0
No files found.
dlls/ntdll/tests/om.c
View file @
c2daea89
...
...
@@ -46,6 +46,7 @@ static NTSTATUS (WINAPI *pNtQueryMutant) ( HANDLE, MUTANT_INFORMATION_CLASS, PVO
static
NTSTATUS
(
WINAPI
*
pNtReleaseMutant
)(
HANDLE
,
PLONG
);
static
NTSTATUS
(
WINAPI
*
pNtCreateSemaphore
)(
PHANDLE
,
ACCESS_MASK
,
const
POBJECT_ATTRIBUTES
,
LONG
,
LONG
);
static
NTSTATUS
(
WINAPI
*
pNtOpenSemaphore
)(
PHANDLE
,
ACCESS_MASK
,
const
POBJECT_ATTRIBUTES
);
static
NTSTATUS
(
WINAPI
*
pNtQuerySemaphore
)(
PHANDLE
,
SEMAPHORE_INFORMATION_CLASS
,
PVOID
,
ULONG
,
PULONG
);
static
NTSTATUS
(
WINAPI
*
pNtCreateTimer
)
(
PHANDLE
,
ACCESS_MASK
,
const
POBJECT_ATTRIBUTES
,
TIMER_TYPE
);
static
NTSTATUS
(
WINAPI
*
pNtOpenTimer
)(
PHANDLE
,
ACCESS_MASK
,
const
POBJECT_ATTRIBUTES
);
static
NTSTATUS
(
WINAPI
*
pNtCreateSection
)(
PHANDLE
,
ACCESS_MASK
,
const
POBJECT_ATTRIBUTES
,
const
PLARGE_INTEGER
,
...
...
@@ -2024,6 +2025,82 @@ static void test_mutant(void)
NtClose
(
mutant
);
}
static
void
test_semaphore
(
void
)
{
SEMAPHORE_BASIC_INFORMATION
info
;
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
str
;
NTSTATUS
status
;
HANDLE
semaphore
;
ULONG
prev
;
ULONG
len
;
DWORD
ret
;
pRtlInitUnicodeString
(
&
str
,
L"
\\
BaseNamedObjects
\\
test_semaphore"
);
InitializeObjectAttributes
(
&
attr
,
&
str
,
0
,
0
,
NULL
);
status
=
pNtCreateSemaphore
(
&
semaphore
,
GENERIC_ALL
,
&
attr
,
2
,
1
);
ok
(
status
==
STATUS_INVALID_PARAMETER
,
"Failed to create Semaphore(%08x)
\n
"
,
status
);
status
=
pNtCreateSemaphore
(
&
semaphore
,
GENERIC_ALL
,
&
attr
,
1
,
2
);
ok
(
status
==
STATUS_SUCCESS
,
"Failed to create Semaphore(%08x)
\n
"
,
status
);
/* bogus */
status
=
pNtQuerySemaphore
(
semaphore
,
SemaphoreBasicInformation
,
&
info
,
0
,
NULL
);
ok
(
status
==
STATUS_INFO_LENGTH_MISMATCH
,
"Failed to NtQuerySemaphore, expected STATUS_INFO_LENGTH_MISMATCH, got %08x
\n
"
,
status
);
status
=
pNtQuerySemaphore
(
semaphore
,
0x42
,
&
info
,
sizeof
(
info
),
NULL
);
ok
(
status
==
STATUS_INVALID_INFO_CLASS
,
"Failed to NtQuerySemaphore, expected STATUS_INVALID_INFO_CLASS, got %08x
\n
"
,
status
);
status
=
pNtQuerySemaphore
((
HANDLE
)
0xdeadbeef
,
SemaphoreBasicInformation
,
&
info
,
sizeof
(
info
),
NULL
);
ok
(
status
==
STATUS_INVALID_HANDLE
,
"Failed to NtQuerySemaphore, expected STATUS_INVALID_HANDLE, got %08x
\n
"
,
status
);
len
=
-
1
;
memset
(
&
info
,
0xcc
,
sizeof
(
info
));
status
=
pNtQuerySemaphore
(
semaphore
,
SemaphoreBasicInformation
,
&
info
,
sizeof
(
info
),
&
len
);
ok
(
status
==
STATUS_SUCCESS
,
"NtQuerySemaphore failed %08x
\n
"
,
status
);
ok
(
info
.
CurrentCount
==
1
,
"expected 1, got %d
\n
"
,
info
.
CurrentCount
);
ok
(
info
.
MaximumCount
==
2
,
"expected 2, got %d
\n
"
,
info
.
MaximumCount
);
ok
(
len
==
sizeof
(
info
),
"got %u
\n
"
,
len
);
ret
=
WaitForSingleObject
(
semaphore
,
1000
);
ok
(
ret
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed %08x
\n
"
,
ret
);
memset
(
&
info
,
0xcc
,
sizeof
(
info
));
status
=
pNtQuerySemaphore
(
semaphore
,
SemaphoreBasicInformation
,
&
info
,
sizeof
(
info
),
NULL
);
ok
(
status
==
STATUS_SUCCESS
,
"NtQuerySemaphore failed %08x
\n
"
,
status
);
ok
(
info
.
CurrentCount
==
0
,
"expected 0, got %d
\n
"
,
info
.
CurrentCount
);
ok
(
info
.
MaximumCount
==
2
,
"expected 2, got %d
\n
"
,
info
.
MaximumCount
);
prev
=
0xdeadbeef
;
status
=
pNtReleaseSemaphore
(
semaphore
,
3
,
&
prev
);
ok
(
status
==
STATUS_SEMAPHORE_LIMIT_EXCEEDED
,
"NtReleaseSemaphore failed %08x
\n
"
,
status
);
ok
(
prev
==
0xdeadbeef
,
"NtReleaseSemaphore failed, expected 0xdeadbeef, got %d
\n
"
,
prev
);
prev
=
0xdeadbeef
;
status
=
pNtReleaseSemaphore
(
semaphore
,
1
,
&
prev
);
ok
(
status
==
STATUS_SUCCESS
,
"NtReleaseSemaphore failed %08x
\n
"
,
status
);
ok
(
prev
==
0
,
"NtReleaseSemaphore failed, expected 0, got %d
\n
"
,
prev
);
prev
=
0xdeadbeef
;
status
=
pNtReleaseSemaphore
(
semaphore
,
1
,
&
prev
);
ok
(
status
==
STATUS_SUCCESS
,
"NtReleaseSemaphore failed %08x
\n
"
,
status
);
ok
(
prev
==
1
,
"NtReleaseSemaphore failed, expected 1, got %d
\n
"
,
prev
);
prev
=
0xdeadbeef
;
status
=
pNtReleaseSemaphore
(
semaphore
,
1
,
&
prev
);
ok
(
status
==
STATUS_SEMAPHORE_LIMIT_EXCEEDED
,
"NtReleaseSemaphore failed %08x
\n
"
,
status
);
ok
(
prev
==
0xdeadbeef
,
"NtReleaseSemaphore failed, expected 0xdeadbeef, got %d
\n
"
,
prev
);
memset
(
&
info
,
0xcc
,
sizeof
(
info
));
status
=
pNtQuerySemaphore
(
semaphore
,
SemaphoreBasicInformation
,
&
info
,
sizeof
(
info
),
NULL
);
ok
(
status
==
STATUS_SUCCESS
,
"NtQuerySemaphore failed %08x
\n
"
,
status
);
ok
(
info
.
CurrentCount
==
2
,
"expected 2, got %d
\n
"
,
info
.
CurrentCount
);
ok
(
info
.
MaximumCount
==
2
,
"expected 2, got %d
\n
"
,
info
.
MaximumCount
);
NtClose
(
semaphore
);
}
static
void
test_wait_on_address
(
void
)
{
DWORD
ticks
;
...
...
@@ -2178,6 +2255,7 @@ START_TEST(om)
pNtQuerySymbolicLinkObject
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtQuerySymbolicLinkObject"
);
pNtCreateSemaphore
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtCreateSemaphore"
);
pNtOpenSemaphore
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtOpenSemaphore"
);
pNtQuerySemaphore
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtQuerySemaphore"
);
pNtCreateTimer
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtCreateTimer"
);
pNtOpenTimer
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtOpenTimer"
);
pNtCreateSection
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtCreateSection"
);
...
...
@@ -2207,6 +2285,7 @@ START_TEST(om)
test_type_mismatch
();
test_event
();
test_mutant
();
test_semaphore
();
test_keyed_events
();
test_null_device
();
test_wait_on_address
();
...
...
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