You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.0 KiB

  1. #include <iostream>
  2. #include "gtest/gtest.h"
  3. #include "log4cplus/logger.h"
  4. #include "log4cplus/loggingmacros.h"
  5. #include "log4cplus/consoleappender.h"
  6. #include "log4cplus/fileappender.h"
  7. #include "src/settings/Settings.h"
  8. log4cplus::Logger logger;
  9. /*!
  10. * Initializes the logging framework.
  11. */
  12. void setUpLogging() {
  13. logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main"));
  14. logger.setLogLevel(log4cplus::WARN_LOG_LEVEL);
  15. log4cplus::SharedAppenderPtr fileLogAppender(new log4cplus::FileAppender("storm-performance-tests.log"));
  16. fileLogAppender->setName("mainFileAppender");
  17. fileLogAppender->setThreshold(log4cplus::WARN_LOG_LEVEL);
  18. fileLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M} (%r ms) - %F:%L : %m%n")));
  19. logger.addAppender(fileLogAppender);
  20. // Uncomment these lines to enable console logging output
  21. // log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender());
  22. // consoleLogAppender->setName("mainConsoleAppender");
  23. // consoleLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%s} (%r ms) - %F:%L : %m%n")));
  24. // logger.addAppender(consoleLogAppender);
  25. }
  26. /*!
  27. * Creates an empty settings object as the standard instance of the Settings class.
  28. */
  29. void createEmptyOptions() {
  30. const char* newArgv[] = {"storm-performance-tests", "--maxiter", "20000"};
  31. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  32. try {
  33. storm::settings::Settings::parse(3, newArgv);
  34. } catch (storm::exceptions::OptionParserException& e) {
  35. std::cout << "Could not recover from settings error: " << e.what() << "." << std::endl;
  36. std::cout << std::endl << s->getHelpText();
  37. }
  38. }
  39. int main(int argc, char* argv[]) {
  40. setUpLogging();
  41. createEmptyOptions();
  42. std::cout << "StoRM (Performance) Testing Suite" << std::endl;
  43. testing::InitGoogleTest(&argc, argv);
  44. int result = RUN_ALL_TESTS();
  45. logger.closeNestedAppenders();
  46. return result;
  47. }