]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1127] fixed unittests
authorRazvan Becheriu <razvan@isc.org>
Fri, 15 May 2020 06:54:17 +0000 (09:54 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 15 May 2020 18:21:41 +0000 (21:21 +0300)
src/lib/hooks/tests/hooks_manager_unittest.cc

index d8339a524505d6d4903f2cdd350eb199844fa107..4614b897ef0aa694d5c59af65d055d7d143b0359 100644 (file)
@@ -38,6 +38,7 @@ public:
     /// Reset the hooks manager.  The hooks manager is a singleton, so needs
     /// to be reset for each test.
     HooksManagerTest() {
+        HooksManager::getHooksManager().setTestMode(false);
         HooksManager::unloadLibraries();
     }
 
@@ -45,6 +46,7 @@ public:
     ///
     /// Unload all libraries and reset the shared manager.
     ~HooksManagerTest() {
+        HooksManager::getHooksManager().setTestMode(false);
         HooksManager::unloadLibraries();
     }
 
@@ -436,20 +438,21 @@ TEST_F(HooksManagerTest, PrePostCalloutTest) {
     EXPECT_EQ(-15, result);
 }
 
-// Test with a shared manager the pre- and post- callout functions survive
-// a reload
+// Test with test mode enabled and the pre- and post- callout functions survive
+// a reload with an empty list of libraries
 
-TEST_F(HooksManagerTest, DISABLED_PrePostCalloutShared) {
+TEST_F(HooksManagerTest, TestModePrePostSurviveLoadListEmpty) {
 
     HookLibsCollection library_names;
 
-
     // Load the pre- and post- callouts.
     HooksManager::preCalloutsLibraryHandle().registerCallout("hookpt_two",
                                                              testPreCallout);
     HooksManager::postCalloutsLibraryHandle().registerCallout("hookpt_two",
                                                               testPostCallout);
 
+    HooksManager::getHooksManager().setTestMode(true);
+
     // With the pre- and post- callouts above, the result expected is
     //
     // 1027 * 2
@@ -479,10 +482,10 @@ TEST_F(HooksManagerTest, DISABLED_PrePostCalloutShared) {
     EXPECT_EQ(2054, result);
 }
 
-// Test with a shared manager the pre- and post- callout functions survive
-// a reload but not with a not empty list of libraries
+// Test with test mode enabled and the pre- and post- callout functions survive
+// a reload with a not empty list of libraries
 
-TEST_F(HooksManagerTest, DISABLED_PrePostCalloutSharedNotEmpty) {
+TEST_F(HooksManagerTest, TestModePrePostSurviveLoadListNotEmpty) {
 
     HookLibsCollection library_names;
     library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
@@ -494,6 +497,8 @@ TEST_F(HooksManagerTest, DISABLED_PrePostCalloutSharedNotEmpty) {
     HooksManager::postCalloutsLibraryHandle().registerCallout("hookpt_two",
                                                               testPostCallout);
 
+    HooksManager::getHooksManager().setTestMode(true);
+
     // With the pre- and post- callouts above, the result expected is
     //
     // 1027 * 2
@@ -517,16 +522,16 @@ TEST_F(HooksManagerTest, DISABLED_PrePostCalloutSharedNotEmpty) {
 
     HooksManager::callCallouts(hookpt_two_index_, *handle);
 
-    // Expect result - data_2
+    // Expect same value i.e. 1027 * 2
     result = 0;
     handle->getArgument("result", result);
-    EXPECT_EQ(-15, result);
+    EXPECT_EQ(2054, result);
 }
 
 // Test with a shared manager the pre- and post- callout functions don't
 // survive a reload if the shared manager is initialized too late.
 
-TEST_F(HooksManagerTest, DISABLED_PrePostCalloutSharedTooLate) {
+TEST_F(HooksManagerTest, TestModePrePostTooLate) {
 
     HookLibsCollection library_names;
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
@@ -555,6 +560,8 @@ TEST_F(HooksManagerTest, DISABLED_PrePostCalloutSharedTooLate) {
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
     handle = HooksManager::createCalloutHandle();
 
+    HooksManager::getHooksManager().setTestMode(true);
+
     handle->setArgument("result", static_cast<int>(0));
     handle->setArgument("data_2", static_cast<int>(15));