BIND 10 trac658_new, updated. 8609d278b5efdee7b218429063df1f6872ab2305 [trac658] Add TCP 'short send' tests

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Mar 15 16:22:44 UTC 2011


The branch, trac658_new has been updated
       via  8609d278b5efdee7b218429063df1f6872ab2305 (commit)
      from  b677c094340db6ba6c37bba7b3e6b177830116f6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8609d278b5efdee7b218429063df1f6872ab2305
Author: Jelte Jansen <jelte at isc.org>
Date:   Tue Mar 15 17:22:00 2011 +0100

    [trac658] Add TCP 'short send' tests
    
    Added an option to tcpSendReturnTest that makes it not send all data, resulting in a timeout

-----------------------------------------------------------------------

Summary of changes:
 src/lib/asiolink/tests/io_fetch_unittest.cc |   36 ++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 3 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/asiolink/tests/io_fetch_unittest.cc b/src/lib/asiolink/tests/io_fetch_unittest.cc
index 3dca930..d5a7151 100644
--- a/src/lib/asiolink/tests/io_fetch_unittest.cc
+++ b/src/lib/asiolink/tests/io_fetch_unittest.cc
@@ -88,6 +88,9 @@ public:
     uint8_t         qid_0;                  ///< First octet of qid
     uint8_t         qid_1;                  ///< Second octet of qid
 
+    bool            tcp_short_send_;        ///< If set to true, we do not send
+                                            ///  all data in the tcp response
+
     /// \brief Constructor
     IOFetchTest() :
         service_(),
@@ -113,7 +116,8 @@ public:
         debug_(DEBUG),
         tcp_send_size_(0),
         qid_0(0),
-        qid_1(0)
+        qid_1(0),
+        tcp_short_send_(false)
     {
         // Construct the data buffer for question we expect to receive.
         Message msg(Message::RENDER);
@@ -337,6 +341,12 @@ public:
             cout << "tcpSendData(): sending " << amount << " bytes" << endl;
         }
 
+		// This is for the short send test; reduce the actual amount of
+		// data we send
+		if (tcp_short_send_) {
+			--amount;
+		}
+
         // ... and send it.  The amount sent is also passed as the first
         // argument of the send callback, as a check.
         socket->async_send(asio::buffer(send_ptr, amount),
@@ -499,13 +509,20 @@ public:
     /// Send a query to the server then receives a response.
     ///
     /// \param Test data to return to client
-    void tcpSendReturnTest(const std::string& return_data) {
+    /// \param short_send If true, do not send all data
+    ///                   (should result in timeout)
+    void tcpSendReturnTest(const std::string& return_data, bool short_send = false) {
         if (debug_) {
             cout << "tcpSendReturnTest(): data size = " << return_data.size() << endl;
         }
         return_data_ = return_data;
         protocol_ = IOFetch::TCP;
-        expected_ = IOFetch::SUCCESS;
+        if (short_send) {
+			tcp_short_send_ = true;
+			expected_ = IOFetch::TIME_OUT;
+		} else {
+			expected_ = IOFetch::SUCCESS;
+		}
 
         // Socket into which the connection will be accepted.
         tcp::socket socket(service_.get_io_service());
@@ -684,4 +701,17 @@ TEST_F(IOFetchTest, TcpSendReceive65535) {
     tcpSendReturnTest(test_data_.substr(0, 65535));
 }
 
+TEST_F(IOFetchTest, TcpSendReceive2ShortSend) {
+    tcpSendReturnTest(test_data_.substr(0, 2), true);
+}
+
+TEST_F(IOFetchTest, TcpSendReceive15ShortSend) {
+    tcpSendReturnTest(test_data_.substr(0, 15), true);
+}
+
+TEST_F(IOFetchTest, TcpSendReceive8192ShortSend) {
+    tcpSendReturnTest(test_data_.substr(0, 8192), true);
+}
+
+
 } // namespace asiolink




More information about the bind10-changes mailing list