From fb8530edc1841f74144038dc5ac9abcbd05cc251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= <davispuh@gmail.com> Date: Sun, 18 Sep 2016 21:40:34 +0300 Subject: [PATCH] ConsoleBuf: Make test more reliable Change-Id: I3a726be174f9799e85d34243182e80cb35c655b5 --- testConsoleBuf.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testConsoleBuf.cxx b/testConsoleBuf.cxx index 59d5633..c5b3b85 100644 --- a/testConsoleBuf.cxx +++ b/testConsoleBuf.cxx @@ -479,14 +479,14 @@ static int testConsole() securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); securityAttributes.bInheritHandle = TRUE; securityAttributes.lpSecurityDescriptor = NULL; - hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, 0, + hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes, OPEN_EXISTING, 0, NULL); - hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, if (hIn == INVALID_HANDLE_VALUE) { DWORD lastError = GetLastError(); std::cerr << "CreateFile(CONIN$)" << std::endl; displayError(lastError); } + hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes, OPEN_EXISTING, 0, NULL); if (hOut == INVALID_HANDLE_VALUE) { DWORD lastError = GetLastError(); @@ -555,6 +555,8 @@ static int testConsole() } writeInputKeyEvent(&inputBuffer[i*2], VK_RETURN); DWORD eventsWritten = 0; + // We need to wait a bit before writing to console so child process have started waiting for input on stdin. + Sleep(300); if (!WriteConsoleInputW(hIn, inputBuffer, sizeof(inputBuffer) / sizeof(inputBuffer[0]), &eventsWritten) || eventsWritten == 0) { -- GitLab