From: Haijun Zhu <haijunz@fb.com>
Date: Fri, 6 May 2016 09:20:30 +0000 (-0700)
Subject: Bind to a random file in unix domain socket test
X-Git-Tag: 2016.07.26~271
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=089f552233a0e0042d40199202f110335f78bcfd;p=folly.git

Bind to a random file in unix domain socket test

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
---

diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp
index 549dc294..d7765445 100644
--- a/folly/io/async/test/AsyncSocketTest2.cpp
+++ b/folly/io/async/test/AsyncSocketTest2.cpp
@@ -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);