Eric Pouech : kernel32/tests: Test resetting ctrl-c handlers on some console APIs.

Alexandre Julliard julliard at winehq.org
Thu Dec 23 16:01:32 CST 2021


Module: wine
Branch: master
Commit: 508e97a2498ac4770ccffb81068126d4fa63efb4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=508e97a2498ac4770ccffb81068126d4fa63efb4

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Fri Dec 17 14:13:46 2021 +0100

kernel32/tests: Test resetting ctrl-c handlers on some console APIs.

AllocConsole(), AttachConsole() and FreeConsole() should reset ctrl
handlers' list.

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/console.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 8b5abfa2da9..e4d9d43f4c4 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -123,6 +123,12 @@ static void resetContent(HANDLE hCon, COORD sbSize, BOOL content)
     }
 }
 
+/* dummy console ctrl handler to test reset of ctrl handler's list */
+static BOOL WINAPI mydummych(DWORD event)
+{
+    return TRUE;
+}
+
 static void testCursor(HANDLE hCon, COORD sbSize)
 {
     COORD		c;
@@ -4060,6 +4066,9 @@ static void test_FreeConsole(void)
     BOOL ret;
 
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n");
+    ok(!SetConsoleCtrlHandler(mydummych, FALSE), "dummy ctrl handler shouldn't be set\n");
+    ret = SetConsoleCtrlHandler(mydummych, TRUE);
+    ok(ret, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
     if (!skip_nt)
     {
         unbound_input  = create_unbound_handle(FALSE, TRUE);
@@ -4169,6 +4178,9 @@ static void test_FreeConsole(void)
     type = GetFileType(unbound_output);
     ok(type == FILE_TYPE_CHAR, "GetFileType returned %u\n", type);
 
+    todo_wine
+    ok(!SetConsoleCtrlHandler(mydummych, FALSE), "FreeConsole() should have reset ctrl handlers' list\n");
+
     CloseHandle(unbound_input);
     CloseHandle(unbound_output);
 }
@@ -4312,6 +4324,10 @@ static void test_AttachConsole_child(DWORD console_pid)
 
     SetStdHandle(STD_ERROR_HANDLE, pipe_out);
 
+    ok(!SetConsoleCtrlHandler(mydummych, FALSE), "dummy ctrl handler shouldn't be set\n");
+    res = SetConsoleCtrlHandler(mydummych, TRUE);
+    ok(res, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
+
     res = AttachConsole(console_pid);
     ok(res, "AttachConsole failed: %u\n", GetLastError());
 
@@ -4326,6 +4342,9 @@ static void test_AttachConsole_child(DWORD console_pid)
     ok(len == 6, "len = %u\n", len);
     ok(!memcmp(buf, "Parent", 6), "Unexpected console output\n");
 
+    todo_wine
+    ok(!SetConsoleCtrlHandler(mydummych, FALSE), "AttachConsole() should have reset ctrl handlers' list\n");
+
     res = FreeConsole();
     ok(res, "FreeConsole failed: %u\n", GetLastError());
 
@@ -4416,6 +4435,9 @@ static void test_AllocConsole_child(void)
     res = GetConsoleMode(unbound_output, &mode);
     ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %u\n", GetLastError());
 
+    ok(!SetConsoleCtrlHandler(mydummych, FALSE), "dummy ctrl handler shouldn't be set\n");
+    res = SetConsoleCtrlHandler(mydummych, TRUE);
+    ok(res, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
     res = AllocConsole();
     ok(res, "AllocConsole failed: %u\n", GetLastError());
 
@@ -4428,6 +4450,9 @@ static void test_AllocConsole_child(void)
     res = GetConsoleMode(unbound_output, &mode);
     ok(res, "GetConsoleMode failed: %u\n", GetLastError());
 
+    todo_wine
+    ok(!SetConsoleCtrlHandler(mydummych, FALSE), "AllocConsole() should have reset ctrl handlers' list\n");
+
     FreeConsole();
     SetStdHandle(STD_OUTPUT_HANDLE, NULL);
     SetStdHandle(STD_ERROR_HANDLE, NULL);




More information about the wine-cvs mailing list