Author: janderwald Date: Sat Oct 21 20:12:42 2006 New Revision: 24593
URL: http://svn.reactos.org/svn/reactos?rev=24593&view=rev Log: - add an option to store emulators pidfile in txt - destroy emulator process when sysreg exits (windows only currently) - the tool now works in windows
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 Sat Oct 21 20:12:42 2006 @@ -22,6 +22,10 @@ #include <assert.h>
+#ifndef __LINUX__ +#include <windows.h> +#endif +
namespace Sysreg_ { @@ -48,6 +52,7 @@ 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 @@ m_Timeout = 60.0; } } + + conf_parser.getStringValue (RosBootTest::PID_FILE, m_PidFile); + if (!_tcscmp(debug_port.c_str(), _T("pipe"))) { @@ -118,11 +126,6 @@ //--------------------------------------------------------------------------------------- bool RosBootTest::checkDebugData(vector<string> & 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 ....
@@ -131,6 +134,8 @@ for(size_t i = 0; i < debug_data.size();i++) { string line = debug_data[i]; + + cerr << line << endl;
if (line.find (_T("*** Fatal System Error")) != string::npos) { @@ -186,7 +191,7 @@ }
- if (clear) + if (clear && debug_data.size () > 5) { debug_data.clear (); } @@ -258,18 +263,33 @@ { 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 @@ return false; }
- TCHAR szBuffer[150]; + TCHAR szBuffer[1000]; bool ret = true; vector<string> 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 @@ } } } -#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; }
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 Sat Oct 21 20:12:42 2006 @@ -33,6 +33,7 @@ static string DEBUG_PORT; static string DEBUG_FILE; static string TIME_OUT; + static string PID_FILE;
//--------------------------------------------------------------------------------------- /// @@ -116,6 +117,7 @@ protected:
double m_Timeout; + string m_PidFile;
}; // 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 Sat Oct 21 20:12:42 2006 @@ -27,7 +27,15 @@ ; 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_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 ;