diff --git a/quic/api/test/Mocks.h b/quic/api/test/Mocks.h index 3c808547d..2bd8bd8f9 100644 --- a/quic/api/test/Mocks.h +++ b/quic/api/test/Mocks.h @@ -401,14 +401,9 @@ class MockLegacyObserver : public LegacyObserver { bool timeoutLoss) { return AllOf( testing::Field( - &SocketObserverInterface::LostPacket::lostByReorderThreshold, - testing::Eq(reorderLoss)), - testing::Field( - &SocketObserverInterface::LostPacket::lostByTimeout, - testing::Eq(timeoutLoss)), - testing::Field( - &SocketObserverInterface::LostPacket::packet, - getLossPacketNum(packetNum))); + &LostPacket::lostByReorderThreshold, testing::Eq(reorderLoss)), + testing::Field(&LostPacket::lostByTimeout, testing::Eq(timeoutLoss)), + testing::Field(&LostPacket::packet, getLossPacketNum(packetNum))); } static auto getStreamEventMatcher( diff --git a/quic/api/test/QuicTransportBaseTest.cpp b/quic/api/test/QuicTransportBaseTest.cpp index e82b84836..16bb508c6 100644 --- a/quic/api/test/QuicTransportBaseTest.cpp +++ b/quic/api/test/QuicTransportBaseTest.cpp @@ -627,8 +627,8 @@ INSTANTIATE_TEST_SUITE_P( QuicTransportImplTestBase, QuicTransportImplTestBase, ::testing::Values( - DelayedStreamNotifsTestParam{.notifyOnNewStreamsExplicitly = false}, - DelayedStreamNotifsTestParam{.notifyOnNewStreamsExplicitly = true})); + DelayedStreamNotifsTestParam{false}, + DelayedStreamNotifsTestParam{true})); TEST_P(QuicTransportImplTestBase, AckTimeoutExpiredWillResetTimeoutFlag) { transport->invokeAckTimeout(); @@ -1662,14 +1662,10 @@ TEST_P(QuicTransportImplTestBase, ByteEventCallbacksManagementSingleStream) { auto stream = transport->createBidirectionalStream().value(); uint64_t offset1 = 10, offset2 = 20; - ByteEvent txEvent1 = { - .id = stream, .offset = offset1, .type = ByteEvent::Type::TX}; - ByteEvent txEvent2 = { - .id = stream, .offset = offset2, .type = ByteEvent::Type::TX}; - ByteEvent ackEvent1 = { - .id = stream, .offset = offset1, .type = ByteEvent::Type::ACK}; - ByteEvent ackEvent2 = { - .id = stream, .offset = offset2, .type = ByteEvent::Type::ACK}; + ByteEvent txEvent1 = ByteEvent{stream, offset1, ByteEvent::Type::TX}; + ByteEvent txEvent2 = ByteEvent{stream, offset2, ByteEvent::Type::TX}; + ByteEvent ackEvent1 = ByteEvent{stream, offset1, ByteEvent::Type::ACK}; + ByteEvent ackEvent2 = ByteEvent{stream, offset2, ByteEvent::Type::ACK}; // Register 2 TX and 2 ACK events for the same stream at 2 different offsets transport->registerTxCallback( @@ -1750,14 +1746,10 @@ TEST_P( auto stream1 = transport->createBidirectionalStream().value(); auto stream2 = transport->createBidirectionalStream().value(); - ByteEvent txEvent1 = { - .id = stream1, .offset = 10, .type = ByteEvent::Type::TX}; - ByteEvent txEvent2 = { - .id = stream2, .offset = 20, .type = ByteEvent::Type::TX}; - ByteEvent ackEvent1 = { - .id = stream1, .offset = 10, .type = ByteEvent::Type::ACK}; - ByteEvent ackEvent2 = { - .id = stream2, .offset = 20, .type = ByteEvent::Type::ACK}; + ByteEvent txEvent1 = ByteEvent{stream1, 10, ByteEvent::Type::TX}; + ByteEvent txEvent2 = ByteEvent{stream2, 20, ByteEvent::Type::TX}; + ByteEvent ackEvent1 = ByteEvent{stream1, 10, ByteEvent::Type::ACK}; + ByteEvent ackEvent2 = ByteEvent{stream2, 20, ByteEvent::Type::ACK}; EXPECT_THAT(byteEventCallback.getByteEventTracker(), IsEmpty()); // Register 2 TX and 2 ACK events for 2 separate streams. @@ -4130,8 +4122,7 @@ class QuicTransportImplTestWithGroups : public QuicTransportImplTestBase {}; INSTANTIATE_TEST_SUITE_P( QuicTransportImplTestWithGroups, QuicTransportImplTestWithGroups, - ::testing::Values(DelayedStreamNotifsTestParam{ - .notifyOnNewStreamsExplicitly = true})); + ::testing::Values(DelayedStreamNotifsTestParam{true})); TEST_P(QuicTransportImplTestWithGroups, ReadCallbackWithGroupsDataAvailable) { auto transportSettings = transport->getTransportSettings(); diff --git a/quic/api/test/QuicTypedTransportTest.cpp b/quic/api/test/QuicTypedTransportTest.cpp index 54f979add..4f28b82c6 100644 --- a/quic/api/test/QuicTypedTransportTest.cpp +++ b/quic/api/test/QuicTypedTransportTest.cpp @@ -1170,11 +1170,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = folly::none}), + testing::Ne( + SocketObserverInterface::CloseStartedEvent{folly::none}), // should be equal to a populated event with default error - testing::Eq(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = defaultError})))); + testing::Eq( + SocketObserverInterface::CloseStartedEvent{defaultError})))); EXPECT_CALL(*observer, closing(transport, _)); transport->close(folly::none); Mock::VerifyAndClearExpectations(observer.get()); @@ -1210,11 +1210,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = folly::none}), + testing::Ne( + SocketObserverInterface::CloseStartedEvent{folly::none}), // should be equal to a populated event with default error - testing::Eq(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = defaultError})))); + testing::Eq( + SocketObserverInterface::CloseStartedEvent{defaultError})))); transport->close(folly::none); // wait for the drain @@ -1257,11 +1257,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = folly::none}), + testing::Ne( + SocketObserverInterface::CloseStartedEvent{folly::none}), // should be equal to a populated event with default error - testing::Eq(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = defaultError})))); + testing::Eq( + SocketObserverInterface::CloseStartedEvent{defaultError})))); transport->close(folly::none); Mock::VerifyAndClearExpectations(observer.get()); @@ -1298,11 +1298,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = folly::none}), + testing::Ne( + SocketObserverInterface::CloseStartedEvent{folly::none}), // should be equal to a populated event with default error - testing::Eq(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = testError})))); + testing::Eq( + SocketObserverInterface::CloseStartedEvent{testError})))); EXPECT_CALL(*observer, closing(transport, _)); transport->close(testError); Mock::VerifyAndClearExpectations(observer.get()); @@ -1340,11 +1340,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = folly::none}), + testing::Ne( + SocketObserverInterface::CloseStartedEvent{folly::none}), // should be equal to a populated event with default error - testing::Eq(SocketObserverInterface::CloseStartedEvent{ - .maybeCloseReason = testError})))); + testing::Eq( + SocketObserverInterface::CloseStartedEvent{testError})))); EXPECT_CALL(*observer, closing(transport, _)); transport->close(testError); Mock::VerifyAndClearExpectations(observer.get()); @@ -2056,7 +2056,8 @@ TYPED_TEST( testing::Gt(strLength))); EXPECT_CALL(*obs1, packetsWritten(_, _)).Times(0); EXPECT_CALL(*obs2, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2067,7 +2068,8 @@ TYPED_TEST( EXPECT_EQ(bytesWritten, event.numBytesWritten); }); EXPECT_CALL(*obs3, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2095,7 +2097,8 @@ TYPED_TEST( EXPECT_CALL(*obs1, appRateLimited(_, _)).Times(0); EXPECT_CALL(*obs2, appRateLimited(transport, appRateLimitedMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2105,7 +2108,8 @@ TYPED_TEST( event.maybeWritableBytes); }); EXPECT_CALL(*obs3, appRateLimited(transport, appRateLimitedMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2233,7 +2237,8 @@ TYPED_TEST( testing::AllOf(testing::Gt(bufLength), testing::Gt(cwndInBytes)))); EXPECT_CALL(*obs1, packetsWritten(_, _)).Times(0); EXPECT_CALL(*obs2, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2244,7 +2249,8 @@ TYPED_TEST( EXPECT_EQ(bytesWritten, event.numBytesWritten); }); EXPECT_CALL(*obs3, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2377,7 +2383,8 @@ TYPED_TEST( testing::Ge(cwndInBytes))); // full CWND written EXPECT_CALL(*obs1, packetsWritten(_, _)).Times(0); EXPECT_CALL(*obs2, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2388,7 +2395,8 @@ TYPED_TEST( EXPECT_EQ(bytesWritten, event.numBytesWritten); }); EXPECT_CALL(*obs3, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2444,7 +2452,8 @@ TYPED_TEST( testing::Lt(cwndInBytes))); EXPECT_CALL(*obs1, packetsWritten(_, _)).Times(0); EXPECT_CALL(*obs2, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2455,7 +2464,8 @@ TYPED_TEST( EXPECT_EQ(bytesWritten, event.numBytesWritten); }); EXPECT_CALL(*obs3, packetsWritten(transport, packetsWrittenMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2482,7 +2492,8 @@ TYPED_TEST( testing::Lt(folly::Optional(cwndInBytes)))); EXPECT_CALL(*obs1, appRateLimited(_, _)).Times(0); EXPECT_CALL(*obs2, appRateLimited(transport, appRateLimitedMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; @@ -2492,7 +2503,8 @@ TYPED_TEST( event.maybeWritableBytes); }); EXPECT_CALL(*obs3, appRateLimited(transport, appRateLimitedMatcher)) - .WillOnce([oldTInfo = this->getTransport()->getTransportInfo()]( + .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), + cwndInBytes = cwndInBytes]( const auto& socket, const auto& event) { const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; diff --git a/quic/codec/test/PacketNumberTest.cpp b/quic/codec/test/PacketNumberTest.cpp index 99b1fdc38..76b62f545 100644 --- a/quic/codec/test/PacketNumberTest.cpp +++ b/quic/codec/test/PacketNumberTest.cpp @@ -67,36 +67,36 @@ INSTANTIATE_TEST_SUITE_P( Packet8DecodeTests, Packet8DecodeTest, Values( - (Packet8DecodeData){0xaa82f30e, 0x94, 0xaa82f294}, - (Packet8DecodeData){0xaa82f3fe, 0xff, 0xaa82f3ff}, - (Packet8DecodeData){0xaa82ffff, 0x01, 0xaa830001}, - (Packet8DecodeData){0xaa82fffe, 0x01, 0xaa830001})); + Packet8DecodeData{0xaa82f30e, 0x94, 0xaa82f294}, + Packet8DecodeData{0xaa82f3fe, 0xff, 0xaa82f3ff}, + Packet8DecodeData{0xaa82ffff, 0x01, 0xaa830001}, + Packet8DecodeData{0xaa82fffe, 0x01, 0xaa830001})); INSTANTIATE_TEST_SUITE_P( Packet16DecodeTests, Packet16DecodeTest, Values( - (Packet16DecodeData){0xaa82f30e, 0x1f94, 0xaa831f94}, - (Packet16DecodeData){0x10000, 0x9000, 0x9000}, - (Packet16DecodeData){0x10000, 0x8000, 0x18000}, - (Packet16DecodeData){0xffff, 0x8000, 0x18000}, - (Packet16DecodeData){0xf20000, 0xffff, 0xf1ffff}, - (Packet16DecodeData){0x0fff00f, 0x0000, 0x1000000}, - (Packet16DecodeData){0x001f, 0x010f, 0x010f}, - (Packet16DecodeData){0x001f, 0x000f, 0x000f}, - (Packet16DecodeData){0x0001, 0x0fff, 0x0fff}, - (Packet16DecodeData){0x0001, 0x0002, 0x0002}, - (Packet16DecodeData){0x10000, 0x0001, 0x10001}, - (Packet16DecodeData){0xaa82f30e, 0x9b3, 0xaa8309b3}, - (Packet16DecodeData){0xa82f30ea, 0x9b32, 0xa82f9b32})); + Packet16DecodeData{0xaa82f30e, 0x1f94, 0xaa831f94}, + Packet16DecodeData{0x10000, 0x9000, 0x9000}, + Packet16DecodeData{0x10000, 0x8000, 0x18000}, + Packet16DecodeData{0xffff, 0x8000, 0x18000}, + Packet16DecodeData{0xf20000, 0xffff, 0xf1ffff}, + Packet16DecodeData{0x0fff00f, 0x0000, 0x1000000}, + Packet16DecodeData{0x001f, 0x010f, 0x010f}, + Packet16DecodeData{0x001f, 0x000f, 0x000f}, + Packet16DecodeData{0x0001, 0x0fff, 0x0fff}, + Packet16DecodeData{0x0001, 0x0002, 0x0002}, + Packet16DecodeData{0x10000, 0x0001, 0x10001}, + Packet16DecodeData{0xaa82f30e, 0x9b3, 0xaa8309b3}, + Packet16DecodeData{0xa82f30ea, 0x9b32, 0xa82f9b32})); INSTANTIATE_TEST_SUITE_P( Packet32DecodeTests, Packet32DecodeTest, Values( - (Packet32DecodeData){0xaa82f30e, 0x0094f30e, 0x10094f30e}, - (Packet32DecodeData){0xbcaa82f30e, 0x00000000, 0xbd00000000}, - (Packet32DecodeData){0xbcaa82f30e, 0xaa82f30f, 0xbcaa82f30f})); + Packet32DecodeData{0xaa82f30e, 0x0094f30e, 0x10094f30e}, + Packet32DecodeData{0xbcaa82f30e, 0x00000000, 0xbd00000000}, + Packet32DecodeData{0xbcaa82f30e, 0xaa82f30f, 0xbcaa82f30f})); class EncodingTest : public Test {}; diff --git a/quic/logging/test/QLoggerTest.cpp b/quic/logging/test/QLoggerTest.cpp index 8bdbb734d..cf94a8398 100644 --- a/quic/logging/test/QLoggerTest.cpp +++ b/quic/logging/test/QLoggerTest.cpp @@ -1422,6 +1422,7 @@ TEST_F(QLoggerTest, NonPrettyStream) { EXPECT_EQ((bool)getline(file, s), false); } +#ifndef _WIN32 TEST_F(QLoggerTest, CompressedStream) { folly::dynamic expected = folly::parseJson(expectedJsonStr1); @@ -1509,6 +1510,7 @@ TEST_F(QLoggerTest, CompressedNonStream) { EXPECT_EQ(expected["summary"], parsed["summary"]); EXPECT_EQ(expected["traces"], parsed["traces"]); } +#endif TEST_F(QLoggerTest, NoThrowOnStreamingWithNonExistentDirectory) { auto headerIn = diff --git a/quic/observer/SocketObserverInterface.h b/quic/observer/SocketObserverInterface.h index cf73e6dfc..1943b3d3e 100644 --- a/quic/observer/SocketObserverInterface.h +++ b/quic/observer/SocketObserverInterface.h @@ -63,6 +63,17 @@ class SocketObserverInterface { friend auto operator<=>( const CloseStartedEvent&, const CloseStartedEvent&) = default; +#elif _WIN32 + friend auto operator!=( + const CloseStartedEvent& right, + const CloseStartedEvent& left) { + return right.maybeCloseReason != left.maybeCloseReason; + } + friend auto operator==( + const CloseStartedEvent& right, + const CloseStartedEvent& left) { + return right.maybeCloseReason == left.maybeCloseReason; + } #endif }; diff --git a/quic/state/test/PacketEventTest.cpp b/quic/state/test/PacketEventTest.cpp index 028173f72..4c543d3bb 100644 --- a/quic/state/test/PacketEventTest.cpp +++ b/quic/state/test/PacketEventTest.cpp @@ -7,7 +7,7 @@ #include -#include +#include namespace quic { namespace test { diff --git a/quic/state/test/QuicStreamManagerTest.cpp b/quic/state/test/QuicStreamManagerTest.cpp index 0e650eab6..fb86598dc 100644 --- a/quic/state/test/QuicStreamManagerTest.cpp +++ b/quic/state/test/QuicStreamManagerTest.cpp @@ -21,8 +21,8 @@ namespace quic { namespace test { struct StreamManagerTestParam { - bool notifyOnNewStreamsExplicitly; - bool isUnidirectional; + bool notifyOnNewStreamsExplicitly{false}; + bool isUnidirectional{false}; }; class QuicStreamManagerTest @@ -707,8 +707,8 @@ INSTANTIATE_TEST_SUITE_P( QuicStreamManagerTest, QuicStreamManagerTest, ::testing::Values( - StreamManagerTestParam{.notifyOnNewStreamsExplicitly = false}, - StreamManagerTestParam{.notifyOnNewStreamsExplicitly = true})); + StreamManagerTestParam{false}, + StreamManagerTestParam{true})); class QuicStreamManagerGroupsTest : public QuicStreamManagerTest { public: @@ -874,12 +874,8 @@ INSTANTIATE_TEST_SUITE_P( QuicStreamManagerGroupsTest, QuicStreamManagerGroupsTest, ::testing::Values( - StreamManagerTestParam{ - .notifyOnNewStreamsExplicitly = true, - .isUnidirectional = false}, - StreamManagerTestParam{ - .notifyOnNewStreamsExplicitly = true, - .isUnidirectional = true})); + StreamManagerTestParam{true, false}, + StreamManagerTestParam{true, true})); } // namespace test } // namespace quic