//============================================================================ // Name : workbench.cpp // Author : Dmitry A Romanov //============================================================================ //Disable posix warning on getch() #pragma warning(disable : 4996) #include /* vfprintf example */ #include #include #ifdef WIN32 #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #ifdef WIN32 #include #endif #include using namespace std; //#include "tests.h" #include "Model/DDirectory.h" #include "Providers/DMySQLDataProvider.h" #include "Tests/tests.h" #include "DConsole.h" #include "DWorkUtils.h" #include "DStopWatch.h" #include "Tests/tests_macros.h" #include "DLog.h" #include "Web/DHttpContext.h" using namespace ccdb; bool benchmark_Providers(); void PrintHelp(); DConsole gConsole; std::string gConnectionString; int main (int argc,char *argv[]) { /*DDataProvider *prov = new DMySQLDataProvider(); if(!prov->Connect(TESTS_CONENCTION_STRING)) { cout<<"error connect"< dirs = prov->SearchDirectories("*", "/");*/ #ifdef WEB DHttpContext::Instance()->ProcessRequest(); return 0; #endif //ok to avoid complex command line parsing //some setup gConnectionString = TESTS_CONENCTION_STRING; gConsole.SetUseColors(true); DLog::SetUseColors(true); bool runTests = false; bool runBenchmarks = false; bool runPause = false; // copy program arguments into vector vector args; for (int i=1;i= (args.size()-1)) PrintHelp(); //check if we have argument after i++; gConnectionString = args[i]; } } //what to do? if(args.size()==0) PrintHelp(); //benchmarks? if(runBenchmarks) { benchmark_Providers(); } //tests? if(runTests) { RunTests(); gConsole.WriteLine(DConsole::cBrightGreen, "\n>>> Tests done <<<"); } //pause? if(runPause) { string x; cout<>x; } return 0; } void PrintHelp() { gConsole.WriteLine("Test and benchmarking of CCDB database"); gConsole.WriteLine(" --nocolors or -c disables colors"); gConsole.WriteLine(" --tests or -t run tests"); gConsole.WriteLine(" --benchmarks or -b run benchmarks"); gConsole.WriteLine(" --pause or -p pause at the end"); gConsole.WriteLine(" --help or -h shows this help"); gConsole.WriteLine(" --server or -s connection string like mysql://user:pwd@server"); gConsole.WriteLine(" --verbose or -v shows additional (probably debug) information"); }