Skip to content

Commit

Permalink
Added duplicate file packet UT
Browse files Browse the repository at this point in the history
  • Loading branch information
DJKessler committed Oct 30, 2024
1 parent a0b7c0a commit f97c010
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Svc/FileUplink/test/ut/FileUplinkMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ TEST(FileUplink, PacketOutOfOrder) {
tester.packetOutOfOrder();
}

TEST(FileUplink, PacketDuplicated) {
Svc::FileUplinkTester tester;
tester.packetDuplicated();
}

TEST(FileUplink, CancelPacketInStartMode) {
Svc::FileUplinkTester tester;
tester.cancelPacketInStartMode();
Expand Down
42 changes: 42 additions & 0 deletions Svc/FileUplink/test/ut/FileUplinkTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,48 @@ namespace Svc {

}

void FileUplinkTester ::
packetDuplicated()
{
const char *const sourcePath = "source.bin";
const char *const destPath = "dest.bin";
U8 packetData[] = { 5, 6, 7, 8, 9 };
const size_t fileSize = 2 * PACKET_SIZE;

// Send the start packet (packet 0)
this->sendStartPacket(sourcePath, destPath, fileSize);
ASSERT_TLM_SIZE(1);
ASSERT_TLM_PacketsReceived(
0,
++this->expectedPacketsReceived
);
ASSERT_EVENTS_SIZE(0);

// Simulate duplication of packet 0
--this->sequenceIndex;

// capture the checksum after sending the first packet
const ::CFDP::Checksum expectedChecksum(component.m_file.m_checksum);

// Send the data packet (packet 0) again
const size_t byteOffset = 0;
this->sendDataPacket(byteOffset, packetData);
ASSERT_TLM_SIZE(2);
ASSERT_TLM_PacketsReceived(
0,
++this->expectedPacketsReceived
);
ASSERT_TLM_Warnings(0, 1);

ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_PacketDuplicate(0, component.m_lastSequenceIndex);

// verify that the checksum hasn't changed
ASSERT_EQ(expectedChecksum, component.m_file.m_checksum);

this->removeFile("test.bin");
}

void FileUplinkTester ::
cancelPacketInStartMode()
{
Expand Down
4 changes: 4 additions & 0 deletions Svc/FileUplink/test/ut/FileUplinkTester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ namespace Svc {
//!
void packetOutOfOrder();

//! Send a file with an duplicated packet
//!
void packetDuplicated();

//! Send a CANCEL packet in START mode
//!
void cancelPacketInStartMode();
Expand Down

0 comments on commit f97c010

Please sign in to comment.