PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::EthernetPacketBackendTestFixture Class Reference

Shared fixture for EthernetPacketBackend tests. More...

#include <ethernetPacketBackendTestFixture.h>

+ Inheritance diagram for profinet::EthernetPacketBackendTestFixture:
+ Collaboration diagram for profinet::EthernetPacketBackendTestFixture:

Protected Types

using Backend = AsioEthernetSocket::EthernetPacketBackend
 Backend implementation under test.
 

Protected Member Functions

std::unique_ptr< Backend > CreateBackend (const std::string &interface, std::uint16_t ethertype=0U)
 Construct one backend instance for the supplied interface.
 
bool MatchesEtherType (const Backend &backend, const std::vector< std::uint8_t > &frame) const
 Query the backend EtherType matcher through the test seam.
 
void SetUp () override
 Start the external Asio execution context.
 
void TearDown () override
 Stop the external Asio execution context.
 

Static Protected Member Functions

static std::optional< std::string > GetTestInterface ()
 Return the explicitly configured live-test interface.
 

Protected Attributes

asio::io_context ioContext
 Asio execution context used by the backend.
 
std::unique_ptr< AsioIoContextRunner > runner
 External Asio worker used by synchronous Recv() operations.
 

Detailed Description

Shared fixture for EthernetPacketBackend tests.

The packet backend is private to AsioEthernetSocket because it is an implementation detail of the public transport. This fixture is declared as a test-only friend so the backend's own validation and VLAN matching logic can be tested without exposing the backend in the production API.

Definition at line 29 of file ethernetPacketBackendTestFixture.h.

Member Typedef Documentation

◆ Backend

Backend implementation under test.

Definition at line 33 of file ethernetPacketBackendTestFixture.h.

Member Function Documentation

◆ CreateBackend()

std::unique_ptr< Backend > profinet::EthernetPacketBackendTestFixture::CreateBackend ( const std::string &  interface,
std::uint16_t  ethertype = 0U 
)
inlineprotected

Construct one backend instance for the supplied interface.

Parameters
interfaceNetwork interface or packet-capture device name.
ethertypeEtherType filter; zero accepts all frame types.
Returns
Newly constructed backend.

Definition at line 40 of file ethernetPacketBackendTestFixture.h.

References ioContext.

◆ GetTestInterface()

static std::optional< std::string > profinet::EthernetPacketBackendTestFixture::GetTestInterface ( )
inlinestaticprotected

Return the explicitly configured live-test interface.

Returns
Interface name, or an empty optional when not configured.

Definition at line 58 of file ethernetPacketBackendTestFixture.h.

◆ MatchesEtherType()

bool profinet::EthernetPacketBackendTestFixture::MatchesEtherType ( const Backend &  backend,
const std::vector< std::uint8_t > &  frame 
) const
inlineprotected

Query the backend EtherType matcher through the test seam.

Parameters
backendBackend under test.
frameComplete or partial Ethernet frame.
Returns
True when the frame matches the backend's configured EtherType.

Definition at line 50 of file ethernetPacketBackendTestFixture.h.

References frame, and profinet::AsioEthernetSocket::EthernetPacketBackend::MatchesEtherType().

+ Here is the call graph for this function:

◆ SetUp()

void profinet::EthernetPacketBackendTestFixture::SetUp ( )
inlineoverrideprotected

Start the external Asio execution context.

Definition at line 77 of file ethernetPacketBackendTestFixture.h.

References ioContext, and runner.

◆ TearDown()

void profinet::EthernetPacketBackendTestFixture::TearDown ( )
inlineoverrideprotected

Stop the external Asio execution context.

Definition at line 83 of file ethernetPacketBackendTestFixture.h.

References runner.

Member Data Documentation

◆ ioContext

asio::io_context profinet::EthernetPacketBackendTestFixture::ioContext
protected

Asio execution context used by the backend.

Definition at line 71 of file ethernetPacketBackendTestFixture.h.

Referenced by CreateBackend(), and SetUp().

◆ runner

std::unique_ptr<AsioIoContextRunner> profinet::EthernetPacketBackendTestFixture::runner
protected

External Asio worker used by synchronous Recv() operations.

Definition at line 74 of file ethernetPacketBackendTestFixture.h.

Referenced by SetUp(), and TearDown().


The documentation for this class was generated from the following file: