Roman Pišl : kernel32/tests: Add test for GetConsoleProcessList.

Alexandre Julliard julliard at winehq.org
Tue Feb 15 16:07:20 CST 2022


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

Author: Roman Pišl <rpisl at seznam.cz>
Date:   Sat Feb 12 12:56:02 2022 +0100

kernel32/tests: Add test for GetConsoleProcessList.

Signed-off-by: Roman Pišl <rpisl at seznam.cz>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

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

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5443a611f80..5a399768d9e 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -1304,8 +1304,8 @@ static void test_GetConsoleProcessList(void)
        GetLastError());
 
     /* We should only have 1 process but only for these specific unit tests as
-     * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS) would
-     * give us two processes for example.
+     * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS)
+     * gives us two processes - see test_AttachConsole.
      */
     list = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
 
@@ -4354,6 +4354,27 @@ static void test_AttachConsole_child(DWORD console_pid)
     res = AttachConsole(ATTACH_PARENT_PROCESS);
     ok(res, "AttachConsole failed: %u\n", GetLastError());
 
+    if (pGetConsoleProcessList)
+    {
+        DWORD list[2] = { 0xbabebabe };
+        DWORD pid = GetCurrentProcessId();
+
+        SetLastError(0xdeadbeef);
+        len = pGetConsoleProcessList(list, 1);
+        todo_wine
+        ok(len == 2, "Expected 2 processes, got %d\n", len);
+        ok(list[0] == 0xbabebabe, "Unexpected value in list %u\n", list[0]);
+
+        len = pGetConsoleProcessList(list, 2);
+        todo_wine
+        ok(len == 2, "Expected 2 processes, got %d\n", len);
+        todo_wine
+        ok(list[0] == console_pid || list[1] == console_pid, "Parent PID not in list\n");
+        todo_wine
+        ok(list[0] == pid || list[1] == pid, "PID not in list\n");
+        ok(GetLastError() == 0xdeadbeef, "Unexpected last error: %u\n", GetLastError());
+    }
+
     ok(pipe_in != GetStdHandle(STD_INPUT_HANDLE), "std handle not set to console\n");
     ok(pipe_out != GetStdHandle(STD_OUTPUT_HANDLE), "std handle not set to console\n");
 




More information about the wine-cvs mailing list