Skip to content

Commit 89932f2

Browse files
committed
[KERNEL32_WINETEST] Sync with Wine Staging 1.9.18.
svn path=/trunk/; revision=72611
1 parent 9018c6f commit 89932f2

File tree

8 files changed

+640
-154
lines changed

8 files changed

+640
-154
lines changed

rostests/winetests/kernel32/console.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,58 @@ static void testScreenBuffer(HANDLE hConOut)
908908
SetConsoleOutputCP(oldcp);
909909
}
910910

911+
static void CALLBACK signaled_function(void *p, BOOLEAN timeout)
912+
{
913+
HANDLE event = p;
914+
SetEvent(event);
915+
ok(!timeout, "wait shouldn't have timed out\n");
916+
}
917+
918+
static void testWaitForConsoleInput(HANDLE input_handle)
919+
{
920+
HANDLE wait_handle;
921+
HANDLE complete_event;
922+
INPUT_RECORD record;
923+
DWORD events_written;
924+
DWORD wait_ret;
925+
BOOL ret;
926+
927+
complete_event = CreateEventW(NULL, FALSE, FALSE, NULL);
928+
929+
/* Test success case */
930+
ret = RegisterWaitForSingleObject(&wait_handle, input_handle, signaled_function, complete_event, INFINITE, WT_EXECUTEONLYONCE);
931+
ok(ret == TRUE, "Expected RegisterWaitForSingleObject to return TRUE, got %d\n", ret);
932+
/* give worker thread a chance to start up */
933+
Sleep(100);
934+
record.EventType = KEY_EVENT;
935+
record.Event.KeyEvent.bKeyDown = 1;
936+
record.Event.KeyEvent.wRepeatCount = 1;
937+
record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
938+
record.Event.KeyEvent.wVirtualScanCode = VK_RETURN;
939+
record.Event.KeyEvent.uChar.UnicodeChar = '\r';
940+
record.Event.KeyEvent.dwControlKeyState = 0;
941+
ret = WriteConsoleInputW(input_handle, &record, 1, &events_written);
942+
ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
943+
wait_ret = WaitForSingleObject(complete_event, INFINITE);
944+
ok(wait_ret == WAIT_OBJECT_0, "Expected the handle to be signaled\n");
945+
ret = UnregisterWait(wait_handle);
946+
/* If the callback is still running, this fails with ERROR_IO_PENDING, but
947+
that's ok and expected. */
948+
ok(ret != 0 || GetLastError() == ERROR_IO_PENDING,
949+
"UnregisterWait failed with error %d\n", GetLastError());
950+
951+
/* Test timeout case */
952+
FlushConsoleInputBuffer(input_handle);
953+
ret = RegisterWaitForSingleObject(&wait_handle, input_handle, signaled_function, complete_event, INFINITE, WT_EXECUTEONLYONCE);
954+
wait_ret = WaitForSingleObject(complete_event, 100);
955+
ok(wait_ret == WAIT_TIMEOUT, "Expected the wait to time out\n");
956+
ret = UnregisterWait(wait_handle);
957+
ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
958+
959+
/* Clean up */
960+
ok(CloseHandle(complete_event), "Failed to close event handle, last error %d\n", GetLastError());
961+
}
962+
911963
static void test_GetSetConsoleInputExeName(void)
912964
{
913965
BOOL ret;
@@ -2938,6 +2990,55 @@ static void test_SetConsoleFont(HANDLE std_output)
29382990
todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
29392991
}
29402992

2993+
static void test_GetConsoleScreenBufferInfoEx(HANDLE std_output)
2994+
{
2995+
HANDLE hmod;
2996+
BOOL (WINAPI *pGetConsoleScreenBufferInfoEx)(HANDLE, CONSOLE_SCREEN_BUFFER_INFOEX *);
2997+
CONSOLE_SCREEN_BUFFER_INFOEX csbix;
2998+
BOOL ret;
2999+
HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE);
3000+
3001+
hmod = GetModuleHandleA("kernel32.dll");
3002+
pGetConsoleScreenBufferInfoEx = (void *)GetProcAddress(hmod, "GetConsoleScreenBufferInfoEx");
3003+
if (!pGetConsoleScreenBufferInfoEx)
3004+
{
3005+
win_skip("GetConsoleScreenBufferInfoEx is not available\n");
3006+
return;
3007+
}
3008+
3009+
SetLastError(0xdeadbeef);
3010+
ret = pGetConsoleScreenBufferInfoEx(NULL, &csbix);
3011+
ok(!ret, "got %d, expected zero\n", ret);
3012+
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
3013+
3014+
SetLastError(0xdeadbeef);
3015+
ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
3016+
ok(!ret, "got %d, expected zero\n", ret);
3017+
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
3018+
3019+
SetLastError(0xdeadbeef);
3020+
ret = pGetConsoleScreenBufferInfoEx(std_output, &csbix);
3021+
ok(!ret, "got %d, expected zero\n", ret);
3022+
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
3023+
3024+
csbix.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
3025+
3026+
SetLastError(0xdeadbeef);
3027+
ret = pGetConsoleScreenBufferInfoEx(NULL, &csbix);
3028+
ok(!ret, "got %d, expected zero\n", ret);
3029+
ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
3030+
3031+
SetLastError(0xdeadbeef);
3032+
ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
3033+
ok(!ret, "got %d, expected zero\n", ret);
3034+
ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
3035+
3036+
SetLastError(0xdeadbeef);
3037+
ret = pGetConsoleScreenBufferInfoEx(std_output, &csbix);
3038+
ok(ret, "got %d, expected non-zero\n", ret);
3039+
ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
3040+
}
3041+
29413042
START_TEST(console)
29423043
{
29433044
static const char font_name[] = "Lucida Console";
@@ -3044,6 +3145,8 @@ START_TEST(console)
30443145
testScroll(hConOut, sbi.dwSize);
30453146
/* will test sb creation / modification / codepage handling */
30463147
testScreenBuffer(hConOut);
3148+
/* Test waiting for a console handle */
3149+
testWaitForConsoleInput(hConIn);
30473150

30483151
/* clear duplicated console font table */
30493152
CloseHandle(hConIn);
@@ -3086,4 +3189,5 @@ START_TEST(console)
30863189
test_GetLargestConsoleWindowSize(hConOut);
30873190
test_GetConsoleFontInfo(hConOut);
30883191
test_SetConsoleFont(hConOut);
3192+
test_GetConsoleScreenBufferInfoEx(hConOut);
30893193
}

rostests/winetests/kernel32/fiber.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,20 @@ static void test_FiberHandling(void)
155155
ok(fiberCount == 1, "Wrong fiber count: %d\n", fiberCount);
156156
pDeleteFiber(fibers[1]);
157157

158-
if (!pCreateFiberEx)
158+
if (pCreateFiberEx)
159159
{
160-
win_skip( "CreateFiberEx not present\n" );
161-
return;
162-
}
163-
164-
fibers[1] = pCreateFiberEx(0,0,0,FiberMainProc,&testparam);
165-
ok(fibers[1] != NULL, "CreateFiberEx failed with error %u\n", GetLastError());
166-
167-
pSwitchToFiber(fibers[1]);
168-
ok(fiberCount == 2, "Wrong fiber count: %d\n", fiberCount);
169-
pDeleteFiber(fibers[1]);
160+
fibers[1] = pCreateFiberEx(0,0,0,FiberMainProc,&testparam);
161+
ok(fibers[1] != NULL, "CreateFiberEx failed with error %u\n", GetLastError());
170162

171-
if (!pIsThreadAFiber)
172-
{
173-
win_skip( "IsThreadAFiber not present\n" );
174-
return;
163+
pSwitchToFiber(fibers[1]);
164+
ok(fiberCount == 2, "Wrong fiber count: %d\n", fiberCount);
165+
pDeleteFiber(fibers[1]);
175166
}
167+
else win_skip( "CreateFiberEx not present\n" );
176168

177-
ok(pIsThreadAFiber(), "IsThreadAFiber reported FALSE\n");
169+
if (pIsThreadAFiber) ok(pIsThreadAFiber(), "IsThreadAFiber reported FALSE\n");
178170
test_ConvertFiberToThread();
179-
ok(!pIsThreadAFiber(), "IsThreadAFiber reported TRUE\n");
171+
if (pIsThreadAFiber) ok(!pIsThreadAFiber(), "IsThreadAFiber reported TRUE\n");
180172
}
181173

182174
static void test_FiberLocalStorage(void)

rostests/winetests/kernel32/file.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,17 +4449,10 @@ static void test_file_access(void)
44494449
else
44504450
{
44514451
/* FIXME: Remove once Wine is fixed */
4452-
if ((td[j].access & (GENERIC_READ | GENERIC_WRITE)) ||
4453-
(!(td[i].access & (GENERIC_WRITE | FILE_WRITE_DATA)) && (td[j].access & FILE_WRITE_DATA)) ||
4454-
(!(td[i].access & (GENERIC_READ | FILE_READ_DATA)) && (td[j].access & FILE_READ_DATA)) ||
4455-
(!(td[i].access & (GENERIC_WRITE)) && (td[j].access & FILE_APPEND_DATA)))
4456-
{
4457-
todo_wine
4458-
ok(!ret, "DuplicateHandle(%#x => %#x) should fail\n", td[i].access, td[j].access);
4459-
todo_wine
4460-
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
4461-
}
4462-
else
4452+
todo_wine_if((td[j].access & (GENERIC_READ | GENERIC_WRITE) ||
4453+
(!(td[i].access & (GENERIC_WRITE | FILE_WRITE_DATA)) && (td[j].access & FILE_WRITE_DATA)) ||
4454+
(!(td[i].access & (GENERIC_READ | FILE_READ_DATA)) && (td[j].access & FILE_READ_DATA)) ||
4455+
(!(td[i].access & (GENERIC_WRITE)) && (td[j].access & FILE_APPEND_DATA))))
44634456
{
44644457
ok(!ret, "DuplicateHandle(%#x => %#x) should fail\n", td[i].access, td[j].access);
44654458
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());

0 commit comments

Comments
 (0)