Parcourir la source

[3736] Suppress cppcheck warnings about the SetUp/TearDown unused.

Marcin Siodelski il y a 10 ans
Parent
commit
659493d4a8

+ 12 - 10
src/bin/dhcp4/tests/config_parser_unittest.cc

@@ -73,9 +73,19 @@ TEST(Dhcp4SpecTest, basicSpec) {
 }
 
 class Dhcp4ParserTest : public ::testing::Test {
+protected:
+    // Check that no hooks libraries are loaded.  This is a pre-condition for
+    // a number of tests, so is checked in one place.  As this uses an
+    // ASSERT call - and it is not clear from the documentation that Gtest
+    // predicates can be used in a constructor - the check is placed in SetUp.
+    virtual void SetUp() {
+        std::vector<std::string> libraries = HooksManager::getLibraryNames();
+        ASSERT_TRUE(libraries.empty());
+    }
+
 public:
     Dhcp4ParserTest()
-    :rcode_(-1) {
+    : rcode_(-1) {
         // Open port 0 means to not do anything at all. We don't want to
         // deal with sockets here, just check if configuration handling
         // is sane.
@@ -85,15 +95,7 @@ public:
         resetConfiguration();
     }
 
-    // Check that no hooks libraries are loaded.  This is a pre-condition for
-    // a number of tests, so is checked in one place.  As this uses an
-    // ASSERT call - and it is not clear from the documentation that Gtest
-    // predicates can be used in a constructor - the check is placed in SetUp.
-    void SetUp() {
-        std::vector<std::string> libraries = HooksManager::getLibraryNames();
-        ASSERT_TRUE(libraries.empty());
-    }
-
+public:
     // Checks if global parameter of name have expected_value
     void checkGlobalUint32(string name, uint32_t expected_value) {
         const Uint32StoragePtr uint32_defaults =

+ 3 - 1
src/bin/dhcp4/tests/dhcp4_test_utils.cc

@@ -388,7 +388,9 @@ Dhcpv4SrvTest::createPacketFromBuffer(const Pkt4Ptr& src_pkt,
     return (::testing::AssertionSuccess());
 }
 
-void Dhcpv4SrvTest::TearDown() {
+void
+// cppcheck-suppress unusedFunction
+Dhcpv4SrvTest::TearDown() {
 
     CfgMgr::instance().clear();
 

+ 10 - 9
src/bin/dhcp6/tests/config_parser_unittest.cc

@@ -71,6 +71,16 @@ TEST(Dhcp6SpecTest, basicSpec) {
 }
 
 class Dhcp6ParserTest : public ::testing::Test {
+protected:
+    // Check that no hooks libraries are loaded.  This is a pre-condition for
+    // a number of tests, so is checked in one place.  As this uses an
+    // ASSERT call - and it is not clear from the documentation that Gtest
+    // predicates can be used in a constructor - the check is placed in SetUp.
+    virtual void SetUp() {
+        std::vector<std::string> libraries = HooksManager::getLibraryNames();
+        ASSERT_TRUE(libraries.empty());
+    }
+
 public:
     Dhcp6ParserTest() :rcode_(-1), srv_(0) {
         // srv_(0) means to not open any sockets. We don't want to
@@ -99,15 +109,6 @@ public:
         resetConfiguration();
     }
 
-    // Check that no hooks libraries are loaded.  This is a pre-condition for
-    // a number of tests, so is checked in one place.  As this uses an
-    // ASSERT call - and it is not clear from the documentation that Gtest
-    // predicates can be used in a constructor - the check is placed in SetUp.
-    void SetUp() {
-        std::vector<std::string> libraries = HooksManager::getLibraryNames();
-        ASSERT_TRUE(libraries.empty());
-    }
-
     ~Dhcp6ParserTest() {
         // Reset configuration database after each test.
         resetConfiguration();

+ 1 - 0
src/lib/dhcpsrv/tests/host_mgr_unittest.cc

@@ -52,6 +52,7 @@ protected:
 };
 
 void
+// cppcheck-suppress unusedFunction
 HostMgrTest::SetUp() {
     // Remove all configuration which may be dangling from the previous test.
     CfgMgr::instance().clear();