Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Svc/BufferAccumulator/test/ut/Accumulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Accumulate {
void BufferAccumulatorTester ::OK() {
ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e);
this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE);
this->component.doDispatch();
this->doDispatch();
ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e);
ASSERT_FROM_PORT_HISTORY_SIZE(0);

Expand All @@ -35,12 +35,12 @@ void BufferAccumulatorTester ::OK() {
Fw::Buffer b(data, size, bufferID);
buffers[i] = b;
this->invoke_to_bufferSendInFill(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_FROM_PORT_HISTORY_SIZE(0);
}

this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::DRAIN);
this->component.doDispatch();
this->doDispatch();
ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e);
ASSERT_FROM_PORT_HISTORY_SIZE(1);
ASSERT_from_bufferSendOutDrain_SIZE(1);
Expand All @@ -49,7 +49,7 @@ void BufferAccumulatorTester ::OK() {
U32 expectedNumBuffers = 1;
for (U32 i = 0; i < MAX_NUM_BUFFERS; ++i) {
this->invoke_to_bufferSendInReturn(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
++expectedNumBuffers;
if (i + 1 < MAX_NUM_BUFFERS) {
++expectedNumBuffers;
Expand Down
4 changes: 4 additions & 0 deletions Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,8 @@ void BufferAccumulatorTester ::initComponents() {
this->component.init(QUEUE_DEPTH, INSTANCE);
}

void BufferAccumulatorTester ::doDispatch() {
this->component.doDispatch();
}

} // end namespace Svc
8 changes: 8 additions & 0 deletions Svc/BufferAccumulator/test/ut/BufferAccumulatorTester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ class BufferAccumulatorTester : public BufferAccumulatorGTestBase {

//! Whether to allocate/deallocate a queue for the user
bool doAllocateQueue;


// ----------------------------------------------------------------------
// Methods
// ----------------------------------------------------------------------

//! Helper method to call doDispatch
void doDispatch(void);
};

} // end namespace Svc
Expand Down
24 changes: 12 additions & 12 deletions Svc/BufferAccumulator/test/ut/Drain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ void BufferAccumulatorTester ::OK() {
Fw::Buffer b(data, size, bufferID);
buffers[i] = b;
this->invoke_to_bufferSendInFill(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_from_bufferSendOutDrain_SIZE(i + 1);
ASSERT_from_bufferSendOutDrain(i, buffers[i]);
this->invoke_to_bufferSendInReturn(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_from_bufferSendOutReturn(i, buffers[i]);
}

Expand All @@ -48,7 +48,7 @@ void BufferAccumulatorTester ::OK() {

void BufferAccumulatorTester ::PartialDrainOK() {
this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE);
this->component.doDispatch();
this->doDispatch();
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, BufferAccumulator::OPCODE_BA_SETMODE, 0,
Fw::CmdResponse::OK);
Expand All @@ -63,10 +63,10 @@ void BufferAccumulatorTester ::PartialDrainOK() {
Fw::Buffer b(data, size, bufferID);
buffers[i] = b;
this->invoke_to_bufferSendInFill(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();

this->sendCmd_BA_DrainBuffers(0, 0, 1, BufferAccumulator_BlockMode::BLOCK);
this->component.doDispatch();
this->doDispatch();
ASSERT_EVENTS_BA_PartialDrainDone_SIZE(i + 1);
ASSERT_EVENTS_BA_PartialDrainDone(i, 1u);
// + 1 for first BufferAccumulator_OpState::ACCUMULATE command; + 1 for
Expand All @@ -79,7 +79,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
ASSERT_from_bufferSendOutDrain(i, buffers[i]);

this->invoke_to_bufferSendInReturn(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_from_bufferSendOutReturn(i, buffers[i]);

ASSERT_EVENTS_BA_PartialDrainDone_SIZE(i + 1);
Expand All @@ -99,7 +99,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
Fw::Buffer b(data, size, bufferID);
buffers[i] = b;
this->invoke_to_bufferSendInFill(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_FROM_PORT_HISTORY_SIZE(0);
}

Expand All @@ -108,7 +108,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
ASSERT_from_bufferSendOutDrain_SIZE(i);

this->sendCmd_BA_DrainBuffers(0, 0, 1, BufferAccumulator_BlockMode::BLOCK);
this->component.doDispatch();
this->doDispatch();
ASSERT_CMD_RESPONSE_SIZE(i + 1);
ASSERT_CMD_RESPONSE(i, BufferAccumulator::OPCODE_BA_DRAINBUFFERS, 0,
Fw::CmdResponse::OK);
Expand All @@ -121,7 +121,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
ASSERT_from_bufferSendOutDrain_SIZE(i + 1);
ASSERT_from_bufferSendOutDrain(i, buffers[i]);
this->invoke_to_bufferSendInReturn(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_from_bufferSendOutReturn(i, buffers[i]);

ASSERT_EVENTS_BA_PartialDrainDone_SIZE(i + 1);
Expand All @@ -140,7 +140,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
Fw::Buffer b(data, size, bufferID);
buffers[i] = b;
this->invoke_to_bufferSendInFill(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_FROM_PORT_HISTORY_SIZE(0);
}

Expand All @@ -152,7 +152,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
ASSERT_EVENTS_BA_PartialDrainDone_SIZE(0);
this->sendCmd_BA_DrainBuffers(0, 0, MAX_NUM_BUFFERS,
BufferAccumulator_BlockMode::BLOCK);
this->component.doDispatch();
this->doDispatch();
ASSERT_CMD_RESPONSE_SIZE(0);

for (U32 i = 0; i < MAX_NUM_BUFFERS; ++i) {
Expand All @@ -170,7 +170,7 @@ void BufferAccumulatorTester ::PartialDrainOK() {
ASSERT_from_bufferSendOutDrain_SIZE(i + 1);
ASSERT_from_bufferSendOutDrain(i, buffers[i]);
this->invoke_to_bufferSendInReturn(0, buffers[i]);
this->component.doDispatch();
this->doDispatch();
ASSERT_from_bufferSendOutReturn(i, buffers[i]);
}

Expand Down
27 changes: 13 additions & 14 deletions Svc/BufferAccumulator/test/ut/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Errors {
void BufferAccumulatorTester ::PartialDrain() {
ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e);
this->sendCmd_BA_DrainBuffers(0, 0, 1, BufferAccumulator_BlockMode::BLOCK);
this->component.doDispatch(); // will fail - we are still in
this->doDispatch(); // will fail - we are still in
// BufferAccumulator_OpState::DRAIN mode
ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e);
ASSERT_FROM_PORT_HISTORY_SIZE(0);
Expand All @@ -32,12 +32,12 @@ void BufferAccumulatorTester ::PartialDrain() {
ASSERT_EQ(0u, this->component.m_numToDrain);

this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE);
this->component.doDispatch();
this->doDispatch();
ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e);
ASSERT_FROM_PORT_HISTORY_SIZE(0);

this->sendCmd_BA_DrainBuffers(0, 0, 10, BufferAccumulator_BlockMode::BLOCK);
this->component.doDispatch(); // will succeed - now we are in ACCUMULATE
this->doDispatch(); // will succeed - now we are in ACCUMULATE
ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e);
ASSERT_FROM_PORT_HISTORY_SIZE(
0); // would be first buffer out, but we are empty
Expand All @@ -49,8 +49,7 @@ void BufferAccumulatorTester ::PartialDrain() {
ASSERT_EQ(10u, this->component.m_numToDrain);

this->sendCmd_BA_DrainBuffers(0, 0, 1, BufferAccumulator_BlockMode::BLOCK);
this->component
.doDispatch(); // will fail - we are still doing a partial drain
this->doDispatch(); // will fail - we are still doing a partial drain
ASSERT_EVENTS_BA_StillDraining_SIZE(1);
ASSERT_EVENTS_BA_StillDraining(0, 0u, 10u);
ASSERT_EVENTS_BA_PartialDrainDone_SIZE(0); // partial drain not done
Expand All @@ -69,57 +68,57 @@ void BufferAccumulatorTester ::QueueFull() {
// Go to Accumulate mode
ASSERT_EQ(BufferAccumulator_OpState::DRAIN, this->component.m_mode.e);
this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::ACCUMULATE);
this->component.doDispatch();
this->doDispatch();
ASSERT_EQ(BufferAccumulator_OpState::ACCUMULATE, this->component.m_mode.e);
ASSERT_FROM_PORT_HISTORY_SIZE(0);

// Fill up the buffer queue
for (U32 i = 0; i < MAX_NUM_BUFFERS; ++i) {
this->invoke_to_bufferSendInFill(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_FROM_PORT_HISTORY_SIZE(0);
}

// Send another buffer and expect an event
this->invoke_to_bufferSendInFill(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_BA_QueueFull_SIZE(1);

// Send another buffer and expect no new event
this->invoke_to_bufferSendInFill(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_EVENTS_SIZE(1);

// Drain one buffer
this->sendCmd_BA_SetMode(0, 0, BufferAccumulator_OpState::DRAIN);
this->component.doDispatch();
this->doDispatch();
ASSERT_FROM_PORT_HISTORY_SIZE(1);
ASSERT_from_bufferSendOutDrain_SIZE(1);
ASSERT_from_bufferSendOutDrain(0, buffer);

// Send another buffer and expect an event
this->invoke_to_bufferSendInFill(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_EVENTS_SIZE(2);
ASSERT_EVENTS_BA_BufferAccepted_SIZE(1);

// Return the original buffer in order to drain one buffer
this->invoke_to_bufferSendInReturn(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_FROM_PORT_HISTORY_SIZE(3);
ASSERT_from_bufferSendOutDrain_SIZE(2);
ASSERT_from_bufferSendOutDrain(1, buffer);

// Send another buffer and expect no new event
this->invoke_to_bufferSendInFill(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_EVENTS_SIZE(2);
ASSERT_EVENTS_BA_BufferAccepted_SIZE(1);

// Send another buffer and expect an event
this->invoke_to_bufferSendInFill(0, buffer);
this->component.doDispatch();
this->doDispatch();
ASSERT_EVENTS_SIZE(3);
ASSERT_EVENTS_BA_QueueFull_SIZE(2);

Expand Down
2 changes: 1 addition & 1 deletion Svc/BufferAccumulator/test/ut/Health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void BufferAccumulatorTester ::Ping() {
U32 key = 42;

this->invoke_to_pingIn(0, key);
this->component.doDispatch();
this->doDispatch();

ASSERT_EVENTS_SIZE(0);
ASSERT_from_pingOut_SIZE(1);
Expand Down
Loading