From: Dave Watson <davejwatson@fb.com>
Date: Mon, 5 Jan 2015 22:45:12 +0000 (-0800)
Subject: fix bootstrap test on older kernels
X-Git-Tag: v0.22.0~49
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c77b1e7d9d59c7fdd84279217ddb593f353d9d0e;p=folly.git

fix bootstrap test on older kernels

Summary: another unittest that doesn't work without reuseport support, add a check

Test Plan: ran it on sandcastle187.prn2, works

Reviewed By: njormrod@fb.com

Subscribers: doug, fugalh, folly-diffs@

FB internal diff: D1764395

Tasks: 5931982

Signature: t1:1764395:1420490666:658aef148ebca9484534a0cebb228570e28f1002
---

diff --git a/folly/wangle/bootstrap/BootstrapTest.cpp b/folly/wangle/bootstrap/BootstrapTest.cpp
index 1efb4e08..1567978b 100644
--- a/folly/wangle/bootstrap/BootstrapTest.cpp
+++ b/folly/wangle/bootstrap/BootstrapTest.cpp
@@ -171,6 +171,20 @@ TEST(Bootstrap, ServerAcceptGroup2Test) {
 }
 
 TEST(Bootstrap, SharedThreadPool) {
+  // Check if reuse port is supported, if not, don't run this test
+  try {
+    EventBase base;
+    auto serverSocket = AsyncServerSocket::newSocket(&base);
+    serverSocket->bind(0);
+    serverSocket->listen(0);
+    serverSocket->startAccepting();
+    serverSocket->setReusePortEnabled(true);
+    serverSocket->stopAccepting();
+  } catch(...) {
+    LOG(INFO) << "Reuse port probably not supported";
+    return;
+  }
+
   auto pool = std::make_shared<IOThreadPoolExecutor>(2);
 
   TestServer server;