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

Unit tests for PROFINET RT_CLASS_1 cyclic frame handling and IO data layout. More...

#include <gtest/gtest.h>
#include "profinet/rpc.h"
#include "profinet/rt.h"
+ Include dependency graph for test_rt.cpp:

Go to the source code of this file.

Classes

class  RTTest
 

Functions

 TEST_F (RTTest, RTFrameRoundTrips)
 
 TEST_F (RTTest, RTFrameRejectsTooShortData)
 
 TEST_F (RTTest, BuildAndParseEthernetFrameRoundTrips)
 
 TEST_F (RTTest, ParseEthernetFrameRejectsNonProfinetEthertype)
 
 TEST_F (RTTest, CyclicDataBuilderSetGetDataRoundTripsThroughSwap)
 
 TEST_F (RTTest, CyclicDataBuilderRejectsUnknownSlotSubslot)
 
 TEST_F (RTTest, BuildReturnsStablePublishedSnapshot)
 
 TEST_F (RTTest, ConcurrentSetDataAndBuildIsRaceFree)
 
 TEST_F (RTTest, DISABLED_BuildIocrConfigsComputesExpectedFrameOffsets)
 

Detailed Description

Unit tests for PROFINET RT_CLASS_1 cyclic frame handling and IO data layout.

Verifies RT frame serialization and parsing, Ethernet frame handling, and cyclic process-data buffer management provided by rt.h.

The tests cover:

  • RTFrame serialization/deserialization round-trips.
  • RT frame status flag interpretation.
  • Rejection of truncated RT frames.
  • PROFINET Ethernet frame construction and parsing.
  • Rejection of Ethernet frames with a non-PROFINET EtherType.
  • CyclicDataBuilder process-data and IOPS handling across buffer swaps.
  • Rejection of unknown slot/subslot mappings.
  • IOCR configuration and frame-offset calculation from configured I/O slots.

Definition in file test_rt.cpp.

Function Documentation

◆ TEST_F() [1/9]

TEST_F ( RTTest  ,
BuildAndParseEthernetFrameRoundTrips   
)
Test:
build_ethernet_frame / parse_ethernet_frame round-trip

Definition at line 64 of file test_rt.cpp.

References profinet::rt::BuildEthernetFrame(), profinet::rt::DATA_STATUS_VALID, frame, profinet::rt::RTFrame::frameId, profinet::rt::ParseEthernetFrame(), and profinet::String2Mac().

+ Here is the call graph for this function:

◆ TEST_F() [2/9]

TEST_F ( RTTest  ,
BuildReturnsStablePublishedSnapshot   
)

Definition at line 141 of file test_rt.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::IOCRConfig::dataLength, profinet::rt::IOCRConfig::objects, profinet::rt::CyclicDataBuilder::SetData(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [3/9]

TEST_F ( RTTest  ,
ConcurrentSetDataAndBuildIsRaceFree   
)

Definition at line 158 of file test_rt.cpp.

References profinet::rt::IOCRConfig::dataLength, profinet::rt::IOCRConfig::objects, and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [4/9]

TEST_F ( RTTest  ,
CyclicDataBuilderRejectsUnknownSlotSubslot   
)
Test:
CyclicDataBuilder rejects unknown slot/subslot

Definition at line 131 of file test_rt.cpp.

References profinet::rt::IOCRConfig::dataLength, and profinet::rt::CyclicDataBuilder::SetData().

+ Here is the call graph for this function:

◆ TEST_F() [5/9]

TEST_F ( RTTest  ,
CyclicDataBuilderSetGetDataRoundTripsThroughSwap   
)
Test:
CyclicDataBuilder set/get data round-trips through swap

Definition at line 101 of file test_rt.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::IOCRConfig::dataLength, profinet::rt::CyclicDataBuilder::GetData(), profinet::rt::IOXS_GOOD, profinet::rt::IOCRConfig::objects, profinet::rt::CyclicDataBuilder::SetData(), profinet::rt::CyclicDataBuilder::SetIops(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [6/9]

TEST_F ( RTTest  ,
DISABLED_BuildIocrConfigsComputesExpectedFrameOffsets   
)
Test:
build_iocr_configs computes frame offsets matching RPCCon's IOCR block builder

Definition at line 184 of file test_rt.cpp.

References profinet::rt::BuildIocrConfigs().

+ Here is the call graph for this function:

◆ TEST_F() [7/9]

TEST_F ( RTTest  ,
ParseEthernetFrameRejectsNonProfinetEthertype   
)
Test:
parse_ethernet_frame rejects non-PROFINET ethertype

Definition at line 88 of file test_rt.cpp.

References profinet::rt::ParseEthernetFrame().

+ Here is the call graph for this function:

◆ TEST_F() [8/9]

TEST_F ( RTTest  ,
RTFrameRejectsTooShortData   
)
Test:
RTFrame::from_bytes rejects too-short data

Definition at line 58 of file test_rt.cpp.

References profinet::rt::RTFrame::FromBytes().

+ Here is the call graph for this function:

◆ TEST_F() [9/9]

TEST_F ( RTTest  ,
RTFrameRoundTrips   
)
Test:
RTFrame round-trips through to_bytes/from_bytes

Definition at line 31 of file test_rt.cpp.

References profinet::rt::RTFrame::cycleCounter, profinet::rt::DATA_STATUS_PROVIDER_RUN, profinet::rt::DATA_STATUS_VALID, profinet::rt::RTFrame::dataStatus, frame, profinet::rt::RTFrame::frameId, profinet::rt::RTFrame::FromBytes(), profinet::rt::RTFrame::IsOk(), profinet::rt::RTFrame::IsRunning(), profinet::rt::RTFrame::IsValid(), and profinet::rt::RTFrame::payload.

+ Here is the call graph for this function: