diff --git a/reactos/tools/sysreg/rosboot_test.cpp b/reactos/tools/sysreg/rosboot_test.cpp index a57e340dc7d..88c7c99c1ab 100644 --- a/reactos/tools/sysreg/rosboot_test.cpp +++ b/reactos/tools/sysreg/rosboot_test.cpp @@ -22,6 +22,10 @@ #include +#ifndef __LINUX__ +#include +#endif + namespace Sysreg_ { @@ -48,6 +52,7 @@ namespace Sysreg_ string RosBootTest::DEBUG_PORT = _T("ROSBOOT_DEBUG_PORT"); 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) @@ -90,6 +95,9 @@ namespace Sysreg_ m_Timeout = 60.0; } } + + conf_parser.getStringValue (RosBootTest::PID_FILE, m_PidFile); + if (!_tcscmp(debug_port.c_str(), _T("pipe"))) { @@ -118,11 +126,6 @@ namespace Sysreg_ //--------------------------------------------------------------------------------------- bool RosBootTest::checkDebugData(vector & debug_data) { - /// - /// FIXME - /// - /// parse debug_data and output STOP errors, UM exception - /// as well as important stages i.e. ntoskrnl loaded /// TBD the information needs to be written into an provided log object /// which writes the info into HTML/log / sends etc .... @@ -132,6 +135,8 @@ namespace Sysreg_ { string line = debug_data[i]; + cerr << line << endl; + if (line.find (_T("*** Fatal System Error")) != string::npos) { cerr << "BSOD detected" < 5) { debug_data.clear (); } @@ -258,18 +263,33 @@ namespace Sysreg_ { PipeReader pipe_reader; -#if 0 _tremove(debug_log.c_str ()); + _tremove(m_PidFile.c_str ()); if (!pipe_reader.openPipe(boot_cmd, string(_T("rt")))) { cerr << "Error: failed to open pipe with cmd: " << boot_cmd << endl; return false; } -#endif // FIXXME // give the emulator some time to load freeloadr _sleep( (clock_t)4 * CLOCKS_PER_SEC ); + int pid = 0; + + if (m_PidFile != _T("")) + { + FILE * pidfile = _tfopen(m_PidFile.c_str (), _T("rt")); + if (pidfile) + { + TCHAR szBuffer[20]; + if (_fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), pidfile)) + { + pid = _ttoi(szBuffer); + } + + } + fclose(pidfile); + } FILE * file = _tfopen(debug_log.c_str (), _T("rt")); if (!file) @@ -279,19 +299,34 @@ namespace Sysreg_ return false; } - TCHAR szBuffer[150]; + TCHAR szBuffer[1000]; bool ret = true; vector vect; -#if 0 + while(!pipe_reader.isEof ()) -#else - while(!feof(file)) -#endif { if (_fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), file)) { + string line = szBuffer; - vect.push_back (line); + + while(line.find (_T("\x10")) != string::npos) + { + line.erase(line.find(_T("\x10")), 1); + } + + if (line[0] != _T('(') && vect.size() >=1) + { + string prev = vect[vect.size () -1]; + prev.insert (prev.length ()-1, line); + vect.pop_back (); + vect.push_back (prev); + + } + else + { + vect.push_back (line); + } if (!checkDebugData(vect)) { @@ -304,9 +339,21 @@ namespace Sysreg_ } } } -#if 0 - pipe_reader.closePipe (); + fclose(file); + if (pid) + { +#ifdef __LINUX__ + +#else + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid); + if (hProcess) + { + TerminateProcess(hProcess, 0); + } + CloseHandle(hProcess); #endif + } + pipe_reader.closePipe (); return ret; } diff --git a/reactos/tools/sysreg/rosboot_test.h b/reactos/tools/sysreg/rosboot_test.h index 42a36d5301d..9a8c423f163 100644 --- a/reactos/tools/sysreg/rosboot_test.h +++ b/reactos/tools/sysreg/rosboot_test.h @@ -33,6 +33,7 @@ namespace Sysreg_ static string DEBUG_PORT; static string DEBUG_FILE; static string TIME_OUT; + static string PID_FILE; //--------------------------------------------------------------------------------------- /// @@ -116,6 +117,7 @@ namespace Sysreg_ protected: double m_Timeout; + string m_PidFile; }; // end of class RosBootTest diff --git a/reactos/tools/sysreg/sample.cfg b/reactos/tools/sysreg/sample.cfg index 48d84a1209e..07ffcad919e 100644 --- a/reactos/tools/sysreg/sample.cfg +++ b/reactos/tools/sysreg/sample.cfg @@ -27,7 +27,15 @@ ROS_ADDR2LINE=addr2line.exe --exe= ; This value is the command which is executed to gain debugging data ; this value is mandatory -ROSBOOT_CMD=D:\sysreg\qemu\qemu.exe -serial file:debug.log -boot c -m 128 -L D:\sysreg\qemu\ D:\sysreg\qemu\RosVM.vmdk -cdrom D:\Reactos\ReactOS-RegTest.iso +ROSBOOT_CMD=D:\sysreg\qemu\qemu.exe -serial file:debug.log -boot c -m 128 -L D:\sysreg\qemu\ D:\sysreg\qemu\RosVM.vmdk -cdrom D:\Reactos\ReactOS-RegTest.iso -pidfile pid.txt + +; +; ROSBOOT_PIDFILE +; +; This option stores the pid of the emulator process in a text file. +; + +ROSBOOT_PID_FILE=pid.txt ; ; ROSBOOT_DEBUG_PORT @@ -49,7 +57,7 @@ ROSBOOT_DEBUG_PORT=file ; ROSBOOT_DEBUG_PORT=file ;ROSBOOT_DEBUG_FILE=D:\ReactOS\tools\sysreg\bsdebug.log -ROSBOOT_DEBUG_FILE=D:\ReactOS\tools\sysreg\umdebug.log +ROSBOOT_DEBUG_FILE=D:\ReactOS\tools\sysreg\debug.log ; ROSBOOT_TIME_OUT ;