Author: janderwald Date: Sun Oct 22 15:27:45 2006 New Revision: 24602
URL: http://svn.reactos.org/svn/reactos?rev=24602&view=rev Log: - implemented ROSBOOT_CHECKPOINT - implemented ROSBOOT_DELAY_READ - dump reached checkpoint in case of bsod / um-exceptions - add error handling - remove hardcoded constants
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp trunk/reactos/tools/sysreg/rosboot_test.h trunk/reactos/tools/sysreg/sample.cfg
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.c... ============================================================================== --- trunk/reactos/tools/sysreg/rosboot_test.cpp (original) +++ trunk/reactos/tools/sysreg/rosboot_test.cpp Sun Oct 22 15:27:45 2006 @@ -53,9 +53,12 @@ string RosBootTest::DEBUG_FILE = _T("ROSBOOT_DEBUG_FILE"); string RosBootTest::TIME_OUT = _T("ROSBOOT_TIME_OUT"); string RosBootTest::PID_FILE= _T("ROSBOOT_PID_FILE"); - -//--------------------------------------------------------------------------------------- - RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME), m_Timeout(60.0) + string RosBootTest::DELAY_READ = _T("ROSBOOT_DELAY_READ"); + string RosBootTest::CHECK_POINT = _T("ROSBOOT_CHECK_POINT"); + string RosBootTest::SYSREG_CHECKPOINT = _T("SYSREG_CHECKPOINT:"); + +//--------------------------------------------------------------------------------------- + RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME), m_Timeout(60.0), m_Delayread(0) {
} @@ -72,7 +75,12 @@ string boot_cmd; string debug_port; string timeout; + string delayread; bool ret; + + /// + /// read required configuration arguments + ///
if (!conf_parser.getStringValue (RosBootTest::DEBUG_PORT, debug_port)) { @@ -96,6 +104,24 @@ } }
+ if (conf_parser.getStringValue(RosBootTest::DELAY_READ, delayread)) + { + TCHAR * stop; + m_Delayread = _tcstoul(delayread.c_str (), &stop, 10); + if (m_Delayread > 60 || m_Delayread < 0) + { + cerr << "Warning: disabling delay read" << endl; + m_Delayread = 0; + } + } + + + + /// + /// read optional arguments + /// + + conf_parser.getStringValue (RosBootTest::CHECK_POINT, m_Checkpoint); conf_parser.getStringValue (RosBootTest::PID_FILE, m_PidFile);
@@ -124,12 +150,27 @@ return ret; } //--------------------------------------------------------------------------------------- - bool RosBootTest::checkDebugData(vector<string> & debug_data) + void RosBootTest::dumpCheckpoints() + { + if (m_Checkpoints.size ()) + { + cerr << "Dumping list of checkpoints: "<< endl; + while(!m_Checkpoints.empty ()) + { + cerr << m_Checkpoints[0] << endl; + m_Checkpoints.erase (m_Checkpoints.begin ()); + + } + } + } +//--------------------------------------------------------------------------------------- + RosBootTest::DebugState RosBootTest::checkDebugData(vector<string> & debug_data) { /// TBD the information needs to be written into an provided log object /// which writes the info into HTML/log / sends etc ....
bool clear = true; + DebugState state = DebugStateContinue;
for(size_t i = 0; i < debug_data.size();i++) { @@ -137,25 +178,28 @@
cerr << line << endl;
- if (line.find (_T("SYSREG_CHECKPOINT")) != string::npos) - { - line.erase (0, line.find (_T("SYSREG_CHECKPOINT")) + 19); - if (!_tcsncmp(line.c_str (), _T("USETUP_COMPLETE"), 15)) - { - /// - /// we need to stop the emulator to avoid - /// looping again into USETUP (at least with bootcdregtest) - - return false; - } - + if (line.find (RosBootTest::SYSREG_CHECKPOINT) != string::npos) + { + line.erase (0, line.find (RosBootTest::SYSREG_CHECKPOINT) + RosBootTest::SYSREG_CHECKPOINT.length ()); + if (!_tcsncmp(line.c_str (), m_Checkpoint.c_str (), m_Checkpoint.length ())) + { + state = DebugStateCPReached; + break; + } + if (line.find (_T("|")) != string::npos) + { + string fline = debug_data[i]; + m_Checkpoints.push_back (fline); + } }
if (line.find (_T("*** Fatal System Error")) != string::npos) { cerr << "BSOD detected" <<endl; - return false; + dumpCheckpoints(); + state = DebugStateBSODDetected; + break; } else if (line.find (_T("Unhandled exception")) != string::npos) { @@ -169,6 +213,7 @@ }
cerr << "UM detected" <<endl; + state = DebugStateUMEDetected;
/// /// extract address from next line @@ -176,15 +221,38 @@
string address = debug_data[i+2]; string::size_type pos = address.find_last_of (_T(" ")); + if (pos == string::npos) + { + cerr << "Error: trace is not available (corrupted debug info" << endl; + dumpCheckpoints(); + break; + } + + address = address.substr (pos, address.length () - 1 - pos);
/// /// extract module name /// string modulename = debug_data[i+3]; + pos = modulename.find_last_of (_T("\")); + if (pos == string::npos) + { + cerr << "Error: trace is not available (corrupted debug info" << endl; + dumpCheckpoints(); + break; + } + modulename = modulename.substr (pos + 1, modulename.length () - pos); pos = modulename.find_last_of (_T(".")); + if (pos == string::npos) + { + cerr << "Error: trace is not available (corrupted debug info" << endl; + dumpCheckpoints(); + break; + } + modulename = modulename.substr (0, pos);
/// @@ -201,16 +269,17 @@ /// /// resolve frame addresses
- return false; - } - + + + break; + } }
if (clear && debug_data.size () > 5) { debug_data.clear (); } - return true; + return state; } //--------------------------------------------------------------------------------------- bool RosBootTest::isTimeout(double max_timeout) @@ -253,6 +322,15 @@ bool ret = true; vector<string> vect;
+ if (m_Delayread) + { + /// + /// delay reading untill emulator is ready + /// + + _sleep( (clock_t)m_Delayread * CLOCKS_PER_SEC ); + } + while(!pipe_reader.isEof ()) { if (isTimeout(m_Timeout)) @@ -263,10 +341,15 @@ pipe_reader.readPipe (Buffer); vect.push_back (Buffer);
- - if (!checkDebugData(vect)) + DebugState state = checkDebugData(vect); + + if (state == DebugStateBSODDetected || state == DebugStateUMEDetected) { ret = false; + break; + } + else if (state == DebugStateCPReached) + { break; } } @@ -285,9 +368,15 @@ cerr << "Error: failed to open pipe with cmd: " << boot_cmd << endl; return false; } - // FIXXME - // give the emulator some time to load freeloadr - _sleep( (clock_t)4 * CLOCKS_PER_SEC ); + + if (m_Delayread) + { + /// + /// delay reading untill emulator is ready + /// + + _sleep( (clock_t)m_Delayread * CLOCKS_PER_SEC ); + }
int pid = 0;
@@ -343,11 +432,18 @@ vect.push_back (line); }
- if (!checkDebugData(vect)) + DebugState state = checkDebugData(vect); + + if (state == DebugStateBSODDetected || state == DebugStateUMEDetected) { ret = false; break; } + else if (state == DebugStateCPReached) + { + break; + } + if (isTimeout(m_Timeout)) { break;
Modified: trunk/reactos/tools/sysreg/rosboot_test.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.h... ============================================================================== --- trunk/reactos/tools/sysreg/rosboot_test.h (original) +++ trunk/reactos/tools/sysreg/rosboot_test.h Sun Oct 22 15:27:45 2006 @@ -34,6 +34,9 @@ static string DEBUG_FILE; static string TIME_OUT; static string PID_FILE; + static string CHECK_POINT; + static string SYSREG_CHECKPOINT; + static string DELAY_READ;
//--------------------------------------------------------------------------------------- /// @@ -95,6 +98,22 @@
//--------------------------------------------------------------------------------------- /// +/// dumpCheckpoints +/// +/// Description: prints a list of all reached checkpoints so far + + void dumpCheckpoints(); + +typedef enum DebugState +{ + DebugStateContinue = 1, /* continue debugging */ + DebugStateBSODDetected, /* bsod detected */ + DebugStateUMEDetected, /* user-mode exception detected */ + DebugStateCPReached /* check-point reached */ +}; + +//--------------------------------------------------------------------------------------- +/// /// checkDebugData /// /// Description: this function parses the given debug data for BSOD, UM exception etc @@ -103,7 +122,7 @@ /// Note: the received debug information should be written to an internal log object /// to facilate post-processing of the results
- bool checkDebugData(vector<string> & debug_data); + DebugState checkDebugData(vector<string> & debug_data);
//--------------------------------------------------------------------------------------- /// @@ -118,6 +137,9 @@
double m_Timeout; string m_PidFile; + string m_Checkpoint; + vector <string> m_Checkpoints; + unsigned long m_Delayread;
}; // end of class RosBootTest
Modified: trunk/reactos/tools/sysreg/sample.cfg URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sample.cfg?rev... ============================================================================== --- trunk/reactos/tools/sysreg/sample.cfg (original) +++ trunk/reactos/tools/sysreg/sample.cfg Sun Oct 22 15:27:45 2006 @@ -59,6 +59,19 @@ ;ROSBOOT_DEBUG_FILE=D:\ReactOS\tools\sysreg\bsdebug.log ROSBOOT_DEBUG_FILE=D:\ReactOS\tools\sysreg\debug.log
+; ROSBOOT_DELAY_READ; +; +; When the emulator is started, it spends a little time loading and running through its +; BIOS. This time delays reading from the pipe/file untill the specified value +; +; the value is in seconds +; +; Note: if the value is not provided, then reading debug info is started immediately + +ROSBOOT_DELAY_READ=4 + + + ; ROSBOOT_TIME_OUT ; ; This variable is the maximum runtime of the ROSBOOT_CMD. If the command @@ -68,3 +81,14 @@ ; ROSBOOT_TIME_OUT=180.0
+; ROSBOOT_CHECK_POINT +; +; RosBoot will stop executing when it finds a string in the form +; SYSREG_CHECKPOINT:CP_NAME +; +; CP_NAME is the value of the ROSBOOT_CHECK_POINT variable + +ROSBOOT_CHECKPOINT=USETUP_COMPLETED + + +