From 164170473920fb0e175ab864133d80531e347c0f Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Thu, 28 Apr 2022 21:12:24 -0700 Subject: [PATCH] add more event tests (#17851) --- src/app/tests/TestEventLogging.cpp | 45 ++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/app/tests/TestEventLogging.cpp b/src/app/tests/TestEventLogging.cpp index a9d70c28d4de82..e0f390728be788 100644 --- a/src/app/tests/TestEventLogging.cpp +++ b/src/app/tests/TestEventLogging.cpp @@ -233,20 +233,37 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC NL_TEST_ASSERT(apSuite, (eid4 + 1) == eid5); NL_TEST_ASSERT(apSuite, (eid5 + 1) == eid6); - chip::app::ObjectList testEventPathParams1; - testEventPathParams1.mValue.mEndpointId = kTestEndpointId1; - testEventPathParams1.mValue.mClusterId = kLivenessClusterId; - chip::app::ObjectList testEventPathParams2; - testEventPathParams2.mValue.mEndpointId = kTestEndpointId2; - testEventPathParams2.mValue.mClusterId = kLivenessClusterId; - testEventPathParams2.mValue.mEventId = kLivenessChangeEvent; - - CheckLogReadOut(apSuite, logMgmt, 0, 3, &testEventPathParams1); - CheckLogReadOut(apSuite, logMgmt, 1, 2, &testEventPathParams1); - CheckLogReadOut(apSuite, logMgmt, 2, 1, &testEventPathParams1); - CheckLogReadOut(apSuite, logMgmt, 3, 3, &testEventPathParams2); - CheckLogReadOut(apSuite, logMgmt, 4, 2, &testEventPathParams2); - CheckLogReadOut(apSuite, logMgmt, 5, 1, &testEventPathParams2); + chip::app::ObjectList paths[2]; + + paths[0].mValue.mEndpointId = kTestEndpointId1; + paths[0].mValue.mClusterId = kLivenessClusterId; + + paths[1].mValue.mEndpointId = kTestEndpointId2; + paths[1].mValue.mClusterId = kLivenessClusterId; + paths[1].mValue.mEventId = kLivenessChangeEvent; + + // interested paths are path list, expect to retrieve all events for each particular interested path + CheckLogReadOut(apSuite, logMgmt, 0, 3, &paths[0]); + CheckLogReadOut(apSuite, logMgmt, 1, 2, &paths[0]); + CheckLogReadOut(apSuite, logMgmt, 2, 1, &paths[0]); + CheckLogReadOut(apSuite, logMgmt, 3, 3, &paths[1]); + CheckLogReadOut(apSuite, logMgmt, 4, 2, &paths[1]); + CheckLogReadOut(apSuite, logMgmt, 5, 1, &paths[1]); + + paths[0].mpNext = &paths[1]; + // interested paths are path list, expect to retrieve all events for those interested paths + CheckLogReadOut(apSuite, logMgmt, 0, 6, paths); + + chip::app::ObjectList pathsWithWildcard[2]; + paths[0].mValue.mEndpointId = kTestEndpointId1; + paths[0].mValue.mClusterId = kLivenessClusterId; + + // second path is wildcard path at default, expect to retrieve all events + CheckLogReadOut(apSuite, logMgmt, 0, 6, &pathsWithWildcard[1]); + + paths[0].mpNext = &paths[1]; + // first path is not wildcard, second path is wildcard path at default, expect to retrieve all events + CheckLogReadOut(apSuite, logMgmt, 0, 6, pathsWithWildcard); } static void CheckLogEventWithDiscardLowEvent(nlTestSuite * apSuite, void * apContext)