Skip to content

Commit db852e4

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Use a non-chunked attribute for non-chunking tests in TestReadInteraction. (#27126)
We were using an attribute that led to multiple reports, in a test that only cares about whether a report is delivered at all. There's no reason to do that, and it can lead to some timing-related failures if we don't spin the event loop long enough to get all the reports.
1 parent 594ede6 commit db852e4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/app/tests/TestReadInteraction.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -4104,7 +4104,7 @@ void TestReadInteraction::TestSubscribeInvalidateFabric(nlTestSuite * apSuite, v
41044104

41054105
readPrepareParams.mpAttributePathParamsList[0].mEndpointId = Test::kMockEndpoint3;
41064106
readPrepareParams.mpAttributePathParamsList[0].mClusterId = Test::MockClusterId(2);
4107-
readPrepareParams.mpAttributePathParamsList[0].mAttributeId = Test::MockAttributeId(4);
4107+
readPrepareParams.mpAttributePathParamsList[0].mAttributeId = Test::MockAttributeId(1);
41084108

41094109
readPrepareParams.mMinIntervalFloorSeconds = 0;
41104110
readPrepareParams.mMaxIntervalCeilingSeconds = 0;
@@ -4163,7 +4163,7 @@ void TestReadInteraction::TestShutdownSubscription(nlTestSuite * apSuite, void *
41634163

41644164
readPrepareParams.mpAttributePathParamsList[0].mEndpointId = Test::kMockEndpoint3;
41654165
readPrepareParams.mpAttributePathParamsList[0].mClusterId = Test::MockClusterId(2);
4166-
readPrepareParams.mpAttributePathParamsList[0].mAttributeId = Test::MockAttributeId(4);
4166+
readPrepareParams.mpAttributePathParamsList[0].mAttributeId = Test::MockAttributeId(1);
41674167

41684168
readPrepareParams.mMinIntervalFloorSeconds = 0;
41694169
readPrepareParams.mMaxIntervalCeilingSeconds = 0;
@@ -4210,7 +4210,7 @@ void TestReadInteraction::TestSubscriptionReportWithDefunctSession(nlTestSuite *
42104210
err = engine->Init(&ctx.GetExchangeManager(), &ctx.GetFabricTable());
42114211
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
42124212

4213-
AttributePathParams subscribePath(Test::kMockEndpoint3, Test::MockClusterId(2), Test::MockAttributeId(4));
4213+
AttributePathParams subscribePath(Test::kMockEndpoint3, Test::MockClusterId(2), Test::MockAttributeId(1));
42144214

42154215
ReadPrepareParams readPrepareParams(ctx.GetSessionBobToAlice());
42164216
readPrepareParams.mpAttributePathParamsList = &subscribePath;
@@ -4231,6 +4231,7 @@ void TestReadInteraction::TestSubscriptionReportWithDefunctSession(nlTestSuite *
42314231
ctx.DrainAndServiceIO();
42324232

42334233
NL_TEST_ASSERT(apSuite, delegate.mGotReport);
4234+
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 1);
42344235
NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Subscribe) == 1);
42354236
NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Read) == 0);
42364237
NL_TEST_ASSERT(apSuite, engine->GetReportingEngine().GetNumReportsInFlight() == 0);
@@ -4244,12 +4245,14 @@ void TestReadInteraction::TestSubscriptionReportWithDefunctSession(nlTestSuite *
42444245

42454246
// Test that we send reports as needed.
42464247
readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
4247-
delegate.mGotReport = false;
4248+
delegate.mGotReport = false;
4249+
delegate.mNumAttributeResponse = 0;
42484250
engine->GetReportingEngine().SetDirty(subscribePath);
42494251

42504252
ctx.DrainAndServiceIO();
42514253

42524254
NL_TEST_ASSERT(apSuite, delegate.mGotReport);
4255+
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 1);
42534256
NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Subscribe) == 1);
42544257
NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Read) == 0);
42554258
NL_TEST_ASSERT(apSuite, engine->GetReportingEngine().GetNumReportsInFlight() == 0);
@@ -4258,12 +4261,14 @@ void TestReadInteraction::TestSubscriptionReportWithDefunctSession(nlTestSuite *
42584261
// up properly.
42594262
readHandler->GetSession()->MarkAsDefunct();
42604263
readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
4261-
delegate.mGotReport = false;
4264+
delegate.mGotReport = false;
4265+
delegate.mNumAttributeResponse = 0;
42624266
engine->GetReportingEngine().SetDirty(subscribePath);
42634267

42644268
ctx.DrainAndServiceIO();
42654269

42664270
NL_TEST_ASSERT(apSuite, !delegate.mGotReport);
4271+
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 0);
42674272
NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Subscribe) == 0);
42684273
NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Read) == 0);
42694274
NL_TEST_ASSERT(apSuite, engine->GetReportingEngine().GetNumReportsInFlight() == 0);

0 commit comments

Comments
 (0)