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.

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