48
48
49
49
namespace {
50
50
51
- static const chip::NodeId kTestDeviceNodeId = 0x18B4300000000001ULL ;
51
+ static const chip::NodeId kTestDeviceNodeId1 = 0x18B4300000000001ULL ;
52
+ static const chip::NodeId kTestDeviceNodeId2 = 0x18B4300000000002ULL ;
52
53
static const chip::ClusterId kLivenessClusterId = 0x00000022 ;
53
54
static const uint32_t kLivenessChangeEvent = 1 ;
54
55
static const chip::EndpointId kTestEndpointId = 2 ;
@@ -71,7 +72,7 @@ void InitializeChip(nlTestSuite * apSuite)
71
72
CHIP_ERROR err = CHIP_NO_ERROR;
72
73
chip::Optional<chip::Transport::PeerAddress> peer (chip::Transport::Type::kUndefined );
73
74
chip::Transport::AdminPairingTable admins;
74
- chip::Transport::AdminPairingInfo * adminInfo = admins.AssignAdminId (gAdminId , kTestDeviceNodeId );
75
+ chip::Transport::AdminPairingInfo * adminInfo = admins.AssignAdminId (gAdminId , kTestDeviceNodeId1 );
75
76
76
77
NL_TEST_ASSERT (apSuite, adminInfo != nullptr );
77
78
@@ -80,7 +81,7 @@ void InitializeChip(nlTestSuite * apSuite)
80
81
81
82
gSystemLayer .Init (nullptr );
82
83
83
- err = gSessionManager .Init (chip:: kTestDeviceNodeId , &gSystemLayer , &gTransportManager , &admins, &gMessageCounterManager );
84
+ err = gSessionManager .Init (kTestDeviceNodeId1 , &gSystemLayer , &gTransportManager , &admins, &gMessageCounterManager );
84
85
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
85
86
86
87
err = gExchangeManager .Init (&gSessionManager );
@@ -143,25 +144,22 @@ static void CheckLogState(nlTestSuite * apSuite, chip::app::EventManagement & aL
143
144
}
144
145
145
146
static void CheckLogReadOut (nlTestSuite * apSuite, chip::app::EventManagement & alogMgmt, chip::app::PriorityLevel priority,
146
- chip::EventNumber startingEventNumber, size_t expectedNumEvents)
147
+ chip::EventNumber startingEventNumber, size_t expectedNumEvents, chip::app::ClusterInfo * clusterInfo )
147
148
{
148
149
CHIP_ERROR err;
149
150
chip::TLV::TLVReader reader;
150
151
chip::TLV::TLVWriter writer;
151
152
uint8_t backingStore[1024 ];
152
153
size_t elementCount;
153
154
writer.Init (backingStore, 1024 );
154
- chip::app::ClusterInfo testClusterInfo;
155
- testClusterInfo.mEventId = 1 ;
156
- err = alogMgmt.FetchEventsSince (writer, &testClusterInfo, priority, startingEventNumber);
155
+ err = alogMgmt.FetchEventsSince (writer, clusterInfo, priority, startingEventNumber);
157
156
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR || err == CHIP_END_OF_TLV);
158
157
159
158
reader.Init (backingStore, writer.GetLengthWritten ());
160
159
161
160
err = chip::TLV::Utilities::Count (reader, elementCount, false );
162
161
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
163
162
NL_TEST_ASSERT (apSuite, elementCount == expectedNumEvents);
164
-
165
163
reader.Init (backingStore, writer.GetLengthWritten ());
166
164
chip::TLV::Debug::Dump (reader, SimpleDumpWriter);
167
165
}
@@ -186,39 +184,42 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC
186
184
{
187
185
CHIP_ERROR err = CHIP_NO_ERROR;
188
186
chip::EventNumber eid1, eid2, eid3, eid4, eid5, eid6;
189
- chip::app::EventSchema schema = { kTestDeviceNodeId , kTestEndpointId , kLivenessClusterId , kLivenessChangeEvent ,
190
- chip::app::PriorityLevel::Info };
191
- chip::app::EventOptions options;
187
+ chip::app::EventSchema schema1 = { kTestDeviceNodeId1 , kTestEndpointId , kLivenessClusterId , kLivenessChangeEvent ,
188
+ chip::app::PriorityLevel::Info };
189
+ chip::app::EventSchema schema2 = { kTestDeviceNodeId2 , kTestEndpointId , kLivenessClusterId , kLivenessChangeEvent ,
190
+ chip::app::PriorityLevel::Info };
191
+ chip::app::EventOptions options1;
192
+ chip::app::EventOptions options2;
192
193
TestEventGenerator testEventGenerator;
193
194
194
- options .mpEventSchema = &schema ;
195
-
195
+ options1 .mpEventSchema = &schema1 ;
196
+ options2. mpEventSchema = &schema2;
196
197
chip::app::EventManagement & logMgmt = chip::app::EventManagement::GetInstance ();
197
198
testEventGenerator.SetStatus (0 );
198
- err = logMgmt.LogEvent (&testEventGenerator, options , eid1);
199
+ err = logMgmt.LogEvent (&testEventGenerator, options1 , eid1);
199
200
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
200
201
CheckLogState (apSuite, logMgmt, 1 , chip::app::PriorityLevel::Debug);
201
202
testEventGenerator.SetStatus (1 );
202
- err = logMgmt.LogEvent (&testEventGenerator, options , eid2);
203
+ err = logMgmt.LogEvent (&testEventGenerator, options1 , eid2);
203
204
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
204
205
CheckLogState (apSuite, logMgmt, 2 , chip::app::PriorityLevel::Debug);
205
206
testEventGenerator.SetStatus (0 );
206
- err = logMgmt.LogEvent (&testEventGenerator, options , eid3);
207
+ err = logMgmt.LogEvent (&testEventGenerator, options1 , eid3);
207
208
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
208
209
CheckLogState (apSuite, logMgmt, 3 , chip::app::PriorityLevel::Debug);
209
210
// Start to copy info event to next buffer since current debug buffer is full and info event is higher priority
210
211
testEventGenerator.SetStatus (1 );
211
- err = logMgmt.LogEvent (&testEventGenerator, options , eid4);
212
+ err = logMgmt.LogEvent (&testEventGenerator, options2 , eid4);
212
213
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
213
214
CheckLogState (apSuite, logMgmt, 4 , chip::app::PriorityLevel::Info);
214
215
215
216
testEventGenerator.SetStatus (0 );
216
- err = logMgmt.LogEvent (&testEventGenerator, options , eid5);
217
+ err = logMgmt.LogEvent (&testEventGenerator, options2 , eid5);
217
218
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
218
219
CheckLogState (apSuite, logMgmt, 5 , chip::app::PriorityLevel::Info);
219
220
220
221
testEventGenerator.SetStatus (1 );
221
- err = logMgmt.LogEvent (&testEventGenerator, options , eid6);
222
+ err = logMgmt.LogEvent (&testEventGenerator, options2 , eid6);
222
223
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
223
224
CheckLogState (apSuite, logMgmt, 6 , chip::app::PriorityLevel::Info);
224
225
@@ -229,19 +230,31 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC
229
230
NL_TEST_ASSERT (apSuite, (eid3 + 1 ) == eid4);
230
231
NL_TEST_ASSERT (apSuite, (eid4 + 1 ) == eid5);
231
232
NL_TEST_ASSERT (apSuite, (eid5 + 1 ) == eid6);
232
- CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid1, 6 );
233
- CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid2, 5 );
234
- CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid3, 4 );
235
- CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid4, 3 );
236
- CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid5, 2 );
237
- CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid6, 1 );
233
+
234
+ chip::app::ClusterInfo testClusterInfo1;
235
+ testClusterInfo1.mNodeId = kTestDeviceNodeId1 ;
236
+ testClusterInfo1.mEndpointId = kTestEndpointId ;
237
+ testClusterInfo1.mClusterId = kLivenessClusterId ;
238
+ testClusterInfo1.mEventId = kLivenessChangeEvent ;
239
+ chip::app::ClusterInfo testClusterInfo2;
240
+ testClusterInfo2.mNodeId = kTestDeviceNodeId2 ;
241
+ testClusterInfo2.mEndpointId = kTestEndpointId ;
242
+ testClusterInfo2.mClusterId = kLivenessClusterId ;
243
+ testClusterInfo2.mEventId = kLivenessChangeEvent ;
244
+
245
+ CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid1, 3 , &testClusterInfo1);
246
+ CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid2, 2 , &testClusterInfo1);
247
+ CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid3, 1 , &testClusterInfo1);
248
+ CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid4, 3 , &testClusterInfo2);
249
+ CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid5, 2 , &testClusterInfo2);
250
+ CheckLogReadOut (apSuite, logMgmt, chip::app::PriorityLevel::Info, eid6, 1 , &testClusterInfo2);
238
251
}
239
252
240
253
static void CheckLogEventWithDiscardLowEvent (nlTestSuite * apSuite, void * apContext)
241
254
{
242
255
CHIP_ERROR err = CHIP_NO_ERROR;
243
256
chip::EventNumber eid1, eid2, eid3, eid4, eid5, eid6;
244
- chip::app::EventSchema schema = { kTestDeviceNodeId , kTestEndpointId , kLivenessClusterId , kLivenessChangeEvent ,
257
+ chip::app::EventSchema schema = { kTestDeviceNodeId1 , kTestEndpointId , kLivenessClusterId , kLivenessChangeEvent ,
245
258
chip::app::PriorityLevel::Debug };
246
259
chip::app::EventOptions options;
247
260
TestEventGenerator testEventGenerator;
0 commit comments