Author: janderwald
Date: Sat Oct 21 01:14:08 2006
New Revision: 24587
URL:
http://svn.reactos.org/svn/reactos?rev=24587&view=rev
Log:
- use timeout to define maximum runtime of emulator
Modified:
trunk/reactos/tools/sysreg/pipe_reader.cpp
trunk/reactos/tools/sysreg/pipe_reader.h
trunk/reactos/tools/sysreg/rosboot_test.cpp
trunk/reactos/tools/sysreg/rosboot_test.h
trunk/reactos/tools/sysreg/sym_file.cpp
Modified: trunk/reactos/tools/sysreg/pipe_reader.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.c…
==============================================================================
--- trunk/reactos/tools/sysreg/pipe_reader.cpp (original)
+++ trunk/reactos/tools/sysreg/pipe_reader.cpp Sat Oct 21 01:14:08 2006
@@ -85,7 +85,7 @@
//---------------------------------------------------------------------------------------
- bool PipeReader::isEof() const
+ bool PipeReader::isEof()
{
return feof(m_File);
}
Modified: trunk/reactos/tools/sysreg/pipe_reader.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.h…
==============================================================================
--- trunk/reactos/tools/sysreg/pipe_reader.h (original)
+++ trunk/reactos/tools/sysreg/pipe_reader.h Sat Oct 21 01:14:08 2006
@@ -103,7 +103,7 @@
/// 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;
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.…
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.cpp (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.cpp Sat Oct 21 01:14:08 2006
@@ -13,6 +13,8 @@
#include "pipe_reader.h"
#include <iostream>
+#include <time.h>
+#include <float.h>
namespace Sysreg_
{
@@ -37,8 +39,10 @@
string RosBootTest::CLASS_NAME = _T("rosboot");
string RosBootTest::DEBUG_PORT = _T("ROSBOOT_DEBUG_PORT");
string RosBootTest::DEBUG_FILE = _T("ROSBOOT_DEBUG_FILE");
-//---------------------------------------------------------------------------------------
- RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME)
+ string RosBootTest::TIME_OUT = _T("ROSBOOT_TIME_OUT");
+
+//---------------------------------------------------------------------------------------
+ RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME), m_Timeout(60.0)
{
}
@@ -54,6 +58,7 @@
{
string boot_cmd;
string debug_port;
+ string timeout;
bool ret;
if (!conf_parser.getStringValue (RosBootTest::DEBUG_PORT, debug_port))
@@ -66,7 +71,18 @@
cerr << "Error: ROSBOOT_CMD is not set in configuration file" <<
endl;
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,8 +118,33 @@
/// 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;
+ }
}
//---------------------------------------------------------------------------------------
@@ -120,26 +161,34 @@
string Buffer;
Buffer.reserve (10000);
-// gettimeofday(&ts, NULL);
+ bool ret = true;
while(!pipe_reader.isEof ())
{
- pipe_reader.readPipe (Buffer);
+ if (isTimeout(m_Timeout))
+ {
+ break;
+ }
+
+ string::size_type size = pipe_reader.readPipe (Buffer);
+ cerr << "XXXsize_type " << size <<endl;
+
+
if (!checkDebugData(Buffer))
{
+ ret = false;
break;
}
- //if (hasTimeout(&ts, 60000)
-
}
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 @@
}
TCHAR szBuffer[500];
-
- do
+ bool ret = true;
+
+ while(!pipe_reader.isEof ())
{
if (_fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), file))
{
string buffer = szBuffer;
if (!checkDebugData(buffer))
{
+ ret = false;
break;
}
- }
- }while(!pipe_reader.isEof ());
+ if (isTimeout(m_Timeout))
+ {
+ break;
+ }
+ }
+ }
pipe_reader.closePipe ();
- return true;
+ return ret;
}
} // end of namespace Sysreg_
Modified: trunk/reactos/tools/sysreg/rosboot_test.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.…
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.h (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.h Sat Oct 21 01:14:08 2006
@@ -30,6 +30,7 @@
static string CLASS_NAME;
static string DEBUG_PORT;
static string DEBUG_FILE;
+ static string TIME_OUT;
//---------------------------------------------------------------------------------------
///
@@ -101,15 +102,20 @@
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_
Modified: trunk/reactos/tools/sysreg/sym_file.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sym_file.cpp?…
==============================================================================
--- trunk/reactos/tools/sysreg/sym_file.cpp (original)
+++ trunk/reactos/tools/sysreg/sym_file.cpp Sat Oct 21 01:14:08 2006
@@ -114,7 +114,7 @@
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));