Skip to content

Commit

Permalink
Migrate from googletest 1.8 to googletest 1.10 (#67)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebookincubator/hsthrift#67

Updating `googletest` from `1.8.0` to `1.10.0`

Reviewed By: mzlee, igorsugak, luciang, meyering, r-barnes

Differential Revision: D34351084

fbshipit-source-id: 939b3985ab63a06b6d511ec8711c2d5863bdfea8
  • Loading branch information
dimitribouche authored and facebook-github-bot committed Mar 3, 2022
1 parent 1ba1204 commit ccaa3f1
Show file tree
Hide file tree
Showing 24 changed files with 292 additions and 263 deletions.
2 changes: 1 addition & 1 deletion build/fbcode_builder/manifests/mvfst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ folly
fizz

[dependencies.all(test=on, not(os=windows))]
googletest_1_8
googletest

[shipit.pathmap]
fbcode/quic/public_root = .
Expand Down
2 changes: 1 addition & 1 deletion build/fbcode_builder/manifests/proxygen
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ wangle
mvfst

[dependencies.test=on]
googletest_1_8
googletest

[shipit.pathmap]
fbcode/proxygen/public_tld = .
Expand Down
2 changes: 1 addition & 1 deletion folly/build/bootstrap-osx-homebrew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cmake \
..

# fetch googletest, if doesn't exist
GTEST_VER=1.8.0
GTEST_VER=1.10.0
GTEST_DIR=gtest-${GTEST_VER}
if [ ! -d ${GTEST_DIR} ]; then
mkdir ${GTEST_DIR}
Expand Down
8 changes: 4 additions & 4 deletions folly/experimental/channels/test/ChannelTestUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class MockNextCallback {
}
}

MOCK_METHOD1_T(onValue, void(TValue));
MOCK_METHOD0(onClosed, void());
MOCK_METHOD0(onCancelled, void());
MOCK_METHOD1(onRuntimeError, void(std::string));
MOCK_METHOD(void, onValue, (TValue));
MOCK_METHOD(void, onClosed, ());
MOCK_METHOD(void, onCancelled, ());
MOCK_METHOD(void, onRuntimeError, (std::string));
};

enum class ConsumptionMode {
Expand Down
8 changes: 4 additions & 4 deletions folly/experimental/coro/test/GmockHelpersTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class Foo {

class MockFoo : Foo {
public:
MOCK_METHOD0(getValues, folly::coro::Task<std::vector<std::string>>());
MOCK_METHOD(folly::coro::Task<std::vector<std::string>>, getValues, ());

MOCK_METHOD0(getString, folly::coro::Task<std::string>());
MOCK_METHOD1(getStringArg, folly::coro::Task<std::string>(std::string));
MOCK_METHOD0(getVoid, folly::coro::Task<void>());
MOCK_METHOD(folly::coro::Task<std::string>, getString, ());
MOCK_METHOD(folly::coro::Task<std::string>, getStringArg, (std::string));
MOCK_METHOD(folly::coro::Task<void>, getVoid, ());
};

} // namespace
Expand Down
6 changes: 4 additions & 2 deletions folly/io/async/test/AsyncSSLSocketTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2827,8 +2827,10 @@ class MockAsyncTFOSSLSocket : public AsyncSSLSocket {
std::shared_ptr<folly::SSLContext> sslCtx, EventBase* evb)
: AsyncSSLSocket(sslCtx, evb) {}

MOCK_METHOD3(
tfoSendMsg, ssize_t(NetworkSocket fd, struct msghdr* msg, int msg_flags));
MOCK_METHOD(
ssize_t,
tfoSendMsg,
(NetworkSocket fd, struct msghdr* msg, int msg_flags));
};

#if defined __linux__
Expand Down
12 changes: 6 additions & 6 deletions folly/io/async/test/AsyncSSLSocketTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ class EmptyReadCallback : public ReadCallback {

class MockCertificateIdentityVerifier : public CertificateIdentityVerifier {
public:
MOCK_CONST_METHOD1(
verifyLeafImpl, Try<Unit>(const AsyncTransportCertificate&));
MOCK_METHOD(
Try<Unit>, verifyLeafImpl, (const AsyncTransportCertificate&), (const));
// decorate to add noexcept
virtual Try<Unit> verifyLeaf(const AsyncTransportCertificate& leafCertificate)
const noexcept override {
Expand All @@ -489,21 +489,21 @@ class MockCertificateIdentityVerifier : public CertificateIdentityVerifier {

class MockHandshakeCB : public AsyncSSLSocket::HandshakeCB {
public:
MOCK_METHOD3(handshakeVerImpl, bool(AsyncSSLSocket*, bool, X509_STORE_CTX*));
MOCK_METHOD(bool, handshakeVerImpl, (AsyncSSLSocket*, bool, X509_STORE_CTX*));
virtual bool handshakeVer(
AsyncSSLSocket* sock,
bool preverifyOk,
X509_STORE_CTX* ctx) noexcept override {
return handshakeVerImpl(sock, preverifyOk, ctx);
}

MOCK_METHOD1(handshakeSucImpl, void(AsyncSSLSocket*));
MOCK_METHOD(void, handshakeSucImpl, (AsyncSSLSocket*));
virtual void handshakeSuc(AsyncSSLSocket* sock) noexcept override {
handshakeSucImpl(sock);
}

MOCK_METHOD2(
handshakeErrImpl, void(AsyncSSLSocket*, const AsyncSocketException&));
MOCK_METHOD(
void, handshakeErrImpl, (AsyncSSLSocket*, const AsyncSocketException&));
virtual void handshakeErr(
AsyncSSLSocket* sock, const AsyncSocketException& ex) noexcept override {
handshakeErrImpl(sock, ex);
Expand Down
12 changes: 6 additions & 6 deletions folly/io/async/test/AsyncSSLSocketWriteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ class MockAsyncSSLSocket : public AsyncSSLSocket {
}

// mock the calls to SSL_write to see the buffer length and contents
MOCK_METHOD3(sslWriteImpl, int(SSL* ssl, const void* buf, int n));
MOCK_METHOD(int, sslWriteImpl, (SSL * ssl, const void* buf, int n));

// mock the calls to SSL_get_error to insert errors
MOCK_METHOD2(sslGetErrorImpl, int(const SSL* s, int ret_code));
MOCK_METHOD(int, sslGetErrorImpl, (const SSL* s, int ret_code));

// mock the calls to sendSocketMessage to see the msg_flags
MOCK_METHOD3(
MOCK_METHOD(
AsyncSocket::WriteResult,
sendSocketMessage,
AsyncSocket::WriteResult(
NetworkSocket fd, struct msghdr* msg, int msg_flags));
(NetworkSocket fd, struct msghdr* msg, int msg_flags));

// mock the calls to getRawBytesWritten()
MOCK_CONST_METHOD0(getRawBytesWritten, size_t());
MOCK_METHOD(size_t, getRawBytesWritten, (), (const));

// public wrapper for protected interface
WriteResult testPerformWrite(
Expand Down
10 changes: 6 additions & 4 deletions folly/io/async/test/AsyncSocketTest2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2861,8 +2861,10 @@ class MockAsyncTFOSocket : public AsyncSocket {

explicit MockAsyncTFOSocket(EventBase* evb) : AsyncSocket(evb) {}

MOCK_METHOD3(
tfoSendMsg, ssize_t(NetworkSocket fd, struct msghdr* msg, int msg_flags));
MOCK_METHOD(
ssize_t,
tfoSendMsg,
(NetworkSocket fd, struct msghdr* msg, int msg_flags));
};

TEST(AsyncSocketTest, TestTFOUnsupported) {
Expand Down Expand Up @@ -3174,8 +3176,8 @@ TEST(AsyncSocketTest, ConnectTFOWithBigData) {

class MockEvbChangeCallback : public AsyncSocket::EvbChangeCallback {
public:
MOCK_METHOD1(evbAttached, void(AsyncSocket*));
MOCK_METHOD1(evbDetached, void(AsyncSocket*));
MOCK_METHOD(void, evbAttached, (AsyncSocket*));
MOCK_METHOD(void, evbDetached, (AsyncSocket*));
};

TEST(AsyncSocketTest, EvbCallbacks) {
Expand Down
19 changes: 10 additions & 9 deletions folly/io/async/test/AsyncUDPSocketTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,10 @@ class MockErrMessageCallback : public AsyncUDPSocket::ErrMessageCallback {
public:
~MockErrMessageCallback() override = default;

MOCK_METHOD1(errMessage_, void(const cmsghdr&));
MOCK_METHOD(void, errMessage_, (const cmsghdr&));
void errMessage(const cmsghdr& cmsg) noexcept override { errMessage_(cmsg); }

MOCK_METHOD1(errMessageError_, void(const folly::AsyncSocketException&));
MOCK_METHOD(void, errMessageError_, (const folly::AsyncSocketException&));
void errMessageError(
const folly::AsyncSocketException& ex) noexcept override {
errMessageError_(ex);
Expand All @@ -661,20 +661,21 @@ class MockUDPReadCallback : public AsyncUDPSocket::ReadCallback {
public:
~MockUDPReadCallback() override = default;

MOCK_METHOD2(getReadBuffer_, void(void**, size_t*));
MOCK_METHOD(void, getReadBuffer_, (void**, size_t*));
void getReadBuffer(void** buf, size_t* len) noexcept override {
getReadBuffer_(buf, len);
}

MOCK_METHOD0(shouldOnlyNotify, bool());
MOCK_METHOD1(onNotifyDataAvailable_, void(folly::AsyncUDPSocket&));
MOCK_METHOD(bool, shouldOnlyNotify, ());
MOCK_METHOD(void, onNotifyDataAvailable_, (folly::AsyncUDPSocket&));
void onNotifyDataAvailable(folly::AsyncUDPSocket& sock) noexcept override {
onNotifyDataAvailable_(sock);
}

MOCK_METHOD4(
MOCK_METHOD(
void,
onDataAvailable_,
void(const folly::SocketAddress&, size_t, bool, OnDataAvailableParams));
(const folly::SocketAddress&, size_t, bool, OnDataAvailableParams));
void onDataAvailable(
const folly::SocketAddress& client,
size_t len,
Expand All @@ -683,12 +684,12 @@ class MockUDPReadCallback : public AsyncUDPSocket::ReadCallback {
onDataAvailable_(client, len, truncated, params);
}

MOCK_METHOD1(onReadError_, void(const folly::AsyncSocketException&));
MOCK_METHOD(void, onReadError_, (const folly::AsyncSocketException&));
void onReadError(const folly::AsyncSocketException& ex) noexcept override {
onReadError_(ex);
}

MOCK_METHOD0(onReadClosed_, void());
MOCK_METHOD(void, onReadClosed_, ());
void onReadClosed() noexcept override { onReadClosed_(); }
};

Expand Down
2 changes: 1 addition & 1 deletion folly/io/async/test/EventHandlerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class EventHandlerMock : public EventHandler {
EventHandlerMock(EventBase* eb, int fd)
: EventHandler(eb, NetworkSocket::fromFd(fd)) {}
// gmock can't mock noexcept methods, so we need an intermediary
MOCK_METHOD1(_handlerReady, void(uint16_t));
MOCK_METHOD(void, _handlerReady, (uint16_t));
void handlerReady(uint16_t events) noexcept override {
_handlerReady(events);
}
Expand Down
64 changes: 35 additions & 29 deletions folly/io/async/test/MockAsyncSSLSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class MockAsyncSSLSocket : public AsyncSSLSocket {
bool deferSecurityNegotiation = false)
: AsyncSSLSocket(ctx, base, deferSecurityNegotiation) {}

MOCK_METHOD6(
MOCK_METHOD(
void,
connect_,
void(
AsyncSocket::ConnectCallback*,
const folly::SocketAddress&,
int,
const folly::SocketOptionMap&,
const folly::SocketAddress&,
const std::string&));
(AsyncSocket::ConnectCallback*,
const folly::SocketAddress&,
int,
const folly::SocketOptionMap&,
const folly::SocketAddress&,
const std::string&));
void connect(
AsyncSocket::ConnectCallback* callback,
const folly::SocketAddress& address,
Expand All @@ -49,17 +49,23 @@ class MockAsyncSSLSocket : public AsyncSSLSocket {
connect_(callback, address, timeout, options, bindAddr, ifName);
}

MOCK_CONST_METHOD1(getLocalAddress, void(folly::SocketAddress*));
MOCK_CONST_METHOD1(getPeerAddress, void(folly::SocketAddress*));
MOCK_METHOD0(closeNow, void());
MOCK_CONST_METHOD0(good, bool());
MOCK_CONST_METHOD0(readable, bool());
MOCK_CONST_METHOD0(hangup, bool());
MOCK_CONST_METHOD2(
getSelectedNextProtocol, void(const unsigned char**, unsigned*));
MOCK_CONST_METHOD2(
getSelectedNextProtocolNoThrow, bool(const unsigned char**, unsigned*));
MOCK_METHOD1(setReadCB, void(ReadCallback*));
MOCK_METHOD(void, getLocalAddress, (folly::SocketAddress*), (const));
MOCK_METHOD(void, getPeerAddress, (folly::SocketAddress*), (const));
MOCK_METHOD(void, closeNow, ());
MOCK_METHOD(bool, good, (), (const));
MOCK_METHOD(bool, readable, (), (const));
MOCK_METHOD(bool, hangup, (), (const));
MOCK_METHOD(
void,
getSelectedNextProtocol,
(const unsigned char**, unsigned*),
(const));
MOCK_METHOD(
bool,
getSelectedNextProtocolNoThrow,
(const unsigned char**, unsigned*),
(const));
MOCK_METHOD(void, setReadCB, (ReadCallback*));

void sslConn(
AsyncSSLSocket::HandshakeCB* cb,
Expand Down Expand Up @@ -91,19 +97,19 @@ class MockAsyncSSLSocket : public AsyncSSLSocket {
sslAcceptMockable(cb, timeout, verify);
}

MOCK_METHOD3(
MOCK_METHOD(
void,
sslConnectMockable,
void(
AsyncSSLSocket::HandshakeCB*,
std::chrono::milliseconds,
const SSLContext::SSLVerifyPeerEnum&));
(AsyncSSLSocket::HandshakeCB*,
std::chrono::milliseconds,
const SSLContext::SSLVerifyPeerEnum&));

MOCK_METHOD3(
MOCK_METHOD(
void,
sslAcceptMockable,
void(
AsyncSSLSocket::HandshakeCB*,
std::chrono::milliseconds,
const SSLContext::SSLVerifyPeerEnum&));
(AsyncSSLSocket::HandshakeCB*,
std::chrono::milliseconds,
const SSLContext::SSLVerifyPeerEnum&));
};

} // namespace test
Expand Down
21 changes: 11 additions & 10 deletions folly/io/async/test/MockAsyncServerSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ class MockAsyncServerSocket : public AsyncServerSocket {

// We explicitly do not mock destroy(), since the base class implementation
// in DelayedDestruction is what actually deletes the object.
// MOCK_METHOD0(destroy,
// void());
MOCK_METHOD1(bind, void(const folly::SocketAddress& address));
MOCK_METHOD2(
// MOCK_METHOD(void, destroy, ());
MOCK_METHOD(void, bind, (const folly::SocketAddress& address));
MOCK_METHOD(
void,
bind,
void(const std::vector<folly::IPAddress>& ipAddresses, uint16_t port));
MOCK_METHOD1(bind, void(uint16_t port));
MOCK_METHOD1(listen, void(int backlog));
MOCK_METHOD0(startAccepting, void());
MOCK_METHOD3(
(const std::vector<folly::IPAddress>& ipAddresses, uint16_t port));
MOCK_METHOD(void, bind, (uint16_t port));
MOCK_METHOD(void, listen, (int backlog));
MOCK_METHOD(void, startAccepting, ());
MOCK_METHOD(
void,
addAcceptCallback,
void(AcceptCallback* callback, EventBase* eventBase, uint32_t maxAtOnce));
(AcceptCallback * callback, EventBase* eventBase, uint32_t maxAtOnce));
};

} // namespace test
Expand Down
Loading

0 comments on commit ccaa3f1

Please sign in to comment.