Daniel Lehman : ntdll/tests: Test return values from CloseHandle.
Alexandre Julliard
julliard at winehq.org
Thu Apr 7 16:19:08 CDT 2022
Module: wine
Branch: master
Commit: 18f46e5a57b6c7655dd0c75e89083cf76e67cf9d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=18f46e5a57b6c7655dd0c75e89083cf76e67cf9d
Author: Daniel Lehman <dlehman25 at gmail.com>
Date: Sun Apr 3 00:13:35 2022 -0700
ntdll/tests: Test return values from CloseHandle.
Signed-off-by: Daniel Lehman <dlehman25 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/tests/exception.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index 98d185f5f07..8af8d6b70da 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -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);
}
More information about the wine-cvs
mailing list