diff --git a/folly/io/async/test/AsyncUDPSocketTest.cpp b/folly/io/async/test/AsyncUDPSocketTest.cpp index 8b3ed8c2300e489a48c24e938c179a208a4b299f..494b7c01f86a8abbb0a0a0d557e25ebbafc40187 100644 --- a/folly/io/async/test/AsyncUDPSocketTest.cpp +++ b/folly/io/async/test/AsyncUDPSocketTest.cpp @@ -19,6 +19,7 @@ #include <folly/Conv.h> #include <folly/SocketAddress.h> #include <folly/String.h> +#include <folly/experimental/TestUtil.h> #include <folly/io/IOBuf.h> #include <folly/io/async/AsyncTimeout.h> #include <folly/io/async/AsyncUDPServerSocket.h> @@ -27,7 +28,6 @@ #include <folly/portability/GMock.h> #include <folly/portability/GTest.h> #include <folly/portability/Sockets.h> -#include <folly/portability/Unistd.h> using folly::AsyncTimeout; using folly::AsyncUDPServerSocket; @@ -614,14 +614,11 @@ TEST_F(AsyncUDPSocketTest, TestBound) { } 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_); EXPECT_FALSE(socket.isBound()); - SCOPE_EXIT { - ::unlink(kTmpUnixSocketPath); - }; - ::unlink(kTmpUnixSocketPath); - socket.bind(folly::SocketAddress::makeFromPath(kTmpUnixSocketPath)); + socket.bind(folly::SocketAddress::makeFromPath(kTmpUnixSocketPath.string())); EXPECT_TRUE(socket.isBound()); socket.close(); }