Sebastian Lackner : ntdll/tests: Add more tests for SystemHandleInformation.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Dec 24 14:40:04 CST 2015
Module: wine
Branch: master
Commit: e4e906c871ffe3e4acc055d5158a8b971f212aea
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e4e906c871ffe3e4acc055d5158a8b971f212aea
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Mon Dec 21 12:51:49 2015 +0100
ntdll/tests: Add more tests for SystemHandleInformation.
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/tests/info.c | 54 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index a521447..3219dbb 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -474,30 +474,62 @@ static void test_query_module(void)
static void test_query_handle(void)
{
NTSTATUS status;
- ULONG ReturnLength;
+ ULONG ExpectedLength, ReturnLength;
ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
+ HANDLE EventHandle;
+ BOOL found;
+ INT i;
+
+ EventHandle = CreateEventA(NULL, FALSE, FALSE, NULL);
+ ok( EventHandle != NULL, "CreateEventA failed %u\n", GetLastError() );
/* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
+ ReturnLength = 0xdeadbeef;
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
+ ok( ReturnLength != 0xdeadbeef, "Expected valid ReturnLength\n" );
SystemInformationLength = ReturnLength;
shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
+
+ ReturnLength = 0xdeadbeef;
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
- if (status != STATUS_INFO_LENGTH_MISMATCH) /* vista */
+ while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
{
- ok( status == STATUS_SUCCESS,
- "Expected STATUS_SUCCESS, got %08x\n", status);
+ SystemInformationLength *= 2;
+ shi = HeapReAlloc(GetProcessHeap(), 0, shi, SystemInformationLength);
+ status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
+ }
+ ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
+ ExpectedLength = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION, Handle[shi->Count]);
+ todo_wine ok( ReturnLength == ExpectedLength || broken(ReturnLength == ExpectedLength - sizeof(DWORD)), /* Vista / 2008 */
+ "Expected length %u, got %u\n", ExpectedLength, ReturnLength );
+ todo_wine ok( shi->Count > 1, "Expected more than 1 handle, got %u\n", shi->Count );
+ for (i = 0, found = FALSE; i < shi->Count && !found; i++)
+ found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) &&
+ ((HANDLE)(ULONG_PTR)shi->Handle[i].HandleValue == EventHandle);
+ todo_wine ok( found, "Expected to find event handle in handle list\n" );
+
+ CloseHandle(EventHandle);
- /* Check if we have some return values */
- trace("Number of Handles : %d\n", shi->Count);
- todo_wine
- {
- /* our implementation is a stub for now */
- ok( shi->Count > 1, "Expected more than 1 handles, got (%d)\n", shi->Count);
- }
+ ReturnLength = 0xdeadbeef;
+ status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
+ while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
+ {
+ SystemInformationLength *= 2;
+ shi = HeapReAlloc(GetProcessHeap(), 0, shi, SystemInformationLength);
+ status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
}
+ ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
+ for (i = 0, found = FALSE; i < shi->Count && !found; i++)
+ found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) &&
+ ((HANDLE)(ULONG_PTR)shi->Handle[i].HandleValue == EventHandle);
+ ok( !found, "Unexpectedly found event handle in handle list\n" );
+
+ status = pNtQuerySystemInformation(SystemHandleInformation, NULL, SystemInformationLength, &ReturnLength);
+ ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status );
+
HeapFree( GetProcessHeap(), 0, shi);
}
More information about the wine-cvs
mailing list