[PATCH] kernel32/tests: Test console input instead of stdin in test_ReadConsole.

Alex Henrie alexhenrie24 at gmail.com
Thu Nov 2 15:10:25 CDT 2017


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
Fixes test failures on both Windows and Linux (bug 43952).

If stdin is connected to a pipe when the ReadConsole tests run (a common
testing configuration although it's not clear why AllocConsole doesn't
reconnect stdin to the console window input), these tests fail because
they are trying to test the properties of a console input handle, which
are different from the properties of a pipe input handle.
---
 dlls/kernel32/tests/console.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index a14bc45034..0e8e559541 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2572,16 +2572,13 @@ static void test_ReadConsoleOutputAttribute(HANDLE output_handle)
     ok(count == 1, "Expected count to be 1, got %u\n", count);
 }
 
-static void test_ReadConsole(void)
+static void test_ReadConsole(HANDLE input_handle)
 {
-    HANDLE std_input;
     DWORD ret, bytes;
     char buf[1024];
 
-    std_input = GetStdHandle(STD_INPUT_HANDLE);
-
     SetLastError(0xdeadbeef);
-    ret = GetFileSize(std_input, NULL);
+    ret = GetFileSize(input_handle, NULL);
     ok(ret == INVALID_FILE_SIZE, "expected INVALID_FILE_SIZE, got %#x\n", ret);
     ok(GetLastError() == ERROR_INVALID_HANDLE ||
        GetLastError() == ERROR_INVALID_FUNCTION, /* Win 8, 10 */
@@ -2589,7 +2586,7 @@ static void test_ReadConsole(void)
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
-    ret = ReadFile(std_input, buf, -128, &bytes, NULL);
+    ret = ReadFile(input_handle, buf, -128, &bytes, NULL);
     ok(!ret, "expected 0, got %u\n", ret);
     ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
        GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
@@ -2598,7 +2595,7 @@ static void test_ReadConsole(void)
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
-    ret = ReadConsoleA(std_input, buf, -128, &bytes, NULL);
+    ret = ReadConsoleA(input_handle, buf, -128, &bytes, NULL);
     ok(!ret, "expected 0, got %u\n", ret);
     ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
        GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
@@ -2607,7 +2604,7 @@ static void test_ReadConsole(void)
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
-    ret = ReadConsoleW(std_input, buf, -128, &bytes, NULL);
+    ret = ReadConsoleW(input_handle, buf, -128, &bytes, NULL);
     ok(!ret, "expected 0, got %u\n", ret);
     ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
        GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
@@ -3107,7 +3104,7 @@ START_TEST(console)
     ok(sbi.dwSize.Y == size, "Unexpected buffer size: %d instead of %d\n", sbi.dwSize.Y, size);
     if (!ret) return;
 
-    test_ReadConsole();
+    test_ReadConsole(hConIn);
     /* Non interactive tests */
     testCursor(hConOut, sbi.dwSize);
     /* test parameters (FIXME: test functionality) */
-- 
2.14.2




More information about the wine-patches mailing list