From 55dd08057c52c3f0baf3f1b34f23f87c2ee7ff35 Mon Sep 17 00:00:00 2001 From: Stephen Morris Date: Tue, 30 Apr 2013 13:57:22 +0100 Subject: [PATCH] [2467] Miscellaneous minor changes as a result of review --- src/bin/dhcp4/tests/dhcp4_srv_unittest.cc | 20 +++++++--------- src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 6 ++--- src/lib/dhcp/tests/iface_mgr_unittest.cc | 10 ++++---- .../dhcp/tests/option4_addrlst_unittest.cc | 2 +- src/lib/dhcp/tests/option_unittest.cc | 2 +- src/lib/dhcp/tests/pkt4_unittest.cc | 24 +++++++++---------- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 5a894e858f..46b588ada2 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -134,8 +134,7 @@ public: // domain-name OptionDefinition def("domain-name", DHO_DOMAIN_NAME, OPT_FQDN_TYPE); - boost::shared_ptr - option_domain_name(new OptionCustom(def, Option::V4)); + OptionCustomPtr option_domain_name(new OptionCustom(def, Option::V4)); option_domain_name->writeFqdn("example.com"); subnet_->addOption(option_domain_name, false, "dhcp4"); @@ -154,8 +153,7 @@ public: /// @brief checks that the response matches request /// @param q query (client's message) /// @param a answer (server's message) - void messageCheck(const boost::shared_ptr& q, - const boost::shared_ptr& a) { + void messageCheck(const Pkt4Ptr& q, const Pkt4Ptr& a) { ASSERT_TRUE(q); ASSERT_TRUE(a); @@ -398,8 +396,8 @@ TEST_F(Dhcpv4SrvTest, processDiscover) { mac[i] = 255 - i; } - boost::shared_ptr pkt(new Pkt4(DHCPDISCOVER, 1234)); - boost::shared_ptr offer; + Pkt4Ptr pkt(new Pkt4(DHCPDISCOVER, 1234)); + Pkt4Ptr offer; pkt->setIface("eth0"); pkt->setIndex(17); @@ -502,8 +500,8 @@ TEST_F(Dhcpv4SrvTest, processRequest) { mac[i] = i * 10; } - boost::shared_ptr req(new Pkt4(DHCPREQUEST, 1234)); - boost::shared_ptr ack; + Pkt4Ptr req(new Pkt4(DHCPREQUEST, 1234)); + Pkt4Ptr ack; req->setIface("eth0"); req->setIndex(17); @@ -588,7 +586,7 @@ TEST_F(Dhcpv4SrvTest, processRequest) { TEST_F(Dhcpv4SrvTest, processRelease) { NakedDhcpv4Srv srv; - boost::shared_ptr pkt(new Pkt4(DHCPRELEASE, 1234)); + Pkt4Ptr pkt(new Pkt4(DHCPRELEASE, 1234)); // Should not throw EXPECT_NO_THROW(srv.processRelease(pkt)); @@ -596,7 +594,7 @@ TEST_F(Dhcpv4SrvTest, processRelease) { TEST_F(Dhcpv4SrvTest, processDecline) { NakedDhcpv4Srv srv; - boost::shared_ptr pkt(new Pkt4(DHCPDECLINE, 1234)); + Pkt4Ptr pkt(new Pkt4(DHCPDECLINE, 1234)); // Should not throw EXPECT_NO_THROW(srv.processDecline(pkt)); @@ -604,7 +602,7 @@ TEST_F(Dhcpv4SrvTest, processDecline) { TEST_F(Dhcpv4SrvTest, processInform) { NakedDhcpv4Srv srv; - boost::shared_ptr pkt(new Pkt4(DHCPINFORM, 1234)); + Pkt4Ptr pkt(new Pkt4(DHCPINFORM, 1234)); // Should not throw EXPECT_NO_THROW(srv.processInform(pkt)); diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 03b2c0cdab..a83b9e8707 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -169,7 +169,7 @@ public: EXPECT_EQ(0, ia->getT1()); EXPECT_EQ(0, ia->getT2()); - boost::shared_ptr status = + OptionCustomPtr status = boost::dynamic_pointer_cast(ia->getOption(D6O_STATUS_CODE)); // It is ok to not include status success as this is the default behavior @@ -189,7 +189,7 @@ public: } void checkMsgStatusCode(const Pkt6Ptr& msg, uint16_t expected_status) { - boost::shared_ptr status = + OptionCustomPtr status = boost::dynamic_pointer_cast(msg->getOption(D6O_STATUS_CODE)); // It is ok to not include status success as this is the default behavior @@ -586,7 +586,7 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) { sol->addOption(clientid); // Pass it to the server and get an advertise - boost::shared_ptr adv = srv.processSolicit(sol); + Pkt6Ptr adv = srv.processSolicit(sol); // check if we get response at all ASSERT_TRUE(adv); diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc index c3f643e89d..4c9bdbca50 100644 --- a/src/lib/dhcp/tests/iface_mgr_unittest.cc +++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc @@ -111,13 +111,13 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) { interfaces << "eth0 fe80::21e:8cff:fe9b:7349"; interfaces.close(); - NakedIfaceMgr* ifacemgr = new NakedIfaceMgr(); + boost::scoped_ptr ifacemgr = new NakedIfaceMgr(); - Pkt6* pkt = NULL; + Pkt6Ptr pkt; int cnt = 0; cout << "---8X-----------------------------------------" << endl; while (true) { - pkt = ifacemgr->receive(); + pkt.reset(ifacemgr->receive()); cout << "// this code is autogenerated. Do NOT edit." << endl; cout << "// Received " << pkt->data_len_ << " bytes packet:" << endl; @@ -145,13 +145,11 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) { cout << " return (pkt);" << endl; cout << "}" << endl << endl; - delete pkt; + pkt.reset(); } cout << "---8X-----------------------------------------" << endl; // Never happens. Infinite loop is infinite - delete pkt; - delete ifacemgr; } #endif diff --git a/src/lib/dhcp/tests/option4_addrlst_unittest.cc b/src/lib/dhcp/tests/option4_addrlst_unittest.cc index ece363ece9..767d69011a 100644 --- a/src/lib/dhcp/tests/option4_addrlst_unittest.cc +++ b/src/lib/dhcp/tests/option4_addrlst_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011i-2013 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-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 diff --git a/src/lib/dhcp/tests/option_unittest.cc b/src/lib/dhcp/tests/option_unittest.cc index 9442ce58d4..237e73b1a0 100644 --- a/src/lib/dhcp/tests/option_unittest.cc +++ b/src/lib/dhcp/tests/option_unittest.cc @@ -46,7 +46,7 @@ public: OutputBuffer outBuf_; }; -// V4 is not really implemented yet. A simple test will do for now. +// Basic tests for V4 functionality TEST_F(OptionTest, v4_basic) { scoped_ptr