-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored transport/raw/tests to more cleanly handle access to priva…
…te members of TCPBase (#33306) * Refactored TestTCP and TestUDP to simplify them. Pulled out the places where test needs access to private members and put those in a TestAccess class. Moved TCPBaseTestAccess into an H file so it can be used by other tests in the future. * Clang formatting. * Added TCPBaseTestAccess.h to BUILD.gn * Minor change to fix failing test * Reordered the includes to match the standard "Related header, C system headers, C++ standard library headers, other libraries' headers, your project's headers"
- Loading branch information
Showing
8 changed files
with
386 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
#include <transport/raw/TCP.h> | ||
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
|
||
namespace chip { | ||
namespace Transport { | ||
/** | ||
* @brief Class acts as an accessor to private members of the TCPBase class without needing to give | ||
* friend access to each individual test. | ||
*/ | ||
template <size_t kActiveConnectionsSize, size_t kPendingPacketSize> | ||
class TCPBaseTestAccess | ||
{ | ||
public: | ||
using TCPImpl = Transport::TCP<kActiveConnectionsSize, kPendingPacketSize>; | ||
|
||
static void * FindActiveConnection(TCPImpl & tcp, Transport::PeerAddress & peerAddress) | ||
{ | ||
return tcp.FindActiveConnection(peerAddress); | ||
} | ||
static Inet::TCPEndPoint * GetEndpoint(void * state) { return static_cast<ActiveTCPConnectionState *>(state)->mEndPoint; } | ||
|
||
static CHIP_ERROR ProcessReceivedBuffer(TCPImpl & tcp, Inet::TCPEndPoint * endPoint, const PeerAddress & peerAddress, | ||
System::PacketBufferHandle && buffer) | ||
{ | ||
return tcp.ProcessReceivedBuffer(endPoint, peerAddress, std::move(buffer)); | ||
} | ||
}; | ||
} // namespace Transport | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.