@@ -319,6 +319,7 @@ class TestReadInteraction
319
319
static void TestSubscribeRoundtripStatusReportTimeout (nlTestSuite * apSuite, void * apContext);
320
320
static void TestPostSubscribeRoundtripStatusReportTimeout (nlTestSuite * apSuite, void * apContext);
321
321
static void TestReadChunkingStatusReportTimeout (nlTestSuite * apSuite, void * apContext);
322
+ static void TestReadReportFailure (nlTestSuite * apSuite, void * apContext);
322
323
static void TestSubscribeRoundtripChunkStatusReportTimeout (nlTestSuite * apSuite, void * apContext);
323
324
static void TestPostSubscribeRoundtripChunkStatusReportTimeout (nlTestSuite * apSuite, void * apContext);
324
325
static void TestPostSubscribeRoundtripChunkReportTimeout (nlTestSuite * apSuite, void * apContext);
@@ -2531,6 +2532,57 @@ void TestReadInteraction::TestReadChunkingStatusReportTimeout(nlTestSuite * apSu
2531
2532
ctx.CreateSessionBobToAlice ();
2532
2533
}
2533
2534
2535
+ // ReadClient sends the read request, but handler fails to send the one report (SendMessage returns an error).
2536
+ // Since this is an un-chunked read, we are not in the AwaitingReportResponse state, so the "reports in flight"
2537
+ // counter should not increase.
2538
+ void TestReadInteraction::TestReadReportFailure (nlTestSuite * apSuite, void * apContext)
2539
+ {
2540
+ TestContext & ctx = *static_cast <TestContext *>(apContext);
2541
+ CHIP_ERROR err = CHIP_NO_ERROR;
2542
+
2543
+ Messaging::ReliableMessageMgr * rm = ctx.GetExchangeManager ().GetReliableMessageMgr ();
2544
+ // Shouldn't have anything in the retransmit table when starting the test.
2545
+ NL_TEST_ASSERT (apSuite, rm->TestGetCountRetransTable () == 0 );
2546
+
2547
+ MockInteractionModelApp delegate;
2548
+ auto * engine = chip::app::InteractionModelEngine::GetInstance ();
2549
+ err = engine->Init (&ctx.GetExchangeManager (), &ctx.GetFabricTable ());
2550
+ NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
2551
+ NL_TEST_ASSERT (apSuite, !delegate.mGotEventResponse );
2552
+
2553
+ chip::app::AttributePathParams attributePathParams[1 ];
2554
+ attributePathParams[0 ].mEndpointId = Test::kMockEndpoint2 ;
2555
+ attributePathParams[0 ].mClusterId = Test::MockClusterId (3 );
2556
+ attributePathParams[0 ].mAttributeId = Test::MockAttributeId (1 );
2557
+
2558
+ ReadPrepareParams readPrepareParams (ctx.GetSessionBobToAlice ());
2559
+ readPrepareParams.mpEventPathParamsList = nullptr ;
2560
+ readPrepareParams.mEventPathParamsListSize = 0 ;
2561
+ readPrepareParams.mpAttributePathParamsList = attributePathParams;
2562
+ readPrepareParams.mAttributePathParamsListSize = 1 ;
2563
+
2564
+ {
2565
+ app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &ctx.GetExchangeManager (), delegate,
2566
+ chip::app::ReadClient::InteractionType::Read);
2567
+
2568
+ ctx.GetLoopback ().mNumMessagesToAllowBeforeError = 1 ;
2569
+ ctx.GetLoopback ().mMessageSendError = CHIP_ERROR_INCORRECT_STATE;
2570
+ err = readClient.SendRequest (readPrepareParams);
2571
+ NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
2572
+
2573
+ ctx.DrainAndServiceIO ();
2574
+ NL_TEST_ASSERT (apSuite, engine->GetReportingEngine ().GetNumReportsInFlight () == 0 );
2575
+ NL_TEST_ASSERT (apSuite, engine->GetNumActiveReadHandlers () == 0 );
2576
+
2577
+ ctx.GetLoopback ().mNumMessagesToAllowBeforeError = 0 ;
2578
+ ctx.GetLoopback ().mMessageSendError = CHIP_NO_ERROR;
2579
+ }
2580
+
2581
+ NL_TEST_ASSERT (apSuite, engine->GetNumActiveReadClients () == 0 );
2582
+ engine->Shutdown ();
2583
+ NL_TEST_ASSERT (apSuite, ctx.GetExchangeManager ().GetNumActiveExchanges () == 0 );
2584
+ }
2585
+
2534
2586
void TestReadInteraction::TestSubscribeRoundtripChunkStatusReportTimeout (nlTestSuite * apSuite, void * apContext)
2535
2587
{
2536
2588
TestContext & ctx = *static_cast <TestContext *>(apContext);
@@ -4155,6 +4207,7 @@ const nlTest sTests[] =
4155
4207
NL_TEST_DEF (" TestSubscribeRoundtripStatusReportTimeout" , chip::app::TestReadInteraction::TestSubscribeRoundtripStatusReportTimeout),
4156
4208
NL_TEST_DEF (" TestPostSubscribeRoundtripStatusReportTimeout" , chip::app::TestReadInteraction::TestPostSubscribeRoundtripStatusReportTimeout),
4157
4209
NL_TEST_DEF (" TestReadChunkingStatusReportTimeout" , chip::app::TestReadInteraction::TestReadChunkingStatusReportTimeout),
4210
+ NL_TEST_DEF (" TestReadReportFailure" , chip::app::TestReadInteraction::TestReadReportFailure),
4158
4211
NL_TEST_DEF (" TestSubscribeRoundtripChunkStatusReportTimeout" , chip::app::TestReadInteraction::TestSubscribeRoundtripChunkStatusReportTimeout),
4159
4212
NL_TEST_DEF (" TestPostSubscribeRoundtripChunkStatusReportTimeout" , chip::app::TestReadInteraction::TestPostSubscribeRoundtripChunkStatusReportTimeout),
4160
4213
NL_TEST_DEF (" TestPostSubscribeRoundtripChunkReportTimeout" , chip::app::TestReadInteraction::TestPostSubscribeRoundtripChunkReportTimeout),
0 commit comments