Suppress some aborts in debug mode when using already closed file descriptors
authorChristopher Dykes <cdykes@fb.com>
Wed, 23 Nov 2016 18:43:24 +0000 (10:43 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Wed, 23 Nov 2016 18:54:24 +0000 (10:54 -0800)
Summary: The helper exists because MSVC is a pain in this regard, so use it.

Reviewed By: yfeldblum

Differential Revision: D4224037

fbshipit-source-id: 6c6415877785f13ea91618a3042f2470dccd08c1

folly/io/async/test/AsyncSSLSocketTest.h
folly/io/async/test/AsyncSocketTest2.cpp

index 7ae4aeb5b0449b06a1e26ad64591904297a7fe76..65c62cb0ad270ca9b6250766081225d17a72d21c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <folly/ExceptionWrapper.h>
 #include <folly/SocketAddress.h>
+#include <folly/experimental/TestUtil.h>
 #include <folly/io/async/AsyncSSLSocket.h>
 #include <folly/io/async/AsyncServerSocket.h>
 #include <folly/io/async/AsyncSocket.h>
@@ -259,7 +260,9 @@ public:
     wcb_->setSocket(socket_);
 
     // Write back the same data.
-    socket_->write(wcb_, currentBuffer.buffer, len);
+    folly::test::msvcSuppressAbortOnInvalidParams([&] {
+      socket_->write(wcb_, currentBuffer.buffer, len);
+    });
 
     if (wcb_->state == STATE_FAILED) {
       setState(STATE_SUCCEEDED);
index 02650418d7a67b00b7cfa63cfc7f8cb245c6645a..36ccc305928ba185ba86d108edb4ef0a06060c9f 100644 (file)
@@ -22,6 +22,7 @@
 #include <folly/io/async/AsyncTimeout.h>
 #include <folly/io/async/EventBase.h>
 
+#include <folly/experimental/TestUtil.h>
 #include <folly/io/IOBuf.h>
 #include <folly/io/async/test/AsyncSocketTest.h>
 #include <folly/io/async/test/Util.h>
@@ -2068,9 +2069,11 @@ TEST(AsyncSocketTest, DestroyCloseTest) {
   acceptedSocket.reset();
 
   // Test that server socket was closed
-  ssize_t sz = read(fd, simpleBuf, simpleBufLength);
-  ASSERT_EQ(sz, -1);
-  ASSERT_EQ(errno, 9);
+  folly::test::msvcSuppressAbortOnInvalidParams([&] {
+    ssize_t sz = read(fd, simpleBuf, simpleBufLength);
+    ASSERT_EQ(sz, -1);
+    ASSERT_EQ(errno, EBADF);
+  });
   delete[] simpleBuf;
 }