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.

69 lines
2.4 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::ERROR_LOG_LEVEL);
  16. log4cplus::SharedAppenderPtr fileLogAppender(new log4cplus::FileAppender("storm-functional-tests.log"));
  17. fileLogAppender->setName("mainFileAppender");
  18. fileLogAppender->setThreshold(log4cplus::FATAL_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-functional-tests"};
  32. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  33. try {
  34. storm::settings::Settings::parse(1, 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 (Functional) Testing Suite" << std::endl;
  44. testing::InitGoogleTest(&argc, argv);
  45. // now all Google Test Options have been removed
  46. storm::settings::Settings* instance = storm::settings::Settings::getInstance();
  47. try {
  48. storm::settings::Settings::parse(argc, argv);
  49. } catch (storm::exceptions::OptionParserException& e) {
  50. std::cout << "Could not recover from settings error: " << e.what() << "." << std::endl;
  51. std::cout << std::endl << instance->getHelpText();
  52. return false;
  53. }
  54. int result = RUN_ALL_TESTS();
  55. logger.closeNestedAppenders();
  56. return result;
  57. }