BIND 10 trac2940, updated. 54910e664a3697b1b486b84d08aba0c382a5ecc7 [2940] Added a unit test for Lease4 to check getClientIdVector function.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Nov 14 14:31:01 UTC 2013
The branch, trac2940 has been updated
via 54910e664a3697b1b486b84d08aba0c382a5ecc7 (commit)
from 91cb5a837770be0fe38b64441ede9bd461443018 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 54910e664a3697b1b486b84d08aba0c382a5ecc7
Author: Marcin Siodelski <marcin at isc.org>
Date: Thu Nov 14 15:30:16 2013 +0100
[2940] Added a unit test for Lease4 to check getClientIdVector function.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcpsrv/tests/Makefile.am | 1 +
src/lib/dhcpsrv/tests/lease_unittest.cc | 49 ++++++++++++++++++++
.../dhcpsrv/tests/memfile_lease_mgr_unittest.cc | 22 +--------
3 files changed, 51 insertions(+), 21 deletions(-)
create mode 100644 src/lib/dhcpsrv/tests/lease_unittest.cc
-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/tests/Makefile.am b/src/lib/dhcpsrv/tests/Makefile.am
index 546ced9..643fd63 100644
--- a/src/lib/dhcpsrv/tests/Makefile.am
+++ b/src/lib/dhcpsrv/tests/Makefile.am
@@ -53,6 +53,7 @@ libdhcpsrv_unittests_SOURCES += alloc_engine_unittest.cc
libdhcpsrv_unittests_SOURCES += callout_handle_store_unittest.cc
libdhcpsrv_unittests_SOURCES += cfgmgr_unittest.cc
libdhcpsrv_unittests_SOURCES += dbaccess_parser_unittest.cc
+libdhcpsrv_unittests_SOURCES += lease_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_mgr_unittest.cc
libdhcpsrv_unittests_SOURCES += memfile_lease_mgr_unittest.cc
diff --git a/src/lib/dhcpsrv/tests/lease_unittest.cc b/src/lib/dhcpsrv/tests/lease_unittest.cc
new file mode 100644
index 0000000..b9ebbab
--- /dev/null
+++ b/src/lib/dhcpsrv/tests/lease_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <config.h>
+#include <dhcpsrv/lease.h>
+#include <gtest/gtest.h>
+#include <vector>
+
+using namespace isc;
+using namespace isc::dhcp;
+
+namespace {
+
+// @todo Currently this file contains a single test. Other tests for Lease
+// objects must be implemented. See http://bind10.isc.org/ticket/3240.
+
+// Verify that the client id can be returned as a vector object and if client
+// id is NULL the empty vector is returned.
+TEST(Lease4Test, getClientIdVector) {
+ // Create a lease.
+ Lease4 lease;
+ // By default, the lease should have client id set to NULL. If it doesn't,
+ // continuing the test makes no sense.
+ ASSERT_FALSE(lease.client_id_);
+ // When client id is NULL the vector returned should be empty.
+ EXPECT_TRUE(lease.getClientIdVector().empty());
+ // Now, let's set the non NULL client id. Fill it with the 8 bytes, each
+ // holding a value of 0x42.
+ std::vector<uint8_t> client_id_vec(8, 0x42);
+ lease.client_id_ = ClientIdPtr(new ClientId(client_id_vec));
+ // Check that the returned vector, encapsulating client id is equal to
+ // the one that has been used to set the client id for the lease.
+ std::vector<uint8_t> returned_vec = lease.getClientIdVector();
+ EXPECT_TRUE(returned_vec == client_id_vec);
+}
+
+
+}; // end of anonymous namespace
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index 0117e38..cd9a222 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -237,24 +237,4 @@ TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetId) {
EXPECT_TRUE(lease == Lease4Ptr());
}
-// This test verifies that the client id can be returned as a vector.
-// @todo This test should be moved to the Lease specific unit tests once
-// these tests are created.
-TEST_F(MemfileLeaseMgrTest, getLease4ClientIdVector) {
- const LeaseMgr::ParameterMap pmap;
- boost::scoped_ptr<Memfile_LeaseMgr> lease_mgr(new Memfile_LeaseMgr(pmap));
-
- Lease4Ptr lease = initializeLease4(straddress4_[7]);
- // Check that this lease has null client-id
- ASSERT_TRUE(lease->client_id_ == ClientIdPtr());
- // Check that this returns empty vector
- ASSERT_TRUE(lease->getClientIdVector().empty());
-
- // Let's take a lease with client-id not null
- lease = initializeLease4(straddress4_[6]);
- ASSERT_TRUE(lease->client_id_);
- // Check that they return the same client-id value
- ASSERT_TRUE(lease->client_id_->getClientId() == lease->getClientIdVector());
-}
-
}; // end of anonymous namespace
More information about the bind10-changes
mailing list