@@ -55,9 +55,9 @@ static const chip::EndpointId kTestEndpointId1 = 2;
55
55
static const chip::EndpointId kTestEndpointId2 = 3 ;
56
56
static const chip::TLV::Tag kLivenessDeviceStatus = chip::TLV::ContextTag(1 );
57
57
58
- static uint8_t gDebugEventBuffer [128 ];
59
- static uint8_t gInfoEventBuffer [128 ];
60
- static uint8_t gCritEventBuffer [128 ];
58
+ static uint8_t gDebugEventBuffer [120 ];
59
+ static uint8_t gInfoEventBuffer [120 ];
60
+ static uint8_t gCritEventBuffer [120 ];
61
61
static chip::app::CircularEventBuffer gCircularEventBuffer [3 ];
62
62
63
63
class TestContext : public chip ::Test::AppContext
@@ -154,6 +154,15 @@ static void CheckLogReadOut(nlTestSuite * apSuite, chip::app::EventManagement &
154
154
err = alogMgmt.FetchEventsSince (writer, clusterInfo, startingEventNumber, eventCount, chip::Access::SubjectDescriptor{});
155
155
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR || err == CHIP_END_OF_TLV);
156
156
157
+ auto eventTLVSize = writer.GetLengthWritten () / eventCount;
158
+ // XXX: Make sure that the sizes of our event storages are big enough to hold at least 3 events
159
+ // but small enough not to hold 4 events. It is very important to check this because of the
160
+ // hard-coded logic of this unit test.
161
+ // The size of TLV-encoded event can vary depending on the UTC vs system time controlled by
162
+ // the CHIP_DEVICE_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS, because the relative system time
163
+ // will be most likely encoded in 1 byte, while the UTC time will be encoded in 8 bytes.
164
+ NL_TEST_ASSERT (apSuite, sizeof (gDebugEventBuffer ) >= eventTLVSize * 3 && sizeof (gDebugEventBuffer ) < eventTLVSize * 4 );
165
+
157
166
reader.Init (backingStore.Get (), writer.GetLengthWritten ());
158
167
159
168
err = chip::TLV::Utilities::Count (reader, totalNumElements, false );
@@ -307,22 +316,19 @@ static void CheckLogEventWithDiscardLowEvent(nlTestSuite * apSuite, void * apCon
307
316
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
308
317
CheckLogState (apSuite, logMgmt, 3 , chip::app::PriorityLevel::Debug);
309
318
}
310
- /* *
311
- * Test Suite. It lists all the test functions.
312
- */
313
319
314
- const nlTest sTests [] = { NL_TEST_DEF (" CheckLogEventWithEvictToNextBuffer" , CheckLogEventWithEvictToNextBuffer),
315
- NL_TEST_DEF (" CheckLogEventWithDiscardLowEvent" , CheckLogEventWithDiscardLowEvent), NL_TEST_SENTINEL () };
320
+ const nlTest sTests [] = {
321
+ NL_TEST_DEF (" CheckLogEventWithEvictToNextBuffer" , CheckLogEventWithEvictToNextBuffer),
322
+ NL_TEST_DEF (" CheckLogEventWithDiscardLowEvent" , CheckLogEventWithDiscardLowEvent),
323
+ NL_TEST_SENTINEL (),
324
+ };
316
325
317
- // clang-format off
318
- nlTestSuite sSuite =
319
- {
326
+ nlTestSuite sSuite = {
320
327
" EventLogging" ,
321
328
&sTests [0 ],
322
329
TestContext::Initialize,
323
- TestContext::Finalize
330
+ TestContext::Finalize,
324
331
};
325
- // clang-format on
326
332
327
333
} // namespace
328
334
0 commit comments