Bind to a random file in unix domain socket test
authorHaijun Zhu <haijunz@fb.com>
Fri, 6 May 2016 09:20:30 +0000 (02:20 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Fri, 6 May 2016 09:35:24 +0000 (02:35 -0700)
Summary:
test console reports "address already in use" failure so add some
randomness to it.

Reviewed By: yfeldblum

Differential Revision: D3265329

fb-gh-sync-id: a825cce787394783bb8d18d92385d2497b163385
fbshipit-source-id: a825cce787394783bb8d18d92385d2497b163385

folly/io/async/test/AsyncSocketTest2.cpp

index 549dc294c82da62858027a58881246ec6721a10b..d77654453b4abc29867c004df5b9a3e31e2a3d42 100644 (file)
@@ -19,6 +19,7 @@
 #include <folly/io/async/EventBase.h>
 #include <folly/RWSpinLock.h>
 #include <folly/SocketAddress.h>
+#include <folly/Random.h>
 
 #include <folly/io/IOBuf.h>
 #include <folly/io/async/test/AsyncSocketTest.h>
@@ -2122,7 +2123,7 @@ TEST(AsyncSocketTest, UnixDomainSocketTest) {
   std::shared_ptr<AsyncServerSocket> serverSocket(
       AsyncServerSocket::newSocket(&eventBase));
   string path(1, 0);
-  path.append("/anonymous");
+  path.append(folly::to<string>("/anonymous", folly::Random::rand64()));
   folly::SocketAddress serverAddress;
   serverAddress.setFromPath(path);
   serverSocket->bind(serverAddress);