ntdll/tests: Test return values from CloseHandle.

Signed-off-by: Daniel Lehman <dlehman25@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2022-04-03 00:13:35 -07:00 committed by Alexandre Julliard
parent bae702a0ee
commit 18f46e5a57
1 changed files with 16 additions and 4 deletions

View File

@ -8606,7 +8606,9 @@ static inline BOOL is_magic_handle(HANDLE handle)
static void test_closehandle(DWORD numexc, HANDLE handle)
{
NTSTATUS status, expect;
PVOID vectored_handler;
BOOL ret, expectret;
if (!pRtlAddVectoredExceptionHandler || !pRtlRemoveVectoredExceptionHandler || !pRtlRaiseException)
{
@ -8618,18 +8620,28 @@ static void test_closehandle(DWORD numexc, HANDLE handle)
ok(vectored_handler != 0, "RtlAddVectoredExceptionHandler failed\n");
invalid_handle_exceptions = 0;
CloseHandle(handle);
todo_wine_if(is_magic_handle(handle))
expectret = is_magic_handle(handle) || broken(numexc && sizeof(handle) == 4); /* < Win10 */
ret = CloseHandle(handle);
ok(expectret || (GetLastError() == ERROR_INVALID_HANDLE),
"CloseHandle had wrong GetLastError(), got %lu for %p\n", GetLastError(), handle);
todo_wine_if(is_magic_handle(handle)) {
ok(ret == expectret || broken(HandleToLong(handle) < 0) /* < Win10 */,
"CloseHandle expected %d, got %d for %p\n", expectret, ret, handle);
ok(invalid_handle_exceptions == numexc || broken(!numexc && is_magic_handle(handle)), /* < Win10 */
"CloseHandle generated %ld exceptions, expected %ld for %p\n",
invalid_handle_exceptions, numexc, handle);
}
invalid_handle_exceptions = 0;
pNtClose(handle);
todo_wine_if(is_magic_handle(handle))
expect = expectret ? STATUS_SUCCESS : STATUS_INVALID_HANDLE;
status = pNtClose(handle);
todo_wine_if(is_magic_handle(handle)) {
ok(status == expect || broken(HandleToLong(handle) < 0), /* < Win10 */
"NtClose returned unexpected status %#lx, expected %#lx for %p\n", status, expect, handle);
ok(invalid_handle_exceptions == numexc || broken(!numexc && is_magic_handle(handle)), /* < Win10 */
"CloseHandle generated %ld exceptions, expected %ld for %p\n",
invalid_handle_exceptions, numexc, handle);
}
pRtlRemoveVectoredExceptionHandler(vectored_handler);
}