-
Notifications
You must be signed in to change notification settings - Fork 2.2k
increasing coverage for src/protocols/bdx folder. #39975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
increasing coverage for src/protocols/bdx folder. #39975
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds new test files to increase test coverage for the src/protocols/bdx
directory. Several tests in TestTransferFacilitator.cpp
and TestTransferDiagnosticLog.cpp
appear to be incomplete placeholders.
TEST_F(TestTransferDiagnosticLog, TestTransferDiagnosticLog) | ||
{ | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST_F(TestTransferFacilitator, InitiatesTransfer) | ||
{ | ||
TestInitiator initiator; | ||
|
||
auto r = initiator.InitiateTransfer(&gSystemLayerAndClock, TransferRole::kSender, | ||
TransferSession::TransferInitData(), System::Clock::Seconds16(60), System::Clock::Milliseconds32(500)); | ||
|
||
ASSERT_EQ(r, CHIP_NO_ERROR); // Placeholder for actual test logic | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case only asserts that the function returns CHIP_NO_ERROR
. A unit test should verify the side effects of the function under test. For InitiateTransfer
, this includes checking that a timer has been started and that a SendInit
or ReceiveInit
message is ready to be sent 1.
Style Guide References
Footnotes
-
Tests should assert conditions. ↩
TEST_F(TestTransferFacilitator, PollsForOutput) | ||
{ | ||
TestInitiator initiator; | ||
|
||
auto r = initiator.InitiateTransfer(&gSystemLayerAndClock, TransferRole::kSender, | ||
TransferSession::TransferInitData(), System::Clock::Seconds16(60), System::Clock::Milliseconds32(500)); | ||
|
||
ASSERT_EQ(r, CHIP_NO_ERROR); // Placeholder for actual test logic | ||
|
||
// hook a callback to the output handler | ||
bool outputHandled = false; | ||
initiator.mTransferSessionOutputHandler = [&outputHandled](TransferSession::OutputEvent & event) { | ||
10000 | outputHandled = true; | |
}; | ||
|
||
// hook a callback to the StartTimerHook | ||
bool timerStarted = false; | ||
gSystemLayerAndClock.mStartTimerHook = [&timerStarted](auto, auto, void *) { | ||
timerStarted = true; | ||
}; | ||
|
||
// Simulate a poll | ||
initiator.PollForOutput(); | ||
|
||
// Check if the poll was handled correctly | ||
ASSERT_TRUE(outputHandled); | ||
|
||
// Check if the timer was started | ||
ASSERT_TRUE(timerStarted); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST_F(TestTransferFacilitator, TriggeringImmediatePollCallsPollForOutput) | ||
{ | ||
TestInitiator initiator; | ||
|
||
gSystemLayerAndClock.SetMonotonic(0_ms); | ||
|
||
auto r = initiator.InitiateTransfer(&gSystemLayerAndClock, TransferRole::kSender, | ||
TransferSession::TransferInitData(), System::Clock::Seconds16(60), System::Clock::Milliseconds32(500)); | ||
|
||
ASSERT_EQ(r, CHIP_NO_ERROR); // Placeholder for actual test logic | ||
|
||
// hook a callback to the output handler | ||
bool outputHandled = false; | ||
initiator.mTransferSessionOutputHandler = [&outputHandled](TransferSession::OutputEvent & event) { | ||
outputHandled = true; | ||
}; | ||
|
||
// hook a callback to the StartTimerHook | ||
bool timerStarted = false; | ||
gSystemLayerAndClock.mStartTimerHook = [&timerStarted](auto, auto, void *) { | ||
timerStarted = true; | ||
}; | ||
|
||
// Schedule an immediate poll | ||
initiator.ScheduleImmediatePoll(); | ||
|
||
// Advancing clock 1_ms triggers the immediate poll disregarding the poll frequency timer | ||
gSystemLayerAndClock.AdvanceMonotonic(1_ms); | ||
|
||
// Check if the poll was handled correctly | ||
ASSERT_TRUE(outputHandled); | ||
|
||
// Check if the timer was started | ||
ASSERT_TRUE(timerStarted); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST_F(TestTransferFacilitator, ResponderPreparesForTransfer) | ||
{ | ||
TestResponder responder; | ||
|
||
gSystemLayerAndClock.SetMonotonic(0_ms); | ||
|
||
auto r = responder.PrepareForTransfer(&gSystemLayerAndClock, TransferRole::kReceiver, | ||
TransferControlFlags::kReceiverDrive, 1024, System::Clock::Seconds16(60), System::Clock::Milliseconds32(500)); | ||
|
||
EXPECT_EQ(r, CHIP_NO_ERROR); // Placeholder for actual test logic | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
17519df
to
9da2a51
Compare
PR #39975: Size comparison from 48704fe to 9da2a51 Full report (56 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, linux, nxp, psoc6, qpg, stm32, telink, tizen)
|
Testing
Increased unit tests coverage for #37247
Tests added for
src/protocols/bdx