]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Disable the actual connect() in the test_dnsdisttcp_cc_c unit tests. 10977/head
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 12 Nov 2021 12:19:47 +0000 (13:19 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Fri, 12 Nov 2021 14:30:36 +0000 (15:30 +0100)
They are not needed and cause (at least on OpenBSD) firewall state table
clashes: they remain in a embryotic state because no actual activity
occurs on them due to the rest of the tests using mockup code.

tcpiohandler.cc is not linked into the tests, so define it locally in
test-dnsdisttcp_cc.cc as well.

pdns/dnsdistdist/test-dnsdisttcp_cc.cc
pdns/tcpiohandler.cc
pdns/tcpiohandler.hh

index 9884fdbba1b4c2f0603ca4d71dbaafea8788c8f1..1fbb00e9ceb71be4097442aa3528d448462abedb 100644 (file)
@@ -41,6 +41,8 @@ GlobalStateHolder<servers_t> g_dstates;
 
 QueryCount g_qcount;
 
+const bool TCPIOHandler::s_disableConnectForUnitTests = true;
+
 bool checkDNSCryptQuery(const ClientState& cs, PacketBuffer& query, std::unique_ptr<DNSCryptQuery>& dnsCryptQuery, time_t now, bool tcp)
 {
   return false;
index 4338f315c871ee1c6d757cad93df861cd7b747fc..6068c1bc84eaa273a4d1ac9888c675506f5319ab 100644 (file)
@@ -5,6 +5,8 @@
 #include "lock.hh"
 #include "tcpiohandler.hh"
 
+const bool TCPIOHandler::s_disableConnectForUnitTests = false;
+
 #ifdef HAVE_LIBSODIUM
 #include <sodium.h>
 #endif /* HAVE_LIBSODIUM */
@@ -20,6 +22,7 @@
 
 #include "libssl.hh"
 
+
 class OpenSSLFrontendContext
 {
 public:
index 7afbef1ffec8b512a6641528b4b3fd243a53b2b0..5b23e00dc3b77589d3e865a7578686080f47a9b8 100644 (file)
@@ -288,10 +288,14 @@ public:
       d_fastOpen = true;
     }
     else {
-      SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0});
+      if (!s_disableConnectForUnitTests) {
+        SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0});
+      }
     }
 #else
-    SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0});
+    if (!s_disableConnectForUnitTests) {
+      SConnectWithTimeout(d_socket, remote, /* no timeout, we will handle it ourselves */ timeval{0,0});
+    }
 #endif /* MSG_FASTOPEN */
 
     if (d_conn) {
@@ -320,10 +324,14 @@ public:
       d_fastOpen = true;
     }
     else {
-      SConnectWithTimeout(d_socket, remote, timeout);
+      if (!s_disableConnectForUnitTests) {
+        SConnectWithTimeout(d_socket, remote, timeout);
+      }
     }
 #else
-    SConnectWithTimeout(d_socket, remote, timeout);
+    if (!s_disableConnectForUnitTests) {
+      SConnectWithTimeout(d_socket, remote, timeout);
+    }
 #endif /* MSG_FASTOPEN */
 
     if (d_conn) {
@@ -539,6 +547,8 @@ public:
     return d_conn->isUsable();
   }
 
+  const static bool s_disableConnectForUnitTests;
+
 private:
   std::unique_ptr<TLSConnection> d_conn{nullptr};
   ComboAddress d_remote;