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
d4fd3c89
Commit
d4fd3c89
authored
Mar 28, 2015
by
Andrew Cook
Committed by
Alexandre Julliard
Mar 30, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add tests for QueryInformationJobObject.
Cleanup and improvements by Sebastian Lackner.
parent
ad04b730
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
process.c
dlls/kernel32/tests/process.c
+93
-0
No files found.
dlls/kernel32/tests/process.c
View file @
d4fd3c89
...
...
@@ -70,6 +70,7 @@ static HANDLE (WINAPI *pCreateJobObjectW)(LPSECURITY_ATTRIBUTES sa, LPCWSTR name
static
BOOL
(
WINAPI
*
pAssignProcessToJobObject
)(
HANDLE
job
,
HANDLE
process
);
static
BOOL
(
WINAPI
*
pIsProcessInJob
)(
HANDLE
process
,
HANDLE
job
,
PBOOL
result
);
static
BOOL
(
WINAPI
*
pTerminateJobObject
)(
HANDLE
job
,
UINT
exit_code
);
static
BOOL
(
WINAPI
*
pQueryInformationJobObject
)(
HANDLE
job
,
JOBOBJECTINFOCLASS
class
,
LPVOID
info
,
DWORD
len
,
LPDWORD
ret_len
);
/* ############################### */
static
char
base
[
MAX_PATH
];
...
...
@@ -217,6 +218,7 @@ static BOOL init(void)
pAssignProcessToJobObject
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"AssignProcessToJobObject"
);
pIsProcessInJob
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"IsProcessInJob"
);
pTerminateJobObject
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"TerminateJobObject"
);
pQueryInformationJobObject
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"QueryInformationJobObject"
);
return
TRUE
;
}
...
...
@@ -2223,6 +2225,91 @@ static void test_TerminateJobObject(void)
CloseHandle
(
job
);
}
static
void
test_QueryInformationJobObject
(
void
)
{
char
buf
[
FIELD_OFFSET
(
JOBOBJECT_BASIC_PROCESS_ID_LIST
,
ProcessIdList
[
5
])];
PJOBOBJECT_BASIC_PROCESS_ID_LIST
pid_list
=
(
JOBOBJECT_BASIC_PROCESS_ID_LIST
*
)
buf
;
DWORD
dwret
,
ret_len
;
PROCESS_INFORMATION
pi
[
2
];
HANDLE
job
;
BOOL
ret
;
job
=
pCreateJobObjectW
(
NULL
,
NULL
);
ok
(
job
!=
NULL
,
"CreateJobObject error %u
\n
"
,
GetLastError
());
/* Only active processes are returned */
create_process
(
"exit"
,
&
pi
[
0
]);
ret
=
pAssignProcessToJobObject
(
job
,
pi
[
0
].
hProcess
);
ok
(
ret
,
"AssignProcessToJobObject error %u
\n
"
,
GetLastError
());
dwret
=
WaitForSingleObject
(
pi
[
0
].
hProcess
,
1000
);
ok
(
dwret
==
WAIT_OBJECT_0
,
"WaitForSingleObject returned %u
\n
"
,
dwret
);
CloseHandle
(
pi
[
0
].
hProcess
);
CloseHandle
(
pi
[
0
].
hThread
);
create_process
(
"wait"
,
&
pi
[
0
]);
ret
=
pAssignProcessToJobObject
(
job
,
pi
[
0
].
hProcess
);
ok
(
ret
,
"AssignProcessToJobObject error %u
\n
"
,
GetLastError
());
create_process
(
"wait"
,
&
pi
[
1
]);
ret
=
pAssignProcessToJobObject
(
job
,
pi
[
1
].
hProcess
);
ok
(
ret
,
"AssignProcessToJobObject error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
QueryInformationJobObject
(
job
,
JobObjectBasicProcessIdList
,
pid_list
,
FIELD_OFFSET
(
JOBOBJECT_BASIC_PROCESS_ID_LIST
,
ProcessIdList
),
&
ret_len
);
ok
(
!
ret
,
"QueryInformationJobObject expected failure
\n
"
);
todo_wine
expect_eq_d
(
ERROR_BAD_LENGTH
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
memset
(
buf
,
0
,
sizeof
(
buf
));
pid_list
->
NumberOfAssignedProcesses
=
42
;
pid_list
->
NumberOfProcessIdsInList
=
42
;
ret
=
QueryInformationJobObject
(
job
,
JobObjectBasicProcessIdList
,
pid_list
,
FIELD_OFFSET
(
JOBOBJECT_BASIC_PROCESS_ID_LIST
,
ProcessIdList
[
1
]),
&
ret_len
);
ok
(
!
ret
,
"QueryInformationJobObject expected failure
\n
"
);
todo_wine
expect_eq_d
(
ERROR_MORE_DATA
,
GetLastError
());
if
(
ret
)
{
expect_eq_d
(
42
,
pid_list
->
NumberOfAssignedProcesses
);
expect_eq_d
(
42
,
pid_list
->
NumberOfProcessIdsInList
);
}
memset
(
buf
,
0
,
sizeof
(
buf
));
ret
=
pQueryInformationJobObject
(
job
,
JobObjectBasicProcessIdList
,
pid_list
,
sizeof
(
buf
),
&
ret_len
);
todo_wine
ok
(
ret
,
"QueryInformationJobObject error %u
\n
"
,
GetLastError
());
if
(
ret
)
{
if
(
pid_list
->
NumberOfAssignedProcesses
==
3
)
/* Win 8 */
win_skip
(
"Number of assigned processes broken on Win 8
\n
"
);
else
{
ULONG_PTR
*
list
=
pid_list
->
ProcessIdList
;
ok
(
ret_len
==
FIELD_OFFSET
(
JOBOBJECT_BASIC_PROCESS_ID_LIST
,
ProcessIdList
[
2
]),
"QueryInformationJobObject returned ret_len=%u
\n
"
,
ret_len
);
expect_eq_d
(
2
,
pid_list
->
NumberOfAssignedProcesses
);
expect_eq_d
(
2
,
pid_list
->
NumberOfProcessIdsInList
);
expect_eq_d
(
pi
[
0
].
dwProcessId
,
list
[
0
]);
expect_eq_d
(
pi
[
1
].
dwProcessId
,
list
[
1
]);
}
}
TerminateProcess
(
pi
[
0
].
hProcess
,
0
);
CloseHandle
(
pi
[
0
].
hProcess
);
CloseHandle
(
pi
[
0
].
hThread
);
TerminateProcess
(
pi
[
1
].
hProcess
,
0
);
CloseHandle
(
pi
[
1
].
hProcess
);
CloseHandle
(
pi
[
1
].
hThread
);
CloseHandle
(
job
);
}
START_TEST
(
process
)
{
BOOL
b
=
init
();
...
...
@@ -2242,6 +2329,11 @@ START_TEST(process)
ok
(
0
,
"Child process not killed
\n
"
);
return
;
}
else
if
(
!
strcmp
(
myARGV
[
2
],
"exit"
))
{
Sleep
(
100
);
return
;
}
ok
(
0
,
"Unexpected command %s
\n
"
,
myARGV
[
2
]);
return
;
...
...
@@ -2279,4 +2371,5 @@ START_TEST(process)
test_IsProcessInJob
();
test_TerminateJobObject
();
test_QueryInformationJobObject
();
}
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