From: Thomas Markwalder Date: Wed, 7 May 2025 15:03:12 +0000 (-0400) Subject: [#3838] Fix Netconf UT X-Git-Tag: Kea-2.6.3~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c520381f38f822b01b30923c9722c6e0c1a83bbe;p=thirdparty%2Fkea.git [#3838] Fix Netconf UT Changes to be committed: modified: get_config_unittest.cc modified: netconf_cfg_mgr_unittests.cc modified: test_libraries.h.in --- diff --git a/src/bin/netconf/tests/get_config_unittest.cc b/src/bin/netconf/tests/get_config_unittest.cc index 2eaa7b1d65..566b73183a 100644 --- a/src/bin/netconf/tests/get_config_unittest.cc +++ b/src/bin/netconf/tests/get_config_unittest.cc @@ -228,6 +228,7 @@ public: // Test a simple configuration. TEST_F(NetconfGetCfgTest, simple) { + ASSERT_TRUE(NETCONF_HOOKS_TEST_PATH); // Avoid unused warning // get the simple configuration string simple_file = string(CFG_EXAMPLES) + "/" + "simple-dhcp4.json"; diff --git a/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc b/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc index 2ca62dfbf4..fcb7948bab 100644 --- a/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc +++ b/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -377,6 +378,26 @@ TEST(NetconfParser, badSocketType) { /// @brief Class used for testing CfgMgr class NetconfParserTest : public isc::process::ConfigParseTest { public: + virtual void SetUp() { + resetHooksPath(); + } + + virtual void TearDown() { + resetHooksPath(); + } + + /// @brief Sets the Hooks path from which hooks can be loaded. + /// @param explicit_path path to use as the hooks path. + void setHooksTestPath(const std::string explicit_path = "") { + HooksLibrariesParser::getHooksPath(true, + (!explicit_path.empty() ? + explicit_path : NETCONF_HOOKS_TEST_PATH)); + } + + /// @brief Resets the hooks path to DEFAULT_HOOKS_PATH. + void resetHooksPath() { + HooksLibrariesParser::getHooksPath(true); + } /// @brief Tries to load input text as a configuration /// @@ -677,6 +698,8 @@ TEST_F(NetconfParserTest, configParseInvalidSocketUrl) { // name. In particular, it checks if such a library exists. Therefore we // can't use NETCONF_CONFIGS[4] as is, but need to run it through path replacer. TEST_F(NetconfParserTest, configParseHooks) { + setHooksTestPath(); + // Create the configuration with proper lib path. string cfg = pathReplacer(NETCONF_CONFIGS[4], BASIC_CALLOUT_LIBRARY); // The configuration should be successful. diff --git a/src/bin/netconf/tests/test_libraries.h.in b/src/bin/netconf/tests/test_libraries.h.in index 2bf269aedd..78b7be6340 100644 --- a/src/bin/netconf/tests/test_libraries.h.in +++ b/src/bin/netconf/tests/test_libraries.h.in @@ -19,6 +19,9 @@ namespace { // Basic library with context_create and three "standard" callouts. static const char* BASIC_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libbasic.so"; +// Test path to use for in place of DEFAULT_HOOKS_PATH +static const char* NETCONF_HOOKS_TEST_PATH = "@abs_builddir@/.libs"; + } // anonymous namespace #endif // TEST_LIBRARIES_H