Skip to content

Commit

Permalink
Integrating Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine committed Jun 11, 2024
1 parent 37122f9 commit c2397ea
Show file tree
Hide file tree
Showing 16 changed files with 634 additions and 1,041 deletions.
17 changes: 6 additions & 11 deletions src/app/tests/TestAclAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,14 @@ chip::Test::AppContext * TestAclAttribute::mpTestContext = nullptr;
// report to client, and client is closed.
TEST_F(TestAclAttribute, TestACLDeniedAttribute)
{
CHIP_ERROR err = CHIP_NO_ERROR;

Messaging::ReliableMessageMgr * rm = mpTestContext->GetExchangeManager().GetReliableMessageMgr();
EXPECT_EQ(rm->TestGetCountRetransTable(), 0);

MockInteractionModelApp delegate;
auto * engine = chip::app::InteractionModelEngine::GetInstance();
err = engine->Init(&mpTestContext->GetExchangeManager(), &mpTestContext->GetFabricTable(),
app::reporting::GetDefaultReportScheduler());
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(engine->Init(&mpTestContext->GetExchangeManager(), &mpTestContext->GetFabricTable(),
app::reporting::GetDefaultReportScheduler()),
CHIP_NO_ERROR);

{
app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &mpTestContext->GetExchangeManager(), delegate,
Expand All @@ -183,8 +181,7 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
readPrepareParams.mpAttributePathParamsList = attributePathParams;
readPrepareParams.mAttributePathParamsListSize = 2;

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();
EXPECT_EQ(delegate.mError, CHIP_IM_GLOBAL_STATUS(InvalidAction));
Expand All @@ -209,8 +206,7 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
readPrepareParams.mpAttributePathParamsList = attributePathParams;
readPrepareParams.mAttributePathParamsListSize = 2;

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();
EXPECT_EQ(delegate.mError, CHIP_IM_GLOBAL_STATUS(InvalidAction));
Expand All @@ -236,8 +232,7 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
readPrepareParams.mpAttributePathParamsList = attributePathParams;
readPrepareParams.mAttributePathParamsListSize = 2;

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();
EXPECT_EQ(delegate.mError, CHIP_NO_ERROR);
Expand Down
28 changes: 11 additions & 17 deletions src/app/tests/TestAclEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class TestEventGenerator : public chip::app::EventLoggingDelegate

void GenerateEvents()
{
CHIP_ERROR err = CHIP_NO_ERROR;
chip::EventNumber eid1, eid2;
chip::app::EventOptions options1;
options1.mPath = { kTestEndpointId, chip::Test::kTestDeniedClusterId2, kTestEventIdDebug };
Expand All @@ -115,11 +114,10 @@ void GenerateEvents()

ChipLogDetail(DataManagement, "Generating Events");
testEventGenerator.SetStatus(0);
err = logMgmt.LogEvent(&testEventGenerator, options1, eid1);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(logMgmt.LogEvent(&testEventGenerator, options1, eid1), CHIP_NO_ERROR);

testEventGenerator.SetStatus(1);
err = logMgmt.LogEvent(&testEventGenerator, options2, eid2);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(logMgmt.LogEvent(&testEventGenerator, options2, eid2), CHIP_NO_ERROR);
}

class MockInteractionModelApp : public chip::app::ReadClient::Callback
Expand Down Expand Up @@ -229,7 +227,6 @@ chip::Test::AppContext * TestAclEvent::mpTestContext = nullptr;

TEST_F(TestAclEvent, TestReadRoundtripWithEventStatusIBInEventReport)
{
CHIP_ERROR err = CHIP_NO_ERROR;

Messaging::ReliableMessageMgr * rm = mpTestContext->GetExchangeManager().GetReliableMessageMgr();
// Shouldn't have anything in the retransmit table when starting the test.
Expand All @@ -238,9 +235,10 @@ TEST_F(TestAclEvent, TestReadRoundtripWithEventStatusIBInEventReport)
GenerateEvents();

auto * engine = chip::app::InteractionModelEngine::GetInstance();
err = engine->Init(&mpTestContext->GetExchangeManager(), &mpTestContext->GetFabricTable(),
app::reporting::GetDefaultReportScheduler());
EXPECT_EQ(err, CHIP_NO_ERROR);

EXPECT_EQ(engine->Init(&mpTestContext->GetExchangeManager(), &mpTestContext->GetFabricTable(),
app::reporting::GetDefaultReportScheduler()),
CHIP_NO_ERROR);

// A custom AccessControl::Delegate has been installed that grants privilege to any cluster except the test cluster.
// When reading events with concrete paths without enough privilege, we will get a EventStatusIB
Expand All @@ -261,8 +259,7 @@ TEST_F(TestAclEvent, TestReadRoundtripWithEventStatusIBInEventReport)
app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &mpTestContext->GetExchangeManager(), delegate,
chip::app::ReadClient::InteractionType::Read);

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();

Expand Down Expand Up @@ -292,8 +289,7 @@ TEST_F(TestAclEvent, TestReadRoundtripWithEventStatusIBInEventReport)
app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &mpTestContext->GetExchangeManager(), delegate,
chip::app::ReadClient::InteractionType::Read);

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();
EXPECT_FALSE(delegate.mGotEventResponse);
Expand All @@ -320,8 +316,7 @@ TEST_F(TestAclEvent, TestReadRoundtripWithEventStatusIBInEventReport)
app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &mpTestContext->GetExchangeManager(), delegate,
chip::app::ReadClient::InteractionType::Read);

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();
EXPECT_TRUE(delegate.mGotEventResponse);
Expand Down Expand Up @@ -353,8 +348,7 @@ TEST_F(TestAclEvent, TestReadRoundtripWithEventStatusIBInEventReport)
app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &mpTestContext->GetExchangeManager(), delegate,
chip::app::ReadClient::InteractionType::Read);

err = readClient.SendRequest(readPrepareParams);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(readClient.SendRequest(readPrepareParams), CHIP_NO_ERROR);

mpTestContext->DrainAndServiceIO();
EXPECT_TRUE(delegate.mGotEventResponse);
Expand Down
11 changes: 5 additions & 6 deletions src/app/tests/TestClusterStateCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,12 @@ void RunAndValidateSequence(AttributeInstructionListType list)
TLV::TLVWriter writer;
writer.Init(buf);
DataVersionFilterIBs::Builder builder;
CHIP_ERROR err = builder.Init(&writer);
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(builder.Init(&writer), CHIP_NO_ERROR);
bool encodedDataVersionList = false;
err = cache.GetBufferedCallback().OnUpdateDataVersionFilterList(builder, pathSpan, encodedDataVersionList);

// We had nothing to encode so far.
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(cache.GetBufferedCallback().OnUpdateDataVersionFilterList(builder, pathSpan, encodedDataVersionList),
CHIP_NO_ERROR);
EXPECT_FALSE(encodedDataVersionList);
}

Expand All @@ -621,10 +620,10 @@ void RunAndValidateSequence(AttributeInstructionListType list)
// We had enough space to start the list. Now try encoding the data
// version filters.
bool encodedDataVersionList = false;
err = cache.GetBufferedCallback().OnUpdateDataVersionFilterList(builder, pathSpan, encodedDataVersionList);

// We should be rolling back properly if we run out of space.
EXPECT_EQ(err, CHIP_NO_ERROR);
EXPECT_EQ(cache.GetBufferedCallback().OnUpdateDataVersionFilterList(builder, pathSpan, encodedDataVersionList),
CHIP_NO_ERROR);
EXPECT_EQ(builder.GetError(), CHIP_NO_ERROR);

if (writer.GetRemainingFreeLength() > 40)
Expand Down
Loading

0 comments on commit c2397ea

Please sign in to comment.