From: Andrei Pavel Date: Fri, 18 Aug 2017 07:27:29 +0000 (+0300) Subject: minor changes: X-Git-Tag: trac5524_base~16^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e5ddf2725b14d37f3ee1755352f1bb206f04687;p=thirdparty%2Fkea.git minor changes: * dynamic exception specifications are deprecated in C++11 (throw on function definition) * INSTANTIATE_TEST_CASE_P gives a warning about variadic arguments having at least one argument. The IntToString functor is what it requires for test cases to be displayed correctly. * Options should be merged with formatted option included in the identifier. This was unit-tested, but masked by an incorrect csv-format value in test data. Merge not used in actual code, but used in Cassandra PR. * ifdefs in MACROS are not portable * added missing doxygen comments --- diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index 0aff18e76e..92f618985d 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -5982,7 +5982,7 @@ outputFormatted(const std::string& config) { } } -}; +} // namespace namespace isc { namespace dhcp { @@ -6013,9 +6013,9 @@ extractConfig(const std::string& config) { ++extract_count; } -}; -}; -}; +} // namespace test +} // namespace dhcp +} // namespace isc namespace { @@ -6199,8 +6199,16 @@ TEST_P(Dhcp4GetConfigTest, run) { EXPECT_TRUE(isEquivalent(unparsed, unparsed2)); } -/// Define the parameterized test loop -INSTANTIATE_TEST_CASE_P(Dhcp4GetConfigTest, Dhcp4GetConfigTest, - ::testing::Range(static_cast(0), max_config_counter)); - +class IntToString { +public: + std::string operator()(const testing::TestParamInfo& n) { + return to_string(n.param); + } }; + +/// Define the parameterized test loop. +INSTANTIATE_TEST_CASE_P(Dhcp4GetConfigTest, Dhcp4GetConfigTest, + ::testing::Range(static_cast(0), + max_config_counter), + IntToString()); +} // namespace diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc.skel b/src/bin/dhcp4/tests/get_config_unittest.cc.skel index 825a6d62ab..0c23840871 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp4/tests/get_config_unittest.cc.skel @@ -338,8 +338,16 @@ TEST_P(Dhcp4GetConfigTest, run) { EXPECT_TRUE(isEquivalent(unparsed, unparsed2)); } -/// Define the parameterized test loop -INSTANTIATE_TEST_CASE_P(Dhcp4GetConfigTest, Dhcp4GetConfigTest, - ::testing::Range(static_cast(0), max_config_counter)); - +class IntToString { +public: + std::string operator()(const testing::TestParamInfo& n) { + return to_string(n.param); + } }; + +/// Define the parameterized test loop. +INSTANTIATE_TEST_CASE_P(Dhcp4GetConfigTest, Dhcp4GetConfigTest, + ::testing::Range(static_cast(0), + max_config_counter), + IntToString()); +} // namespace diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc b/src/bin/dhcp6/tests/get_config_unittest.cc index 901e954336..223d29b6c6 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc +++ b/src/bin/dhcp6/tests/get_config_unittest.cc @@ -3204,7 +3204,7 @@ const char* UNPARSED_CONFIGS[] = { " {\n" " \"always-send\": false,\n" " \"code\": 7,\n" -" \"csv-format\": false,\n" +" \"csv-format\": true,\n" " \"data\": \"01\",\n" " \"name\": \"preference\",\n" " \"space\": \"dhcp6\"\n" @@ -5831,7 +5831,7 @@ outputFormatted(const std::string& config) { } } -}; +} namespace isc { namespace dhcp { @@ -5862,9 +5862,9 @@ extractConfig(const std::string& config) { ++extract_count; } -}; -}; -}; +} // namespace test +} // namespace dhcp +} // namespace isc namespace { @@ -6051,8 +6051,16 @@ TEST_P(Dhcp6GetConfigTest, run) { EXPECT_TRUE(isEquivalent(unparsed, unparsed2)); } -/// Define the parameterized test loop -INSTANTIATE_TEST_CASE_P(Dhcp6GetConfigTest, Dhcp6GetConfigTest, - ::testing::Range(static_cast(0), max_config_counter)); - +class IntToString { +public: + std::string operator()(const testing::TestParamInfo& n) { + return to_string(n.param); + } }; + +/// Define the parameterized test loop. +INSTANTIATE_TEST_CASE_P(Dhcp6GetConfigTest, Dhcp6GetConfigTest, + ::testing::Range(static_cast(0), + max_config_counter), + IntToString()); +} // namespace diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc.skel b/src/bin/dhcp6/tests/get_config_unittest.cc.skel index 93604ed6c9..59d9d722a6 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp6/tests/get_config_unittest.cc.skel @@ -341,8 +341,16 @@ TEST_P(Dhcp6GetConfigTest, run) { EXPECT_TRUE(isEquivalent(unparsed, unparsed2)); } -/// Define the parameterized test loop -INSTANTIATE_TEST_CASE_P(Dhcp6GetConfigTest, Dhcp6GetConfigTest, - ::testing::Range(static_cast(0), max_config_counter)); - +class IntToString { +public: + std::string operator()(const testing::TestParamInfo& n) { + return to_string(n.param); + } }; + +/// Define the parameterized test loop. +INSTANTIATE_TEST_CASE_P(Dhcp6GetConfigTest, Dhcp6GetConfigTest, + ::testing::Range(static_cast(0), + max_config_counter), + IntToString()); +} // namespace diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 4a83e688e0..836923a5d9 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -608,7 +608,7 @@ Element::nameToType(const std::string& type_name) { } ElementPtr -Element::fromJSON(std::istream& in, bool preproc) throw(JSONError) { +Element::fromJSON(std::istream& in, bool preproc) { int line = 1, pos = 1; stringstream filtered; @@ -623,7 +623,6 @@ Element::fromJSON(std::istream& in, bool preproc) throw(JSONError) { ElementPtr Element::fromJSON(std::istream& in, const std::string& file_name, bool preproc) - throw(JSONError) { int line = 1, pos = 1; stringstream filtered; @@ -635,7 +634,7 @@ Element::fromJSON(std::istream& in, const std::string& file_name, bool preproc) ElementPtr Element::fromJSON(std::istream& in, const std::string& file, int& line, - int& pos) throw(JSONError) + int& pos) { int c = 0; ElementPtr element; @@ -1236,7 +1235,7 @@ prettyPrint(ConstElementPtr element, std::ostream& out, // open the list out << "[" << (complex ? "\n" : " "); - + // iterate on items typedef std::vector ListType; const ListType& l = element->listValue(); diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index d609615e9b..36e7c0f26c 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -427,8 +427,7 @@ public: /// should be performed /// @return An ElementPtr that contains the element(s) specified /// in the given input stream. - static ElementPtr fromJSON(std::istream& in, bool preproc = false) - throw(JSONError); + static ElementPtr fromJSON(std::istream& in, bool preproc = false); /// Creates an Element from the given input stream containing JSON /// formatted data. @@ -440,8 +439,7 @@ public: /// @return An ElementPtr that contains the element(s) specified /// in the given input stream. static ElementPtr fromJSON(std::istream& in, const std::string& file_name, - bool preproc = false) - throw(JSONError); + bool preproc = false); /// Creates an Element from the given input stream, where we keep /// track of the location in the stream for error reporting. @@ -456,8 +454,7 @@ public: /// in the given input stream. // make this one private? static ElementPtr fromJSON(std::istream& in, const std::string& file, - int& line, int &pos) - throw(JSONError); + int& line, int &pos); /// Reads contents of specified file and interprets it as JSON. /// @@ -742,7 +739,7 @@ void merge(ElementPtr element, ConstElementPtr other); /// negative means outbound and perhaps looping forever). /// @return a pointer to a fresh copy /// \throw raises a BadValue is a null pointer occurs. -ElementPtr copy(ConstElementPtr from, int level = 100); +ElementPtr copy(ConstElementPtr from, int level = 100); /// @brief Compares the data with other using unordered lists /// diff --git a/src/lib/config/module_spec.cc b/src/lib/config/module_spec.cc index 0c9613b2b4..b9f135082f 100644 --- a/src/lib/config/module_spec.cc +++ b/src/lib/config/module_spec.cc @@ -188,8 +188,7 @@ namespace config { ModuleSpec::ModuleSpec(ConstElementPtr module_spec_element, const bool check) - throw(ModuleSpecError) - + { module_specification = module_spec_element; if (check) { @@ -298,7 +297,6 @@ ModuleSpec::validateStatistics(ConstElementPtr data, const bool full, ModuleSpec moduleSpecFromFile(const std::string& file_name, const bool check) - throw(JSONError, ModuleSpecError) { std::ifstream file; @@ -322,7 +320,6 @@ moduleSpecFromFile(const std::string& file_name, const bool check) ModuleSpec moduleSpecFromFile(std::ifstream& in, const bool check) - throw(JSONError, ModuleSpecError) { ConstElementPtr module_spec_element = Element::fromJSON(in); if (module_spec_element->contains("module_spec")) { @@ -439,7 +436,7 @@ ModuleSpec::validateSpec(ConstElementPtr spec, ConstElementPtr data, bool optional = spec->get("item_optional")->boolValue(); ConstElementPtr data_el; data_el = data->get(item_name); - + if (data_el) { if (!validateItem(spec, data_el, full, errors)) { return (false); @@ -468,7 +465,7 @@ ModuleSpec::validateSpecList(ConstElementPtr spec, ConstElementPtr data, } typedef std::pair maptype; - + BOOST_FOREACH(maptype m, data->mapValue()) { // Ignore 'version' as a config element if (m.first.compare("version") != 0) { diff --git a/src/lib/config/module_spec.h b/src/lib/config/module_spec.h index ef8c2a287b..591e826c04 100644 --- a/src/lib/config/module_spec.h +++ b/src/lib/config/module_spec.h @@ -43,8 +43,7 @@ namespace isc { namespace config { /// \param check If false, the module specification in the file /// is not checked to be of the correct form. explicit ModuleSpec(isc::data::ConstElementPtr e, - const bool check = true) - throw(ModuleSpecError); + const bool check = true); /// Returns the commands part of the specification as an /// ElementPtr, returns an empty ElementPtr if there is none @@ -72,11 +71,11 @@ namespace isc { namespace config { /// Returns the module name as specified by the specification const std::string getModuleName() const; - + /// Returns the module description as specified by the specification /// returns an empty string if there is no description const std::string getModuleDescription() const; - + // returns true if the given element conforms to this data // configuration specification /// Validates the given configuration data for this specification. @@ -176,8 +175,7 @@ namespace isc { namespace config { /// \param check If true, the module specification in the file /// is checked to be of the correct form ModuleSpec - moduleSpecFromFile(const std::string& file_name, const bool check = true) - throw(isc::data::JSONError, ModuleSpecError); + moduleSpecFromFile(const std::string& file_name, const bool check = true); /// Creates a \c ModuleSpec instance from the given input /// stream that contains the contents of a .spec file. @@ -188,12 +186,11 @@ namespace isc { namespace config { /// \param check If true, the module specification is checked /// to be of the correct form ModuleSpec - moduleSpecFromFile(std::ifstream& in, const bool check = true) - throw(isc::data::JSONError, ModuleSpecError); + moduleSpecFromFile(std::ifstream& in, const bool check = true); } } #endif // _DATA_DEF_H -// Local Variables: +// Local Variables: // mode: c++ -// End: +// End: diff --git a/src/lib/dhcpsrv/cfg_option.cc b/src/lib/dhcpsrv/cfg_option.cc index 5d6c153918..3cd05dec40 100644 --- a/src/lib/dhcpsrv/cfg_option.cc +++ b/src/lib/dhcpsrv/cfg_option.cc @@ -4,10 +4,12 @@ // 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 + #include -#include #include #include +#include #include #include #include @@ -169,9 +171,9 @@ CfgOption::mergeInternal(const OptionSpaceContaineroption_, - src_opt->persistent_), - *it); + dest_container.addItem(OptionDescriptor( + src_opt->option_, src_opt->persistent_, + src_opt->formatted_value_), *it); } } } @@ -276,5 +278,5 @@ CfgOption::toElement() const { return (result); } -} // end of namespace isc::dhcp -} // end of namespace isc +} // namespace dhcp +} // namespace isc diff --git a/src/lib/dhcpsrv/mysql_host_data_source.h b/src/lib/dhcpsrv/mysql_host_data_source.h index 11e52bd5e3..94614494ab 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.h +++ b/src/lib/dhcpsrv/mysql_host_data_source.h @@ -11,6 +11,11 @@ #include #include +#include + +#include +#include + namespace isc { namespace dhcp { @@ -234,9 +239,13 @@ public: /// /// This method supports v4 hosts only. /// - /// @param subnet_id subnet identifier. - /// @param addr specified address. - /// @return true if deletion was successful, false if the host was not there. + /// @param subnet_id subnet identfier + /// @param identifier_type type of host identifier (e.g. DUID, hardware + /// address) + /// @param identifier_begin pointer to the beginning of a buffer containing + /// an identifier + /// @param identifier_len host identifier length + /// @return true if deletion was successful, false if the host was not there /// @throw various exceptions in case of errors virtual bool del4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type, @@ -246,9 +255,13 @@ public: /// /// This method supports v6 hosts only. /// - /// @param subnet_id subnet identifier. - /// @param addr specified address. - /// @return true if deletion was successful, false if the host was not there. + /// @param subnet_id subnet identfier + /// @param identifier_type type of host identifier (e.g. DUID, hardware + /// address) + /// @param identifier_begin pointer to the beginning of a buffer containing + /// an identifier + /// @param identifier_len host identifier length + /// @return true if deletion was successful, false if the host was not there /// @throw various exceptions in case of errors virtual bool del6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type, @@ -298,7 +311,6 @@ public: virtual void rollback(); private: - /// @brief Pointer to the implementation of the @ref MySqlHostDataSource. MySqlHostDataSourceImpl* impl_; }; @@ -307,3 +319,4 @@ private: } #endif // MYSQL_HOST_DATA_SOURCE_H + diff --git a/src/lib/util/threads/tests/condvar_unittest.cc b/src/lib/util/threads/tests/condvar_unittest.cc index 40d43715e2..40013d93ff 100644 --- a/src/lib/util/threads/tests/condvar_unittest.cc +++ b/src/lib/util/threads/tests/condvar_unittest.cc @@ -134,13 +134,11 @@ signalAndWait(CondVar* condvar, Mutex* mutex) { condvar->wait(*mutex); } -TEST_F(CondVarTest, #ifdef HAS_UNDEFINED_PTHREAD_BEHAVIOR - DISABLED_destroyWhileWait +TEST_F(CondVarTest, DISABLED_destroyWhileWait) { #else - destroyWhileWait +TEST_F(CondVarTest, destroyWhileWait) { #endif -) { // We'll destroy a CondVar object while the thread is still waiting // on it. This will trigger an assertion failure. if (!isc::util::unittests::runningOnValgrind()) { diff --git a/src/lib/util/threads/tests/lock_unittest.cc b/src/lib/util/threads/tests/lock_unittest.cc index 7969798750..0ed9be0c13 100644 --- a/src/lib/util/threads/tests/lock_unittest.cc +++ b/src/lib/util/threads/tests/lock_unittest.cc @@ -79,13 +79,11 @@ TEST(MutexTest, lockNonBlocking) { #endif // ENABLE_DEBUG // Destroying a locked mutex is a bad idea as well -TEST(MutexTest, #ifdef HAS_UNDEFINED_PTHREAD_BEHAVIOR - DISABLED_destroyLocked +TEST(MutexTest, DISABLED_destroyLocked) { #else - destroyLocked +TEST(MutexTest, destroyLocked) { #endif -) { if (!isc::util::unittests::runningOnValgrind()) { EXPECT_DEATH_IF_SUPPORTED({ Mutex* mutex = new Mutex;