Commit c15ca8db authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac3161'

parents 79d4f00a 0470cfd9
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -15,6 +15,7 @@
#include <dhcpsrv/testutils/config_result_check.h>
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
using namespace std;
......@@ -1227,10 +1228,10 @@ TEST_F(DdnsDomainTest, duplicateDomain) {
/// @brief Tests construction of D2CfgMgr
/// This test verifies that a D2CfgMgr constructs properly.
TEST(D2CfgMgr, construction) {
D2CfgMgr *cfg_mgr = NULL;
boost::scoped_ptr<D2CfgMgr> cfg_mgr;
// Verify that configuration manager constructions without error.
ASSERT_NO_THROW(cfg_mgr = new D2CfgMgr());
ASSERT_NO_THROW(cfg_mgr.reset(new D2CfgMgr()));
// Verify that the context can be retrieved and is not null.
D2CfgContextPtr context;
......@@ -1244,7 +1245,7 @@ TEST(D2CfgMgr, construction) {
EXPECT_TRUE(context->getReverseMgr());
// Verify that the manager can be destructed without error.
EXPECT_NO_THROW(delete cfg_mgr);
EXPECT_NO_THROW(cfg_mgr.reset());
}
/// @brief Tests the parsing of a complete, valid DHCP-DDNS configuration.
......
......@@ -1579,7 +1579,7 @@ Dhcpv4Srv::createNameChangeRequests(const Lease4Ptr& lease,
isc_throw(isc::Unexpected,
"NULL lease specified when creating NameChangeRequest");
} else if (!old_lease || (old_lease && !lease->hasIdenticalFqdn(*old_lease))) {
} else if (!old_lease || !lease->hasIdenticalFqdn(*old_lease)) {
// We may need to generate the NameChangeRequest for the new lease. It
// will be generated only if hostname is set and if forward or reverse
// update has been requested.
......
......@@ -453,7 +453,7 @@ public:
/// reservation.
void testReservationByIdentifier(Dhcp6Client& client,
const unsigned int config_index,
const std::string exp_ip_address) {
const std::string& exp_ip_address) {
configure(CONFIGS[config_index], *client.getServer());
const Subnet6Collection* subnets = CfgMgr::instance().getCurrentCfg()->
......
......@@ -79,7 +79,7 @@ public:
/// data.
///
/// \param which Which of the two callback objects this is
UDPCallback(std::string which) : ptr_(new PrivateData())
UDPCallback(const std::string& which) : ptr_(new PrivateData())
{
setName(which);
}
......
......@@ -300,7 +300,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
unpackOptions(OptionBuffer(data, data_buf.end()));
}
}
} else if (data_type == OPT_EMPTY_TYPE) {
} else {
// Unpack suboptions if any.
if (data != data_buf.end() && !getEncapsulatedSpace().empty()) {
unpackOptions(OptionBuffer(data, data_buf.end()));
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......@@ -291,8 +291,9 @@ TEST_F(Option6IATest, suboptionsUnpack) {
ASSERT_NE(OptionPtr(), subopt); // non-NULL
// Checks for address option
Option6IAAddr * addr = dynamic_cast<Option6IAAddr*>(subopt.get());
ASSERT_TRUE(NULL != addr);
Option6IAAddrPtr addr =
boost::dynamic_pointer_cast<Option6IAAddr>(subopt);
ASSERT_TRUE(addr);
EXPECT_EQ(D6O_IAADDR, addr->getType());
EXPECT_EQ(28, addr->len());
......
......@@ -1240,10 +1240,11 @@ public:
MySqlLeaseStatsQuery(MySqlConnection& conn, const size_t statement_index,
const bool fetch_type)
: conn_(conn), statement_index_(statement_index), statement_(NULL),
fetch_type_(fetch_type),
// Set the number of columns in the bind array based on fetch_type
// This is the number of columns expected in the result set
bind_(fetch_type_ ? 4 : 3) {
fetch_type_(fetch_type),
// Set the number of columns in the bind array based on fetch_type
// This is the number of columns expected in the result set
bind_(fetch_type_ ? 4 : 3),
subnet_id_(0), lease_type_(0), lease_state_(0), state_count_(0) {
if (statement_index_ >= MySqlLeaseMgr::NUM_STATEMENTS) {
isc_throw(BadValue, "MySqlLeaseStatsQuery"
" - invalid statement index" << statement_index_);
......
......@@ -1020,7 +1020,8 @@ public:
/// @brief Constructor.
PgSqlOptionExchange()
: PgSqlExchange(OPTION_COLUMNS) {
: PgSqlExchange(OPTION_COLUMNS), value_(),
value_len_(0), option_() {
columns_[OPTION_ID_COL] = "option_id";
columns_[CODE_COL] = "code";
columns_[VALUE_COL] = "value";
......
......@@ -1030,7 +1030,6 @@ setHooksLibrariesConfig(const char* lib1 = NULL, const char* lib2 = NULL,
const string quote("\"");
const string comma_space(", ");
const string library("\"library\": ");
const string parameters("\"parameters\": ");
string config = string("{ \"hooks-libraries\": [");
if (lib1 != NULL) {
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......@@ -49,7 +49,7 @@ public:
/// @param duid_type DUID type in numeric format.
/// @param duid_type_text DUID type in textual format.
void testTypeOnly(const DUID::DUIDType& duid_type,
const std::string duid_type_text) const;
const std::string& duid_type_text) const;
/// @brief Test that invalid configuration is rejected.
///
......@@ -109,7 +109,7 @@ DUIDConfigParserTest::build(const std::string& config) const {
void
DUIDConfigParserTest::testTypeOnly(const DUID::DUIDType& duid_type,
const std::string duid_type_text) const {
const std::string& duid_type_text) const {
// Use DUID configuration with only a "type".
ASSERT_NO_THROW(build(createConfigWithType(duid_type_text)));
......
......@@ -225,7 +225,7 @@ public:
/// @lineno line number from where the call was invoked
///
/// Asserts if the result set status does not equal the expected outcome.
void runSql(PgSqlResultPtr& r, const std::string sql, int exp_outcome,
void runSql(PgSqlResultPtr& r, const std::string& sql, int exp_outcome,
int lineno) {
r.reset(new PgSqlResult(PQexec(*conn_, sql.c_str())));
ASSERT_EQ(PQresultStatus(*r), exp_outcome)
......
......@@ -173,7 +173,7 @@ public:
/// @param exp_code expected option code to be parsed
/// @param exp_repr expected representation to be parsed
/// @param exp_tokens expected number of tokens
void testRelay6Option(std::string expr,
void testRelay6Option(const std::string& expr,
uint8_t exp_level,
uint16_t exp_code,
TokenOption::RepresentationType exp_repr,
......@@ -221,7 +221,7 @@ public:
/// @param expr expression to be parsed
/// @param exp_type expected metadata type to be parsed
/// @param exp_tokens expected number of tokens
void testPktMetadata(std::string expr,
void testPktMetadata(const std::string& expr,
TokenPkt::MetadataType exp_type,
int exp_tokens) {
EvalContext eval(Option::V6);
......@@ -266,7 +266,7 @@ public:
/// @param expr expression to be parsed
/// @param exp_type expected field type to be parsed
/// @param exp_tokens expected number of tokens
void testPkt4Field(std::string expr,
void testPkt4Field(const std::string& expr,
TokenPkt4::FieldType exp_type,
int exp_tokens) {
EvalContext eval(Option::V4);
......@@ -314,7 +314,8 @@ public:
/// @param expr expression to be parsed
/// @param exp_type expected field type to be parsed
/// @param exp_tokens expected number of tokens
void testPkt6Field(std::string expr, TokenPkt6::FieldType exp_type,
void testPkt6Field(const std::string& expr,
TokenPkt6::FieldType exp_type,
int exp_tokens) {
EvalContext eval(Option::V6);
......@@ -363,7 +364,7 @@ public:
/// @param exp_level expected level to be parsed
/// @param exp_type expected field type to be parsed
/// @param exp_tokens expected number of tokens
void testRelay6Field(std::string expr,
void testRelay6Field(const std::string& expr,
uint8_t exp_level,
TokenRelay6Field::FieldType exp_type,
int exp_tokens) {
......@@ -461,8 +462,9 @@ public:
/// @param vendor_id expected vendor-id (aka enterprise number)
/// @param option_code expected option code (ignored if 0)
/// @param expected_repr expected representation (either 'exists' or 'hex')
void testVendor(std::string expr, Option::Universe u, uint32_t vendor_id,
uint16_t option_code, TokenOption::RepresentationType expected_repr) {
void testVendor(const std::string& expr, Option::Universe u,
uint32_t vendor_id, uint16_t option_code,
TokenOption::RepresentationType expected_repr) {
EvalContext eval(u);
EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
......@@ -487,7 +489,8 @@ public:
/// @param u universe (V4 or V6)
/// @param vendor_id expected vendor-id (aka enterprise number)
/// @param expected_repr expected representation (either 'exists' or 'hex')
void testVendor(std::string expr, Option::Universe u, uint32_t vendor_id,
void testVendor(const std::string& expr, Option::Universe u,
uint32_t vendor_id,
TokenOption::RepresentationType expected_repr) {
testVendor(expr, u, vendor_id, 0, expected_repr);
}
......@@ -499,7 +502,8 @@ public:
///
/// @param expr expression to be parsed
/// @param u universe (V4 or V6)
void testVendorEnterprise(std::string expr, Option::Universe u) {
void testVendorEnterprise(const std::string& expr,
Option::Universe u) {
EvalContext eval(u);
EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
......@@ -524,7 +528,8 @@ public:
/// @param expr expression to be parsed
/// @param u universe (V4 or V6)
/// @param vendor_id expected vendor-id (aka enterprise number)
void testVendorClass(std::string expr, Option::Universe u, uint32_t vendor_id) {
void testVendorClass(const std::string& expr,
Option::Universe u, uint32_t vendor_id) {
EvalContext eval(u);
EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
......@@ -548,8 +553,8 @@ public:
/// @param u universe (V4 or V6)
/// @param vendor_id expected vendor-id (aka enterprise number)
/// @param index expected data index
void testVendorClass(std::string expr, Option::Universe u, uint32_t vendor_id,
uint16_t index) {
void testVendorClass(const std::string& expr, Option::Universe u,
uint32_t vendor_id, uint16_t index) {
EvalContext eval(u);
EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
......@@ -572,7 +577,8 @@ public:
///
/// @param expr expression to be parsed
/// @param u universe (V4 or V6)
void testVendorClassEnterprise(std::string expr, Option::Universe u) {
void testVendorClassEnterprise(const std::string& expr,
Option::Universe u) {
EvalContext eval(u);
EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
......
......@@ -352,7 +352,8 @@ public:
/// create the option)
/// @param expected_result text representation of the expected outcome
void testVendorExists(Option::Universe u, uint32_t token_vendor_id,
uint32_t option_vendor_id, std::string expected_result) {
uint32_t option_vendor_id,
const std::string& expected_result) {
// Let's clear any old values, so we can run multiple cases in each test
clearStack();
......@@ -375,7 +376,7 @@ public:
/// create the option)
/// @param expected_result text representation of the expected outcome
void testVendorEnterprise(Option::Universe u, uint32_t option_vendor_id,
std::string expected_result) {
const std::string& expected_result) {
// Let's clear any old values, so we can run multiple cases in each test
clearStack();
......@@ -394,7 +395,7 @@ public:
/// create the option)
/// @param expected_result text representation of the expected outcome
void testVendorClassEnterprise(Option::Universe u, uint32_t option_vendor_id,
std::string expected_result) {
const std::string& expected_result) {
// Let's clear any old values, so we can run multiple cases in each test
clearStack();
......@@ -414,7 +415,8 @@ public:
/// create the option)
/// @param expected_result text representation of the expected outcome
void testVendorClassExists(Option::Universe u, uint32_t token_vendor_id,
uint32_t option_vendor_id, std::string expected_result) {
uint32_t option_vendor_id,
const std::string& expected_result) {
// Let's clear any old values, so we can run multiple cases in each test
clearStack();
......@@ -441,7 +443,8 @@ public:
void testVendorSuboption(Option::Universe u,
uint32_t token_vendor_id, uint16_t token_option_code,
uint32_t option_vendor_id, uint16_t option_code,
TokenOption::RepresentationType repr, std::string expected) {
TokenOption::RepresentationType repr,
const std::string& expected) {
// Let's clear any old values, so we can run multiple cases in each test
clearStack();
......@@ -471,7 +474,7 @@ public:
void testVendorClassData(Option::Universe u,
uint32_t token_vendor_id, uint16_t token_index,
uint32_t option_vendor_id, uint16_t data_tuples,
std::string expected) {
const std::string& expected) {
// Let's clear any old values, so we can run multiple cases in each test
clearStack();
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......@@ -246,7 +246,6 @@ TEST_F(StopwatchTest, realTime) {
usleep(1000);
// The durations should get updated as appropriate.
current_duration = stopwatch.getLastMilliseconds();
EXPECT_GE(stopwatch.getLastMilliseconds(), 1);
EXPECT_GE(stopwatch.getTotalMilliseconds(), 2);
}
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......@@ -246,7 +246,7 @@ std::string replaceShell(const std::string& src, char c,
/// @brief Replace blank lines
/// Replaces blank lines in an array with the contents of the 'blank' section.
LinesType replaceBlankLines(const LinesType lines)
LinesType replaceBlankLines(const LinesType& lines)
{
LinesType result;
for (LinesType::const_iterator l = lines.begin(); l != lines.end(); ++l) {
......@@ -451,6 +451,7 @@ void processFileContent(const std::string& filename,
char* word1 = strtok(NULL, " \t\r\n\t\v");
prefix = word1;
}
delete[] line;
} else if (l->at(0) == '%') {
// Start of a message. Add the message we were processing to the
// dictionary and clear everything apart from the file name.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment