- fix command line handlung

- fix configuration and file parser
- remove hack

svn path=/trunk/; revision=27647
This commit is contained in:
Johannes Anderwald 2007-07-14 10:24:02 +00:00
parent bdd2ecc99e
commit d07065ab90
3 changed files with 7 additions and 13 deletions

View file

@ -16,7 +16,6 @@
namespace Sysreg_ namespace Sysreg_
{ {
using std::ifstream; using std::ifstream;
extern "C" FILE * open(char * filename, char* filemode);
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
ConfigParser::ConfigParser() ConfigParser::ConfigParser()
{ {
@ -36,14 +35,13 @@ namespace Sysreg_
#ifdef UNICODE #ifdef UNICODE
file = _tfopen(FileName, _T("rt,ccs=UNICODE")); file = _tfopen(FileName, _T("rt,ccs=UNICODE"));
#else #else
file = open(FileName, "rt"); file = fopen(FileName, "rt");
#endif #endif
if (!file) if (!file)
{ {
cerr << "Error: ConfigParser::parseFile failed to open configuration file " << FileName << endl; cerr << "Error: ConfigParser::parseFile failed to open configuration file " << FileName << endl;
return false; return false;
} }
bool ret = false; bool ret = false;
while (!feof(file)) while (!feof(file))
{ {

View file

@ -12,7 +12,6 @@
#include <cstdio> #include <cstdio>
namespace System_ namespace System_
{ {
extern "C" FILE * open(char * filename, char* filemode);
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
FileReader::FileReader() : DataSource(), m_File(NULL) FileReader::FileReader() : DataSource(), m_File(NULL)
{ {
@ -27,7 +26,7 @@ namespace System_
#ifdef UNICODE #ifdef UNICODE
m_File = (FILE*)_tfopen(filename.c_str(), _T("rb,ccs=UNICODE")); m_File = (FILE*)_tfopen(filename.c_str(), _T("rb,ccs=UNICODE"));
#else #else
m_File = open((char*)filename.c_str(), (char*)"rb"); m_File = fopen((char*)filename.c_str(), (char*)"rb");
#endif #endif
if (m_File) if (m_File)

View file

@ -23,7 +23,7 @@ using System_::SymbolFile;
#endif #endif
static const TCHAR USAGE[] = static const TCHAR USAGE[] =
_T("sysreg.exe -l | [conf_file] <testname>\n\n-l - list available tests\nconf_file - (optional) path to a configuration file (default: sysreg.cfg)\ntest_name - name of test to execute\n"); _T("sysreg.exe [conf_file]\nconfiguration file (default: sysreg.cfg)");
@ -33,9 +33,8 @@ int _tmain(int argc, TCHAR * argv[])
ConfigParser config; ConfigParser config;
TCHAR DefaultConfig[] = _T("sysreg.cfg"); TCHAR DefaultConfig[] = _T("sysreg.cfg");
TCHAR *ConfigFile; TCHAR *ConfigFile;
TCHAR * TestName;
if ((argc != 3) && (argc != 2)) if ((argc >= 2))
{ {
cerr << USAGE << endl; cerr << USAGE << endl;
return -1; return -1;
@ -45,13 +44,11 @@ int _tmain(int argc, TCHAR * argv[])
if (argc == 2) if (argc == 2)
{ {
ConfigFile = DefaultConfig; ConfigFile = argv[1];
TestName = argv[1];
} }
else else
{ {
ConfigFile = argv[1]; ConfigFile = DefaultConfig;
TestName = argv[2];
} }
@ -64,7 +61,7 @@ int _tmain(int argc, TCHAR * argv[])
RosBootTest * regtest = new RosBootTest(); RosBootTest * regtest = new RosBootTest();
if (!regtest) if (!regtest)
{ {
cerr << "Error: the requested regression test does not exist" << endl; cerr << "Error: failed to create regression test" << endl;
return -1; return -1;
} }