delete sysreg, it is obsolete now

svn path=/trunk/; revision=35878
This commit is contained in:
Christoph von Wittich 2008-09-02 12:57:26 +00:00
parent 3da774ad40
commit 03ba3b67d1
28 changed files with 0 additions and 4074 deletions

View file

@ -1,205 +0,0 @@
#ifndef COMPONENT_FACTORY_TEMPLATE_H_ //comp_factory.h
#define COMPONENT_FACTORY_TEMPLATE_H_
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/comp_factory.h
* PURPOSE: component management
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include <map>
#include <vector>
namespace System_
{
using std::map;
using std::vector;
//----------------------------------------------------------
///
/// ComponentFactoryTemplate
///
/// This class servess as a factory class for components. In general
/// can be used for any possible class which has base class
/// and a derrived class
///
//--------------------------------------------------------------------
///
/// create
///
/// Description: this template function creates a function which returns
/// objects of type ElementType but in real are objects of DerrivedType
///
template<class ElementType, class DerrivedType>
static ElementType * create ()
{
return new DerrivedType();
}
//--------------------------------------------------------------------
template<typename ElementType, typename ElementId>
class ComponentFactoryTemplate
{
typedef ElementType * (*creation_function)();
typedef map<ElementId, creation_function> ElementMap;
typedef vector<ElementId> ElementIdVector;
public:
//--------------------------------------------------------------------
///
/// ComponentFactoryTemplate
///
/// Description: default destructor of class ComponentFactoryTemplate
///
ComponentFactoryTemplate()
{
}
//--------------------------------------------------------------------
///
/// ~ComponentFactoryTemplate
///
/// Description: default destructor of class ComponentFactoryTemplate
///
virtual ~ComponentFactoryTemplate()
{
}
//--------------------------------------------------------------------
///
/// listComponent
///
/// Description: lists all registererd components ids
void listComponentIds()
{
for(unsigned i = 0; i < ids_.size (); i++)
cout<<ids_[i]<<endl;
}
//--------------------------------------------------------------------
///
/// isComponentRegistered
///
/// Description: this function just checks if a component with a given
/// id has been registered or not. If it is it returns true else false
///
/// @return bool
/// @param element id of the component
bool isComponentRegistered(ElementId const & id)
{
typename ElementMap::const_iterator iter = elements_.find(id);
if(iter != elements_.end())
return true;
else
return false;
}
//--------------------------------------------------------------------
///
/// getNumOfComponents
///
/// Description: returns how many components have been registered
const unsigned getNumOfComponents()
{
return ids_.size ();
}
//--------------------------------------------------------------------
///
/// registerComponent
///
/// Description: this function is template function in a class template.
/// The purpose is that at compiletime for each of the derriving classes of
/// ElementType a registerComponent function is generated and then all classes
/// of that type are added at runtime to factory.
/// returns zero on success, nonzero on failure
///
/// @return bool
/// @param id the element id of the content type
template<typename ContentType>
bool registerComponent(ElementId const & id)
{
typename ElementMap::const_iterator iter = elements_.find(id);
if(iter != elements_.end())
return false;
ids_.insert(ids_.begin(),id);
elements_.insert(std::make_pair<ElementId, creation_function >(id, &create<ElementType, ContentType>));
return true;
}
//--------------------------------------------------------------------
///
/// deregisterComponent
///
/// Description: unregisters a given component indentified by param id
/// After unregistration, the specified component can no longer be
/// created
/// @return bool
/// @param id the element id of the ContentType
template<typename ContentType>
const bool deregisterComponent(ElementId const & id)
{
typename ElementMap::const_iterator iterator = elements_.find(id);
if(iterator != elements_.end())
{
elements_.erase(iterator);
return true;
}
else
return false;
}
//--------------------------------------------------------------------
///
/// createComponent
///
/// Description: creates a component according to the specified information
/// returns the component encapsulated in an std::auto_ptr
/// @param id specifies the key id, to look for
/// @return std::auto_ptr<ElementType>
ElementType * createComponent(ElementId const & id) const
{
typename ElementMap::const_iterator first_it = elements_.find(id);
if(first_it != elements_.end())
return (first_it->second)();
else
return 0;
}
//--------------------------------------------------------------------
///
/// deleteComponent
///
/// Description: deletes a component
/// @param element the element to be deleted
void deleteComponent(ElementType * element)
{
delete element;
}
protected:
ElementMap elements_;
ElementIdVector ids_;
};
} //end of namespace Sysreg_
#endif

View file

@ -1,112 +0,0 @@
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: configuration parser
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "conf_parser.h"
namespace Sysreg_
{
using std::ifstream;
//---------------------------------------------------------------------------------------
ConfigParser::ConfigParser()
{
}
//---------------------------------------------------------------------------------------
ConfigParser::~ConfigParser()
{
m_Map.clear ();
}
//---------------------------------------------------------------------------------------
bool ConfigParser::parseFile(char * FileName)
{
FILE * file = fopen(FileName, "rt");
if (!file)
{
cerr << "Error: ConfigParser::parseFile failed to open configuration file " << FileName << endl;
return false;
}
bool ret = false;
while (!feof(file))
{
char buffer[500];
char * buf;
buf = fgets(buffer, sizeof(buffer) / sizeof(char), file);
if (buf)
{
if (buffer[0] != ';')
{
string s_buffer = string(buffer);
string::size_type ws_pos = s_buffer.find_first_of ("=");
if (ws_pos != string::npos && ws_pos > 0 && ws_pos < s_buffer.size())
{
string name = s_buffer.substr (0, ws_pos);
string value = s_buffer.substr (ws_pos + 1, s_buffer.size() - ws_pos - 2);
/*
if (value[value.length () -1] == 0xA)
{
// remove newline char
value[value.length ()-1] = '\0';
}
*/
// cerr << "name: "<< name << "value: "<< value << "|" << endl;
m_Map[name] = value;
ret = true;
}
}
}
}
fclose(file);
return ret;
}
//---------------------------------------------------------------------------------------
bool ConfigParser::getStringValue(string &ConfVariable, string &ConfValue)
{
ConfigMap::iterator it = m_Map.find (ConfVariable);
if (it == m_Map.end ())
{
//cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl;
return false;
}
ConfValue = it->second;
return true;
}
//----------------------------------------------------------------------------------------
bool ConfigParser::getDoubleValue(string ConfVariable, double & ConfValue)
{
ConfigMap::iterator it = m_Map.find (ConfVariable);
if (it == m_Map.end ())
{
cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl;
return false;
}
ConfValue = strtod(it->second.c_str(), NULL);
return true;
}
//-----------------------------------------------------------------------------------------
bool ConfigParser::getIntValue(string ConfVariable, long int & ConfValue)
{
ConfigMap::iterator it = m_Map.find (ConfVariable);
if (it == m_Map.end ())
{
cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl;
return false;
}
ConfValue = strtol(it->second.c_str(), NULL, 10);
return true;
}
} // end of namespace Sysreg_

View file

@ -1,97 +0,0 @@
#ifndef CONF_PARSER_H__
#define CONF_PARSER_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: configuration parser
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include <map>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
namespace Sysreg_
{
using std::map;
//---------------------------------------------------------------------------------------
///
/// class ConfigParser
///
/// Description: this class reads configuration entries from a configuration file
/// Each entry must have the form of VALUE=XXX. The entries are stored
/// in a map which can be queried after parsing the configuration file
///
/// Note: lines beginning with an ; are ignored
///
/// Usage: First, call parseFile with param to file. Finally, call getValue with the
/// appropiate type
class ConfigParser
{
public:
typedef map<string, string> ConfigMap;
//---------------------------------------------------------------------------------------
///
/// ConfigParser
///
/// Description: constructor of class ConfigParser
ConfigParser();
//---------------------------------------------------------------------------------------
///
/// ~ConfigParser
///
/// Description: destructor of class ConfigParser
virtual ~ConfigParser();
//---------------------------------------------------------------------------------------
///
/// parseFile
///
/// Description: this function takes as param a path to file. it attempts to parse this specific
/// file with the given syntax. On success it returns true.
///
/// Note: Everytime parseFile is called, the previous stored values are cleared
///
/// @param FileName path to configuration file
/// @return bool
bool parseFile(char * FileName);
//--------------------------------------------------------------------------------------
///
/// getStringValue
///
/// Description: attempts to read a config variable from the configuration file
/// If the variable name is not found, it returns false and the param
/// ConfValue remains untouched. On success it returns the true.
///
/// @param ConfVariable name of the configuration variable to retrieve
/// @param ConfValue type of value to retrieve
bool getStringValue(string & ConfVariable, string & ConfValue);
bool getDoubleValue(string ConfVariable, double & value);
bool getIntValue(string ConfVariable, long int & value);
protected:
ConfigMap m_Map;
}; // end of class ConfigParser
} // end of namspace Sysreg_
#endif /* end of CONF_PARSER_H__ */

View file

@ -1,51 +0,0 @@
#ifndef DATA_SOURCE_H__
#define DATA_SOURCE_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: data source abstraction
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include <vector>
#include "user_types.h"
namespace System_
{
class DataSource
{
public:
DataSource()
{}
virtual ~DataSource()
{}
virtual bool openSource(const string & opencmd) = 0;
virtual bool closeSource() = 0;
virtual bool readSource(std::vector<string> & vect) = 0;
virtual bool isSourceOpen() = 0;
}; // end of class DataSource
} // end of namespace System_
#endif /* end of DATA_SOURCE_H__ */

View file

@ -1,61 +0,0 @@
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: environment variable lookup
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "env_var.h"
namespace System_
{
EnvironmentVariable::EnvironmentMap EnvironmentVariable::m_Map;
//---------------------------------------------------------------------------------------
EnvironmentVariable::EnvironmentVariable()
{
}
//---------------------------------------------------------------------------------------
EnvironmentVariable::~EnvironmentVariable()
{
m_Map.clear ();
}
//---------------------------------------------------------------------------------------
bool EnvironmentVariable::getValue( string const &EnvName, string &EnvValue)
{
EnvironmentMap::const_iterator it = m_Map.find (EnvName);
if (it != m_Map.end())
{
EnvValue = it->second;
return true;
}
char * value = getenv(EnvName.c_str ());
if (!value)
{
cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl;
return false;
}
if (!strlen(value))
{
cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl;
return false;
}
EnvValue = value;
m_Map[EnvName] = EnvValue;
return true;
}
} // end of namespace System_

View file

@ -1,72 +0,0 @@
#ifndef ENV_VAR_H__
#define ENV_VAR_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: environment variable lookup
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include <map>
#include <iostream>
#include <cstdlib>
#include <cstring>
namespace System_
{
using std::map;
//---------------------------------------------------------------------------------------
///
/// class EnvironmentVariable
///
/// Description: this class performs looking up environment variable from the system
/// The result is also stored in its internal map to cache results
class EnvironmentVariable
{
public:
typedef map<string, string> EnvironmentMap;
//---------------------------------------------------------------------------------------
///
/// ~EnvironmentVariable
///
/// Description: destructor of class EnvironmentVariable
virtual ~EnvironmentVariable();
//---------------------------------------------------------------------------------------
///
/// getValue
///
/// Description: this function returns the value of an associated environment variable. if
/// the variable is set it returns true and the value in the parameter EnvValue. On error
/// it returns false and the param EnvValue remains untouched
///
/// @param EnvName name of environment variable to retrieve
/// @param EnvValue value of the environment variable
/// @return bool
static bool getValue(const string & EnvName, string & EnvValue);
protected:
//---------------------------------------------------------------------------------------
///
/// EnvironmentVariable
///
/// Description: constructor of class EnvironmentVariable
EnvironmentVariable();
static EnvironmentMap m_Map;
}; // end of class EnvironmentVariable
} // end of namespace System_
#endif /* end of ENV_VAR_H__ */

View file

@ -1,127 +0,0 @@
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: file reading support
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "file_reader.h"
namespace System_
{
//---------------------------------------------------------------------------------------
FileReader::FileReader() : DataSource(), m_File(NULL)
{
}
//---------------------------------------------------------------------------------------
FileReader::~FileReader()
{
}
//---------------------------------------------------------------------------------------
bool FileReader::openSource(const string & filename)
{
m_File = fopen((char*)filename.c_str(), (char*)"rb");
if (m_File)
{
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------------------
bool FileReader::closeSource()
{
if (!m_File)
{
return false;
}
if (!fclose(m_File))
{
m_File = NULL;
return true;
}
return false;
}
//---------------------------------------------------------------------------------------
bool FileReader::readSource(vector<string> & lines)
{
if (!m_File)
{
return false;
}
bool ret = true;
size_t total_length = 0;
size_t line_count = lines.size();
size_t num = 0;
char szBuffer[256];
int readoffset = 0;
if (m_BufferedLines.length())
{
strcpy(szBuffer, m_BufferedLines.c_str());
readoffset = m_BufferedLines.length();
}
do
{
if (total_length < num)
{
memmove(szBuffer, &szBuffer[total_length], num - total_length);
readoffset = num - total_length;
}
num = fread(&szBuffer[readoffset],
sizeof(char), sizeof(szBuffer)/sizeof(char) - (readoffset+1) * sizeof(char),
m_File);
szBuffer[num] = L'\0';
if (!num)
{
if (line_count == lines.size ())
{
ret = false;
}
break;
}
char * ptr;
char * offset = szBuffer;
total_length = 0;
while((ptr = strstr(offset, "\x0D\x0A")) != NULL)
{
long length = ((long )ptr - (long)offset);
length /= sizeof(char);
offset[length] = '\0';
string line = offset;
lines.push_back (line);
offset += length + 2;
total_length += length + 2;
if (total_length == num)
{
break;
}
}
}while(num );
if (total_length < num)
{
m_BufferedLines = &szBuffer[total_length];
}
return ret;
}
} // end of namespace System_

View file

@ -1,93 +0,0 @@
#ifndef FILE_READER_H__
#define FILE_READER_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: pipe reader support
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include "data_source.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstring>
namespace System_
{
using std::vector;
//---------------------------------------------------------------------------------------
///
/// class FileReader
///
/// Description: this class implements reading from a file
class FileReader : public DataSource
{
public:
//---------------------------------------------------------------------------------------
///
/// FileReader
///
/// Description: constructor of class FileReader
FileReader();
//---------------------------------------------------------------------------------------
///
/// ~FileReader
///
/// Description: destructor of class FileReader
virtual ~FileReader();
//---------------------------------------------------------------------------------------
///
/// openFile
///
/// Description: attempts to open a file. Returns true on success
///
/// @param filename name of the file to open
/// @return bool
virtual bool openSource(const string & filename);
//---------------------------------------------------------------------------------------
///
/// closeFile
///
/// Description: attempts to close a file. Returns true on success
///
/// @return bool
virtual bool closeSource();
//---------------------------------------------------------------------------------------
///
/// readFile
///
/// Description: reads from file. The result is stored in a vector of strings
///
/// Note: returns true on success
///
virtual bool readSource(vector<string> & lines);
protected:
FILE * m_File;
string m_BufferedLines;
}; // end of class FileReader
} // end of namespace System_
#endif /* end of FILE_READER_H__ */

View file

@ -1,330 +0,0 @@
/* $Id: pipe_reader.cpp 24643 2006-10-24 11:45:21Z janderwald $
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/namedpipe_reader.cpp
* PURPOSE: pipe reader support
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
* Christoph von Wittich (Christoph_vW@ReactOS.org)
*/
#include "namedpipe_reader.h"
namespace System_
{
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#ifndef WIN32
const char * NamedPipeReader::s_LineBreak = "\x0A\0";
#else
const char * NamedPipeReader::s_LineBreak = "\x0D\x0A\0";
#endif
using std::vector;
//---------------------------------------------------------------------------------------
NamedPipeReader::NamedPipeReader() : DataSource(), h_Pipe(NULLVAL), m_Buffer(0)
{
}
//---------------------------------------------------------------------------------------
NamedPipeReader::~NamedPipeReader()
{
if (m_Buffer)
free(m_Buffer);
}
bool NamedPipeReader::isSourceOpen()
{
return true;
}
//---------------------------------------------------------------------------------------
bool NamedPipeReader::openSource(const string & PipeCmd)
{
if (h_Pipe != NULLVAL)
{
cerr << "NamedPipeReader::openPipe> pipe already open" << endl;
return false;
}
#ifdef WIN32
h_Pipe = CreateFile(PipeCmd.c_str(),
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)
NULL);
if(INVALID_HANDLE_VALUE == h_Pipe) {
cerr << "NamedPipeReader::openPipe> failed to open pipe " << PipeCmd << " Error:" << GetLastError() << endl;
h_Pipe = NULLVAL;
return false;
}
else
{
cout << "NamedPipeReader::openPipe> successfully opened pipe" << endl;
if (!m_Buffer)
{
m_BufferLength = 100;
m_Buffer = (char*)malloc(sizeof(char) * m_BufferLength);
}
ConnectNamedPipe(h_Pipe,
0);
return true;
}
#else
h_Pipe = open(PipeCmd.c_str(), O_RDONLY);
if(INVALID_HANDLE_VALUE == h_Pipe) {
cerr << "NamedPipeReader::openPipe> failed to open pipe " << PipeCmd << endl;
h_Pipe = NULLVAL;
return false;
}
else
{
cout << "NamedPipeReader::openPipe> successfully opened pipe handle: "<< h_Pipe << endl << "Src: " << PipeCmd << endl;
if (!m_Buffer)
{
m_BufferLength = 100;
m_Buffer = (char*)malloc(sizeof(char) * m_BufferLength);
}
return true;
}
#endif
}
//---------------------------------------------------------------------------------------
bool NamedPipeReader::closeSource()
{
cerr << "NamedPipeReader::closePipe> entered" << endl;
if (h_Pipe == NULLVAL)
{
cerr << "NamedPipeReader::closePipe> pipe is not open" << endl;
return false;
}
#ifndef WIN32
close(h_Pipe);
#else
DisconnectNamedPipe(h_Pipe);
CloseHandle(h_Pipe);
#endif
h_Pipe = NULLVAL;
return true;
}
//---------------------------------------------------------------------------------------
void NamedPipeReader::insertLine(std::vector<string> & vect, string line, bool append_line)
{
if (append_line && vect.size ())
{
string prev = vect[vect.size () - 1];
prev += line;
vect[vect.size () - 1] = prev;
}
else
{
vect.push_back (line);
}
}
//---------------------------------------------------------------------------------------
void NamedPipeReader::extractLines(char * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead)
{
#if 0
long offset = 0;
size_t start_size = vect.size ();
char * start = buffer;
buffer[cbRead] = '\0';
char * end = strstr(buffer, s_LineBreak);
//cout << "extractLines entered with append_line: " << append_line << " cbRead: " << cbRead << "buffer: " << buffer << endl;
do
{
if (end)
{
end[0] = '\0';
string line = start;
end += (sizeof(s_LineBreak) / sizeof(char));
start = end;
offset += line.length() + (sizeof(s_LineBreak) / sizeof(char));
// cout << "Offset: "<< offset << "cbRead: " << cbRead << "line: " << line << endl;
insertLine(vect, line, append_line);
if (append_line)
{
append_line = false;
}
}
else
{
string line = start;
// cout << "inserting line start_size: " << start_size << "current: " << vect.size () << "line length: "<< line.length () << endl;
if (!line.length ())
{
if (start_size == vect.size ())
append_line = true;
break;
}
if (start_size == vect.size ())
{
insertLine(vect, line, true);
}
else
{
insertLine(vect, line, false);
}
append_line = true;
break;
}
end = strstr(end, s_LineBreak);
}while(append_line);
#else
DWORD buf_offset = 0;
char * offset = strchr(buffer, '\x0D');
while(offset)
{
///
/// HACKHACK
/// due to some mysterious reason, strchr / strstr sometimes returns
/// not always the offset to the CR character but to the next LF
/// in MSVC 2005 (Debug Modus)
if (offset[0] == '\x0A')
{
if (buf_offset)
{
offset--;
}
else
{
//TODO
// implement me special case
}
}
if (offset[0] == '\x0D')
{
buf_offset += 2;
offset[0] = '\0';
offset +=2;
}
else
{
///
/// BUG detected in parsing code
///
abort();
}
string line = buffer;
if (append_line)
{
assert(vect.empty () == false);
string prev_line = vect[vect.size () -1];
prev_line += line;
vect.pop_back ();
vect.push_back (prev_line);
append_line = false;
}
else
{
vect.push_back (line);
}
buf_offset += line.length();
if (buf_offset >= cbRead)
{
break;
}
buffer = offset;
offset = strstr(buffer, "\n");
}
if (buf_offset < cbRead)
{
buffer[cbRead - buf_offset] = '\0';
string line = buffer;
if (append_line)
{
assert(vect.empty () == false);
string prev_line = vect[vect.size () -1];
vect.pop_back ();
prev_line += line;
vect.push_back (prev_line);
}
else
{
vect.push_back (line);
append_line = true;
}
}
else
{
append_line = false;
}
#endif
}
//---------------------------------------------------------------------------------------
bool NamedPipeReader::readPipe(char * buffer, int bufferlength, long & bytesread)
{
#ifndef WIN32
long cbRead = read(h_Pipe,
buffer,
(bufferlength-1) * sizeof(char));
#else
DWORD cbRead = 0;
BOOL fSuccess = ReadFile(h_Pipe,
buffer,
(bufferlength-1) * sizeof(char),
&cbRead,
NULL);
if (!fSuccess && GetLastError() != ERROR_MORE_DATA)
return false;
#endif
bytesread = cbRead;
return true;
}
//---------------------------------------------------------------------------------------
bool NamedPipeReader::readSource(vector<string> & vect)
{
size_t lines = vect.size ();
if (h_Pipe == NULLVAL)
{
cerr << "Error: pipe is not open" << endl;
return false;
}
if (!m_Buffer)
{
cerr << "Error: no memory" << endl;
return false;
}
bool append_line = false;
do
{
memset(m_Buffer, 0x0, m_BufferLength * sizeof(char));
long cbRead = 0;
if (!readPipe(m_Buffer, m_BufferLength-1, cbRead))
break;
extractLines(m_Buffer, vect, append_line, cbRead);
}while (append_line);
return (vect.size () - lines);
}
} // end of namespace System_

View file

@ -1,142 +0,0 @@
#ifndef NAMEDPIPE_READER_H__
#define NAMEDPIPE_READER_H__
/* $Id: namedpipe_reader.h 24643 2006-10-24 11:45:21Z janderwald $
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/namedpipe_reader.h
* PURPOSE: file reading support
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
* Christoph von Wittich (Christoph@ApiViewer.de)
*/
#include "user_types.h"
#include "data_source.h"
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <cstring>
#if defined(WIN32)
#include <windows.h>
#define NULLVAL NULL
#else
#include <unistd.h>
#include <fcntl.h>
#define NULLVAL 0
#define DWORD unsigned long
#define HANDLE long
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE -1
#endif
#endif
namespace System_
{
//---------------------------------------------------------------------------------------
///
/// class NamedPipeReader
///
/// Description: this class implements a named pipe reader.
class NamedPipeReader : public DataSource
{
public:
//---------------------------------------------------------------------------------------
///
/// NamedPipeReader
///
/// Description: constructor of class PipeReader
NamedPipeReader();
//---------------------------------------------------------------------------------------
///
/// virtual ~NamedPipeReader
///
/// Description: destructor of class PipeReader
virtual ~NamedPipeReader();
//---------------------------------------------------------------------------------------
///
/// open
///
/// Description: this function attempts to open a pipe. If an pipe is already open or
/// it fails to open a pipe, the function returns false
///
/// @param PipeCmd command of the pipe to open
///
/// @return bool
virtual bool openSource(const string & PipeCmd);
//---------------------------------------------------------------------------------------
///
/// close
///
/// Description: closes a pipe. Returns true on success
///
/// @return bool
virtual bool closeSource();
//---------------------------------------------------------------------------------------
///
/// readPipe
///
/// Description: attempts to read from the pipe. Returns true on success. If it returns
/// false, call PipeReader::isEoF() to determine if the pipe should be closed
///
/// @param Buffer to be written to
/// @return size_t
virtual bool readSource(std::vector<string> & vect);
//---------------------------------------------------------------------------------------
///
/// isEof
///
/// Description: returns true if the pipe has reached end of file. The caller should call
/// closePipe if this function returns true
virtual bool isSourceOpen();
protected:
//---------------------------------------------------------------------------------------
///
/// extractLines
///
/// Description: this functions extract lines from a buffer and pushes them into the supplied vector
///
/// @param buffer from which the lines are extracted from
/// @param vect vector storing the extracted lines
/// @param append_line if the line isnt fully read, the line is appended
void extractLines(char * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead);
void insertLine(std::vector<string> & vect, string line, bool append_line);
bool readPipe(char * buffer, int bufferlength, long & read);
HANDLE h_Pipe;
char * m_Buffer;
int m_BufferLength;
#ifdef UNICODE
WCHAR * m_WBuffer;
#endif
static const char * s_LineBreak;
}; // end of class NamedPipeReader
} // end of namespace System_
#endif /* end of NAMEDPIPE_READER_H__ */

View file

@ -1,341 +0,0 @@
/* $Id: os_support.h 24643 2006-10-24 11:45:21Z janderwald $
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: operating systems specific code
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "os_support.h"
namespace System_
{
OsSupport::TimeEntryVector OsSupport::s_Entries;
//int gettimeofday(struct timeval *tv, void * tz);
//------------------------------------------------------------------------
void OsSupport::checkAlarms()
{
struct timeval tm;
size_t i;
#if 0
// gettimeofday(&tm, 0);
#else
memset(&tm, 0, sizeof(tm));
#endif
for (i = 0; i < s_Entries.size(); i++)
{
long diffsec = s_Entries[i]->tm.tv_sec - tm.tv_sec;
if (diffsec < 0)
{
cout << "terminating process pid:" << s_Entries[i]->pid << endl;
terminateProcess(s_Entries[i]->pid, -2);
free(s_Entries[i]);
s_Entries.erase (s_Entries.begin () + i);
i = MAX(0, i-1);
}
}
#ifndef WIN32
if (s_Entries.size())
{
long secs = s_Entries[i]->tm.tv_sec - tm.tv_sec;
alarm(secs);
}
#endif
}
bool OsSupport::hasAlarms ()
{
return (s_Entries.size () != 0);
}
//------------------------------------------------------------------------
void OsSupport::cancelAlarms()
{
#ifdef WIN32
if (s_hThread)
{
TerminateThread(s_hThread, 0);
s_hThread = 0;
}
#endif
for(size_t i = 0; i < s_Entries.size(); i++)
{
free(s_Entries[i]);
}
s_Entries.clear();
}
#ifdef WIN32
HANDLE OsSupport::s_hThread = 0;
static HANDLE hTimer;
#if 0
__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
LARGE_INTEGER li;
__int64 t;
static int tzflag;
if (tv)
{
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
t = li.QuadPart; /* In 100-nanosecond intervals */
t -= EPOCHFILETIME; /* Offset to the Epoch time */
t /= 10; /* In microseconds */
tv->tv_sec = (long)(t / 1000000);
tv->tv_usec = (long)(t % 1000000);
}
if (tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#endif
bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode)
{
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
if (!hProcess)
{
return false;
}
bool ret = TerminateProcess(hProcess, exitcode);
CloseHandle(hProcess);
return ret;
}
OsSupport::ProcessID OsSupport::createProcess(const char *procname, int procargsnum, const char **procargs, bool wait)
{
STARTUPINFO siStartInfo;
PROCESS_INFORMATION piProcInfo;
OsSupport::ProcessID pid;
DWORD length = 0;
char * szBuffer;
char * cmd;
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.wShowWindow = SW_SHOWNORMAL;
siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
if (procargsnum)
{
for (int i = 1; i < procargsnum; i++)
{
length += strlen(procargs[i]);
}
length += procargsnum;
szBuffer = (char*)malloc(length * sizeof(char));
length = 0;
for (int i = 1; i < procargsnum; i++)
{
strcpy(&szBuffer[length], procargs[i]);
length += strlen(procargs[i]);
if (i + 1 < procargsnum)
{
szBuffer[length] = ' ';
}
else
{
szBuffer[length] = '\0';
}
length++;
}
length = strlen(procname) + strlen(szBuffer) + 2;
cmd = (char*)malloc(length * sizeof(char));
strcpy(cmd, procname);
strcat(cmd, " ");
strcat(cmd, szBuffer);
free(szBuffer);
}
else
{
cmd = _strdup(procname);
}
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo))
{
cerr << "Error: CreateProcess failed " << cmd << endl;
pid = 0;
}
else
{
pid = piProcInfo.dwProcessId;
if (wait)
{
WaitForSingleObject(piProcInfo.hThread, INFINITE);
}
CloseHandle(piProcInfo.hProcess);
CloseHandle(piProcInfo.hThread);
}
free(cmd);
return pid;
}
void OsSupport::delayExecution(long value)
{
Sleep(value * 1000);
}
DWORD WINAPI AlarmThread(LPVOID param)
{
LARGE_INTEGER liDueTime;
hTimer = CreateWaitableTimer(NULL, TRUE, "SysRegTimer");
if (!hTimer)
{
return 0;
}
liDueTime.QuadPart = -100000000LL;
while(1)
{
SetWaitableTimer(hTimer, &liDueTime, 5000, NULL, NULL, FALSE);
WaitForSingleObject(hTimer, INFINITE);
OsSupport::checkAlarms ();
}
return 0;
}
void OsSupport::setAlarm(long secs, OsSupport::ProcessID pid)
{
return;
PTIME_ENTRY entry = (PTIME_ENTRY) malloc(sizeof(TIME_ENTRY));
if (entry)
{
cout << "secs: " << secs << endl;
struct timeval tm;
#if 0
gettimeofday(&tm, 0);
#else
#endif
tm.tv_sec += secs;
entry->tm = tm;
entry->pid = pid;
s_Entries.push_back(entry);
if (s_Entries.size () == 1)
{
s_hThread = CreateThread(NULL, 0, AlarmThread, 0, 0, NULL);
}
}
}
#else
/********************************************************************************************************************/
struct sigaction OsSupport::s_sact;
OsSupport::ProcessID OsSupport::createProcess(const char *procname, int procargsnum, const char **procargs, bool bWait)
{
ProcessID pid;
if ((pid = fork()) < 0)
{
cerr << "OsSupport::createProcess> fork failed" << endl;
return 0;
}
if (pid == 0)
{
execv(procname, (char* const*)procargs);
return 0;
}
else
{
/* parent process */
if (bWait)
{
waitpid(pid, NULL, 0);
}
}
return pid;
}
bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode)
{
kill(pid, SIGKILL);
return true;
}
void OsSupport::delayExecution(long value)
{
sleep( value );
}
void handleSignal(int sig)
{
if (sig == SIGALRM)
{
OsSupport::checkAlarms();
}
else if (sig == SIGCHLD)
{
if (OsSupport::hasAlarms())
{
///
/// FIXME
///
/// there are expiriation alarms active and a child died unexpectly
/// lets commit suicide
exit(-2);
}
}
}
void OsSupport::setAlarm(long secs, OsSupport::ProcessID pid)
{
sigemptyset( &s_sact.sa_mask );
s_sact.sa_flags = 0;
s_sact.sa_handler = handleSignal;
sigaction( SIGALRM, &s_sact, NULL );
PTIME_ENTRY entry = (PTIME_ENTRY) malloc(sizeof(TIME_ENTRY));
if (entry)
{
struct timeval tm;
gettimeofday(&tm, 0);
tm.tv_sec += secs;
entry->tm = tm;
entry->pid = pid;
for(size_t i = 0; i < s_Entries.size(); i++)
{
if (tm.tv_sec < s_Entries[i]->tm.tv_sec && tm.tv_usec < s_Entries[i]->tm.tv_usec)
{
if (i == 0)
{
/* adjust alarm timer to new period */
alarm(secs);
}
s_Entries.insert(s_Entries.begin() + i, entry);
return;
}
}
s_Entries.push_back(entry);
alarm(secs);
}
}
#endif
} // end of namespace System_

View file

@ -1,160 +0,0 @@
#ifndef OS_SUPPORT_H__
#define OS_SUPPORT_H__
/* $Id: os_support.h 24643 2006-10-24 11:45:21Z janderwald $
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: operating systems specific code
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
#endif
#include "user_types.h"
#include <ctime>
#include <vector>
#include <cstdlib>
#include <cstring>
#ifndef _MSC_VER
#include <sys/time.h>
#endif
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
namespace System_
{
//---------------------------------------------------------------------------------------
///
/// class OsSupport
///
/// Description: this class encapsulates operating system specific functions
///
///
class OsSupport
{
public:
#ifdef WIN32
typedef DWORD ProcessID;
#else
typedef pid_t ProcessID;
#endif
//---------------------------------------------------------------------------------------
///
/// OsSupport
///
/// Description: constructor of class OsSupport
virtual ~OsSupport()
{}
//---------------------------------------------------------------------------------------
///
/// createProcess
///
/// Description: this functions creates a new process and returns its pid on success
///
/// @param procname name of the file to execute
/// @param procargsnum num of arguments for the new process
/// @param procargs arguments for the new process
///
///
static ProcessID createProcess(const char * procname, int procargsnum, const char ** procargs, bool wait);
//---------------------------------------------------------------------------------------
///
/// terminateProcess
///
/// Description: this function terminates a process given by its pid
///
/// Note: returns true if the process with the given pid was terminated
///
/// @param pid process id of the process to terminate
/// @param exitcode for the killed process
static bool terminateProcess(ProcessID pid, int exitcode);
//----------------------------------------------------------------------------------------
///
/// delayExecution
///
/// Description: this function sleeps the current process for the amount given in seconds
///
/// @param sec amount of seconds to sleep
static void delayExecution(long sec);
///---------------------------------------------------------------------------------------
///
/// initializeTimer
///
/// Description: this function initializes an alarm. When the alarm expires, it will terminate
/// the given process
static void setAlarm(long sec, OsSupport::ProcessID pid);
///---------------------------------------------------------------------------------------
///
/// cancelAlarms
///
/// Description: this function cancels all available timers
static void cancelAlarms();
///---------------------------------------------------------------------------------------
///
/// checkAlarms
///
/// Description: this function checks for expired alarams
static void checkAlarms();
///---------------------------------------------------------------------------------------
///
/// hasAlarms
///
/// Description: this function checks wether there are alarms set active
static bool hasAlarms();
protected:
//---------------------------------------------------------------------------------------
///
/// OsSupport
///
/// Description: constructor of class OsSupport
OsSupport()
{}
#ifndef WIN32
static struct sigaction s_sact;
#else
static HANDLE s_hThread;
#endif
typedef struct
{
struct timeval tm;
ProcessID pid;
}TIME_ENTRY, *PTIME_ENTRY;
typedef std::vector<PTIME_ENTRY> TimeEntryVector;
static TimeEntryVector s_Entries;
}; // end of class OsSupport
} // end of namespace System_
#endif /* end of OS_SUPPORT_H__ */

View file

@ -1,101 +0,0 @@
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: pipe reader support
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "pipe_reader.h"
namespace System_
{
using std::vector;
//---------------------------------------------------------------------------------------
PipeReader::PipeReader() : m_File(NULL)
{
}
//---------------------------------------------------------------------------------------
PipeReader::~PipeReader()
{
}
//---------------------------------------------------------------------------------------
bool PipeReader::openSource(string const & PipeCmd)
{
if (m_File != NULL)
{
cerr << "PipeReader::openPipe> pipe already open" << endl;
return false;
}
cerr << "cmd>" << PipeCmd << endl;
m_File = popen(PipeCmd.c_str(), "r"); //AccessMode.c_str());
if (m_File)
{
cerr << "PipeReader::openPipe> successfully opened pipe" << endl;
return true;
}
cerr << "PipeReader::openPipe> failed to open pipe " << PipeCmd << endl;
return false;
}
//---------------------------------------------------------------------------------------
bool PipeReader::closeSource()
{
if (!m_File)
{
cerr << "PipeReader::closePipe> pipe is not open" << endl;
return false;
}
int res = pclose(m_File);
if (res == INT_MAX)
{
cerr << "Error: _pclose failed " <<endl;
return false;
}
m_File = NULL;
return true;
}
//---------------------------------------------------------------------------------------
bool PipeReader::isSourceOpen()
{
return feof(m_File);
}
//---------------------------------------------------------------------------------------
bool PipeReader::readSource(vector<string> & lines)
{
char * buf = (char*)malloc(100 * sizeof(char));
//#ifdef NDEBUG
memset(buf, 0x0, sizeof(char) * 100);
//#endif
char * res = fgets(buf, 100, m_File);
if (!res)
{
//cerr << "Error: PipeReader::readPipe failed" << endl;
free(buf);
return false;
}
fflush(m_File);
string line(buf);
lines.push_back(line);
return true;
}
} // end of namespace System_

View file

@ -1,110 +0,0 @@
#ifndef PIPE_READER_H__
#define PIPE_READER_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: file reading support
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include "data_source.h"
#include <cstdio>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <limits.h>
namespace System_
{
//---------------------------------------------------------------------------------------
///
/// class PipeReader
///
/// Description: this class implements a pipe reader. It uses _popen to perform opening of
/// pipe / _pclose
class PipeReader : public DataSource
{
public:
//---------------------------------------------------------------------------------------
///
/// PipeReader
///
/// Description: constructor of class PipeReader
PipeReader();
//---------------------------------------------------------------------------------------
///
/// virtual ~PipeReader
///
/// Description: destructor of class PipeReader
virtual ~PipeReader();
//---------------------------------------------------------------------------------------
///
/// openPipe
///
/// Description: this function attempts to open a pipe. If an pipe is already open or
/// it fails to open a pipe, the function returns false
///
/// @param PipeCmd command of the pipe to open
/// @param AccessMode on how to open the pipe
/// accepted modes are t ... text mode - not compatible with b
/// b ... binary mode - not compatible with t
/// r ... allows reading from the pipe
/// w ... allows writing to the pipe
/// @return bool
virtual bool openSource(const string & PipeCmd);
//---------------------------------------------------------------------------------------
///
/// closePipe
///
/// Description: closes a pipe. Returns true on success
///
/// @return bool
virtual bool closeSource();
//---------------------------------------------------------------------------------------
///
/// readPipe
///
/// Description: attempts to read from the pipe. Returns true on success. If it returns
/// false, call PipeReader::isEoF() to determine if the pipe should be closed
///
/// @param Buffer to be written to
/// @return string::size_type
bool readSource(std::vector<string> & lines);
//---------------------------------------------------------------------------------------
///
/// isEof
///
/// Description: returns true if the pipe has reached end of file. The caller should call
/// closePipe if this function returns true
virtual bool isSourceOpen();
protected:
FILE * m_File;
}; // end of class PipeReader
} // end of namespace System_
#endif /* end of PIPE_READER_H__ */

View file

@ -1,93 +0,0 @@
#ifndef REG_TEST_H__
#define REG_TEST_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: regression test abstract class
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include "conf_parser.h"
namespace Sysreg_
{
using Sysreg_::ConfigParser;
//-------------------------------------------------------------------
///
/// class RegressionTest
///
/// Description: The class RegressionTest is an abstract base class. Every
/// regression test class derives from this class.
class RegressionTest
{
public:
//---------------------------------------------------------------------------------------
///
/// RegressionTest
///
/// Description: constructor of class RegressionTest
///
/// @param RegName name of derriving subclass
RegressionTest(const string RegName) : m_Name(RegName)
{}
//---------------------------------------------------------------------------------------
///
/// ~RegressionTest
///
/// Description: destructor of class RegressionTest
virtual ~RegressionTest()
{}
//---------------------------------------------------------------------------------------
///
/// getName
///
/// Description: returns the value of the member m_Name
const string & getName() const
{ return m_Name; }
//---------------------------------------------------------------------------------------
///
/// execute
///
/// Description: the execute function passes an System_::ConfigParser object to the
/// derriving RegresssionTest class. The class can then read required options from the
/// configuration file. The RegressionTest shall then perform its specific regression test.
/// @see System_::PipeReader
/// @see System_::SymbolFile
///
/// Note : if an error happens or the option cannot be found, this function
/// should return false.
virtual bool execute(ConfigParser & conf_parser) = 0;
//---------------------------------------------------------------------------------------
///
/// checkForHang
///
///
///
protected:
string m_Name;
}; // end of class RegressionTest
} // end of namespace Sysreg_
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,194 +0,0 @@
#ifndef ROSBOOT_TEST_H__
#define ROSBOOT_TEST_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: ReactOS boot test
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "data_source.h"
#include "conf_parser.h"
#include "os_support.h"
#include "user_types.h"
#include "pipe_reader.h"
#include "namedpipe_reader.h"
#include "file_reader.h"
#include "os_support.h"
#include "env_var.h"
#include <vector>
#include <iostream>
#include <vector>
#include <fstream>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef WIN32
#include <io.h>
#include <errno.h>
#endif
#ifndef WIN32
#include <unistd.h>
#include <sys/types.h>
#if defined(__FreeBSD__) || defined(__APPLE__)
# include <sys/stat.h>
#endif // __FreeBSD__
#endif
namespace Sysreg_
{
using std::vector;
using System_::DataSource;
using System_::OsSupport;
//---------------------------------------------------------------------------------------
///
/// class RosBootTest
///
/// Description: this class attempts to boot ReactOS in an emulator with console logging enabled.
/// It
class RosBootTest
{
public:
static string ROS_EMU_TYPE;
static string EMU_TYPE_QEMU;
static string EMU_TYPE_VMWARE;
static string EMU_TYPE_XEN;
static string ROS_EMU_PATH;
static string ROS_HDD_IMAGE;
static string ROS_CD_IMAGE;
static string ROS_MAX_TIME;
static string ROS_LOG_FILE;
static string ROS_SYM_DIR;
static string ROS_DELAY_READ;
static string ROS_SYSREG_CHECKPOINT;
static string ROS_CRITICAL_IMAGE;
static string ROS_EMU_KILL;
static string ROS_EMU_MEM;
static string ROS_BOOT_CMD;
static string XEN_CONFIG_FILE;
static string XEN_CONFIG_NAME;
//---------------------------------------------------------------------------------------
///
/// RosBootTest
///
/// Description: constructor of class RosBootTest
///
RosBootTest();
//---------------------------------------------------------------------------------------
///
/// ~RosBootTest
///
/// Description: destructor of class RosBootTest
///
virtual ~RosBootTest();
//---------------------------------------------------------------------------------------
///
/// execute
///
/// Description: this function performs a ReactOS boot test. It reads the variable
/// ROSBOOT_CMD and executes this specific command. This command shall contain the path
/// to an emulator (i.e. qemu) and the required arguments (-serial switch, hdd img etc) to be able
/// to read from console. If an error is detected, it attempts to resolve the faulting
/// module and address.
virtual bool execute(ConfigParser & conf_parser);
protected:
void getDefaultHDDImage(string & img);
bool isFileExisting(string filename);
bool isDefaultHDDImageExisting();
bool createHDDImage(string filename);
bool isQemuPathValid();
bool getQemuDir(string &);
bool createBootCmd();
bool extractPipeFromBootCmd();
bool configureCDImage();
bool configureHDDImage();
void getPidFromFile();
bool executeBootCmd();
void delayRead();
bool configurePipe();
bool configureFile();
bool analyzeDebugData();
bool readConfigurationValues(ConfigParser & conf_parser);
bool configureQemu();
bool configureVmWare();
bool configureXen(ConfigParser &conf_parser);
bool hasQemuNoRebootOption();
void cleanup(ConfigParser &conf_parser);
bool xenGetCaps();
//---------------------------------------------------------------------------------------
///
/// dumpCheckpoints
///
/// Description: prints a list of all reached checkpoints so far
void dumpCheckpoints();
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
/// If it detects an fatal error, it should return false
///
/// Note: the received debug information should be written to an internal log object
/// to facilate post-processing of the results
DebugState checkDebugData(vector<string> & debug_data);
protected:
string m_EmuType;
string m_EmuPath;
string m_HDDImage;
string m_CDImage;
long int m_MaxTime;
string m_DebugFile;
string m_SymDir;
long int m_DelayRead;
string m_Checkpoint;
string m_CriticalImage;
string m_KillEmulator;
string m_MaxMem;
string m_BootCmd;
string m_Src;
string m_DebugPort;
string m_PidFile;
string m_XenConfig;
DataSource * m_DataSource;
OsSupport::ProcessID m_Pid;
std::vector<string> m_Checkpoints;
}; // end of class RosBootTest
} // end of namespace Sysreg_
#endif /* end of ROSBOOT_H__ */

View file

@ -1,191 +0,0 @@
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: source symbol lookup
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "sym_file.h"
#include "env_var.h"
#include "pipe_reader.h"
#include "conf_parser.h"
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#define _FINDDATA_T_DEFINED
#include <io.h>
#include <time.h>
namespace System_
{
using std::vector;
string SymbolFile::VAR_ROS_OUTPUT = "ROS_OUTPUT";
string SymbolFile::ROS_ADDR2LINE = "ROS_ADDR2LINE";
string SymbolFile::m_SymbolPath= "";
string SymbolFile::m_SymResolver= "";
SymbolFile::SymbolMap SymbolFile::m_Map;
//---------------------------------------------------------------------------------------
SymbolFile::SymbolFile()
{
}
//---------------------------------------------------------------------------------------
SymbolFile::~SymbolFile()
{
}
//---------------------------------------------------------------------------------------
bool SymbolFile::initialize(ConfigParser & conf_parser, string const &Path)
{
vector<string> vect;
string current_dir;
if (Path == "")
{
current_dir = "output-i386";
EnvironmentVariable::getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir);
}
else
{
current_dir = Path;
}
m_SymbolPath = current_dir;
if (!conf_parser.getStringValue (ROS_ADDR2LINE, m_SymResolver))
{
cerr << "Warning: ROS_ADDR2LINE is not set in configuration file -> symbol lookup will fail" <<endl;
return false;
}
string val = current_dir;
val.insert (val.length()-1, "\\*");
struct _finddatai64_t c_file;
intptr_t hFile = _findfirsti64(val.c_str(), &c_file);
if (hFile == -1L)
{
cerr << "SymbolFile::initialize> failed" <<endl;
return false;
}
do
{
do
{
char * pos;
if ((pos = strstr(c_file.name, ".nostrip.")))
{
size_t len = strlen(pos);
string modulename = c_file.name;
string filename = modulename;
modulename.erase(modulename.length() - len, len);
string path = current_dir;
path.insert (path.length () -1, "\\");
path.insert (path.length () -1, filename);
#ifdef NDEBUG
cerr << "Module Name " << modulename << endl << "File Name " << path << endl;
#endif
m_Map.insert(std::make_pair<string, string>(modulename, path));
}
if (c_file.attrib & _A_SUBDIR)
{
if (c_file.name[0] != _T('.'))
{
string path = current_dir;
path.insert (path.length ()-1, "\\");
path.insert (path.length ()-1, c_file.name);
vect.push_back (path);
}
}
}while(_tfindnexti64(hFile, &c_file) == 0);
_findclose(hFile);
hFile = -1L;
while(!vect.empty ())
{
current_dir = vect.front ();
vect.erase (vect.begin());
val = current_dir;
val.insert (val.length() -1, "\\*");
hFile = _tfindfirsti64(val.c_str(), &c_file);
if (hFile != -1L)
{
break;
}
}
if (hFile == -1L)
{
break;
}
}while(1);
return !m_Map.empty();
}
//---------------------------------------------------------------------------------------
bool SymbolFile::resolveAddress(const string &module_name, const string &module_address, string &Buffer)
{
SymbolMap::const_iterator it = m_Map.find (module_name);
if (it == m_Map.end () || m_SymResolver == "")
{
cerr << "SymbolFile::resolveAddress> no symbol file or ROS_ADDR2LINE not set" << endl;
return false;
}
char szCmd[300];
sprintf(szCmd, "%s %s %s", m_SymResolver.c_str (), it->second.c_str (), module_address.c_str());
string pipe_cmd(szCmd);
vector<string> vect;
PipeReader pipe_reader;
if (!pipe_reader.openSource(pipe_cmd))
{
cerr << "SymbolFile::resolveAddress> failed to open pipe" <<pipe_cmd <<endl;
return false;
}
bool ret = pipe_reader.readSource (vect);
pipe_reader.closeSource ();
return ret;
}
//---------------------------------------------------------------------------------------
bool SymbolFile::getSymbolFilePath(string const &ModuleName, string &FilePath)
{
SymbolMap::const_iterator it = m_Map.find (ModuleName);
if (it == m_Map.end ())
{
cerr << "SymbolFile::resolveAddress> no symbol file found for module " << ModuleName << endl;
return false;
}
FilePath = it->second;
return true;
}
} // end of namespace System_

View file

@ -1,111 +0,0 @@
#ifndef SYM_FILE_H__
#define SYM_FILE_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: source symbol lookup
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "conf_parser.h"
#include <map>
namespace System_
{
using Sysreg_::ConfigParser;
//---------------------------------------------------------------------------------------
///
/// class SymbolFile
///
/// Description: this class performs 2 tasks: First, it locates all available module names
/// and their associated symbol files. Secondly, it performs resolving address to source addresses
/// via the function resolveAddress
///
/// Usage: call initialize(). Then call resolveAddress();
/// i.e. resolveAddress("comctl32.dll", 0xBLABLABLA, result);
class SymbolFile
{
public:
static string VAR_ROS_OUTPUT;
static string ROS_ADDR2LINE;
typedef std::map<string, string> SymbolMap;
//---------------------------------------------------------------------------------------
///
/// ~SymbolFile
///
/// Description: destructor of class SymbolFile
virtual ~SymbolFile();
//---------------------------------------------------------------------------------------
///
/// initialize
///
/// Description: this function initialize the class. It searches the subdirs
/// of ROS_OUTPUT and adds all files with name *.nostrip.* to a map with module
/// name as the key.
///
/// Note: if the param Path is not empty, it adds all found modules to the internal
/// map
///
/// Note: if the path does not exist or the no symbol files were added then false is returned
///
/// Note: if a module with same module name is already in the map, then the new module is not added
///
/// @param Path path to ROS_OUTPUT containing symbol files
/// @return bool
static bool initialize(ConfigParser & conf_parser, const string & Path);
//---------------------------------------------------------------------------------------
///
/// resolveAddress
///
/// Description: this function attempts to resolve an address using a given symbol file
///
/// Note: the lookup is performed with raddr2line
///
/// @param module_name name of the module to examine
/// @param module_address address of the module to resolve
/// @param buffer receives information about the resolved location
/// @return bool
static bool resolveAddress(const string & module_name, const string & module_address, string & Buffer);
//---------------------------------------------------------------------------------------
///
/// getSymbolFilePath
///
/// Description: this function returns the associated FilePath to a given module name. If
/// the module name is not known, it returns false and the param FilePath remains untouched
///
/// @param ModuleName name of the module to lookup
/// @param FilePath buffer receiving the address of symbol file
static bool getSymbolFilePath(const string & ModuleName, string & FilePath);
protected:
//---------------------------------------------------------------------------------------
///
/// SymbolFile
///
/// Description: constructor of class SymbolFile
SymbolFile();
static SymbolMap m_Map;
static string m_SymbolPath;
static string m_SymResolver;
};
} // end of namespace System_
#endif /* end of SYM_FILE_H__ */

View file

@ -1,87 +0,0 @@
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: app initialization
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "sysreg.h"
using System_::EnvironmentVariable;
using Sysreg_::ConfigParser;
//regression test classes
using Sysreg_::RosBootTest;
#if 0
using System_::SymbolFile;
#endif
static const char USAGE[] =
"sysreg.exe [conf_file]\nconfiguration file (default: sysreg.cfg)";
int main(int argc, char * argv[])
{
ConfigParser config;
char DefaultConfig[] = "sysreg.cfg";
char *ConfigFile;
if ((argc > 2))
{
cerr << USAGE << endl;
return -1;
}
//---------------------------------------------------------------------------------------
if (argc == 2)
{
ConfigFile = argv[1];
}
else
{
ConfigFile = DefaultConfig;
}
if (!config.parseFile (ConfigFile))
{
cerr << USAGE << endl;
return -1;
}
RosBootTest * regtest = new RosBootTest();
if (!regtest)
{
cerr << "Error: failed to create regression test" << endl;
return -1;
}
string envvar;
string ros = "ROS_OUTPUT";
config.getStringValue (ros, envvar);
#if 0
SymbolFile::initialize (config, envvar);
#endif
for(int i = 0; i < 3; i++)
{
bool ret = regtest->execute(config);
if (!ret)
{
cout << "The regression test has failed at stage: " << i << endl;
delete regtest;
return -2;
}
}
cout << "The regression test completed successfully" << endl;
delete regtest;
return 0;
}

View file

@ -1,23 +0,0 @@
#ifndef SYSREG_H__
#define SYSREG_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/conf_parser.h
* PURPOSE: app initialization
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include "user_types.h"
#include "env_var.h"
#include "sym_file.h"
#include "conf_parser.h"
// regression test classes
#include "rosboot_test.h"
#endif /* end of SYSREG_H__ */

View file

@ -1,14 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
<module name="sysreg" type="buildtool">
<file>conf_parser.cpp</file>
<file>env_var.cpp</file>
<file>rosboot_test.cpp</file>
<file>namedpipe_reader.cpp</file>
<file>pipe_reader.cpp</file>
<file>sysreg.cpp</file>
<file>file_reader.cpp</file>
<file>os_support.cpp</file>
<file>timer_command_callback.cpp</file>
</module>

View file

@ -1,56 +0,0 @@
#ifndef TIMER_CALLBACK_H__
#define TIMER_CALLBACK_H__
namespace System_
{
//---------------------------------------------------------------------------------------
///
/// TimerCallback
///
/// Description: base class for all timer callback functions
class TimerCallback
{
public:
//---------------------------------------------------------------------------------------
///
/// TimerCallback
///
/// Description: constructor of class TimerCallback
TimerCallback() {}
//---------------------------------------------------------------------------------------
///
/// TimerCallback
///
/// Description: destructor of class TimerCallback
virtual ~TimerCallback() {}
//---------------------------------------------------------------------------------------
///
/// initialize
///
/// Description: this function is called when the timercallback object is initialized in
/// in the callback mechanism
virtual bool initialize(){ return true;}
//---------------------------------------------------------------------------------------
///
/// hasExpired
///
/// Description: this function is called everytime timer event has started. The callback object
/// should return true if the expiration function has expired.
/// Note: the function should then also cleanup all consumed resourced
virtual bool hasExpired() = 0;
}; //end of class TimerCallback
}// end of namespace System_
#endif

View file

@ -1,41 +0,0 @@
#include "timer_command_callback.h"
namespace System_
{
using Sysreg_::ConfigParser;
string TimerCommandCallback::ROS_TIMER_COMMAND="ROS_TIMER_COMMAND";
string TimerCommandCallback::ROS_TIMER_TIMEOUT="ROS_TIMER_TIMEOUT";
//---------------------------------------------------------------
TimerCommandCallback::TimerCommandCallback(ConfigParser &conf_parser) : TimerCallback(), m_parser(conf_parser), m_Cmd(""), m_Timeout(0)
{
}
//---------------------------------------------------------------
TimerCommandCallback::~TimerCommandCallback()
{
}
//---------------------------------------------------------------
bool TimerCommandCallback::initialize()
{
m_parser.getStringValue(ROS_TIMER_COMMAND, m_Cmd);
m_parser.getIntValue(ROS_TIMER_TIMEOUT, m_Timeout);
//FIXME
// calculate current time
return true;
}
//---------------------------------------------------------------
bool TimerCommandCallback::hasExpired()
{
// FIXME
// calculate current time
// calculate difference
// and invoke m_Cmd when it has expired
return false;
}
} // end of namespace System_

View file

@ -1,57 +0,0 @@
#ifndef TIMER_COMMAND_CALLBACK_H__ //timer_command_callback.h
#define TIMER_COMMAND_CALLBACK_H__
#include "conf_parser.h"
#include "timer_callback.h"
namespace System_
{
class TimerCommandCallback : public TimerCallback
{
public:
//---------------------------------------------------------------
///
/// TimerCommandCallback
///
/// Description: constructor of class TimerCommandCallback
///
/// @param conf_parser contains configuration data
TimerCommandCallback(Sysreg_::ConfigParser &conf_parser);
//---------------------------------------------------------------
///
/// ~TimerCommandCallback
///
/// Description: destructor of class TimerCommandCallback
virtual ~TimerCommandCallback();
//---------------------------------------------------------------
///
/// initialize
///
/// Description: initializes the callback object
virtual bool initialize();
//---------------------------------------------------------------
///
/// hasExpired
///
/// Description: returns true when the callback object has expired
virtual bool hasExpired();
protected:
Sysreg_::ConfigParser & m_parser;
string m_Cmd;
long int m_Timeout;
static string ROS_TIMER_TIMEOUT;
static string ROS_TIMER_COMMAND;
};
} /* EOF namspace System_ */
#endif /* EOF TIMER_COMMAND_CALLBACK_H__ */

View file

@ -1,110 +0,0 @@
; ROS_EMULATOR_TYPE
;
; This variable defines which emulator should be used to emulate ReactOS
;
;ROS_EMU_TYPE=[qemu|vmware|xen]
ROS_EMU_TYPE=qemu
; ROS_EMU_PATH[LIN|WIN]
;
; This variable sets the path to the emulator (path to xm for xen [/usr/sbin])
;
ROS_EMU_PATH_WIN=E:\reactos\qemu\qemu.exe
ROS_EMU_PATH_LIN=/usr/bin/qemu
; ROS_HDD_IMAGE
;
; The hdd image to use for running the emulator. If this variable is not
; set, SysReg will create a HDD with name "ros.img" using the qemu-img tool. It will search
; this tool in the directory of emulator and abort if the tool cannot be found
;ROS_HDD_IMAGE=E:\reactos\qemu\ReactOS.hd
; ROS_CD_IMAGE
;
; Set this variable if you want sysreg to perform a full ReactOS installation using
; an ReactOS unattended installation disk. If this variable is not set, SysReg lets the emulator boot
; from harddisk.
;
;ROS_CD_IMAGE=E:\reactos\qemu\Reactos-Regtest.iso
;-------------------------------------------------------------------------------------------
; Additional Options
;
; ROS_MAX_TIME
;
;
; Set this variable to value which is the maximum time the emulator lets ReactOS run
; If not set, the emulator runs as long as no exception occurs in the emulator.
ROS_MAX_TIME=180
; ROS_LOG_FILE
;
; filename of log which receives all debugging data gained from the Emulator
; ROS_LOG_FILE=debug.log
; ROS_SYM_DIR
;
; This directory sets the location where to search symbol files for modules
; In case of an BSOD, usermode exception, Sysreg will attempt to create a backtrace
; from the debugging data
;
; ROS_SYM_DIR=E:\reactos\output-i386
; ROS_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.
;
; Note: set this value if you have problems with timeouts or cutoff debugging data
;
ROS_DELAY_READ=1
; ROS_CHECK_POINT
;
; RosBoot will stop executing when it finds a string in the form
; SYSREG_CHECKPOINT:YOUR_CHECKPOINT_NAME
;
;ROS_CHECK_POINT=YOUR_CHECKPOINT_NAME
;ROS_CRITICAL_IMAGE
;
; If an user-mode exception occurs in an critical application, dll etc, i.e. setup.exe / explorer.exe, sysreg will report
; that the test has failed and quit debugging immediately
;
;ROS_CRITICAL_IMAGE=setup.exe userinit.exe smss.exe winlogon.exe csrss.exe explorer.exe
; ROS_EMU_KILL
;
; Set this variable to true if you want SysReg to kill the emulator process when it has decided to exit.
;
; Note: Qemu>=0.9.0 has the option to shutdown on reboot (-no--reboot)
;
; ROS_EMU_KILL=yes
; ROS_EMU_MEM
;
; Controls how much memory the emulator use for ReactOS
;
; ROS_EMU_MEM=64
; ROS_BOOT_CMD
;
; Sysreg normally builds the boot command from ROS_EMU_PATH and ROS_CD_IMAGE etc... If you want to override
; all settings set this value
;
; ROS_BOOT_CMD=/usr/bin/qemu -serial stdio -m 64 -hda ~/reactos/qemu/ReactOS.hd -boot d -cdrom ~/reactos/qemu/bootcd.iso
; -no-reboot
; XEN_CONFIG_FILE
;
; Set this variable to path of xen config file when ROS_EMU_TYPE=xen is used
; XEN_CONFIG_FILE=
; XEN_CONFIG_NAME
;
; Set this variable to the name of xen station
; XEN_CONFIG_NAME=reactos

View file

@ -1,29 +0,0 @@
#ifndef USER_TYPES_H__
#define USER_TYPES_H__
/* $Id$
*
* PROJECT: System regression tool for ReactOS
* LICENSE: GPL - See COPYING in the top level directory
* FILE: tools/sysreg/user_types.h
* PURPOSE: user types
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/
#include <string>
#include <iostream>
#ifdef WIN32
#define popen _popen
#define pclose _pclose
#endif
typedef std::basic_string<char> string;
typedef std::basic_istringstream<char> istringstream;
using std::cout;
using std::cerr;
using std::endl;
#endif // end of USER_TYPES_H__

View file

@ -13,9 +13,6 @@
<directory name="rgenstat">
<xi:include href="rgenstat/rgenstat.rbuild" />
</directory>
<directory name="sysreg">
<xi:include href="sysreg/sysreg.rbuild" />
</directory>
<directory name="unicode">
<xi:include href="unicode/unicode.rbuild" />
</directory>