|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Unit tests for the PROFINET DCE/RPC UDP transport. More...
#include <gtest/gtest.h>#include <array>#include <asio.hpp>#include <chrono>#include <cstdint>#include <memory>#include <string>#include <system_error>#include <thread>#include <vector>#include "profinet/AsioIoContextRunner.h"#include "profinet/exceptions.h"#include "profinet/rpcTransport.h"
Include dependency graph for test_rpcTransport.cpp:Go to the source code of this file.
Classes | |
| class | RpcTransportTests |
Functions | |
| TEST_F (RpcTransportTests, ConstructorCreatesClosedTransport) | |
| TEST_F (RpcTransportTests, OpenCreatesUdpSocket) | |
| TEST_F (RpcTransportTests, OpenListenerBindsRequestedPort) | |
| TEST_F (RpcTransportTests, OpenRejectsInvalidIpv4Address) | |
| TEST_F (RpcTransportTests, OpenListenerRejectsOccupiedPort) | |
| TEST_F (RpcTransportTests, OpenUpdatesEndpointWhenTransportIsAlreadyOpen) | |
| TEST_F (RpcTransportTests, ReceiveReturnsDatagramAndSenderEndpoint) | |
| TEST_F (RpcTransportTests, ReceiveFailsWhenTransportIsClosed) | |
| TEST_F (RpcTransportTests, ReceiveRejectsZeroTimeout) | |
| TEST_F (RpcTransportTests, ReceiveRejectsNegativeTimeout) | |
| TEST_F (RpcTransportTests, ReceiveThrowsOnTimeout) | |
| TEST_F (RpcTransportTests, ReceiveThrowsSystemErrorWhenSocketIsCancelled) | |
| TEST_F (RpcTransportTests, SendToTransmitsDatagramToSuppliedEndpoint) | |
| TEST_F (RpcTransportTests, SendToFailsWhenTransportIsClosed) | |
| TEST_F (RpcTransportTests, SendToReportsUnderlyingSocketError) | |
| TEST_F (RpcTransportTests, SendReceiveReturnsEchoResponse) | |
| TEST_F (RpcTransportTests, SendReceiveUsesExternallyDrivenIoContext) | |
| TEST_F (RpcTransportTests, SendReceiveThrowsOnTimeout) | |
| TEST_F (RpcTransportTests, SendReceiveFailsWhenTransportIsClosed) | |
| TEST_F (RpcTransportTests, SendReceiveRejectsZeroTimeout) | |
| TEST_F (RpcTransportTests, SendReceiveRejectsNegativeTimeout) | |
| TEST_F (RpcTransportTests, SendReceiveThrowsSystemErrorWhenSocketIsCancelled) | |
| TEST_F (RpcTransportTests, SendTransmitsDatagramWithoutWaiting) | |
| TEST_F (RpcTransportTests, SendFailsWhenTransportIsClosed) | |
| TEST_F (RpcTransportTests, CloseClosesSocket) | |
| TEST_F (RpcTransportTests, CloseIsIdempotent) | |
| TEST_F (RpcTransportTests, CloseOnClosedTransportDoesNothing) | |
| TEST_F (RpcTransportTests, IsOpenReturnsTrueForOpenTransport) | |
| TEST_F (RpcTransportTests, IsOpenReturnsFalseForClosedTransport) | |
| TEST_F (RpcTransportTests, ReceiveUsesExternallyDrivenIoContext) | |
Unit tests for the PROFINET DCE/RPC UDP transport.
Tests the synchronous RpcTransport wrapper around standalone Asio. The tests use localhost UDP communication so socket creation, transmission, reception, timeout handling, cancellation, listener mode, and shutdown are exercised without requiring a physical PROFINET IO-Device.
Definition in file test_rpcTransport.cpp.
| TEST_F | ( | RpcTransportTests | , |
| CloseClosesSocket | |||
| ) |
Definition at line 621 of file test_rpcTransport.cpp.
References profinet::rpc::RpcTransport::Close(), ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| CloseIsIdempotent | |||
| ) |
Definition at line 635 of file test_rpcTransport.cpp.
References profinet::rpc::RpcTransport::Close(), ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| CloseOnClosedTransportDoesNothing | |||
| ) |
Definition at line 648 of file test_rpcTransport.cpp.
References profinet::rpc::RpcTransport::Close(), ioContext, and profinet::rpc::RpcTransport::IsOpen().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ConstructorCreatesClosedTransport | |||
| ) |
Definition at line 237 of file test_rpcTransport.cpp.
References ioContext, and profinet::rpc::RpcTransport::IsOpen().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| IsOpenReturnsFalseForClosedTransport | |||
| ) |
Definition at line 672 of file test_rpcTransport.cpp.
References profinet::rpc::RpcTransport::Close(), ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| IsOpenReturnsTrueForOpenTransport | |||
| ) |
Definition at line 660 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| OpenCreatesUdpSocket | |||
| ) |
Definition at line 245 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| OpenListenerBindsRequestedPort | |||
| ) |
Definition at line 257 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| OpenListenerRejectsOccupiedPort | |||
| ) |
Definition at line 279 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| OpenRejectsInvalidIpv4Address | |||
| ) |
Definition at line 269 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::IsOpen(), and profinet::rpc::RpcTransport::Open().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| OpenUpdatesEndpointWhenTransportIsAlreadyOpen | |||
| ) |
Definition at line 297 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::IsOpen(), profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::Send().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveFailsWhenTransportIsClosed | |||
| ) |
Definition at line 343 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveRejectsNegativeTimeout | |||
| ) |
Definition at line 366 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveRejectsZeroTimeout | |||
| ) |
Definition at line 353 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveReturnsDatagramAndSenderEndpoint | |||
| ) |
Definition at line 323 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveThrowsOnTimeout | |||
| ) |
Definition at line 379 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveThrowsSystemErrorWhenSocketIsCancelled | |||
| ) |
Definition at line 392 of file test_rpcTransport.cpp.
References profinet::rpc::RpcTransport::Close(), ioContext, profinet::rpc::RpcTransport::Open(), profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| ReceiveUsesExternallyDrivenIoContext | |||
| ) |
A dedicated AsioIoContextRunner drives the io_context from another thread. The transport then starts its asynchronous receive operation and blocks synchronously until that operation completes.
This test is specifically intended to protect the execution model where RpcTransport schedules asynchronous work but does not call asio::io_context::run() or asio::io_context::restart() itself.
Definition at line 696 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), profinet::rpc::RpcTransport::Receive(), and remoteEndpoint.
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendFailsWhenTransportIsClosed | |||
| ) |
Definition at line 611 of file test_rpcTransport.cpp.
References ioContext, and profinet::rpc::RpcTransport::Send().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveFailsWhenTransportIsClosed | |||
| ) |
Definition at line 525 of file test_rpcTransport.cpp.
References ioContext, and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveRejectsNegativeTimeout | |||
| ) |
Definition at line 551 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveRejectsZeroTimeout | |||
| ) |
Definition at line 535 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveReturnsEchoResponse | |||
| ) |
Definition at line 460 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveThrowsOnTimeout | |||
| ) |
Definition at line 511 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveThrowsSystemErrorWhenSocketIsCancelled | |||
| ) |
Definition at line 567 of file test_rpcTransport.cpp.
References profinet::rpc::RpcTransport::Close(), ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendReceiveUsesExternallyDrivenIoContext | |||
| ) |
The transport and the test echo server use independent execution contexts. The transport's context is driven only by AsioIoContextRunner, proving that SendReceive() does not call io_context::run() internally.
Definition at line 484 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendReceive().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendToFailsWhenTransportIsClosed | |||
| ) |
Definition at line 437 of file test_rpcTransport.cpp.
References ioContext, and profinet::rpc::RpcTransport::SendTo().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendToReportsUnderlyingSocketError | |||
| ) |
Definition at line 448 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendTo().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendToTransmitsDatagramToSuppliedEndpoint | |||
| ) |
Definition at line 415 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::SendTo().
Here is the call graph for this function:| TEST_F | ( | RpcTransportTests | , |
| SendTransmitsDatagramWithoutWaiting | |||
| ) |
Definition at line 592 of file test_rpcTransport.cpp.
References ioContext, profinet::rpc::RpcTransport::Open(), and profinet::rpc::RpcTransport::Send().
Here is the call graph for this function: