From dcd07a42aa3a016688ceb2e656bee2bca33739e5 Mon Sep 17 00:00:00 2001 From: Thomas Markwalder Date: Wed, 14 May 2025 14:56:56 -0400 Subject: [PATCH] [#3831] Fixed UT build and minor nits modified: doc/sphinx/arm/dhcp6-srv.rst modified: doc/sphinx/arm/logging.rst modified: src/bin/d2/tests/d2_process_tests.sh.in modified: src/bin/dhcp4/tests/dhcp4_process_tests.sh.in modified: src/bin/dhcp6/json_config_parser.cc modified: src/bin/dhcp6/tests/dhcp6_process_tests.sh.in modified: src/hooks/dhcp/forensic_log/libloadtests/load_unload_unittests.cc modified: src/lib/dhcpsrv/tests/cfgmgr_unittest.cc modified: src/lib/hooks/hooks_parser.cc modified: src/lib/process/log_parser.cc modified: src/lib/process/log_parser.h modified: src/lib/testutils/env_var_wrapper.h modified: src/lib/util/filesystem.cc --- doc/sphinx/arm/dhcp6-srv.rst | 1 - doc/sphinx/arm/logging.rst | 2 +- src/bin/d2/tests/d2_process_tests.sh.in | 3 ++- src/bin/dhcp4/tests/dhcp4_process_tests.sh.in | 2 +- src/bin/dhcp6/json_config_parser.cc | 4 ++-- src/bin/dhcp6/tests/dhcp6_process_tests.sh.in | 3 ++- .../dhcp/forensic_log/libloadtests/load_unload_unittests.cc | 1 + src/lib/dhcpsrv/tests/cfgmgr_unittest.cc | 2 +- src/lib/hooks/hooks_parser.cc | 2 +- src/lib/process/log_parser.cc | 5 ++--- src/lib/process/log_parser.h | 4 ++-- src/lib/testutils/env_var_wrapper.h | 2 +- src/lib/util/filesystem.cc | 2 +- 13 files changed, 17 insertions(+), 16 deletions(-) diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 55c7f11237..b5a5aa8fe4 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -333,7 +333,6 @@ that can be used to configure the memfile backend. or, if already running, log an unrecoverable error. For ease of use in specifying a custom file name simply omit the path component from ``name``. - - ``lfc-interval``: specifies the interval, in seconds, at which the server will perform a lease file cleanup (LFC). This removes redundant (historical) information from the lease file and diff --git a/doc/sphinx/arm/logging.rst b/doc/sphinx/arm/logging.rst index 38ccb3ba45..974f1579c4 100644 --- a/doc/sphinx/arm/logging.rst +++ b/doc/sphinx/arm/logging.rst @@ -563,7 +563,7 @@ interpreted as a filename to which messages should be written. path may be overridden at startup by setting the environment variable ``KEA_LOG_FILE_DIR`` to the desired path. If a path other than this value is used in ``output``, Kea will emit an error and refuse to start - or, if already running, log an unrecoverable error. For ease of use simply + or, if already running, log an unrecoverable error. For ease of use simply omit the path component from ``output`` and specify only the file name. diff --git a/src/bin/d2/tests/d2_process_tests.sh.in b/src/bin/d2/tests/d2_process_tests.sh.in index 71cd4b22d4..614d1c3695 100755 --- a/src/bin/d2/tests/d2_process_tests.sh.in +++ b/src/bin/d2/tests/d2_process_tests.sh.in @@ -14,13 +14,14 @@ set -eu CFG_FILE="@abs_top_builddir@/src/bin/d2/tests/test_config.json" # Path to the D2 log file. LOG_FILE="@abs_top_builddir@/src/bin/d2/tests/test.log" -# D2 configuration to be stored in the configuration file. + # Set env KEA_HOOKS_PATH to override DEFAULT_HOOKS_PATH export KEA_HOOKS_PATH="@abs_top_builddir@/src/bin/d2/tests/@dotlibs@" # Set env KEA_LOG_FILE_DIR to override default log path export KEA_LOG_FILE_DIR="@abs_top_builddir@/src/bin/d2/tests" +# D2 configuration to be stored in the configuration file. CONFIG="{ \"DhcpDdns\": { diff --git a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in index ada74d9d1d..2b3f76f15b 100755 --- a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in +++ b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in @@ -24,7 +24,7 @@ HOOK_FAIL_LOAD_PATH="@abs_top_builddir@/src/bin/dhcp4/tests/@dotlibs@libco3.so" # Path to test hooks library HOOK_FAIL_POLL_PATH="@abs_top_builddir@/src/bin/dhcp4/tests/@dotlibs@libco4.so" -# Set env KEA_HOOKS_PATH to override DEFAULT_HOOKS_PATH +# Set env KEA_HOOKS_PATH to override DEFAULT_HOOKS_PATH export KEA_HOOKS_PATH="@abs_top_builddir@/src/bin/dhcp4/tests/@dotlibs@" # Set env KEA_LOG_FILE_DIR to override default log path. diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index e37a9f0536..1f9aec6760 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -178,9 +178,9 @@ public: if (global->contains("data-directory")) { auto dd = getString(global, "data-directory"); if (dd != CfgMgr::instance().getDataDir()) { - isc_throw(DhcpConfigError, + isc_throw(DhcpConfigError, "'data-directory' of '" << dd << "' is invalid," - << " supported path is '" + << " supported path is '" << CfgMgr::instance().getDataDir() << "'"); } diff --git a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in index b84afc8eb2..0f170b8565 100755 --- a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in +++ b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in @@ -23,7 +23,8 @@ export KEA_LFC_EXECUTABLE="@abs_top_builddir@/src/bin/lfc/kea-lfc" HOOK_FAIL_LOAD_PATH="@abs_top_builddir@/src/bin/dhcp6/tests/@dotlibs@libco3.so" # Path to test hooks library HOOK_FAIL_POLL_PATH="@abs_top_builddir@/src/bin/dhcp6/tests/@dotlibs@libco4.so" -# Set env KEA_HOOKS_PATH to override DEFAULT_HOOKS_PATH + +# Set env KEA_HOOKS_PATH to override DEFAULT_HOOKS_PATH export KEA_HOOKS_PATH="@abs_top_builddir@/src/bin/dhcp6/tests/@dotlibs@" # Set env KEA_LOG_FILE_DIR to override default log path diff --git a/src/hooks/dhcp/forensic_log/libloadtests/load_unload_unittests.cc b/src/hooks/dhcp/forensic_log/libloadtests/load_unload_unittests.cc index 0844511bf3..123db2d4d2 100644 --- a/src/hooks/dhcp/forensic_log/libloadtests/load_unload_unittests.cc +++ b/src/hooks/dhcp/forensic_log/libloadtests/load_unload_unittests.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #ifdef HAVE_MYSQL diff --git a/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc b/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc index 9bac59f84c..77e6dc7147 100644 --- a/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc @@ -288,7 +288,7 @@ public: /// @brief Sets the DHCP data path for server data files. /// @param custom_path path to use. void setDataDir(const std::string explicit_path = "") { - CfgMgr::instance().getDataDir(true, + CfgMgr::instance().getDataDir(true, (!explicit_path.empty() ? explicit_path : std::string(DHCP_DATA_DIR))); } diff --git a/src/lib/hooks/hooks_parser.cc b/src/lib/hooks/hooks_parser.cc index 5e5d06e90f..a79a255c18 100644 --- a/src/lib/hooks/hooks_parser.cc +++ b/src/lib/hooks/hooks_parser.cc @@ -98,7 +98,7 @@ HooksLibrariesParser::parse(HooksConfig& libraries, ConstElementPtr value) { libname = validatePath((entry_item.second)->stringValue()); } catch (const std::exception& ex) { isc_throw(DhcpConfigError, "hooks library configuration" - " error: " << ex.what() << " (" + " error: " << ex.what() << " (" << entry_item.second->getPosition() << ")"); } diff --git a/src/lib/process/log_parser.cc b/src/lib/process/log_parser.cc index 53a37bcd77..c016e5eb94 100644 --- a/src/lib/process/log_parser.cc +++ b/src/lib/process/log_parser.cc @@ -155,7 +155,6 @@ LogConfigParser::validatePath(const std::string logpath, return (log_path_checker_->validatePath(logpath, enforce_path)); } - void LogConfigParser::parseOutputOptions(std::vector& destination, isc::data::ConstElementPtr output_options) { if (!output_options) { @@ -181,8 +180,8 @@ void LogConfigParser::parseOutputOptions(std::vector& destin try { dest.output_ = validatePath(output_str); } catch (const std::exception& ex) { - isc_throw(BadValue, "invalid path in `output`: " << ex.what() - << " (" << output_option->getPosition() << ")"); + isc_throw(BadValue, "invalid path in `output`: " << ex.what() + << " (" << output_option->getPosition() << ")"); } } diff --git a/src/lib/process/log_parser.h b/src/lib/process/log_parser.h index bf9e913d84..cf3a7f2c24 100644 --- a/src/lib/process/log_parser.h +++ b/src/lib/process/log_parser.h @@ -58,7 +58,7 @@ public: void parseConfiguration(const isc::data::ConstElementPtr& log_config, bool verbose = false); - /// @brief Fetches the supported log file path. + /// @brief Fetches the supported log file path. /// /// The first call to this function with no arguments will set the default /// hooks path to either the value of LOGFILE_DIR or the environment @@ -80,7 +80,7 @@ public: /// /// @return validated path static std::string validatePath(const std::string logpath, bool enforce_path = true); - + private: /// @brief Parses one JSON structure in Server/loggers" array diff --git a/src/lib/testutils/env_var_wrapper.h b/src/lib/testutils/env_var_wrapper.h index d50ebc61ab..e1d284f5df 100644 --- a/src/lib/testutils/env_var_wrapper.h +++ b/src/lib/testutils/env_var_wrapper.h @@ -45,7 +45,7 @@ private: std::string name_; /// @brief Value of the env variable at the time the wrapper - /// was constructed. + /// was constructed. std::string original_value_; }; diff --git a/src/lib/util/filesystem.cc b/src/lib/util/filesystem.cc index 5bec879b7c..8a752ca577 100644 --- a/src/lib/util/filesystem.cc +++ b/src/lib/util/filesystem.cc @@ -257,7 +257,7 @@ PathChecker::validatePath(const std::string input_path_str, auto filename = input_path.filename(); if (filename.empty()) { isc_throw(BadValue, "path: '" << input_path.str() << "' has no filename"); - } + } auto parent_path = input_path.parentPath(); if (!parent_path.empty()) {