[PATCH] programs/conhost/tests: loosen up some tests (that fail on some VMs)

Eric Pouech eric.pouech at gmail.com
Sat Mar 12 09:16:01 CST 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52648
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 programs/conhost/tests/tty.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/programs/conhost/tests/tty.c b/programs/conhost/tests/tty.c
index 849986a1c29..fa1552b3299 100644
--- a/programs/conhost/tests/tty.c
+++ b/programs/conhost/tests/tty.c
@@ -453,8 +453,9 @@ static void child_expect_read_result_(unsigned int line, HANDLE pipe, const WCHA
     ok_(__FILE__,line)(!memcmp(expect, buf, count), "unexpected data %s\n", wine_dbgstr_w(buf));
 }
 
-#define child_expect_read_control_result(a,b,c) child_expect_read_control_result_(__LINE__,a,b,c)
-static void child_expect_read_control_result_(unsigned int line, HANDLE pipe, const WCHAR *expect, DWORD state)
+#define child_expect_read_control_result(a,b,c) child_expect_read_control_result_(__LINE__,a,b,c,c)
+#define child_expect_read_control_result_broken(a,b,c,d) child_expect_read_control_result_(__LINE__,a,b,c,d)
+static void child_expect_read_control_result_(unsigned int line, HANDLE pipe, const WCHAR *expect, DWORD state, DWORD altstate)
 {
     size_t exlen = wcslen(expect);
     WCHAR buf[4096];
@@ -468,7 +469,7 @@ static void child_expect_read_control_result_(unsigned int line, HANDLE pipe, co
                        count, sizeof(DWORD) + exlen * sizeof(WCHAR));
     buf[count / sizeof(WCHAR)] = 0;
     todo_wine_if(*(DWORD *)buf != state && *(DWORD *)buf == 0)
-    ok_(__FILE__,line)(*(DWORD *)buf == state, "keyboard state: got %lx, expected %lx\n", *(DWORD *)buf, state);
+    ok_(__FILE__,line)(*(DWORD *)buf == state || broken(*(DWORD *)buf == altstate), "keyboard state: got %lx, expected %lx\n", *(DWORD *)buf, state);
     ok_(__FILE__,line)(!memcmp(expect, ptr, count - sizeof(DWORD)), "unexpected data %s %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(expect));
 }
 
@@ -1359,10 +1360,12 @@ static void test_read_console_control(void)
         strcpy(buf, "def."); buf[3] = ctrl;
         write_console_pipe(buf);
         wcscpy(bufw, L"abcdef."); bufw[6] = (WCHAR)ctrl;
-        child_expect_read_control_result(child_pipe, bufw,
-                                         (ctrl == '\t' || ctrl == '\r') ? 0
-                                         : ((ctrl == 30 || ctrl == 31) ? (LEFT_CTRL_PRESSED | SHIFT_PRESSED)
-                                            : LEFT_CTRL_PRESSED));
+        if (ctrl == 30 || ctrl == 31)
+            child_expect_read_control_result_broken(child_pipe, bufw,
+                                              LEFT_CTRL_PRESSED | SHIFT_PRESSED, LEFT_CTRL_PRESSED);
+        else
+            child_expect_read_control_result(child_pipe, bufw,
+                                             (ctrl == '\t' || ctrl == '\r') ? 0 : LEFT_CTRL_PRESSED);
         skip_sequence("\x1b[?25l"); /* hide cursor */
         expect_output_sequence("def");
         skip_sequence("\x1b[?25h"); /* show cursor */




More information about the wine-devel mailing list