YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
simulated_network_delayTest.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026-2026 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7#include <yarp/os/Network.h>
8#include <yarp/os/LogStream.h>
9#include <yarp/os/Time.h>
10#include <yarp/os/Port.h>
11#include <yarp/os/Carriers.h>
12
14
15#include <array>
16#include <thread>
17
18#include <catch2/catch_amalgamated.hpp>
19#include <harness.h>
20
21TEST_CASE("pm::simulated_network_delayTest", "[yarp::pm]")
22{
23 YARP_REQUIRE_PLUGIN("simulated_network_delay", "portmonitor")
24
26
28
29 REQUIRE(yarp::os::Carriers::getCarrierTemplate("portmonitor") != nullptr);
30
32
33 auto tc = GENERATE(
34 "fast_tcp",
35 "fast_tcp+send.portmonitor+file.simulated_network_delay+delay_ms.10+type.dll"
36 );
37
38 SECTION("Test that normally the portmonitor is not used")
39 {
40 yarp::os::Port sender;
41 yarp::os::Port receiver;
42
43 sender.open("/send");
44 receiver.open("/recv");
45
46 bool b = yarp::os::Network::connect("/send", "/recv", tc);
47 REQUIRE(b);
48
49 yarp::os::Value val(10);
50 sender.write(val);
51
53
54 yarp::os::Value recv;
55
56 receiver.read(recv);
57 CHECK(recv.asInt16()== 10);
58
59 receiver.close();
60 sender.close();
61 }
62
64}
static Carrier * getCarrierTemplate(const std::string &name)
Get template for carrier.
Definition Carriers.cpp:238
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition Network.cpp:784
static bool setLocalMode(bool flag)
Chooses whether communication is process-local.
Definition Network.cpp:1137
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:718
A mini-server for network communication.
Definition Port.h:46
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition Port.cpp:395
bool read(PortReader &reader, bool willReply=false) override
Read an object from the port.
Definition Port.cpp:440
void close() override
Stop port activity.
Definition Port.cpp:330
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition Port.cpp:79
A single value (typically within a Bottle).
Definition Value.h:44
virtual std::int16_t asInt16() const
Get 16-bit integer value.
Definition Value.cpp:198
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
@ YARP_CLOCK_SYSTEM
Definition Time.h:28
The main, catch-all namespace for YARP.
Definition dirs.h:16
TEST_CASE("pm::simulated_network_delayTest", "[yarp::pm]")