Skip to content

Commit

Permalink
Allow Stdout Logging for Catalogue Testing from CMakeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Camarero Vera committed Jun 23, 2021
1 parent 355b5c4 commit 7f87444
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ if (CMAKE_COMPILER_IS_GNUCC AND ((GCC_VERSION VERSION_GREATER 4.8.0) OR (GCC_VER
set (GCC_VERSION_GE_4_8_0 TRUE)
endif (CMAKE_COMPILER_IS_GNUCC AND ((GCC_VERSION VERSION_GREATER 4.8.0) OR (GCC_VERSION VERSION_EQUAL 4.8.0)))

# To enable logging for testing purposes set -DENABLE_STDOUT_LOGGING=1
if (ENABLE_STDOUT_LOGGING)
add_definitions (-DSTDOUT_LOGGING)
endif ()

# Generate the compilation variables, if needed
if (NOT DEFINED SKIP_UNIT_TESTS)
message (STATUS "Setting SKIP_UNIT_TESTS to the value of 0")
Expand Down
8 changes: 8 additions & 0 deletions catalogue/InMemoryVersionOfCatalogueTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

#include "catalogue/CatalogueTest.hpp"
#include "catalogue/InMemoryCatalogueFactory.hpp"
#ifdef STDOUT_LOGGING
#include "common/log/StdoutLogger.hpp"
#else
#include "common/log/DummyLogger.hpp"
#endif

namespace unitTests {

Expand All @@ -26,7 +30,11 @@ namespace {
const uint64_t g_in_memory_CatalogueTest_nbConn = 1;
const uint64_t g_in_memory_nbArchiveFileListingConns = 1;
const uint64_t g_in_memory_maxTriesToConnect = 1;
#ifdef STDOUT_LOGGING
cta::log::StdoutLogger g_in_memory_CatalogueTest_dummyLogger("stdout", "stdout");
#else
cta::log::DummyLogger g_in_memory_CatalogueTest_dummyLogger("dummy", "dummy");
#endif

cta::catalogue::InMemoryCatalogueFactory g_inMemoryCatalogueFactory(g_in_memory_CatalogueTest_dummyLogger,
g_in_memory_CatalogueTest_nbConn, g_in_memory_nbArchiveFileListingConns, g_in_memory_maxTriesToConnect);
Expand Down
8 changes: 8 additions & 0 deletions tests/rdbmsUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
*/

#include "catalogue/CatalogueFactoryFactory.hpp"
#ifdef STDOUT_LOGGING
#include "common/log/StdoutLogger.hpp"
#else
#include "common/log/DummyLogger.hpp"
#endif
#include "rdbms/Login.hpp"
#include "tests/GlobalCatalogueFactoryForUnitTests.hpp"
#include "tests/RdbmsUnitTestsCmdLineArgs.hpp"
Expand Down Expand Up @@ -66,7 +70,11 @@ int main(int argc, char** argv) {
// Google test will consume its options from the command-line and leave everything else
g_cmdLineArgs = parseCmdLine(argc, argv);

#ifdef STDOUT_LOGGING
cta::log::StdoutLogger dummyLogger("stdout", "stdout");
#else
cta::log::DummyLogger dummyLogger("dummy", "dummy");
#endif
const auto login = cta::rdbms::Login::parseFile(g_cmdLineArgs.dbConfigPath);
const uint64_t nbConns = 1;
const uint64_t nbArchiveFileListingConns = 1;
Expand Down

0 comments on commit 7f87444

Please sign in to comment.