From 6818c6dc0d8da01869368d630dbdd0a92079b61e Mon Sep 17 00:00:00 2001 From: sjunges Date: Thu, 25 Feb 2016 13:44:58 +0100 Subject: [PATCH] Fixed tests when no log4plus is available. Former-commit-id: f1ae81376c79043b32e8a05f2a9b5c1a1bed4227 --- test/functional/storm-functional-tests.cpp | 17 +++++++++++------ test/performance/storm-performance-tests.cpp | 14 ++++++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/test/functional/storm-functional-tests.cpp b/test/functional/storm-functional-tests.cpp index 5051bb659..e206561e0 100644 --- a/test/functional/storm-functional-tests.cpp +++ b/test/functional/storm-functional-tests.cpp @@ -2,21 +2,25 @@ #include #include +#include "storm-config.h" + #include "gtest/gtest.h" +#ifdef STORM_LOGGING_FRAMEWORK #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" #include "log4cplus/consoleappender.h" #include "log4cplus/fileappender.h" -#include "storm-config.h" -#include "src/settings/SettingsManager.h" - log4cplus::Logger logger; +#endif + +#include "src/settings/SettingsManager.h" /*! * Initializes the logging framework. */ void setUpLogging() { +#ifdef STORM_LOGGING_FRAMEWORK logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main")); logger.setLogLevel(log4cplus::ERROR_LOG_LEVEL); log4cplus::SharedAppenderPtr fileLogAppender(new log4cplus::FileAppender("storm-functional-tests.log")); @@ -24,7 +28,7 @@ void setUpLogging() { fileLogAppender->setThreshold(log4cplus::FATAL_LOG_LEVEL); fileLogAppender->setLayout(std::auto_ptr(new log4cplus::PatternLayout("%-5p - %D{%H:%M} (%r ms) - %F:%L : %m%n"))); logger.addAppender(fileLogAppender); - +#endif // Uncomment these lines to enable console logging output // log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender()); // consoleLogAppender->setName("mainConsoleAppender"); @@ -39,9 +43,10 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); int result = RUN_ALL_TESTS(); - +#ifdef STORM_LOGGING_FRAMEWORK logger.closeNestedAppenders(); - +#endif + std::list untestedModules; #ifndef STORM_HAVE_GUROBI untestedModules.push_back("Gurobi"); diff --git a/test/performance/storm-performance-tests.cpp b/test/performance/storm-performance-tests.cpp index 0c29f19c8..3291d6823 100644 --- a/test/performance/storm-performance-tests.cpp +++ b/test/performance/storm-performance-tests.cpp @@ -1,19 +1,24 @@ #include #include "gtest/gtest.h" +#include "storm-config.h" + + +#include "src/settings/SettingsManager.h" +#ifdef STORM_LOGGING_FRAMEWORK #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" #include "log4cplus/consoleappender.h" #include "log4cplus/fileappender.h" -#include "src/settings/SettingsManager.h" - log4cplus::Logger logger; +#endif /*! * Initializes the logging framework. */ void setUpLogging() { +#ifdef STORM_LOGGING_FRAMEWORK logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main")); logger.setLogLevel(log4cplus::WARN_LOG_LEVEL); log4cplus::SharedAppenderPtr fileLogAppender(new log4cplus::FileAppender("storm-performance-tests.log")); @@ -21,7 +26,7 @@ void setUpLogging() { fileLogAppender->setThreshold(log4cplus::WARN_LOG_LEVEL); fileLogAppender->setLayout(std::auto_ptr(new log4cplus::PatternLayout("%-5p - %D{%H:%M} (%r ms) - %F:%L : %m%n"))); logger.addAppender(fileLogAppender); - +#endif // Uncomment these lines to enable console logging output // log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender()); // consoleLogAppender->setName("mainConsoleAppender"); @@ -36,7 +41,8 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); int result = RUN_ALL_TESTS(); - +#ifdef STORM_LOGGING_FRAMEWORK logger.closeNestedAppenders(); +#endif return result; }