Skip to content

Commit

Permalink
Add packet loss to test
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjectsByJackHe committed Sep 5, 2023
1 parent d1e9df4 commit 28c338d
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/test/lib/DataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3255,24 +3255,29 @@ QuicTestStreamReliableReset(
TEST_TRUE(Listener.LastConnection->HandshakeComplete);
CxPlatSleep(50); // Wait for things to idle out

MsQuicStream Stream(Connection, QUIC_STREAM_OPEN_FLAG_NONE, CleanUpManual, StreamReliableReset::ClientStreamCallback, &Context);
TEST_QUIC_SUCCEEDED(Stream.GetInitStatus());
TEST_QUIC_SUCCEEDED(Stream.Start());
TEST_QUIC_SUCCEEDED(Stream.Send(&SendBuffer, 1, QUIC_SEND_FLAG_DELAY_SEND, &Context));
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_STATE,
Stream.SetReliableOffset(UINT64_MAX));
TEST_QUIC_SUCCEEDED(Stream.SetReliableOffset(RELIABLE_SIZE));
TEST_QUIC_SUCCEEDED(Stream.Shutdown(0)); // Queues up a shutdown operation.
// Should behave similar to QUIC_STREAM_SHUTDOWN_FLAG_GRACEFUL, with some restrictions.
TEST_TRUE(Context.ClientStreamShutdownComplete.WaitTimeout(TestWaitTimeout));
TEST_TRUE(Context.ServerStreamShutdownComplete.WaitTimeout(TestWaitTimeout));
TEST_TRUE(Context.ReceivedBufferSize >= RELIABLE_SIZE);

// We shouldn't be able to change ReliableSize now that the stream has already been reset.
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_STATE,
Stream.SetReliableOffset(1));
for (uint64_t Bitmap = 0; Bitmap < 8; ++Bitmap) { // Try dropping the first 3 packets
char Name[64]; sprintf_s(Name, sizeof(Name), "Try Reliably Shutting Down Stream %llu", (unsigned long long)Bitmap);
TestScopeLogger logScope(Name);
BitmapLossHelper LossHelper(Bitmap);
MsQuicStream Stream(Connection, QUIC_STREAM_OPEN_FLAG_NONE, CleanUpManual, StreamReliableReset::ClientStreamCallback, &Context);
TEST_QUIC_SUCCEEDED(Stream.GetInitStatus());
TEST_QUIC_SUCCEEDED(Stream.Start());
TEST_QUIC_SUCCEEDED(Stream.Send(&SendBuffer, 1, QUIC_SEND_FLAG_DELAY_SEND, &Context));
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_STATE,
Stream.SetReliableOffset(UINT64_MAX));
TEST_QUIC_SUCCEEDED(Stream.SetReliableOffset(RELIABLE_SIZE));
TEST_QUIC_SUCCEEDED(Stream.Shutdown(0)); // Queues up a shutdown operation.
// Should behave similar to QUIC_STREAM_SHUTDOWN_FLAG_GRACEFUL, with some restrictions.
TEST_TRUE(Context.ClientStreamShutdownComplete.WaitTimeout(TestWaitTimeout));
TEST_TRUE(Context.ServerStreamShutdownComplete.WaitTimeout(TestWaitTimeout));
TEST_TRUE(Context.ReceivedBufferSize >= RELIABLE_SIZE);

// We shouldn't be able to change ReliableSize now that the stream has already been reset.
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_STATE,
Stream.SetReliableOffset(1));
}
}


Expand Down

0 comments on commit 28c338d

Please sign in to comment.