From 47d7dfb1d5d957b9d273b54f7dc47c70cb465b4f Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Tue, 17 May 2022 03:16:50 +0800 Subject: [PATCH] Move TestContext to scoped --- src/app/tests/TestReadInteraction.cpp | 3 +- src/messaging/tests/TestExchangeMgr.cpp | 4 +- .../tests/TestReliableMessageProtocol.cpp | 45 ++++++++++++------- .../secure_channel/tests/TestCASESession.cpp | 10 +++-- .../tests/TestMessageCounterManager.cpp | 3 +- .../secure_channel/tests/TestPASESession.cpp | 19 ++++++-- src/transport/raw/tests/TestTCP.cpp | 3 +- src/transport/raw/tests/TestUDP.cpp | 3 +- src/transport/tests/TestSessionManager.cpp | 4 +- 9 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 6b7b78e469799a..f44d7972293559 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -103,8 +103,6 @@ class TestContext : public chip::Test::AppContext chip::MonotonicallyIncreasingCounter mEventCounter; }; -TestContext sContext; - class TestEventGenerator : public chip::app::EventLoggingDelegate { public: @@ -2622,6 +2620,7 @@ nlTestSuite sSuite = int TestReadInteraction() { + TestContext sContext; nlTestRunner(&sSuite, &sContext); return (nlTestRunnerStats(&sSuite)); } diff --git a/src/messaging/tests/TestExchangeMgr.cpp b/src/messaging/tests/TestExchangeMgr.cpp index 5b63eff590a19e..39d14dab1477cc 100644 --- a/src/messaging/tests/TestExchangeMgr.cpp +++ b/src/messaging/tests/TestExchangeMgr.cpp @@ -56,8 +56,6 @@ enum : uint8_t kMsgType_TEST2 = 2, }; -TestContext sContext; - class MockAppDelegate : public UnsolicitedMessageHandler, public ExchangeDelegate { public: @@ -262,6 +260,8 @@ nlTestSuite sSuite = */ int TestExchangeMgr() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index 406a8cb1896f32..588777966993dc 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -56,12 +56,8 @@ using namespace chip::System::Clock::Literals; using TestContext = Test::LoopbackMessagingContext; -TestContext sContext; - const char PAYLOAD[] = "Hello!"; -auto & gLoopback = sContext.GetLoopback(); - class MockAppDelegate : public UnsolicitedMessageHandler, public ExchangeDelegate { public: @@ -222,6 +218,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) }); // Let's drop the initial message + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 2; gLoopback.mDroppedMessageCount = 0; @@ -241,7 +238,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1); // Wait for the first re-transmit (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 2; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 2; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was dropped, and is still there in the retransmit table @@ -251,7 +248,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1); // Wait for the second re-transmit (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 3; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 3; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was NOT dropped, and the retransmit table is empty, as we should have gotten an ack @@ -285,6 +282,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void * }); // Let's drop the initial message + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 2; gLoopback.mDroppedMessageCount = 0; @@ -302,7 +300,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void * NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1); // Wait for the first re-transmit (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 2; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 2; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was dropped, and is still there in the retransmit table @@ -312,7 +310,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void * NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1); // Wait for the second re-transmit (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 3; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 3; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was NOT dropped, and the retransmit table is empty, as we should have gotten an ack @@ -344,6 +342,7 @@ void CheckFailedMessageRetainOnSend(nlTestSuite * inSuite, void * inContext) mockSender.mMessageDispatch.mRetainMessageOnSend = false; // Let's drop the initial message + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 1; gLoopback.mDroppedMessageCount = 0; @@ -358,7 +357,7 @@ void CheckFailedMessageRetainOnSend(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, gLoopback.mDroppedMessageCount == 1); // Wait for the first re-transmit (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 2; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 2; }); ctx.DrainAndServiceIO(); // Ensure the retransmit table is empty, as we did not provide a message to retain @@ -386,6 +385,7 @@ void CheckUnencryptedMessageReceiveFailure(nlTestSuite * inSuite, void * inConte ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -431,6 +431,7 @@ void CheckResendApplicationMessageWithPeerExchange(nlTestSuite * inSuite, void * }); // Let's drop the initial message + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 1; gLoopback.mDroppedMessageCount = 0; @@ -449,7 +450,7 @@ void CheckResendApplicationMessageWithPeerExchange(nlTestSuite * inSuite, void * NL_TEST_ASSERT(inSuite, !mockReceiver.IsOnMessageReceivedCalled); // Wait for the first re-transmit (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 2; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 2; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was not dropped, and is no longer in the retransmit table @@ -492,6 +493,7 @@ void CheckDuplicateMessageClosedExchange(nlTestSuite * inSuite, void * inContext }); // Let's not drop the message. Expectation is that it is received by the peer, but the ack is dropped + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -520,7 +522,7 @@ void CheckDuplicateMessageClosedExchange(nlTestSuite * inSuite, void * inContext NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); // Wait for the first re-transmit and ack (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 3; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 3; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was sent and the ack was sent @@ -558,6 +560,7 @@ void CheckDuplicateOldMessageClosedExchange(nlTestSuite * inSuite, void * inCont }); // Let's not drop the message. Expectation is that it is received by the peer, but the ack is dropped + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -620,7 +623,7 @@ void CheckDuplicateOldMessageClosedExchange(nlTestSuite * inSuite, void * inCont // Wait for the first re-transmit and ack (should take 64ms) rm->StartTimer(); - ctx.GetIOContext().DriveIOUntil(1000_ms32, [extraMessages] { return gLoopback.mSentMessageCount >= 3 + extraMessages; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 3 + extraMessages; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was sent and the ack was sent @@ -662,6 +665,7 @@ void CheckResendSessionEstablishmentMessageWithPeerExchange(nlTestSuite * inSuit }); // Let's drop the initial message + auto & gLoopback = inctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 1; gLoopback.mDroppedMessageCount = 0; @@ -680,7 +684,7 @@ void CheckResendSessionEstablishmentMessageWithPeerExchange(nlTestSuite * inSuit NL_TEST_ASSERT(inSuite, !mockReceiver.IsOnMessageReceivedCalled); // Wait for the first re-transmit (should take 64ms) - inctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 2; }); + inctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 2; }); inctx.DrainAndServiceIO(); // Ensure the retransmit message was not dropped, and is no longer in the retransmit table @@ -725,6 +729,7 @@ void CheckDuplicateMessage(nlTestSuite * inSuite, void * inContext) }); // Let's not drop the message. Expectation is that it is received by the peer, but the ack is dropped + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -754,7 +759,7 @@ void CheckDuplicateMessage(nlTestSuite * inSuite, void * inContext) mockReceiver.mRetainExchange = false; // Wait for the first re-transmit and ack (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 3; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 3; }); ctx.DrainAndServiceIO(); // Ensure the retransmit message was sent and the ack was sent @@ -798,6 +803,7 @@ void CheckReceiveAfterStandaloneAck(nlTestSuite * inSuite, void * inContext) // exchange alive until it does the message send (so we can send the // response from the receiver and so the initial sender exchange can get // it). + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -888,6 +894,7 @@ void CheckPiggybackAfterPiggyback(nlTestSuite * inSuite, void * inContext) // piggybacked. We need to keep both exchanges alive for that (so we can // send the response from the receiver and so the initial sender exchange // can get it). + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -1016,6 +1023,7 @@ void CheckSendUnsolicitedStandaloneAckMessage(nlTestSuite * inSuite, void * inCo // We send a message, have it get received by the peer, expect an ack from // the peer. + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -1096,6 +1104,7 @@ void CheckMessageAfterClosed(nlTestSuite * inSuite, void * inContext) // Ensure the retransmit table is empty right now NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 0); + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -1227,6 +1236,7 @@ void CheckLostResponseWithPiggyback(nlTestSuite * inSuite, void * inContext) // we can send the response from the receiver), but don't need anything // special for the sender exchange, because it will be waiting for the // application-level response. + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -1290,7 +1300,7 @@ void CheckLostResponseWithPiggyback(nlTestSuite * inSuite, void * inContext) mockSender.mReceivedPiggybackAck = false; // Wait for re-transmit from sender and ack (should take 64ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 4; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 4; }); ctx.DrainAndServiceIO(); // We resent our first message, which did not make it to the app-level @@ -1319,7 +1329,7 @@ void CheckLostResponseWithPiggyback(nlTestSuite * inSuite, void * inContext) } // Wait for re-transmit from receiver (should take 256ms) - ctx.GetIOContext().DriveIOUntil(1000_ms32, [] { return gLoopback.mSentMessageCount >= 6; }); + ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return gLoopback.mSentMessageCount >= 6; }); ctx.DrainAndServiceIO(); // And now we've definitely resent our response message, which should show @@ -1374,6 +1384,7 @@ void CheckLostStandaloneAck(nlTestSuite * inSuite, void * inContext) // We need to keep both exchanges alive for that (so we can send the // response from the receiver and so the initial sender exchange can send a // response to that). + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 0; gLoopback.mDroppedMessageCount = 0; @@ -1599,6 +1610,8 @@ nlTestSuite sSuite = */ int TestReliableMessageProtocol() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/protocols/secure_channel/tests/TestCASESession.cpp b/src/protocols/secure_channel/tests/TestCASESession.cpp index 709f0e7df2978b..075a68b6afab6e 100644 --- a/src/protocols/secure_channel/tests/TestCASESession.cpp +++ b/src/protocols/secure_channel/tests/TestCASESession.cpp @@ -53,10 +53,6 @@ using namespace chip::Protocols; using TestContext = Test::LoopbackMessagingContext; namespace { -TestContext sContext; - -auto & gLoopback = sContext.GetLoopback(); - FabricTable gCommissionerFabrics; FabricIndex gCommissionerFabricIndex; GroupDataProviderImpl gCommissionerGroupDataProvider; @@ -227,6 +223,7 @@ void CASE_SecurePairingStartTest(nlTestSuite * inSuite, void * inContext) pairing.EstablishSession(sessionManager, fabric, Node01_01, context, nullptr, &delegate) == CHIP_NO_ERROR); ctx.DrainAndServiceIO(); + auto & gLoopback = ctx.GetLoopback(); NL_TEST_ASSERT(inSuite, gLoopback.mSentMessageCount == 1); // Clear pending packet in CRMP @@ -264,6 +261,7 @@ void CASE_SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inConte ReliableMessageProtocolConfig nonSleepyCommissionerRmpConfig(System::Clock::Milliseconds32(5000), System::Clock::Milliseconds32(300)); + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; NL_TEST_ASSERT(inSuite, @@ -317,6 +315,7 @@ void CASE_SecurePairingHandshakeServerTest(nlTestSuite * inSuite, void * inConte TestContext & ctx = *reinterpret_cast(inContext); + auto & gLoopback = ctx.GetLoopback(); gLoopback.mSentMessageCount = 0; // Use the same session manager on both CASE client and server sides to validate that both @@ -740,6 +739,7 @@ static void CASE_SessionResumptionStorage(nlTestSuite * inSuite, void * inContex }, }; + auto & gLoopback = ctx.GetLoopback(); for (size_t i = 0; i < sizeof(testVectors) / sizeof(testVectors[0]); ++i) { auto * pairingCommissioner = chip::Platform::New(); @@ -847,6 +847,8 @@ int CASE_TestSecurePairing_Teardown(void * inContext) */ int TestCASESession() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp b/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp index 28206c1136193f..df27e0f1d983bd 100644 --- a/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp +++ b/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp @@ -48,7 +48,6 @@ using namespace chip::Messaging; using namespace chip::Protocols; using TestContext = chip::Test::LoopbackMessagingContext; -TestContext sContext; const char PAYLOAD[] = "Hello!"; @@ -169,6 +168,8 @@ int Finalize(void * aContext) */ int TestMessageCounterManager() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index ec2eb369b5e472..9ed90b0dafcb05 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -81,9 +81,6 @@ class PASETestLoopbackTransportDelegate : public Test::LoopbackTransportDelegate using TestContext = chip::Test::LoopbackMessagingContext; -TestContext sContext; -auto & gLoopback = sContext.GetLoopback(); - class TestSecurePairingDelegate : public SessionEstablishmentDelegate { public: @@ -120,6 +117,7 @@ void SecurePairingWaitTest(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, pairing.GetSecureSessionType() == SecureSession::Type::kPASE); + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); NL_TEST_ASSERT(inSuite, @@ -158,6 +156,7 @@ void SecurePairingStartTest(nlTestSuite * inSuite, void * inContext) TestSecurePairingDelegate delegate; PASESession pairing; + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); ExchangeContext * context = ctx.NewUnauthenticatedExchangeToBob(&pairing); @@ -205,6 +204,7 @@ void SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inContext, S PASESession pairingAccessory; PASETestLoopbackTransportDelegate delegate; + auto & gLoopback = ctx.GetLoopback(); gLoopback.SetLoopbackTransportDelegate(&delegate); gLoopback.mSentMessageCount = 0; @@ -282,6 +282,8 @@ void SecurePairingHandshakeTest(nlTestSuite * inSuite, void * inContext) SessionManager sessionManager; TestSecurePairingDelegate delegateCommissioner; PASESession pairingCommissioner; + TestContext & ctx = *reinterpret_cast(inContext); + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); SecurePairingHandshakeTestCommon(inSuite, inContext, sessionManager, pairingCommissioner, Optional::Missing(), @@ -293,6 +295,8 @@ void SecurePairingHandshakeWithCommissionerMRPTest(nlTestSuite * inSuite, void * SessionManager sessionManager; TestSecurePairingDelegate delegateCommissioner; PASESession pairingCommissioner; + TestContext & ctx = *reinterpret_cast(inContext); + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); ReliableMessageProtocolConfig config(1000_ms32, 10000_ms32); SecurePairingHandshakeTestCommon(inSuite, inContext, sessionManager, pairingCommissioner, @@ -305,6 +309,8 @@ void SecurePairingHandshakeWithDeviceMRPTest(nlTestSuite * inSuite, void * inCon SessionManager sessionManager; TestSecurePairingDelegate delegateCommissioner; PASESession pairingCommissioner; + TestContext & ctx = *reinterpret_cast(inContext); + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); ReliableMessageProtocolConfig config(1000_ms32, 10000_ms32); SecurePairingHandshakeTestCommon(inSuite, inContext, sessionManager, pairingCommissioner, @@ -317,6 +323,8 @@ void SecurePairingHandshakeWithAllMRPTest(nlTestSuite * inSuite, void * inContex SessionManager sessionManager; TestSecurePairingDelegate delegateCommissioner; PASESession pairingCommissioner; + TestContext & ctx = *reinterpret_cast(inContext); + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); ReliableMessageProtocolConfig commissionerConfig(1000_ms32, 10000_ms32); ReliableMessageProtocolConfig deviceConfig(2000_ms32, 7000_ms32); @@ -330,6 +338,8 @@ void SecurePairingHandshakeWithPacketLossTest(nlTestSuite * inSuite, void * inCo SessionManager sessionManager; TestSecurePairingDelegate delegateCommissioner; PASESession pairingCommissioner; + TestContext & ctx = *reinterpret_cast(inContext); + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); gLoopback.mNumMessagesToDrop = 2; SecurePairingHandshakeTestCommon(inSuite, inContext, sessionManager, pairingCommissioner, @@ -350,6 +360,7 @@ void SecurePairingFailedHandshake(nlTestSuite * inSuite, void * inContext) TestSecurePairingDelegate delegateAccessory; PASESession pairingAccessory; + auto & gLoopback = ctx.GetLoopback(); gLoopback.Reset(); gLoopback.mSentMessageCount = 0; @@ -471,6 +482,8 @@ int TestSecurePairing_Teardown(void * inContext) */ int TestPASESession() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/transport/raw/tests/TestTCP.cpp b/src/transport/raw/tests/TestTCP.cpp index 5add4e15081b05..40be2b8873d84e 100644 --- a/src/transport/raw/tests/TestTCP.cpp +++ b/src/transport/raw/tests/TestTCP.cpp @@ -70,7 +70,6 @@ constexpr NodeId kDestinationNodeId = 111222333; constexpr uint32_t kMessageCounter = 18; using TestContext = chip::Test::IOContext; -TestContext sContext; const char PAYLOAD[] = "Hello!"; @@ -503,6 +502,8 @@ static int Finalize(void * aContext) int TestTCP() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/transport/raw/tests/TestUDP.cpp b/src/transport/raw/tests/TestUDP.cpp index f1621b723d9ec0..82fd218e2ed5a6 100644 --- a/src/transport/raw/tests/TestUDP.cpp +++ b/src/transport/raw/tests/TestUDP.cpp @@ -47,7 +47,6 @@ constexpr NodeId kDestinationNodeId = 111222333; constexpr uint32_t kMessageCounter = 18; using TestContext = chip::Test::IOContext; -TestContext sContext; const char PAYLOAD[] = "Hello!"; int ReceiveHandlerCallCount = 0; @@ -211,6 +210,8 @@ static int Finalize(void * aContext) int TestUDP() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext); diff --git a/src/transport/tests/TestSessionManager.cpp b/src/transport/tests/TestSessionManager.cpp index 9f9cd5de15cd1c..13170c707187b1 100644 --- a/src/transport/tests/TestSessionManager.cpp +++ b/src/transport/tests/TestSessionManager.cpp @@ -54,8 +54,6 @@ using namespace chip::TestCerts; using TestContext = chip::Test::LoopbackTransportManager; -TestContext sContext; - const char PAYLOAD[] = "Hello!"; const char LARGE_PAYLOAD[kMaxAppMessageLen + 1] = "test message"; @@ -825,6 +823,8 @@ int Finalize(void * aContext) */ int TestSessionManager() { + TestContext sContext; + // Run test suit against one context nlTestRunner(&sSuite, &sContext);