Commit fe95b7f0 authored by Amol Bhave's avatar Amol Bhave Committed by Facebook Github Bot

Fix test AsyncUDPSocketTest for stress testing

Summary:
If multiple instances of this test are running, it is possible for a
filename conflict to occur. This fixes that behavior by using a different temp
name each time.

Reviewed By: yfeldblum

Differential Revision: D15258558

fbshipit-source-id: 40e71c57e68a90bc730fb5ba427d999789f6f88c
parent fd4e0165
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <folly/Conv.h> #include <folly/Conv.h>
#include <folly/SocketAddress.h> #include <folly/SocketAddress.h>
#include <folly/String.h> #include <folly/String.h>
#include <folly/experimental/TestUtil.h>
#include <folly/io/IOBuf.h> #include <folly/io/IOBuf.h>
#include <folly/io/async/AsyncTimeout.h> #include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/AsyncUDPServerSocket.h> #include <folly/io/async/AsyncUDPServerSocket.h>
...@@ -27,7 +28,6 @@ ...@@ -27,7 +28,6 @@
#include <folly/portability/GMock.h> #include <folly/portability/GMock.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
#include <folly/portability/Sockets.h> #include <folly/portability/Sockets.h>
#include <folly/portability/Unistd.h>
using folly::AsyncTimeout; using folly::AsyncTimeout;
using folly::AsyncUDPServerSocket; using folly::AsyncUDPServerSocket;
...@@ -614,14 +614,11 @@ TEST_F(AsyncUDPSocketTest, TestBound) { ...@@ -614,14 +614,11 @@ TEST_F(AsyncUDPSocketTest, TestBound) {
} }
TEST_F(AsyncUDPSocketTest, TestBoundUnixSocket) { TEST_F(AsyncUDPSocketTest, TestBoundUnixSocket) {
const auto kTmpUnixSocketPath{"/tmp/tmp_unix_socket"}; folly::test::TemporaryDirectory tmpDirectory;
const auto kTmpUnixSocketPath{tmpDirectory.path() / "unix_socket_path"};
AsyncUDPSocket socket(&evb_); AsyncUDPSocket socket(&evb_);
EXPECT_FALSE(socket.isBound()); EXPECT_FALSE(socket.isBound());
SCOPE_EXIT { socket.bind(folly::SocketAddress::makeFromPath(kTmpUnixSocketPath.string()));
::unlink(kTmpUnixSocketPath);
};
::unlink(kTmpUnixSocketPath);
socket.bind(folly::SocketAddress::makeFromPath(kTmpUnixSocketPath));
EXPECT_TRUE(socket.isBound()); EXPECT_TRUE(socket.isBound());
socket.close(); socket.close();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment