Skip to content

Commit bddc3c9

Browse files
committed
Fixed clang and GN formatting. Moved BDXTests from test_components_nl.txt to test_components.txt.
1 parent bafa47a commit bddc3c9

File tree

4 files changed

+34
-44
lines changed

4 files changed

+34
-44
lines changed

src/protocols/bdx/tests/TestBdxMessages.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ struct TestBdxMessages : public ::testing::Test
4646
EXPECT_EQ(error, CHIP_NO_ERROR);
4747
}
4848

49-
static void TearDownTestSuite()
50-
{
51-
chip::Platform::MemoryShutdown();
52-
}
49+
static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
5350
};
5451

5552
TEST_F(TestBdxMessages, TestTransferInitMessage)

src/protocols/bdx/tests/TestBdxTransferSession.cpp

+32-39
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ CHIP_ERROR WriteTLVString(uint8_t * buf, uint32_t bufLen, const char * data, uin
4747
}
4848

4949
// 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)
5251
{
5352
TLV::TLVReader reader;
5453
char tmp[64] = { 0 };
@@ -90,8 +89,7 @@ CHIP_ERROR AttachHeaderAndSend(TransferSession::MessageTypeData typeData, chip::
9089
}
9190

9291
// 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)
9593
{
9694
static_assert(std::is_same<std::underlying_type_t<decltype(expected)>, uint8_t>::value, "Cast is not safe");
9795
EXPECT_EQ(outEvent.EventType, TransferSession::OutputEventType::kMsgToSend);
@@ -136,9 +134,8 @@ void VerifyNoMoreOutput(TransferSession & transferSession)
136134

137135
// Helper method for initializing two TransferSession objects, generating a TransferInit message, and passing it to a responding
138136
// 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,
142139
BitFlags<TransferControlFlags> & responderControlOpts, uint16_t responderMaxBlock)
143140
{
144141
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -173,7 +170,8 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent,
173170
if (outEvent.EventType == TransferSession::OutputEventType::kInitReceived &&
174171
outEvent.transferInitData.FileDesignator != nullptr)
175172
{
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));
177175
}
178176
if (outEvent.transferInitData.Metadata != nullptr)
179177
{
@@ -186,7 +184,8 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent,
186184
{
187185
// Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
188186
// 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));
190189
}
191190
}
192191
else
@@ -202,8 +201,7 @@ void SendAndVerifyTransferInit(TransferSession::OutputEvent & outEvent,
202201
// receiver should emit a StatusCode event instead.
203202
//
204203
// 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,
207205
TransferSession::TransferAcceptData acceptData, TransferSession & acceptReceiver,
208206
TransferSession::TransferInitData initData)
209207
{
@@ -246,7 +244,9 @@ void SendAndVerifyAcceptMsg(TransferSession::OutputEvent & outEvent,
246244
{
247245
// Only check that metadata buffers match. The OutputEvent can still be inspected when this function returns to
248246
// 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));
250250
}
251251
}
252252
else
@@ -260,8 +260,7 @@ void SendAndVerifyAcceptMsg(TransferSession::OutputEvent & outEvent,
260260
}
261261

262262
// 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)
265264
{
266265
// Verify that querySender emits BlockQuery message
267266
CHIP_ERROR err = querySender.PrepareBlockQuery();
@@ -281,8 +280,8 @@ void SendAndVerifyQuery(TransferSession & queryReceiver, TransferSession & query
281280

282281
// Helper method for preparing a sending a Block message between two TransferSession objects. The sender refers to the node that is
283282
// 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)
286285
{
287286
CHIP_ERROR err = CHIP_NO_ERROR;
288287
static uint8_t dataCount = 0;
@@ -329,8 +328,8 @@ void SendAndVerifyArbitraryBlock(TransferSession & sender, TransferSession & rec
329328
}
330329

331330
// 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)
334333
{
335334
TransferSession::OutputEventType expectedEventType =
336335
expectEOF ? TransferSession::OutputEventType::kAckEOFReceived : TransferSession::OutputEventType::kAckReceived;
@@ -360,10 +359,7 @@ struct TestBdxTransferSession : public ::testing::Test
360359
EXPECT_EQ(error, CHIP_NO_ERROR);
361360
}
362361

363-
static void TearDownTestSuite()
364-
{
365-
chip::Platform::MemoryShutdown();
366-
}
362+
static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
367363
};
368364

369365
// Test a full transfer using a responding receiver and an initiating sender, receiver drive.
@@ -398,8 +394,8 @@ TEST_F(TestBdxTransferSession, TestInitiatingReceiverReceiverDrive)
398394
BitFlags<TransferControlFlags> senderOpts;
399395
senderOpts.Set(driveMode);
400396

401-
SendAndVerifyTransferInit(outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions,
402-
respondingSender, senderOpts, proposedBlockSize);
397+
SendAndVerifyTransferInit(outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender,
398+
senderOpts, proposedBlockSize);
403399

404400
// Test metadata for Accept message
405401
uint8_t tlvBuf[64] = { 0 };
@@ -418,8 +414,7 @@ TEST_F(TestBdxTransferSession, TestInitiatingReceiverReceiverDrive)
418414
acceptData.Metadata = tlvBuf;
419415
acceptData.MetadataLength = metadataSize;
420416

421-
SendAndVerifyAcceptMsg(outEvent, respondingSender, TransferRole::kSender, acceptData, initiatingReceiver,
422-
initOptions);
417+
SendAndVerifyAcceptMsg(outEvent, respondingSender, TransferRole::kSender, acceptData, initiatingReceiver, initOptions);
423418

424419
// Verify that MaxBlockSize was chosen correctly
425420
EXPECT_EQ(respondingSender.GetTransferBlockSize(), testSmallerBlockSize);
@@ -506,13 +501,13 @@ TEST_F(TestBdxTransferSession, TestInitiatingSenderSenderDrive)
506501
initOptions.Metadata = tlvBuf;
507502
initOptions.MetadataLength = metadataSize;
508503

509-
SendAndVerifyTransferInit(outEvent, timeout, initiatingSender, TransferRole::kSender, initOptions,
510-
respondingReceiver, receiverOpts, transferBlockSize);
504+
SendAndVerifyTransferInit(outEvent, timeout, initiatingSender, TransferRole::kSender, initOptions, respondingReceiver,
505+
receiverOpts, transferBlockSize);
511506

512507
// 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)));
516511
EXPECT_EQ(err, CHIP_NO_ERROR);
517512

518513
// Compose SendAccept parameters struct and give to respondingSender
@@ -525,8 +520,7 @@ TEST_F(TestBdxTransferSession, TestInitiatingSenderSenderDrive)
525520
acceptData.Metadata = nullptr;
526521
acceptData.MetadataLength = 0;
527522

528-
SendAndVerifyAcceptMsg(outEvent, respondingReceiver, TransferRole::kReceiver, acceptData, initiatingSender,
529-
initOptions);
523+
SendAndVerifyAcceptMsg(outEvent, respondingReceiver, TransferRole::kReceiver, acceptData, initiatingSender, initOptions);
530524

531525
uint32_t numBlocksSent = 0;
532526
// Test multiple Block -> BlockAck -> Block
@@ -571,8 +565,8 @@ TEST_F(TestBdxTransferSession, TestBadAcceptMessageFields)
571565
BitFlags<TransferControlFlags> responderControl;
572566
responderControl.Set(driveMode);
573567

574-
SendAndVerifyTransferInit(outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions,
575-
respondingSender, responderControl, maxBlockSize);
568+
SendAndVerifyTransferInit(outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender,
569+
responderControl, maxBlockSize);
576570

577571
// Verify AcceptTransfer() returns error for choosing larger max block size
578572
TransferSession::TransferAcceptData acceptData;
@@ -668,8 +662,8 @@ TEST_F(TestBdxTransferSession, TestDuplicateBlockError)
668662
BitFlags<TransferControlFlags> senderOpts;
669663
senderOpts.Set(driveMode);
670664

671-
SendAndVerifyTransferInit(outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions,
672-
respondingSender, senderOpts, blockSize);
665+
SendAndVerifyTransferInit(outEvent, timeout, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender,
666+
senderOpts, blockSize);
673667

674668
// Compose ReceiveAccept parameters struct and give to respondingSender
675669
TransferSession::TransferAcceptData acceptData;
@@ -680,8 +674,7 @@ TEST_F(TestBdxTransferSession, TestDuplicateBlockError)
680674
acceptData.Metadata = nullptr;
681675
acceptData.MetadataLength = 0;
682676

683-
SendAndVerifyAcceptMsg(outEvent, respondingSender, TransferRole::kSender, acceptData, initiatingReceiver,
684-
initOptions);
677+
SendAndVerifyAcceptMsg(outEvent, respondingSender, TransferRole::kSender, acceptData, initiatingReceiver, initOptions);
685678

686679
SendAndVerifyQuery(respondingSender, initiatingReceiver, outEvent);
687680

src/test_driver/openiotsdk/unit-tests/test_components.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
accesstest
22
SystemLayerTests
33
ASN1Tests
4+
BDXTests
45
MinimalMdnsRecordsTests
56
MinimalMdnsRespondersTests
67
PlatformTests

src/test_driver/openiotsdk/unit-tests/test_components_nl.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
AppTests
2-
BDXTests
32
ChipCryptoTests
43
CoreTests
54
CredentialsTest

0 commit comments

Comments
 (0)