[PATCH 0/1] MR5123: kernel32/tests: Fix console test with odd-sized consoles.
From: Jinoh Kang <jinoh.kang.kr(a)gmail.com> --- dlls/kernel32/tests/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 2904a31d014..364d0ae2561 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -545,8 +545,8 @@ static void doChild(const char* file, const char* option) ok( ret, "Setting mode (%ld)\n", GetLastError()); ret = SetConsoleMode(hConOut, modeOut ^ 1); ok( ret, "Setting mode (%ld)\n", GetLastError()); - sbi.dwCursorPosition.X ^= 1; - sbi.dwCursorPosition.Y ^= 1; + sbi.dwCursorPosition.X = (sbi.dwCursorPosition.X ^ 1) % sbi.dwSize.X; + sbi.dwCursorPosition.Y = (sbi.dwCursorPosition.Y ^ 1) % sbi.dwSize.Y; ret = SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition); ok( ret, "Setting cursor position (%ld)\n", GetLastError()); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5123
eric pouech (@epo) commented about dlls/kernel32/tests/process.c:
ok( ret, "Setting mode (%ld)\n", GetLastError()); ret = SetConsoleMode(hConOut, modeOut ^ 1); ok( ret, "Setting mode (%ld)\n", GetLastError()); - sbi.dwCursorPosition.X ^= 1; - sbi.dwCursorPosition.Y ^= 1; + sbi.dwCursorPosition.X = (sbi.dwCursorPosition.X ^ 1) % sbi.dwSize.X; + sbi.dwCursorPosition.Y = (sbi.dwCursorPosition.Y ^ 1) % sbi.dwSize.Y;
afaict, there's no explicit check to avoid 0 sized screen buffers in either dimension (right click inside a console let you change window&sb size to eg. (0,1)) so I'm not 100% confident that the modular operation will not yield a division by zero exception perhaps something like (untested) ``` sbi.dwCursorPosition.X = !sbi.dwCursorPosition.X; ``` would be sufficient (the test only checks in parent that it gets same position as the one set by child) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5123#note_62052
0 sized screen buffers in either dimension
In this case, `SetConsoleCursorPosition` will alwaya fail since even `(0, 0)` is out of bounds. Maybe just skip this test? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5123#note_62059
On Tue Feb 20 14:40:17 2024 +0000, Jinoh Kang wrote:
0 sized screen buffers in either dimension In this case, `SetConsoleCursorPosition` will alwaya fail since even `(0, 0)` is out of bounds. Maybe just skip this test? Actually I don't think this is a problem. If size is 0 (either dim), the test already fails w/o this patch. The modulo just turns test failure into a div exception.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/5123#note_62060
participants (3)
-
eric pouech (@epo) -
Jinoh Kang -
Jinoh Kang (@iamahuman)