Index: modules/rostests/rosautotest/CWineTest.cpp =================================================================== --- modules/rostests/rosautotest/CWineTest.cpp (revision 64595) +++ modules/rostests/rosautotest/CWineTest.cpp (working copy) @@ -260,13 +260,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 +275,21 @@ { /* 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); + if(GetLastError() != ERROR_BROKEN_PIPE) + FATAL("ReadFile failed for the test run\n"); } /* Print what's left */