[4/5] kernel32: Add a test for threads state after NtTerminateProcess(0) call.

Dmitry Timoshkov dmitry at baikal.ru
Thu Apr 11 04:15:23 CDT 2013


---
 dlls/kernel32/tests/loader.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 5aea940..521aafc 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -33,6 +33,7 @@
 
 static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T, const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG);
 static NTSTATUS (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID);
+static NTSTATUS (WINAPI *pNtTerminateProcess)(HANDLE, DWORD);
 
 static PVOID RVAToAddr(DWORD_PTR rva, HMODULE module)
 {
@@ -1100,9 +1101,10 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
 static void child_process(const char *dll_name, DWORD target_offset)
 {
     void *target;
-    DWORD ret, dummy;
+    DWORD ret, dummy, i, code;
     HANDLE file, thread, event;
     HMODULE hmod;
+    NTSTATUS status;
 
     trace("writing %p at %#x\n", dll_entry_point, target_offset);
 
@@ -1144,6 +1146,38 @@ static void child_process(const char *dll_name, DWORD target_offset)
     CloseHandle(event);
 
     Sleep(100);
+
+    ok(attached_thread_count != 0, "attached thread count should not be 0\n");
+    for (i = 0; i < attached_thread_count; i++)
+    {
+        ret = GetExitCodeThread(attached_thread[i], &code);
+        trace("child: GetExitCodeThread(%u) => %d,%u\n", i, ret, code);
+        ok(ret == 1, "GetExitCodeThread returned %d, expected 1\n", ret);
+        ok(code == STILL_ACTIVE, "expected thread exit code STILL_ACTIVE, got %u\n", code);
+    }
+
+    Sleep(100);
+
+    SetLastError(0xdeadbeef);
+    ret = TerminateProcess(0, 195);
+    ok(!ret, "TerminateProcess(0) should fail\n");
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+
+    status = pNtTerminateProcess(0, 195);
+todo_wine
+    ok(!status, "NtTerminateProcess error %#x\n", status);
+
+    Sleep(100);
+
+    for (i = 0; i < attached_thread_count; i++)
+    {
+        ret = GetExitCodeThread(attached_thread[i], &code);
+        trace("child: GetExitCodeThread(%u) => %d,%u\n", i, ret, code);
+        ok(ret == 1, "GetExitCodeThread returned %d, expected 1\n", ret);
+todo_wine
+        ok(code == 195, "expected thread exit code 195, got %u\n", code);
+    }
+
     trace("call ExitProcess()\n");
     ExitProcess(195);
 }
@@ -1258,6 +1292,7 @@ START_TEST(loader)
 
     pNtMapViewOfSection = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtMapViewOfSection");
     pNtUnmapViewOfSection = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtUnmapViewOfSection");
+    pNtTerminateProcess = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtTerminateProcess");
 
     argc = winetest_get_mainargs(&argv);
     if (argc > 3)
-- 
1.8.2.1




More information about the wine-patches mailing list