]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
minor changes:
authorAndrei Pavel <andrei.pavel@qualitance.com>
Fri, 18 Aug 2017 07:27:29 +0000 (10:27 +0300)
committerAndrei Pavel <andrei.pavel@qualitance.com>
Fri, 18 Aug 2017 07:34:26 +0000 (10:34 +0300)
    * 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

12 files changed:
src/bin/dhcp4/tests/get_config_unittest.cc
src/bin/dhcp4/tests/get_config_unittest.cc.skel
src/bin/dhcp6/tests/get_config_unittest.cc
src/bin/dhcp6/tests/get_config_unittest.cc.skel
src/lib/cc/data.cc
src/lib/cc/data.h
src/lib/config/module_spec.cc
src/lib/config/module_spec.h
src/lib/dhcpsrv/cfg_option.cc
src/lib/dhcpsrv/mysql_host_data_source.h
src/lib/util/threads/tests/condvar_unittest.cc
src/lib/util/threads/tests/lock_unittest.cc

index 0aff18e76eb1fb366bc7e95d8629cf4dec3c787b..92f618985d54b800daac3753b35cda7689004d88 100644 (file)
@@ -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<size_t>(0), max_config_counter));
-
+class IntToString {
+public:
+    std::string operator()(const testing::TestParamInfo<size_t>& n) {
+        return to_string(n.param);
+    }
 };
+
+/// Define the parameterized test loop.
+INSTANTIATE_TEST_CASE_P(Dhcp4GetConfigTest, Dhcp4GetConfigTest,
+                        ::testing::Range(static_cast<size_t>(0),
+                                         max_config_counter),
+                        IntToString());
+}  // namespace
index 825a6d62ab126beba29c514436b31899a566eb82..0c23840871286e2825d84df0ae16cbda3fac41ca 100644 (file)
@@ -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<size_t>(0), max_config_counter));
-
+class IntToString {
+public:
+    std::string operator()(const testing::TestParamInfo<size_t>& n) {
+        return to_string(n.param);
+    }
 };
+
+/// Define the parameterized test loop.
+INSTANTIATE_TEST_CASE_P(Dhcp4GetConfigTest, Dhcp4GetConfigTest,
+                        ::testing::Range(static_cast<size_t>(0),
+                                         max_config_counter),
+                        IntToString());
+}  // namespace
index 901e954336bb0957c9e8be307133c09d4c713842..223d29b6c6dd5b52b54c6476c483177132fe7f80 100644 (file)
@@ -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<size_t>(0), max_config_counter));
-
+class IntToString {
+public:
+    std::string operator()(const testing::TestParamInfo<size_t>& n) {
+        return to_string(n.param);
+    }
 };
+
+/// Define the parameterized test loop.
+INSTANTIATE_TEST_CASE_P(Dhcp6GetConfigTest, Dhcp6GetConfigTest,
+                        ::testing::Range(static_cast<size_t>(0),
+                                         max_config_counter),
+                        IntToString());
+}  // namespace
index 93604ed6c9201532ba445dd3408b671358a623e1..59d9d722a6265fe1e0d9379f51b4e145736710dd 100644 (file)
@@ -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<size_t>(0), max_config_counter));
-
+class IntToString {
+public:
+    std::string operator()(const testing::TestParamInfo<size_t>& n) {
+        return to_string(n.param);
+    }
 };
+
+/// Define the parameterized test loop.
+INSTANTIATE_TEST_CASE_P(Dhcp6GetConfigTest, Dhcp6GetConfigTest,
+                        ::testing::Range(static_cast<size_t>(0),
+                                         max_config_counter),
+                        IntToString());
+}  // namespace
index 4a83e688e027e2b6ef6e9e91f4bf1cd1e93010df..836923a5d9fd7f8ec66acdf4aee1946ff1c490ae 100644 (file)
@@ -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<ElementPtr> ListType;
         const ListType& l = element->listValue();
index d609615e9b1c27611591dca82ea129edb707877a..36e7c0f26c389b6a3e977d2fc2419d28963b181e 100644 (file)
@@ -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
 ///
index 0c9613b2b46af1b69eb4800331233729995dbc2a..b9f135082f1d46a9d9469ea8b8aaec7302f50e8d 100644 (file)
@@ -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<std::string, ConstElementPtr> maptype;
-    
+
     BOOST_FOREACH(maptype m, data->mapValue()) {
         // Ignore 'version' as a config element
         if (m.first.compare("version") != 0) {
index ef8c2a287bbfb5681acccf2fa4c3e5b7fb3c9d51..591e826c044750a3d388ceff33d09e5ae931b5ed 100644 (file)
@@ -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:
index 5d6c153918fc9ed6cd17d4a68d31127728c19410..3cd05dec40078c5a67d072b8c6577e80fb1836cf 100644 (file)
@@ -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 <config.h>
+
 #include <dhcp/libdhcp++.h>
-#include <dhcp/option_space.h>
 #include <dhcpsrv/cfg_option.h>
 #include <dhcp/dhcp6.h>
+#include <dhcp/option_space.h>
 #include <util/encode/hex.h>
 #include <string>
 #include <sstream>
@@ -169,9 +171,9 @@ CfgOption::mergeInternal(const OptionSpaceContainer<OptionContainer,
             // If there is no such option in the destination container,
             // add one.
             if (std::distance(range.first, range.second) == 0) {
-                dest_container.addItem(OptionDescriptor(src_opt->option_,
-                                                        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
index 11e52bd5e3dca104937235e35250d0504a5f0df0..94614494abc2df191cf956bc19e7cab8481bb68b 100644 (file)
 #include <dhcpsrv/db_exceptions.h>
 #include <dhcpsrv/mysql_connection.h>
 
+#include <stdint.h>
+
+#include <utility>
+#include <string>
+
 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
+
index 40d43715e20a719d2364ca24ae3cc53dc5e6da35..40013d93ff28320c59720568b3099d06ae3168bb 100644 (file)
@@ -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()) {
index 79697987503a219290bbd4f6b4b7e96c9db25b90..0ed9be0c139c8bdbf0b792492977055d5f977f2c 100644 (file)
@@ -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;