@@ -47,8 +47,7 @@ CHIP_ERROR WriteTLVString(uint8_t * buf, uint32_t bufLen, const char * data, uin
47
47
}
48
48
49
49
// Helper method: read a TLV structure with a single tag and string and verify it matches expected string.
50
- CHIP_ERROR ReadAndVerifyTLVString (const uint8_t * dataStart, uint32_t len,
51
- const char * expected, size_t expectedLen)
50
+ CHIP_ERROR ReadAndVerifyTLVString (const uint8_t * dataStart, uint32_t len, const char * expected, size_t expectedLen)
52
51
{
53
52
TLV::TLVReader reader;
54
53
char tmp[64 ] = { 0 };
@@ -90,8 +89,7 @@ CHIP_ERROR AttachHeaderAndSend(TransferSession::MessageTypeData typeData, chip::
90
89
}
91
90
92
91
// Helper method for verifying that a PacketBufferHandle contains a valid BDX header and message type matches expected.
93
- void VerifyBdxMessageToSend (const TransferSession::OutputEvent & outEvent,
94
- MessageType expected)
92
+ void VerifyBdxMessageToSend (const TransferSession::OutputEvent & outEvent, MessageType expected)
95
93
{
96
94
static_assert (std::is_same<std::underlying_type_t <decltype (expected)>, uint8_t >::value, " Cast is not safe" );
97
95
EXPECT_EQ (outEvent.EventType , TransferSession::OutputEventType::kMsgToSend );
@@ -136,9 +134,8 @@ void VerifyNoMoreOutput(TransferSession & transferSession)
136
134
137
135
// Helper method for initializing two TransferSession objects, generating a TransferInit message, and passing it to a responding
138
136
// TransferSession.
139
- void SendAndVerifyTransferInit (TransferSession::OutputEvent & outEvent,
140
- System::Clock::Timeout timeout, TransferSession & initiator, TransferRole initiatorRole,
141
- TransferSession::TransferInitData initData, TransferSession & responder,
137
+ void SendAndVerifyTransferInit (TransferSession::OutputEvent & outEvent, System::Clock::Timeout timeout, TransferSession & initiator,
138
+ TransferRole initiatorRole, TransferSession::TransferInitData initData, TransferSession & responder,
142
139
BitFlags<TransferControlFlags> & responderControlOpts, uint16_t responderMaxBlock)
143
140
{
144
141
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -173,7 +170,8 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent,
173
170
if (outEvent.EventType == TransferSession::OutputEventType::kInitReceived &&
174
171
outEvent.transferInitData .FileDesignator != nullptr )
175
172
{
176
- EXPECT_EQ (0 , memcmp (initData.FileDesignator , outEvent.transferInitData .FileDesignator , outEvent.transferInitData .FileDesLength ));
173
+ EXPECT_EQ (
174
+ 0 , memcmp (initData.FileDesignator , outEvent.transferInitData .FileDesignator , outEvent.transferInitData .FileDesLength ));
177
175
}
178
176
if (outEvent.transferInitData .Metadata != nullptr )
179
177
{
@@ -186,7 +184,8 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent,
186
184
{
187
185
// Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
188
186
// parse the metadata and verify that it matches.
189
- EXPECT_EQ (0 , memcmp (initData.Metadata , outEvent.transferInitData .Metadata , outEvent.transferInitData .MetadataLength ));
187
+ EXPECT_EQ (0 ,
188
+ memcmp (initData.Metadata , outEvent.transferInitData .Metadata , outEvent.transferInitData .MetadataLength ));
190
189
}
191
190
}
192
191
else
@@ -202,8 +201,7 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent,
202
201
// receiver should emit a StatusCode event instead.
203
202
//
204
203
// The acceptSender is the node that is sending the Accept message (not necessarily the same node that will send Blocks).
205
- void SendAndVerifyAcceptMsg (TransferSession::OutputEvent & outEvent,
206
- TransferSession & acceptSender, TransferRole acceptSenderRole,
204
+ void SendAndVerifyAcceptMsg (TransferSession::OutputEvent & outEvent, TransferSession & acceptSender, TransferRole acceptSenderRole,
207
205
TransferSession::TransferAcceptData acceptData, TransferSession & acceptReceiver,
208
206
TransferSession::TransferInitData initData)
209
207
{
@@ -246,7 +244,9 @@ void SendAndVerifyAcceptMsg(TransferSession::OutputEvent & outEvent,
246
244
{
247
245
// Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
248
246
// parse the metadata and verify that it matches.
249
- EXPECT_EQ (0 , memcmp (acceptData.Metadata , outEvent.transferAcceptData .Metadata , outEvent.transferAcceptData .MetadataLength ));
247
+ EXPECT_EQ (
248
+ 0 ,
249
+ memcmp (acceptData.Metadata , outEvent.transferAcceptData .Metadata , outEvent.transferAcceptData .MetadataLength ));
250
250
}
251
251
}
252
252
else
@@ -260,8 +260,7 @@ void SendAndVerifyAcceptMsg(TransferSession::OutputEvent & outEvent,
260
260
}
261
261
262
262
// Helper method for preparing a sending a BlockQuery message between two TransferSession objects.
263
- void SendAndVerifyQuery (TransferSession & queryReceiver, TransferSession & querySender,
264
- TransferSession::OutputEvent & outEvent)
263
+ void SendAndVerifyQuery (TransferSession & queryReceiver, TransferSession & querySender, TransferSession::OutputEvent & outEvent)
265
264
{
266
265
// Verify that querySender emits BlockQuery message
267
266
CHIP_ERROR err = querySender.PrepareBlockQuery ();
@@ -281,8 +280,8 @@ void SendAndVerifyQuery(TransferSession & queryReceiver, TransferSession & query
281
280
282
281
// Helper method for preparing a sending a Block message between two TransferSession objects. The sender refers to the node that is
283
282
// sending Blocks. Uses a static counter incremented with each call. Also verifies that block data received matches what was sent.
284
- void SendAndVerifyArbitraryBlock (TransferSession & sender, TransferSession & receiver,
285
- TransferSession::OutputEvent & outEvent, bool isEof, uint32_t inBlockCounter)
283
+ void SendAndVerifyArbitraryBlock (TransferSession & sender, TransferSession & receiver, TransferSession::OutputEvent & outEvent,
284
+ bool isEof, uint32_t inBlockCounter)
286
285
{
287
286
CHIP_ERROR err = CHIP_NO_ERROR;
288
287
static uint8_t dataCount = 0 ;
@@ -329,8 +328,8 @@ void SendAndVerifyArbitraryBlock(TransferSession & sender, TransferSession & rec
329
328
}
330
329
331
330
// Helper method for sending a BlockAck or BlockAckEOF, depending on the state of the receiver.
332
- void SendAndVerifyBlockAck (TransferSession & ackReceiver, TransferSession & ackSender,
333
- TransferSession::OutputEvent & outEvent, bool expectEOF)
331
+ void SendAndVerifyBlockAck (TransferSession & ackReceiver, TransferSession & ackSender, TransferSession::OutputEvent & outEvent,
332
+ bool expectEOF)
334
333
{
335
334
TransferSession::OutputEventType expectedEventType =
336
335
expectEOF ? TransferSession::OutputEventType::kAckEOFReceived : TransferSession::OutputEventType::kAckReceived ;
@@ -360,10 +359,7 @@ struct TestBdxTransferSession : public ::testing::Test
360
359
EXPECT_EQ (error, CHIP_NO_ERROR);
361
360
}
362
361
363
- static void TearDownTestSuite ()
364
- {
365
- chip::Platform::MemoryShutdown ();
366
- }
362
+ static void TearDownTestSuite () { chip::Platform::MemoryShutdown (); }
367
363
};
368
364
369
365
// Test a full transfer using a responding receiver and an initiating sender, receiver drive.
@@ -398,8 +394,8 @@ TEST_F(TestBdxTransferSession, TestInitiatingReceiverReceiverDrive)
398
394
BitFlags<TransferControlFlags> senderOpts;
399
395
senderOpts.Set (driveMode);
400
396
401
- SendAndVerifyTransferInit (outEvent, timeout, initiatingReceiver, TransferRole::kReceiver , initOptions,
402
- respondingSender, senderOpts, proposedBlockSize);
397
+ SendAndVerifyTransferInit (outEvent, timeout, initiatingReceiver, TransferRole::kReceiver , initOptions, respondingSender,
398
+ senderOpts, proposedBlockSize);
403
399
404
400
// Test metadata for Accept message
405
401
uint8_t tlvBuf[64 ] = { 0 };
@@ -418,8 +414,7 @@ TEST_F(TestBdxTransferSession, TestInitiatingReceiverReceiverDrive)
418
414
acceptData.Metadata = tlvBuf;
419
415
acceptData.MetadataLength = metadataSize;
420
416
421
- SendAndVerifyAcceptMsg (outEvent, respondingSender, TransferRole::kSender , acceptData, initiatingReceiver,
422
- initOptions);
417
+ SendAndVerifyAcceptMsg (outEvent, respondingSender, TransferRole::kSender , acceptData, initiatingReceiver, initOptions);
423
418
424
419
// Verify that MaxBlockSize was chosen correctly
425
420
EXPECT_EQ (respondingSender.GetTransferBlockSize (), testSmallerBlockSize);
@@ -506,13 +501,13 @@ TEST_F(TestBdxTransferSession, TestInitiatingSenderSenderDrive)
506
501
initOptions.Metadata = tlvBuf;
507
502
initOptions.MetadataLength = metadataSize;
508
503
509
- SendAndVerifyTransferInit (outEvent, timeout, initiatingSender, TransferRole::kSender , initOptions,
510
- respondingReceiver, receiverOpts, transferBlockSize);
504
+ SendAndVerifyTransferInit (outEvent, timeout, initiatingSender, TransferRole::kSender , initOptions, respondingReceiver,
505
+ receiverOpts, transferBlockSize);
511
506
512
507
// Verify parsed TLV metadata matches the original
513
- err = ReadAndVerifyTLVString (outEvent. transferInitData . Metadata ,
514
- static_cast <uint32_t >(outEvent.transferInitData .MetadataLength ), metadataStr ,
515
- static_cast <uint16_t >(strlen (metadataStr)));
508
+ err =
509
+ ReadAndVerifyTLVString (outEvent. transferInitData . Metadata , static_cast <uint32_t >(outEvent.transferInitData .MetadataLength ),
510
+ metadataStr, static_cast <uint16_t >(strlen (metadataStr)));
516
511
EXPECT_EQ (err, CHIP_NO_ERROR);
517
512
518
513
// Compose SendAccept parameters struct and give to respondingSender
@@ -525,8 +520,7 @@ TEST_F(TestBdxTransferSession, TestInitiatingSenderSenderDrive)
525
520
acceptData.Metadata = nullptr ;
526
521
acceptData.MetadataLength = 0 ;
527
522
528
- SendAndVerifyAcceptMsg (outEvent, respondingReceiver, TransferRole::kReceiver , acceptData, initiatingSender,
529
- initOptions);
523
+ SendAndVerifyAcceptMsg (outEvent, respondingReceiver, TransferRole::kReceiver , acceptData, initiatingSender, initOptions);
530
524
531
525
uint32_t numBlocksSent = 0 ;
532
526
// Test multiple Block -> BlockAck -> Block
@@ -571,8 +565,8 @@ TEST_F(TestBdxTransferSession, TestBadAcceptMessageFields)
571
565
BitFlags<TransferControlFlags> responderControl;
572
566
responderControl.Set (driveMode);
573
567
574
- SendAndVerifyTransferInit (outEvent, timeout, initiatingReceiver, TransferRole::kReceiver , initOptions,
575
- respondingSender, responderControl, maxBlockSize);
568
+ SendAndVerifyTransferInit (outEvent, timeout, initiatingReceiver, TransferRole::kReceiver , initOptions, respondingSender,
569
+ responderControl, maxBlockSize);
576
570
577
571
// Verify AcceptTransfer() returns error for choosing larger max block size
578
572
TransferSession::TransferAcceptData acceptData;
@@ -668,8 +662,8 @@ TEST_F(TestBdxTransferSession, TestDuplicateBlockError)
668
662
BitFlags<TransferControlFlags> senderOpts;
669
663
senderOpts.Set (driveMode);
670
664
671
- SendAndVerifyTransferInit (outEvent, timeout, initiatingReceiver, TransferRole::kReceiver , initOptions,
672
- respondingSender, senderOpts, blockSize);
665
+ SendAndVerifyTransferInit (outEvent, timeout, initiatingReceiver, TransferRole::kReceiver , initOptions, respondingSender,
666
+ senderOpts, blockSize);
673
667
674
668
// Compose ReceiveAccept parameters struct and give to respondingSender
675
669
TransferSession::TransferAcceptData acceptData;
@@ -680,8 +674,7 @@ TEST_F(TestBdxTransferSession, TestDuplicateBlockError)
680
674
acceptData.Metadata = nullptr ;
681
675
acceptData.MetadataLength = 0 ;
682
676
683
- SendAndVerifyAcceptMsg (outEvent, respondingSender, TransferRole::kSender , acceptData, initiatingReceiver,
684
- initOptions);
677
+ SendAndVerifyAcceptMsg (outEvent, respondingSender, TransferRole::kSender , acceptData, initiatingReceiver, initOptions);
685
678
686
679
SendAndVerifyQuery (respondingSender, initiatingReceiver, outEvent);
687
680
0 commit comments