Skip to content

Commit

Permalink
Fix EFR32 Unit Test build (#10448)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgoliver authored Oct 20, 2021
1 parent f04c428 commit 247d904
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import("${chip_root}/src/platform/device.gni")
chip_test_suite("interaction-tests") {
output_name = "libInteractionTests"

if (chip_device_platform != "mbed") {
if (chip_device_platform != "mbed" && chip_device_platform != "efr32") {
test_sources = [ "TestCommands.cpp" ]
test_sources += [ "TestRead.cpp" ]
}
Expand Down
28 changes: 12 additions & 16 deletions src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/UnitTestRegistration.h>
#include <lib/support/UnitTestUtils.h>
#include <messaging/ReliableMessageContext.h>
#include <messaging/ReliableMessageMgr.h>
#include <protocols/Protocols.h>
Expand Down Expand Up @@ -166,11 +167,6 @@ class MockSessionEstablishmentDelegate : public ExchangeDelegate
nlTestSuite * mTestSuite = nullptr;
};

void test_os_sleep_ms(uint64_t millisecs)
{
usleep(static_cast<useconds_t>(millisecs * 1000));
}

void CheckAddClearRetrans(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);
Expand Down Expand Up @@ -260,7 +256,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1);

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was dropped, and is still there in the retransmit table
Expand All @@ -270,7 +266,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1);

// sleep another 65 ms to trigger second re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was NOT dropped, and the retransmit table is empty, as we should have gotten an ack
Expand Down Expand Up @@ -322,7 +318,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void *
NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1);

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was dropped, and is still there in the retransmit table
Expand All @@ -332,7 +328,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void *
NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1);

// sleep another 65 ms to trigger second re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was NOT dropped, and the retransmit table is empty, as we should have gotten an ack
Expand Down Expand Up @@ -383,7 +379,7 @@ void CheckFailedMessageRetainOnSend(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, gLoopback.mDroppedMessageCount == 1);

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit table is empty, as we did not provide a message to retain
Expand Down Expand Up @@ -481,7 +477,7 @@ void CheckResendApplicationMessageWithPeerExchange(nlTestSuite * inSuite, void *
NL_TEST_ASSERT(inSuite, !mockReceiver.IsOnMessageReceivedCalled);

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was not dropped, and is no longer in the retransmit table
Expand Down Expand Up @@ -553,7 +549,7 @@ void CheckDuplicateMessageClosedExchange(nlTestSuite * inSuite, void * inContext
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was sent and the ack was sent
Expand Down Expand Up @@ -618,7 +614,7 @@ void CheckResendSessionEstablishmentMessageWithPeerExchange(nlTestSuite * inSuit
NL_TEST_ASSERT(inSuite, !mockReceiver.IsOnMessageReceivedCalled);

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was not dropped, and is no longer in the retransmit table
Expand Down Expand Up @@ -702,7 +698,7 @@ void CheckDuplicateMessage(nlTestSuite * inSuite, void * inContext)
mockReceiver.mRetainExchange = false;

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// Ensure the retransmit message was sent and the ack was sent
Expand Down Expand Up @@ -1220,7 +1216,7 @@ void CheckLostResponseWithPiggyback(nlTestSuite * inSuite, void * inContext)
mockSender.mReceivedPiggybackAck = false;

// 1 tick is 64 ms, sleep 65 ms to trigger re-transmit from sender
test_os_sleep_ms(65);
chip::test_utils::SleepMillis(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// We resent our first message, which did not make it to the app-level
Expand Down Expand Up @@ -1249,7 +1245,7 @@ void CheckLostResponseWithPiggyback(nlTestSuite * inSuite, void * inContext)
}

// 1 tick is 64 ms, sleep 65*3 ms to trigger re-transmit from receiver
test_os_sleep_ms(65 * 3);
chip::test_utils::SleepMillis(65 * 3);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm);

// And now we've definitely resent our response message, which should show
Expand Down

0 comments on commit 247d904

Please sign in to comment.