Index: rosautotest/CWineTest.cpp =================================================================== --- modules/rostests_disabled/rosautotest/CWineTest.cpp (revision 64658) +++ modules/rostests_disabled/rosautotest/CWineTest.cpp (working copy) @@ -6,6 +6,7 @@ */ #include "precomp.h" +#include static const DWORD ListTimeout = 10000; @@ -260,13 +261,12 @@ void CWineTest::RunTest(CTestInfo* TestInfo) { - bool BreakLoop = false; DWORD BytesAvailable; - DWORD Temp; stringstream ss, ssFinish; DWORD StartTime = GetTickCount(); float TotalTime; string tailString; + char Buffer[1024]; ss << "Running Wine Test, Module: " << TestInfo->Module << ", Test: " << TestInfo->Test << endl; StringOut(ss.str()); @@ -276,39 +276,22 @@ { /* Execute the test */ CProcess Process(TestInfo->CommandLine, &m_StartupInfo); + CloseHandle(m_hWritePipe); + m_hWritePipe = NULL; /* Receive all the data from the pipe */ - do + while(ReadFile(m_hReadPipe, Buffer, sizeof(Buffer) - 1, &BytesAvailable, NULL) && BytesAvailable) { - /* When the application finished, make sure that we peek the pipe one more time, so that we get all data. - If the following condition would be the while() condition, we might hit a race condition: - - We check for data with PeekNamedPipe -> no data available - - The application outputs its data and finishes - - WaitForSingleObject reports that the application has finished and we break the loop without receiving any data - */ - if(WaitForSingleObject(Process.GetProcessHandle(), 0) != WAIT_TIMEOUT) - BreakLoop = true; + /* Output text through StringOut, even while the test is still running */ + Buffer[BytesAvailable] = 0; + tailString = StringOut(tailString.append(string(Buffer)), false); - if(!PeekNamedPipe(m_hReadPipe, NULL, 0, NULL, &BytesAvailable, NULL)) - FATAL("PeekNamedPipe failed for the test run\n"); - - if(BytesAvailable) - { - /* There is data, so get it and output it */ - auto_array_ptr Buffer(new char[BytesAvailable + 1]); - - if(!ReadFile(m_hReadPipe, Buffer, BytesAvailable, &Temp, NULL)) - FATAL("ReadFile failed for the test run\n"); - - /* Output text through StringOut, even while the test is still running */ - Buffer[BytesAvailable] = 0; - tailString = StringOut(tailString.append(string(Buffer)), false); - - if(Configuration.DoSubmit()) - TestInfo->Log += Buffer; - } + if(Configuration.DoSubmit()) + TestInfo->Log += Buffer; } - while(!BreakLoop); + printf("ReadFile last error %lu, avail %lu\n", GetLastError(), BytesAvailable); + if(GetLastError() != ERROR_BROKEN_PIPE) + FATAL("ReadFile failed for the test run\n"); } /* Print what's left */ Index: rosautotest/tools.cpp =================================================================== --- modules/rostests_disabled/rosautotest/tools.cpp (revision 64658) +++ modules/rostests_disabled/rosautotest/tools.cpp (working copy) @@ -95,6 +95,29 @@ string StringOut(const string& String, bool forcePrint) { + char Buffer[DBGPRINT_BUFSIZE + 1]; + size_t i; + size_t iBuf = 0;; + + (void)forcePrint; + for(i = 0; i < String.size(); i++) + { + if (String[i] == '\r') + continue; + Buffer[iBuf++] = String[i]; + if (iBuf == DBGPRINT_BUFSIZE) + { + Buffer[iBuf] = ANSI_NULL; + OutputDebugStringA(Buffer); + cout << Buffer; + iBuf = 0; + } + } + Buffer[iBuf] = ANSI_NULL; + OutputDebugStringA(Buffer); + cout << Buffer; + return string(); +#if 0 char DbgString[DBGPRINT_BUFSIZE + 1]; size_t i, start = 0, last_newline = 0, size = 0, curr_pos = 0; string NewString; @@ -161,6 +184,7 @@ /* Return the remaining chunk */ return NewString.substr(start, size); +#endif } /**