${CMAKE_SOURCE_DIR}/src/config/option/linkdownintervaloption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/linkupintervaloption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/logleveloption.cpp
+ ${CMAKE_SOURCE_DIR}/src/config/option/logoutputoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/nameserveroption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/pingfaillimitoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/sourcenetworkinterfaceoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/statusnotifiercmdoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/versionoption.cpp
${CMAKE_SOURCE_DIR}/src/host/loglevel.cpp
+ ${CMAKE_SOURCE_DIR}/src/host/logoutput.cpp
${CMAKE_SOURCE_DIR}/src/host/pingprotocol.cpp
)
${CMAKE_SOURCE_DIR}/src/config/option/linkdownintervaloption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/linkupintervaloption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/logleveloption.cpp
+ ${CMAKE_SOURCE_DIR}/src/config/option/logoutputoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/nameserveroption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/pingfaillimitoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/sourcenetworkinterfaceoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/statusnotifiercmdoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/versionoption.cpp
${CMAKE_SOURCE_DIR}/src/host/loglevel.cpp
+ ${CMAKE_SOURCE_DIR}/src/host/logoutput.cpp
${CMAKE_SOURCE_DIR}/src/host/pingprotocol.cpp
)
${CMAKE_SOURCE_DIR}/src/config/option/linkdownintervaloption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/linkupintervaloption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/logleveloption.cpp
+ ${CMAKE_SOURCE_DIR}/src/config/option/logoutputoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/nameserveroption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/pingfaillimitoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/sourcenetworkinterfaceoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/statusnotifiercmdoption.cpp
${CMAKE_SOURCE_DIR}/src/config/option/versionoption.cpp
${CMAKE_SOURCE_DIR}/src/host/loglevel.cpp
+ ${CMAKE_SOURCE_DIR}/src/host/logoutput.cpp
${CMAKE_SOURCE_DIR}/src/host/pingprotocol.cpp
)
--- /dev/null
+# compiler: creates the binaries
+add_executable(test_logoutput
+ test_logoutput.cpp
+ ${CMAKE_SOURCE_DIR}/src/host/logoutput.cpp
+)
+
+# linker: link the program against the libraries
+target_link_libraries(
+ test_logoutput
+ ${I2NCOMMON_LIBRARIES}
+ ${Boost_LIBRARIES}
+)
+
+# cmake: invocation via "make test"
+add_test(test_logoutput test_logoutput)
include(CMakeLists.test_hoststatus.txt)
include(CMakeLists.test_linkstatus.txt)
include(CMakeLists.test_loglevel.txt)
+include(CMakeLists.test_logoutput.txt)
include(CMakeLists.test_ipv4header.txt)
include(CMakeLists.test_ipv6header.txt)
include(CMakeLists.test_icmpv4header.txt)
#include <boost/test/unit_test.hpp>
#include "host/loglevel.h"
+#include "host/logoutput.h"
#include "host/pingprotocol.h"
#include "config/configurationoptions.h"
// if this assert fails, you must add or remove one of the options in the
// test bellow
- BOOST_CHECK_EQUAL( options.size(), 5 ); // help, version, daemon, config-file and log-level
+ BOOST_CHECK_EQUAL( options.size(), 6 ); // help, version, daemon, config-file, log-level and log-output
BOOST_CHECK_EQUAL( option_present( options, "help" ), true );
BOOST_CHECK_EQUAL( option_present( options, "config-file" ), true );
BOOST_CHECK_EQUAL( option_present( options, "daemon" ), true );
BOOST_CHECK_EQUAL( option_present( options, "version" ), true );
BOOST_CHECK_EQUAL( option_present( options, "log-level" ), true );
+ BOOST_CHECK_EQUAL( option_present( options, "log-output" ), true );
}
BOOST_AUTO_TEST_CASE( get_configuration_options )
option_insert( "config-file", boost::any( std::string("pingcheck.conf") ), vm );
option_insert( "daemon", boost::any(), vm );
option_insert( "log-level", boost::any( std::string("EMERGENCY") ), vm );
+ option_insert( "log-output", boost::any( std::string("TERMINAL") ), vm );
ConfigurationOptions config_options;
Configuration configuration;
BOOST_CHECK_EQUAL( configuration.get_config_file_name(), "pingcheck.conf" );
BOOST_CHECK_EQUAL( configuration.get_daemon(), true );
BOOST_CHECK_EQUAL( static_cast<int>(configuration.get_log_level()), static_cast<int>(I2n::Logger::LogLevel::Emergency) );
+ BOOST_CHECK_EQUAL( static_cast<int>(configuration.get_log_output()), static_cast<int>(LogOutput_TERMINAL) );
}
BOOST_AUTO_TEST_CASE( parse_configuration_options )
option_clear_and_insert( "log-level", value, vm );
BOOST_CHECK_EQUAL( config_options.halt_on_generic_options( vm ), false );
+ option_clear_and_insert( "log-output", value, vm );
+ BOOST_CHECK_EQUAL( config_options.halt_on_generic_options( vm ), false );
+
option_clear_and_insert( "hosts-down-limit", value, vm );
BOOST_CHECK_EQUAL( config_options.halt_on_generic_options( vm ), false );
--- /dev/null
+/*
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
+
+#define BOOST_TEST_MAIN
+#define BOOST_TEST_DYN_LINK
+
+#include <boost/test/unit_test.hpp>
+
+#include <logfunc.hpp>
+
+#include "host/logoutput.h"
+
+BOOST_AUTO_TEST_SUITE( TestLogOutput )
+
+BOOST_AUTO_TEST_CASE( lowercase )
+{
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "syslog" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "terminal" )), static_cast<int>(LogOutput_TERMINAL) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "console" )), static_cast<int>(LogOutput_TERMINAL) );
+}
+
+BOOST_AUTO_TEST_CASE( uppercase )
+{
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "SYSLOG" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "TERMINAL" )), static_cast<int>(LogOutput_TERMINAL) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "CONSOLE" )), static_cast<int>(LogOutput_TERMINAL) );
+}
+
+BOOST_AUTO_TEST_CASE( mixed_case )
+{
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "SysLoG" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "teRmINAl" )), static_cast<int>(LogOutput_TERMINAL) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "ConSOlE" )), static_cast<int>(LogOutput_TERMINAL) );
+}
+
+BOOST_AUTO_TEST_CASE( misspelled )
+{
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "when" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "the" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "word" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "is" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "wrong" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "stick" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "to" )), static_cast<int>(LogOutput_SYSLOG) );
+ BOOST_CHECK_EQUAL( static_cast<int>(get_log_output_from_string( "SYSLOG" )), static_cast<int>(LogOutput_SYSLOG) );
+}
+
+BOOST_AUTO_TEST_SUITE_END()