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

Tests for the common EthernetPacketBackend implementation. More...

#include <chrono>
#include <cstdint>
#include <stdexcept>
#include <vector>
#include "ethernetPacketBackendTestFixture.h"
#include "profinet/exceptions.h"
#include "profinet/protocol.h"
#include "profinet/util.h"
+ Include dependency graph for test_ethernetPacketBackend.cpp:

Go to the source code of this file.

Functions

 TEST_F (EthernetPacketBackendTestFixture, ConstructorRejectsEmptyInterface)
 
 TEST_F (EthernetPacketBackendTestFixture, ConstructorRejectsUnknownInterface)
 
 TEST_F (EthernetPacketBackendTestFixture, ConstructorAcceptsConfiguredInterface)
 
 TEST_F (EthernetPacketBackendTestFixture, SendAcceptsMinimumEthernetFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, SendRejectsShortEthernetFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterAcceptsMatchingUntaggedFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterRejectsNonMatchingUntaggedFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterAcceptsSingleVlanTaggedFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterAcceptsQinQFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterAcceptsLegacyDoubleTaggedFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterRejectsFrameShorterThanHeader)
 
 TEST_F (EthernetPacketBackendTestFixture, EtherTypeFilterRejectsTruncatedVlanFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, ZeroEtherTypeAcceptsCompleteFrame)
 
 TEST_F (EthernetPacketBackendTestFixture, RecvReturnsEmptyFrameOnTimeout)
 
 TEST_F (EthernetPacketBackendTestFixture, RecvSkipsNonMatchingTraffic)
 

Detailed Description

Tests for the common EthernetPacketBackend implementation.

Covers validation, Ethernet EtherType matching, VLAN-aware filtering, frame-size validation, and receive timeout behavior. Tests which exercise libpcap access require PROFINET_TEST_INTERFACE to select an Ethernet device.

Definition in file test_ethernetPacketBackend.cpp.

Function Documentation

◆ TEST_F() [1/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
ConstructorAcceptsConfiguredInterface   
)
Test:
Verifies that the configured Ethernet interface can be opened.

Definition at line 64 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [2/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
ConstructorRejectsEmptyInterface   
)
Test:
Verifies that an empty interface name is rejected before packet access.

Definition at line 52 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [3/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
ConstructorRejectsUnknownInterface   
)
Test:
Verifies that an unknown interface name is rejected.

Definition at line 58 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [4/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterAcceptsLegacyDoubleTaggedFrame   
)
Test:
Verifies that legacy 0x9100 VLAN tagging is skipped before EtherType matching.

Definition at line 167 of file test_ethernetPacketBackend.cpp.

References frame.

◆ TEST_F() [5/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterAcceptsMatchingUntaggedFrame   
)
Test:
Verifies that an untagged frame with the configured EtherType matches.

Definition at line 107 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [6/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterAcceptsQinQFrame   
)
Test:
Verifies that two stacked VLAN tags are skipped before EtherType matching.

Definition at line 153 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [7/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterAcceptsSingleVlanTaggedFrame   
)
Test:
Verifies that one 802.1Q tag is skipped before EtherType matching.

Definition at line 139 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [8/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterRejectsFrameShorterThanHeader   
)
Test:
Verifies that a frame shorter than an Ethernet header cannot match a filter.

Definition at line 190 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [9/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterRejectsNonMatchingUntaggedFrame   
)
Test:
Verifies that a non-matching untagged EtherType is rejected.

Definition at line 121 of file test_ethernetPacketBackend.cpp.

References frame.

◆ TEST_F() [10/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
EtherTypeFilterRejectsTruncatedVlanFrame   
)
Test:
Verifies that a frame containing only an incomplete VLAN tag is rejected.

Definition at line 204 of file test_ethernetPacketBackend.cpp.

References frame.

◆ TEST_F() [11/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
RecvReturnsEmptyFrameOnTimeout   
)
Test:
Verifies that Recv returns an empty frame when the configured timeout expires.

Definition at line 237 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [12/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
RecvSkipsNonMatchingTraffic   
)
Test:
Verifies that non-matching captured traffic is ignored until a matching frame arrives.

Definition at line 255 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [13/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
SendAcceptsMinimumEthernetFrame   
)
Test:
Verifies that a complete minimum-size Ethernet frame can be sent.

Definition at line 77 of file test_ethernetPacketBackend.cpp.

References frame.

◆ TEST_F() [14/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
SendRejectsShortEthernetFrame   
)
Test:
Verifies that frames shorter than the Ethernet header are rejected.

Definition at line 93 of file test_ethernetPacketBackend.cpp.

◆ TEST_F() [15/15]

TEST_F ( EthernetPacketBackendTestFixture  ,
ZeroEtherTypeAcceptsCompleteFrame   
)
Test:
Verifies that an EtherType value of zero accepts a complete frame.

Definition at line 223 of file test_ethernetPacketBackend.cpp.