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

Unit tests for PROFINET protocol wire-format structures. More...

#include <gtest/gtest.h>
#include "profinet/protocol.h"
+ Include dependency graph for test_protocol.cpp:

Go to the source code of this file.

Classes

class  ProtocolTest
 

Functions

 TEST_F (ProtocolTest, PNDCPHeaderRoundTrips)
 
 TEST_F (ProtocolTest, PNDCPBlockParsesStatusAndPayload)
 
 TEST_F (ProtocolTest, EthernetHeaderRoundTrips)
 
 TEST_F (ProtocolTest, PacketStructFixedSizesMatchExpectedSizes)
 
 TEST_F (ProtocolTest, PNRPCHeaderInterfaceUUIDMatchesExpectedPrefix)
 
 TEST (EthernetVLANHeaderTests, RejectsTruncatedHeader)
 
 TEST (EthernetVLANHeaderTests, AcceptsCompleteHeader)
 

Detailed Description

Unit tests for PROFINET protocol wire-format structures.

Verifies serialization, parsing, fixed-size definitions, and selected protocol constants for the structures declared in protocol.h.

The tests cover:

  • DCP header and block parsing/serialization.
  • Ethernet header parsing and serialization.
  • Fixed wire-format sizes of PROFINET packet structures.
  • PROFINET DCE/RPC interface UUID generation.
  • IP configuration decoding from DCP blocks.

Fixed-size checks are compared against the expected wire-format sizes established to help preserve binary compatibility with PROFINET devices.

Definition in file test_protocol.cpp.

Function Documentation

◆ TEST() [1/2]

TEST ( EthernetVLANHeaderTests  ,
AcceptsCompleteHeader   
)
Test:
Accepts the complete minimum-sized VLAN header.

Definition at line 292 of file test_protocol.cpp.

References profinet::EthernetVLANHeader::Parse().

+ Here is the call graph for this function:

◆ TEST() [2/2]

TEST ( EthernetVLANHeaderTests  ,
RejectsTruncatedHeader   
)
Test:
Rejects every truncated 802.1Q VLAN header before parsing fields.

Definition at line 280 of file test_protocol.cpp.

References profinet::EthernetVLANHeader::Parse().

+ Here is the call graph for this function:

◆ TEST_F() [1/5]

TEST_F ( ProtocolTest  ,
EthernetHeaderRoundTrips   
)
Test:
EthernetHeader round-trips

Definition at line 99 of file test_protocol.cpp.

References profinet::EthernetHeader::dst, profinet::EthernetHeader::Parse(), profinet::EthernetHeader::payload, profinet::PROFINET_ETHERTYPE, profinet::EthernetHeader::src, profinet::String2Mac(), profinet::EthernetHeader::ToBytes(), and profinet::EthernetHeader::type.

+ Here is the call graph for this function:

◆ TEST_F() [2/5]

◆ TEST_F() [3/5]

TEST_F ( ProtocolTest  ,
PNDCPBlockParsesStatusAndPayload   
)
Test:
PNDCPBlock parses status+payload with -2 offset convention

Definition at line 55 of file test_protocol.cpp.

References profinet::IPConfiguration::address, profinet::IPConfiguration::gateway, profinet::IPConfiguration::netmask, profinet::PNDCPBlock::option, profinet::PNDCPBlock::Parse(), profinet::PNDCPBlock::ParseIp(), profinet::PNDCPBlock::payload, and profinet::PNDCPBlock::suboption.

+ Here is the call graph for this function:

◆ TEST_F() [4/5]

TEST_F ( ProtocolTest  ,
PNDCPHeaderRoundTrips   
)
Test:
PNDCPHeader round-trips

Definition at line 29 of file test_protocol.cpp.

References profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::kFixedSize, profinet::PNDCPHeader::length, profinet::PNDCPHeader::Parse(), profinet::PNDCPHeader::payload, profinet::PNDCPHeader::respDelay, profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::PNDCPHeader::ToBytes(), and profinet::PNDCPHeader::xId.

+ Here is the call graph for this function:

◆ TEST_F() [5/5]

TEST_F ( ProtocolTest  ,
PNRPCHeaderInterfaceUUIDMatchesExpectedPrefix   
)
Test:
PNRPCHeader interface UUIDs match expected PROFINET prefix

Definition at line 259 of file test_protocol.cpp.

References profinet::PNRPCHeader::IfaceUuidDevice().

+ Here is the call graph for this function: