Fix Build: IPv6: SocketAddressTest.SetFromStrings and AsyncSocketTest.ConnectTimeout...
authorYedidya Feldblum <yfeldblum@fb.com>
Fri, 11 Sep 2015 03:21:30 +0000 (20:21 -0700)
committerfacebook-github-bot-9 <folly-bot@fb.com>
Fri, 11 Sep 2015 04:20:17 +0000 (21:20 -0700)
commit814b989e7103cf62ead37ac7f41c277b6d5564c7
treec0fc9fd20f4604776aabaac39bce0e67b0a5ce4e
parent6caa3d95ee837703f8f094ffbff5592627417711
Fix Build: IPv6: SocketAddressTest.SetFromStrings and AsyncSocketTest.ConnectTimeout failing

Summary: [Folly] Fix Build: IPv6: `SocketAddressTest.SetFromStrings` and `AsyncSocketTest.ConnectTimeout` failing

On IPv6-only machines, the `SocketAddressTest.SetFromStrings` example in `folly/test/SocketAddressTest.cpp` was failing because it tries to resolve `127.0.0.1` with `AI_ADDRCONFIG` set. Fix it by detecting which of IPv6 and IPv4 are enabled, and picking an appropriate loopback address.

On IPv6-only machines, the `AsyncSocketTest.ConnectTimeout` example in `folly/io/async/test/AsyncSocketTest2.cpp` was failing because it tries to connect `8.8.8.8`, which is IPv4. Fix it by detecting which of IPv6 and IPv4 are enabled, and picking an approprate remote address.

Reviewed By: @chipturner

Differential Revision: D2429109
folly/io/async/test/AsyncSocketTest2.cpp
folly/test/SocketAddressTest.cpp
folly/test/SocketAddressTestHelper.cpp [new file with mode: 0644]
folly/test/SocketAddressTestHelper.h [new file with mode: 0644]