]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3838] Fix Netconf UT
authorThomas Markwalder <tmark@isc.org>
Wed, 7 May 2025 15:03:12 +0000 (11:03 -0400)
committerThomas Markwalder <tmark@isc.org>
Thu, 8 May 2025 11:51:13 +0000 (07:51 -0400)
Changes to be committed:
modified:   get_config_unittest.cc
    modified:   netconf_cfg_mgr_unittests.cc
  modified:   test_libraries.h.in

src/bin/netconf/tests/get_config_unittest.cc
src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc
src/bin/netconf/tests/test_libraries.h.in

index 2eaa7b1d654c80606dff17281e66a79743ab45d1..566b73183a074e98eebbb0b50da0077810dd5c4f 100644 (file)
@@ -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";
index 2ca62dfbf4db21a00238c29ad7b4a4152995946e..fcb7948babcd3ab54146ab7ba134e80875f60003 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <cc/command_interpreter.h>
 #include <exceptions/exceptions.h>
+#include <hooks/hooks_parser.h>
 #include <netconf/netconf_cfg_mgr.h>
 #include <netconf/parser_context.h>
 #include <netconf/tests/test_libraries.h>
@@ -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.
index 2bf269aeddea5f882c3ecfc370f98d0486fd99d5..78b7be6340d7d43634911ffe0e78259603b30909 100644 (file)
@@ -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