mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:35:43 +00:00
- use timeout to define maximum runtime of emulator
svn path=/trunk/; revision=24587
This commit is contained in:
parent
74847bd6f5
commit
ee5b1449f9
5 changed files with 79 additions and 18 deletions
|
@ -85,7 +85,7 @@ namespace System_
|
|||
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
bool PipeReader::isEof() const
|
||||
bool PipeReader::isEof()
|
||||
{
|
||||
return feof(m_File);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace System_
|
|||
/// Description: returns true if the pipe has reached end of file. The caller should call
|
||||
/// closePipe if this function returns true
|
||||
|
||||
bool isEof() const;
|
||||
bool isEof();
|
||||
|
||||
protected:
|
||||
FILE * m_File;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "pipe_reader.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include <float.h>
|
||||
|
||||
namespace Sysreg_
|
||||
{
|
||||
|
@ -37,8 +39,10 @@ namespace Sysreg_
|
|||
string RosBootTest::CLASS_NAME = _T("rosboot");
|
||||
string RosBootTest::DEBUG_PORT = _T("ROSBOOT_DEBUG_PORT");
|
||||
string RosBootTest::DEBUG_FILE = _T("ROSBOOT_DEBUG_FILE");
|
||||
string RosBootTest::TIME_OUT = _T("ROSBOOT_TIME_OUT");
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME)
|
||||
RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME), m_Timeout(60.0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -54,6 +58,7 @@ namespace Sysreg_
|
|||
{
|
||||
string boot_cmd;
|
||||
string debug_port;
|
||||
string timeout;
|
||||
bool ret;
|
||||
|
||||
if (!conf_parser.getStringValue (RosBootTest::DEBUG_PORT, debug_port))
|
||||
|
@ -67,6 +72,17 @@ namespace Sysreg_
|
|||
return false;
|
||||
}
|
||||
|
||||
if (conf_parser.getStringValue(RosBootTest::TIME_OUT, timeout))
|
||||
{
|
||||
TCHAR * stop;
|
||||
m_Timeout = _tcstod(timeout.c_str (), &stop);
|
||||
if (_isnan(m_Timeout) || m_Timeout == 0.0)
|
||||
{
|
||||
cerr << "Warning: overriding timeout with default of 60 sec" << endl;
|
||||
m_Timeout = 60.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_tcscmp(debug_port.c_str(), _T("pipe")))
|
||||
{
|
||||
ret = fetchDebugByPipe(boot_cmd);
|
||||
|
@ -102,9 +118,34 @@ namespace Sysreg_
|
|||
/// TBD the information needs to be written into an provided log object
|
||||
/// which writes the info into HTML/log / sends etc ....
|
||||
|
||||
cerr << debug_data << endl;
|
||||
// cerr << debug_data << endl;
|
||||
return true;
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
bool RosBootTest::isTimeout(double max_timeout)
|
||||
{
|
||||
static time_t start = 0;
|
||||
|
||||
if (!start)
|
||||
{
|
||||
time(&start);
|
||||
return false;
|
||||
}
|
||||
|
||||
time_t stop;
|
||||
time(&stop);
|
||||
|
||||
double elapsed = difftime(stop, start);
|
||||
if (elapsed > max_timeout)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
bool RosBootTest::fetchDebugByPipe(string boot_cmd)
|
||||
|
@ -120,26 +161,34 @@ namespace Sysreg_
|
|||
string Buffer;
|
||||
Buffer.reserve (10000);
|
||||
|
||||
// gettimeofday(&ts, NULL);
|
||||
bool ret = true;
|
||||
|
||||
while(!pipe_reader.isEof ())
|
||||
{
|
||||
pipe_reader.readPipe (Buffer);
|
||||
if (!checkDebugData(Buffer))
|
||||
if (isTimeout(m_Timeout))
|
||||
{
|
||||
break;
|
||||
}
|
||||
//if (hasTimeout(&ts, 60000)
|
||||
|
||||
string::size_type size = pipe_reader.readPipe (Buffer);
|
||||
cerr << "XXXsize_type " << size <<endl;
|
||||
|
||||
|
||||
if (!checkDebugData(Buffer))
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pipe_reader.closePipe ();
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
bool RosBootTest::fetchDebugByFile(Sysreg_::string boot_cmd, Sysreg_::string debug_log)
|
||||
{
|
||||
PipeReader pipe_reader;
|
||||
|
||||
_tremove(debug_log.c_str ());
|
||||
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt"))))
|
||||
{
|
||||
cerr << "Error: failed to open pipe with cmd: " << boot_cmd << endl;
|
||||
|
@ -154,21 +203,27 @@ namespace Sysreg_
|
|||
}
|
||||
|
||||
TCHAR szBuffer[500];
|
||||
bool ret = true;
|
||||
|
||||
do
|
||||
while(!pipe_reader.isEof ())
|
||||
{
|
||||
if (_fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), file))
|
||||
{
|
||||
string buffer = szBuffer;
|
||||
if (!checkDebugData(buffer))
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
if (isTimeout(m_Timeout))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(!pipe_reader.isEof ());
|
||||
}
|
||||
|
||||
pipe_reader.closePipe ();
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end of namespace Sysreg_
|
|
@ -30,6 +30,7 @@ namespace Sysreg_
|
|||
static string CLASS_NAME;
|
||||
static string DEBUG_PORT;
|
||||
static string DEBUG_FILE;
|
||||
static string TIME_OUT;
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -101,15 +102,20 @@ namespace Sysreg_
|
|||
|
||||
bool checkDebugData(string debug_data);
|
||||
|
||||
}; // end of class RosBootTest
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// checkTimeOut
|
||||
///
|
||||
/// Description: this function checks if the the application has already hung
|
||||
/// Description: this function checks if the ReactOS has run longer than the maximum available
|
||||
/// time
|
||||
|
||||
bool checkTimeOut(struct timeval * ts, unsigned max_timeout);
|
||||
bool isTimeout(double max_timeout);
|
||||
|
||||
protected:
|
||||
|
||||
double m_Timeout;
|
||||
|
||||
}; // end of class RosBootTest
|
||||
|
||||
} // end of namespace Sysreg_
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace System_
|
|||
path.insert (path.length () -1, _T("\\"));
|
||||
path.insert (path.length () -1, filename);
|
||||
|
||||
cerr << "Module Name " << modulename << endl << "File Name " << filename << endl;
|
||||
cerr << "Module Name " << modulename << endl << "File Name " << path << endl;
|
||||
|
||||
m_Map.insert(std::make_pair<string, string>(modulename, path));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue