PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
test_asioEthernetSocket.cpp File Reference

Tests for the Asio-backed Linux raw Ethernet socket. More...

#include <gtest/gtest.h>
#include <asio.hpp>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <memory>
#include <optional>
#include <thread>
#include <vector>
#include "profinet/asioEthernetSocket.h"
#include "profinet/exceptions.h"
#include "profinet/protocol.h"
#include "profinet/util.h"
+ Include dependency graph for test_asioEthernetSocket.cpp:

Go to the source code of this file.

Functions

 TEST_F (AsioEthernetSocketTests, ConstructorRejectsUnknownInterface)
 
 TEST_F (AsioEthernetSocketTests, ConstructorAcceptsEthernetInterface)
 
 TEST_F (AsioEthernetSocketTests, ConstructorAcceptsSpecificEtherType)
 
 TEST_F (AsioEthernetSocketTests, SetTimeoutAcceptsFiniteDuration)
 
 TEST_F (AsioEthernetSocketTests, RecvReturnsEmptyFrameOnTimeout)
 
 TEST_F (AsioEthernetSocketTests, RecvUsesExternallyDrivenIoContext)
 
 TEST_F (AsioEthernetSocketTests, InjectedEthernetFrameCanBeCapturedByPeer)
 
 TEST_F (AsioEthernetSocketTests, EtherTypeFilterAcceptsVlanTaggedFrame)
 
 TEST_F (AsioEthernetSocketTests, UnicastFrameCanBeReceivedByPeer)
 
 TEST_F (AsioEthernetSocketTests, ConcurrentUnicastFrameCanBeReceivedByPeer)
 
 TEST_F (AsioEthernetSocketTests, PeerCanReceiveAndRespondToController)
 

Detailed Description

Tests for the Asio-backed Linux raw Ethernet socket.

These tests exercise socket creation, interface validation, timeout handling, and asynchronous send operations. The tests use the Linux loopback interface so they do not depend on a physical PROFINET device.

Creating an AF_PACKET socket requires CAP_NET_RAW.

Definition in file test_asioEthernetSocket.cpp.

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( AsioEthernetSocketTests  ,
ConcurrentUnicastFrameCanBeReceivedByPeer   
)
Test:
Verifies that a frame can be received concurrently while another thread sends through a second AF_PACKET socket.//kan weg?

Definition at line 315 of file test_asioEthernetSocket.cpp.

References frame, ioContext, profinet::AsioEthernetSocket::Recv(), profinet::AsioEthernetSocket::Send(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [2/11]

TEST_F ( AsioEthernetSocketTests  ,
ConstructorAcceptsEthernetInterface   
)
Test:
Verifies that a configured Ethernet interface can be opened.

Definition at line 131 of file test_asioEthernetSocket.cpp.

References ioContext.

◆ TEST_F() [3/11]

TEST_F ( AsioEthernetSocketTests  ,
ConstructorAcceptsSpecificEtherType   
)
Test:
Verifies that a specific EtherType can be configured.

Definition at line 144 of file test_asioEthernetSocket.cpp.

References ioContext, and profinet::PROFINET_ETHERTYPE.

◆ TEST_F() [4/11]

TEST_F ( AsioEthernetSocketTests  ,
ConstructorRejectsUnknownInterface   
)
Test:
Verifies that an unknown network interface is rejected.

Definition at line 125 of file test_asioEthernetSocket.cpp.

References ioContext.

◆ TEST_F() [5/11]

TEST_F ( AsioEthernetSocketTests  ,
EtherTypeFilterAcceptsVlanTaggedFrame   
)
Test:
Verifies that an EtherType filter is applied after VLAN tags.

Definition at line 245 of file test_asioEthernetSocket.cpp.

References frame, ioContext, profinet::PROFINET_ETHERTYPE, profinet::AsioEthernetSocket::Recv(), profinet::AsioEthernetSocket::Send(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [6/11]

TEST_F ( AsioEthernetSocketTests  ,
InjectedEthernetFrameCanBeCapturedByPeer   
)
Test:
Verifies that an injected Ethernet frame can be captured by a peer.

Definition at line 216 of file test_asioEthernetSocket.cpp.

References frame, ioContext, profinet::AsioEthernetSocket::Recv(), profinet::AsioEthernetSocket::Send(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [7/11]

TEST_F ( AsioEthernetSocketTests  ,
PeerCanReceiveAndRespondToController   
)
Test:
Verifies that a controller can send a frame to a peer and receive the peer's response through the Ethernet transport.

Definition at line 350 of file test_asioEthernetSocket.cpp.

References controller, ioContext, profinet::AsioEthernetSocket::Recv(), profinet::AsioEthernetSocket::Send(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [8/11]

TEST_F ( AsioEthernetSocketTests  ,
RecvReturnsEmptyFrameOnTimeout   
)
Test:
Verifies that Recv returns an empty frame when its configured receive timeout expires.

Definition at line 174 of file test_asioEthernetSocket.cpp.

References ioContext, profinet::AsioEthernetSocket::Recv(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [9/11]

TEST_F ( AsioEthernetSocketTests  ,
RecvUsesExternallyDrivenIoContext   
)
Test:
Verifies that Recv uses an externally driven Asio execution context rather than running the context itself.

Definition at line 194 of file test_asioEthernetSocket.cpp.

References ioContext, profinet::AsioEthernetSocket::Recv(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [10/11]

TEST_F ( AsioEthernetSocketTests  ,
SetTimeoutAcceptsFiniteDuration   
)
Test:
Verifies that SetTimeout configures a finite receive timeout without performing socket I/O immediately.

Definition at line 158 of file test_asioEthernetSocket.cpp.

References ioContext, and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function:

◆ TEST_F() [11/11]

TEST_F ( AsioEthernetSocketTests  ,
UnicastFrameCanBeReceivedByPeer   
)
Test:
Verifies that a complete unicast Ethernet frame sent through one AF_PACKET socket can be received by another socket on the test interface.// Kan weg?

Definition at line 285 of file test_asioEthernetSocket.cpp.

References frame, ioContext, profinet::AsioEthernetSocket::Recv(), profinet::AsioEthernetSocket::Send(), and profinet::AsioEthernetSocket::SetTimeout().

+ Here is the call graph for this function: