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

Additional unit tests for PROFINET RT_CLASS_1 helpers. More...

#include <gtest/gtest.h>
#include <array>
#include <cstdint>
#include <string>
#include <vector>
#include "profinet/rpc.h"
#include "profinet/rt.h"
#include "profinet/util.h"
+ Include dependency graph for test_rtMore.cpp:

Go to the source code of this file.

Functions

 TEST_F (RtMoreTests, RTFrameStatusAccessorsCoverAllBits)
 
 TEST_F (RtMoreTests, RTFrameSerializationPreservesAllFields)
 
 TEST_F (RtMoreTests, RTFrameFromBytesRejectsShortBuffers)
 
 TEST_F (RtMoreTests, RTFrameToStringIsNonEmpty)
 
 TEST_F (RtMoreTests, ParseEthernetFrameRejectsShortFrames)
 
 TEST_F (RtMoreTests, ParseEthernetFrameAcceptsPriorityVlan)
 
 TEST_F (RtMoreTests, ParseEthernetFrameRejectsVlanNonProfinet)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetIopsUpdatesDataObject)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetIocsUpdatesIocsOnlyObject)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetIopsIgnoresIocsOnlyObject)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetIocsUpdatesDataObject)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetAllIopsUpdatesAllDataObjects)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetAllIocsUpdatesAllIocs)
 
 TEST_F (RtMoreTests, CyclicDataBuilderClearResetsBuffers)
 
 TEST_F (RtMoreTests, CyclicDataBuilderLoadCopiesAndClearsRemainder)
 
 TEST_F (RtMoreTests, CyclicDataBuilderLoadTruncatesLongPayload)
 
 TEST_F (RtMoreTests, CyclicDataBuilderGetDataRejectsUnknownSlotSubslot)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetDataTruncatesOversizedData)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSwapWithoutChangesPreservesData)
 
 TEST_F (RtMoreTests, IOCRTimingHelpersCalculateCycleAndWatchdog)
 
 TEST_F (RtMoreTests, IOCRTypePredicatesCoverBothDirections)
 
 TEST_F (RtMoreTests, BuildIocrConfigsHandlesEmptySlotList)
 
 TEST_F (RtMoreTests, BuildIocrConfigsCoversInputAndOutputBranches)
 
 TEST_F (RtMoreTests, BuildIocrConfigsUsesMinimumCSduLength)
 
 TEST_F (RtMoreTests, BuildIocrConfigsUsesCalculatedSizeWhenLarger)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSetDataRejectsUnknownSlotSubslot)
 
 TEST_F (RtMoreTests, CyclicDataBuilderSwapPromotesDirtyBuffer)
 
 TEST_F (RtMoreTests, CyclicDataBuilderConfigReturnsConfiguration)
 

Detailed Description

Additional unit tests for PROFINET RT_CLASS_1 helpers.

Extends coverage for RT frame status flags, malformed Ethernet input,/// VLAN handling, cyclic-buffer state transitions, IOPS/IOCS updates,/// clearing/loading, and IOCR configuration helper behavior.

Definition in file test_rtMore.cpp.

Function Documentation

◆ TEST_F() [1/28]

TEST_F ( RtMoreTests  ,
BuildIocrConfigsCoversInputAndOutputBranches   
)
Test:
Verify BuildIocrConfigs covers data, IOCS-only, and bidirectional submodule paths for both input and output IOCRs.

Definition at line 477 of file test_rtMore.cpp.

References profinet::rt::BuildIocrConfigs(), profinet::rt::IOCR_TYPE_INPUT, and profinet::rt::IOCR_TYPE_OUTPUT.

+ Here is the call graph for this function:

◆ TEST_F() [2/28]

TEST_F ( RtMoreTests  ,
BuildIocrConfigsHandlesEmptySlotList   
)
Test:
Verify BuildIocrConfigs handles the empty-slot case using the CSdu minimum.

Definition at line 463 of file test_rtMore.cpp.

References profinet::rt::BuildIocrConfigs().

+ Here is the call graph for this function:

◆ TEST_F() [3/28]

TEST_F ( RtMoreTests  ,
BuildIocrConfigsUsesCalculatedSizeWhenLarger   
)
Test:
Verify BuildIocrConfigs preserves a calculated size larger than cSduLength.

Definition at line 637 of file test_rtMore.cpp.

References profinet::rt::BuildIocrConfigs().

+ Here is the call graph for this function:

◆ TEST_F() [4/28]

TEST_F ( RtMoreTests  ,
BuildIocrConfigsUsesMinimumCSduLength   
)
Test:
Verify BuildIocrConfigs uses cSduLength when it exceeds the calculated input/output size.

Definition at line 624 of file test_rtMore.cpp.

References profinet::rt::BuildIocrConfigs().

+ Here is the call graph for this function:

◆ TEST_F() [5/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderClearResetsBuffers   
)
Test:
Verify CyclicDataBuilder Clear resets the cyclic buffers to zero.

Definition at line 319 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::Clear(), profinet::rt::IOCRConfig::dataLength, profinet::rt::CyclicDataBuilder::GetData(), profinet::rt::IOCRConfig::objects, profinet::rt::CyclicDataBuilder::SetData(), profinet::rt::CyclicDataBuilder::SetIocs(), profinet::rt::IODataObject::slot, and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [6/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderConfigReturnsConfiguration   
)
Test:
Verify CyclicDataBuilder exposes its configured IOCR.

Definition at line 677 of file test_rtMore.cpp.

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

+ Here is the call graph for this function:

◆ TEST_F() [7/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderGetDataRejectsUnknownSlotSubslot   
)
Test:
Verify CyclicDataBuilder GetData rejects an unknown slot/subslot.

Definition at line 387 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::GetData().

+ Here is the call graph for this function:

◆ TEST_F() [8/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderLoadCopiesAndClearsRemainder   
)
Test:
Verify CyclicDataBuilder Load copies a shorter payload and clears the remainder.

Definition at line 355 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::Load(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [9/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderLoadTruncatesLongPayload   
)
Test:
Verify CyclicDataBuilder Load truncates a payload larger than the configured buffer.

Definition at line 372 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::Load(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [10/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetAllIocsUpdatesAllIocs   
)
Test:
Verify CyclicDataBuilder SetAllIocs updates every configured IOCS position.

Definition at line 278 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::IOCRConfig::dataLength, profinet::rt::IOCRConfig::objects, profinet::rt::CyclicDataBuilder::SetAllIocs(), profinet::rt::IODataObject::slot, and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [11/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetAllIopsUpdatesAllDataObjects   
)
Test:
Verify CyclicDataBuilder SetAllIops updates every data-bearing object.

Definition at line 263 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::SetAllIops(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [12/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetDataRejectsUnknownSlotSubslot   
)
Test:
Verify CyclicDataBuilder SetData rejects an unknown slot/subslot.

Definition at line 652 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::SetData().

+ Here is the call graph for this function:

◆ TEST_F() [13/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetDataTruncatesOversizedData   
)
Test:
Verify CyclicDataBuilder SetData truncates data larger than the mapped object.

Definition at line 395 of file test_rtMore.cpp.

References profinet::rt::IOCRConfig::dataLength, profinet::rt::CyclicDataBuilder::GetData(), profinet::rt::IOCRConfig::objects, profinet::rt::CyclicDataBuilder::SetData(), and profinet::rt::IODataObject::slot.

+ Here is the call graph for this function:

◆ TEST_F() [14/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetIocsUpdatesDataObject   
)
Test:
Verify CyclicDataBuilder SetIocs updates ordinary data objects as well.

Definition at line 252 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::SetIocs(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [15/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetIocsUpdatesIocsOnlyObject   
)
Test:
Verify CyclicDataBuilder SetIocs updates IOCS-only objects.

Definition at line 228 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::SetIocs(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [16/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetIopsIgnoresIocsOnlyObject   
)
Test:
Verify CyclicDataBuilder SetIops ignores an IOCS-only object without an IOPS byte.

Definition at line 241 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::SetIops(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [17/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSetIopsUpdatesDataObject   
)
Test:
Verify CyclicDataBuilder SetIops updates IOPS for data-bearing objects.

Definition at line 215 of file test_rtMore.cpp.

References profinet::rt::CyclicDataBuilder::Build(), profinet::rt::CyclicDataBuilder::SetIops(), and profinet::rt::CyclicDataBuilder::Swap().

+ Here is the call graph for this function:

◆ TEST_F() [18/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSwapPromotesDirtyBuffer   
)
Test:
Verify CyclicDataBuilder Swap promotes a dirty write buffer.

Definition at line 660 of file test_rtMore.cpp.

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

+ Here is the call graph for this function:

◆ TEST_F() [19/28]

TEST_F ( RtMoreTests  ,
CyclicDataBuilderSwapWithoutChangesPreservesData   
)
Test:
Verify CyclicDataBuilder Swap leaves an already clean buffer unchanged.

Definition at line 417 of file test_rtMore.cpp.

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

+ Here is the call graph for this function:

◆ TEST_F() [20/28]

TEST_F ( RtMoreTests  ,
IOCRTimingHelpersCalculateCycleAndWatchdog   
)
Test:
Verify IOCR timing helpers use the configured reduction and send-clock factors.

Definition at line 432 of file test_rtMore.cpp.

References profinet::rt::IOCRConfig::CycleTimeMs(), profinet::rt::IOCRConfig::CycleTimeUs(), profinet::rt::IOCRConfig::reductionRatio, profinet::rt::IOCRConfig::sendClockFactor, profinet::rt::IOCRConfig::watchdogFactor, and profinet::rt::IOCRConfig::WatchdogTimeUs().

+ Here is the call graph for this function:

◆ TEST_F() [21/28]

TEST_F ( RtMoreTests  ,
IOCRTypePredicatesCoverBothDirections   
)
Test:
Verify IOCR type predicates cover input and output configurations.

Definition at line 445 of file test_rtMore.cpp.

References profinet::rt::IOCR_TYPE_INPUT, profinet::rt::IOCR_TYPE_OUTPUT, profinet::rt::IOCRConfig::IsInput(), profinet::rt::IOCRConfig::IsOutput(), and profinet::rt::IOCRConfig::typeIOCR.

+ Here is the call graph for this function:

◆ TEST_F() [22/28]

TEST_F ( RtMoreTests  ,
ParseEthernetFrameAcceptsPriorityVlan   
)
Test:
Verify ParseEthernetFrame accepts a single priority VLAN tag.

Definition at line 180 of file test_rtMore.cpp.

References frame, and profinet::rt::ParseEthernetFrame().

+ Here is the call graph for this function:

◆ TEST_F() [23/28]

TEST_F ( RtMoreTests  ,
ParseEthernetFrameRejectsShortFrames   
)
Test:
Verify ParseEthernetFrame rejects packets shorter than an Ethernet header.

Definition at line 171 of file test_rtMore.cpp.

References length, and profinet::rt::ParseEthernetFrame().

+ Here is the call graph for this function:

◆ TEST_F() [24/28]

TEST_F ( RtMoreTests  ,
ParseEthernetFrameRejectsVlanNonProfinet   
)
Test:
Verify ParseEthernetFrame rejects a VLAN-tagged frame with a non-PROFINET EtherType.

Definition at line 203 of file test_rtMore.cpp.

References profinet::rt::ParseEthernetFrame().

+ Here is the call graph for this function:

◆ TEST_F() [25/28]

TEST_F ( RtMoreTests  ,
RTFrameFromBytesRejectsShortBuffers   
)
Test:
Verify RTFrame parsing rejects every length below the fixed header size.

Definition at line 151 of file test_rtMore.cpp.

References profinet::rt::RTFrame::FromBytes(), and length.

+ Here is the call graph for this function:

◆ TEST_F() [26/28]

TEST_F ( RtMoreTests  ,
RTFrameSerializationPreservesAllFields   
)
Test:
Verify RTFrame serialization retains transfer status as well as payload.

Definition at line 136 of file test_rtMore.cpp.

References frame, and profinet::rt::RTFrame::FromBytes().

+ Here is the call graph for this function:

◆ TEST_F() [27/28]

TEST_F ( RtMoreTests  ,
RTFrameStatusAccessorsCoverAllBits   
)
Test:
Verify RTFrame accessors independently evaluate every status bit.

Definition at line 108 of file test_rtMore.cpp.

References profinet::rt::DATA_STATUS_PROVIDER_RUN, profinet::rt::DATA_STATUS_STATE, profinet::rt::DATA_STATUS_STATION_OK, profinet::rt::DATA_STATUS_VALID, and frame.

◆ TEST_F() [28/28]

TEST_F ( RtMoreTests  ,
RTFrameToStringIsNonEmpty   
)
Test:
Verify RTFrame::ToString provides a stable non-empty diagnostic string.

Definition at line 163 of file test_rtMore.cpp.