]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4351] Remove couts from dhcpsrv tests which make you think that they are errors...
authorAndrei Pavel <andrei@isc.org>
Thu, 19 Feb 2026 13:19:25 +0000 (15:19 +0200)
committerAndrei Pavel <andrei@isc.org>
Fri, 20 Feb 2026 09:42:34 +0000 (11:42 +0200)
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
src/lib/dhcpsrv/tests/d2_client_unittest.cc

index 020d17682b0e239545391b23990bf1c72ec54720..951cf3b1926c36ca87b190e15d7e0c998bdf9c11 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2025 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2026 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -4198,7 +4198,6 @@ TEST_F(AllocEngine4Test, storeExtendedInfoEnabled4) {
 
         // If we have a MAC address this scenario is for a new client.
         if (!scenario.mac_.empty()) {
-            std::cout << "setting mac address" << std::endl;
             ASSERT_NO_THROW(ctx.hwaddr_.reset(new HWAddr(scenario.mac_, HTYPE_ETHER)))
                             << "invalid MAC address, test is broken";
         }
@@ -4295,7 +4294,6 @@ TEST_F(AllocEngine4Test, storeExtendedInfoDisabled4) {
 
         // If we have a MAC address this scenario is for a new client.
         if (!scenario.mac_.empty()) {
-            std::cout << "setting mac address" << std::endl;
             ASSERT_NO_THROW(ctx.hwaddr_.reset(new HWAddr(scenario.mac_, HTYPE_ETHER)))
                             << "invalid MAC address, test is broken";
         }
index ad77f11f5959435273d86fba313405b59039bf19..679ca6972b847bf53ad2463ebeab519aca9bb0e6 100644 (file)
@@ -1,10 +1,11 @@
-// Copyright (C) 2015-2025 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2026 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 #include <config.h>
+
 #include <dhcp/pkt4.h>
 #include <dhcp/pkt6.h>
 #include <dhcpsrv/allocator.h>
@@ -15,6 +16,9 @@
 #include <eval/eval_context.h>
 #include <stats/stats_mgr.h>
 #include <testutils/gtest_utils.h>
+
+#include <string>
+
 #include <boost/pointer_cast.hpp>
 
 using namespace std;
@@ -34,29 +38,29 @@ const bool IN_POOL = true;
 
 // Test convenience method adding hints to IA context.
 TEST(ClientContext6Test, addHint) {
-   AllocEngine::ClientContext6 ctx;
-   ctx.currentIA().addHint(IOAddress("2001:db8:1::1"));
-   ctx.currentIA().addHint(IOAddress("3000:1::"), 64);
-   ctx.currentIA().addHint(IOAddress("3001:2::"), 64, 100, 200);
+    AllocEngine::ClientContext6 ctx;
+    ctx.currentIA().addHint(IOAddress("2001:db8:1::1"));
+    ctx.currentIA().addHint(IOAddress("3000:1::"), 64);
+    ctx.currentIA().addHint(IOAddress("3001:2::"), 64, 100, 200);
 
-   ASSERT_EQ(3, ctx.currentIA().hints_.size());
-   EXPECT_EQ("2001:db8:1::1", ctx.currentIA().hints_[0].getAddress().toText());
-   EXPECT_EQ("3000:1::", ctx.currentIA().hints_[1].getAddress().toText());
-   EXPECT_EQ("3001:2::", ctx.currentIA().hints_[2].getAddress().toText());
-   EXPECT_EQ(100, ctx.currentIA().hints_[2].getPreferred());
-   EXPECT_EQ(200, ctx.currentIA().hints_[2].getValid());
+    ASSERT_EQ(3, ctx.currentIA().hints_.size());
+    EXPECT_EQ("2001:db8:1::1", ctx.currentIA().hints_[0].getAddress().toText());
+    EXPECT_EQ("3000:1::", ctx.currentIA().hints_[1].getAddress().toText());
+    EXPECT_EQ("3001:2::", ctx.currentIA().hints_[2].getAddress().toText());
+    EXPECT_EQ(100, ctx.currentIA().hints_[2].getPreferred());
+    EXPECT_EQ(200, ctx.currentIA().hints_[2].getValid());
 }
 
 // Test convenience method adding allocated prefixes and addresses to
 // a context.
 TEST(ClientContext6Test, addAllocatedResource) {
-   AllocEngine::ClientContext6 ctx;
-   ctx.addAllocatedResource(IOAddress("2001:db8:1::1"));
-   ctx.addAllocatedResource(IOAddress("3000:1::"), 64);
+    AllocEngine::ClientContext6 ctx;
+    ctx.addAllocatedResource(IOAddress("2001:db8:1::1"));
+    ctx.addAllocatedResource(IOAddress("3000:1::"), 64);
 
-   ASSERT_EQ(2, ctx.allocated_resources_.size());
-   EXPECT_TRUE(ctx.isAllocated(IOAddress("2001:db8:1::1")));
-   EXPECT_TRUE(ctx.isAllocated(IOAddress("3000:1::"), 64));
+    ASSERT_EQ(2, ctx.allocated_resources_.size());
+    EXPECT_TRUE(ctx.isAllocated(IOAddress("2001:db8:1::1")));
+    EXPECT_TRUE(ctx.isAllocated(IOAddress("3000:1::"), 64));
 }
 
 // This test checks if the v6 Allocation Engine can be instantiated, parses
@@ -2183,7 +2187,7 @@ TEST_F(AllocEngine6Test, reservedAddress) {
         Lease6Collection leases = engine.allocateLeases6(ctx);
         if (leases.empty()) {
             failure++;
-            std::cout << "Alloc for client " << (int)i << " failed." << std::endl;
+            SCOPED_TRACE("Alloc for client " + to_string(i) + " expected to fail.");
             EXPECT_EQ(failure, getStatistics("v6-allocation-fail"));
             EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network"));
             EXPECT_EQ(failure, getStatistics("v6-allocation-fail-subnet"));
@@ -2197,8 +2201,8 @@ TEST_F(AllocEngine6Test, reservedAddress) {
             EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
         } else {
             success++;
-            std::cout << "Alloc for client " << (int)i << " succeeded:"
-                      << leases[0]->addr_.toText() << std::endl;
+            SCOPED_TRACE("Alloc for client " + to_string(i) +
+                         " expected to succeed: " + leases[0]->addr_.toText());
 
             // The assigned addresses must not match the one reserved.
             EXPECT_NE("2001:db8:1::12", leases[0]->addr_.toText());
index 00375d0066c7abb495955125df074434a81adf94..4684d395bdfac0768f94ee177025adf84dedd6de 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2025 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2026 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -114,8 +114,11 @@ TEST(D2ClientConfigTest, constructorsAndAccessors) {
     EXPECT_EQ(d2_client_config->getContext()->str(), user_context);
 
     // Verify that toText called by << operator doesn't bomb.
-    ASSERT_NO_THROW(std::cout << "toText test:" << std::endl <<
-                    *d2_client_config << std::endl);
+    stringstream stream;
+    ASSERT_NO_THROW(stream << "toText test: " << *d2_client_config);
+    EXPECT_EQ(stream.str(), "toText test: enable_updates: yes, server-ip: 127.0.0.1, server-port: "
+                            "477, sender-ip: 127.0.0.1, sender-port: 478, max-queue-size: 2048, "
+                            "ncr-protocol: UDP, ncr-format: JSON");
 
     // Verify what toElement returns.
     std::string expected = "{\n"