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
e50edb61
Commit
e50edb61
authored
Jul 19, 2007
by
Paul Vriens
Committed by
Alexandre Julliard
Jul 20, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32/service: Some 'refcount' tests.
parent
4c24492d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
service.c
dlls/advapi32/tests/service.c
+99
-0
No files found.
dlls/advapi32/tests/service.c
View file @
e50edb61
...
...
@@ -517,6 +517,101 @@ static void test_sequence(void)
CloseServiceHandle
(
scm_handle
);
}
static
void
test_refcount
(
void
)
{
SC_HANDLE
scm_handle
,
svc_handle1
,
svc_handle2
,
svc_handle3
,
svc_handle4
,
svc_handle5
;
static
const
CHAR
servicename
[]
=
"Winetest"
;
static
const
CHAR
pathname
[]
=
"we_dont_care.exe"
;
BOOL
ret
;
/* Get a handle to the Service Control Manager */
SetLastError
(
0xdeadbeef
);
scm_handle
=
OpenSCManagerA
(
NULL
,
NULL
,
GENERIC_ALL
);
if
(
!
scm_handle
&&
(
GetLastError
()
==
ERROR_ACCESS_DENIED
))
{
skip
(
"Not enough rights to get a handle to the manager
\n
"
);
return
;
}
/* Create a service */
svc_handle1
=
CreateServiceA
(
scm_handle
,
servicename
,
NULL
,
GENERIC_ALL
,
SERVICE_WIN32_OWN_PROCESS
|
SERVICE_INTERACTIVE_PROCESS
,
SERVICE_DISABLED
,
0
,
pathname
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
svc_handle1
!=
NULL
,
"Expected success
\n
"
);
/* Get a handle to this new service */
svc_handle2
=
OpenServiceA
(
scm_handle
,
servicename
,
GENERIC_READ
);
ok
(
svc_handle2
!=
NULL
,
"Expected success
\n
"
);
/* Get another handle to this new service */
svc_handle3
=
OpenServiceA
(
scm_handle
,
servicename
,
GENERIC_READ
);
ok
(
svc_handle3
!=
NULL
,
"Expected success
\n
"
);
/* Check if we can close the handle to the Service Control Manager */
ret
=
CloseServiceHandle
(
scm_handle
);
ok
(
ret
,
"Expected success
\n
"
);
/* Get a new handle to the Service Control Manager */
scm_handle
=
OpenSCManagerA
(
NULL
,
NULL
,
GENERIC_ALL
);
ok
(
scm_handle
!=
NULL
,
"Expected success
\n
"
);
/* Get a handle to this new service */
svc_handle4
=
OpenServiceA
(
scm_handle
,
servicename
,
GENERIC_ALL
);
ok
(
svc_handle4
!=
NULL
,
"Expected success
\n
"
);
/* Delete the service */
ret
=
DeleteService
(
svc_handle4
);
ok
(
ret
,
"Expected success
\n
"
);
/* We cannot create the same service again as it's still marked as 'being deleted'.
* The reason is that we still have 4 open handles to this service eventhough we
* closed the handle to the Service Control Manager in between.
*/
SetLastError
(
0xdeadbeef
);
svc_handle5
=
CreateServiceA
(
scm_handle
,
servicename
,
NULL
,
GENERIC_ALL
,
SERVICE_WIN32_OWN_PROCESS
|
SERVICE_INTERACTIVE_PROCESS
,
SERVICE_DISABLED
,
0
,
pathname
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
{
ok
(
!
svc_handle5
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_SERVICE_MARKED_FOR_DELETE
,
"Expected ERROR_SERVICE_MARKED_FOR_DELETE, got %d
\n
"
,
GetLastError
());
}
/* FIXME: Remove this when Wine is fixed */
if
(
svc_handle5
)
{
DeleteService
(
svc_handle5
);
CloseServiceHandle
(
svc_handle5
);
}
/* Close all the handles to the service and try again */
ret
=
CloseServiceHandle
(
svc_handle4
);
ok
(
ret
,
"Expected success
\n
"
);
ret
=
CloseServiceHandle
(
svc_handle3
);
ok
(
ret
,
"Expected success
\n
"
);
ret
=
CloseServiceHandle
(
svc_handle2
);
ok
(
ret
,
"Expected success
\n
"
);
ret
=
CloseServiceHandle
(
svc_handle1
);
ok
(
ret
,
"Expected success
\n
"
);
/* We succeed now as all handles are closed (tested this also with a long SLeep() */
svc_handle5
=
CreateServiceA
(
scm_handle
,
servicename
,
NULL
,
GENERIC_ALL
,
SERVICE_WIN32_OWN_PROCESS
|
SERVICE_INTERACTIVE_PROCESS
,
SERVICE_DISABLED
,
0
,
pathname
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
svc_handle5
!=
NULL
,
"Expected success
\n
"
);
/* Delete the service */
ret
=
DeleteService
(
svc_handle5
);
ok
(
ret
,
"Expected success
\n
"
);
/* Wait a while. Just in case one of the following tests does a CreateService again */
Sleep
(
1000
);
CloseServiceHandle
(
svc_handle5
);
CloseServiceHandle
(
scm_handle
);
}
START_TEST
(
service
)
{
SC_HANDLE
scm_handle
;
...
...
@@ -539,4 +634,8 @@ START_TEST(service)
test_close
();
/* Test the creation, querying and deletion of a service */
test_sequence
();
/* The main reason for this test is to check if any refcounting is used
* and what the rules are
*/
test_refcount
();
}
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