55 tc->ports()->addEventPort( *mr1 );
56 tc->ports()->addPort( *mw1 );
60 t2->ports()->addPort( *mw2 );
83 signalled_port = port;
95 void testPortDataConnection();
96 void testPortBufferConnection();
97 void testPortDisconnected();
114 #define ASSERT_PORT_SIGNALLING(code, read_port) do { \ 115 signalled_port = 0; \ 117 rtos_disable_rt_warning(); \ 119 rtos_enable_rt_warning(); \ 120 BOOST_CHECK( read_port == signalled_port ); \ 128 BOOST_CHECK( mw1->connected() );
129 BOOST_CHECK( mr2->connected() );
134 BOOST_CHECK(
NoData == mr2->read(value) );
138 BOOST_CHECK( mr2->read(value) );
139 BOOST_CHECK_EQUAL( 1.0, value );
141 BOOST_CHECK( mr2->read(value) );
142 BOOST_CHECK_EQUAL( 2.0, value );
143 BOOST_CHECK(
OldData == mr2->read(value) );
153 BOOST_CHECK( mw1->connected() );
154 BOOST_CHECK( mr2->connected() );
159 BOOST_CHECK(
NoData == mr2->read(value) );
166 BOOST_CHECK( mr2->read(value) );
167 BOOST_CHECK_EQUAL( 1.0, value );
168 BOOST_CHECK( mr2->read(value) );
169 BOOST_CHECK_EQUAL( 2.0, value );
170 BOOST_CHECK( mr2->read(value) );
171 BOOST_CHECK_EQUAL( 3.0, value );
172 BOOST_CHECK(
OldData == mr2->read(value) );
179 BOOST_CHECK( !mw1->connected() );
180 BOOST_CHECK( !mr2->connected() );
199 policy.name_id =
"/data1";
200 BOOST_REQUIRE( mw1->createConnection(*mr2, policy) );
201 BOOST_CHECK( policy.name_id ==
"/data1" );
202 testPortDataConnection();
205 testPortDisconnected();
210 BOOST_REQUIRE( mw1->createConnection(*mr2, policy) );
211 testPortDataConnection();
214 testPortDisconnected();
222 BOOST_REQUIRE( mw1->createConnection(*mr2, policy) );
223 testPortBufferConnection();
226 testPortDisconnected();
234 BOOST_REQUIRE( mw1->createConnection(*mr2, policy) );
235 testPortBufferConnection();
239 testPortDisconnected();
248 policy.name_id =
"/data1";
249 BOOST_REQUIRE( mw1->createStream( policy ) );
250 BOOST_REQUIRE( mr2->createStream( policy ) );
251 testPortDataConnection();
254 testPortDisconnected();
259 BOOST_REQUIRE( mw1->createStream( policy ) );
260 BOOST_REQUIRE( mr2->createStream( policy ) );
261 testPortDataConnection();
264 testPortDisconnected();
269 policy.name_id =
"/buffer1";
270 BOOST_REQUIRE( mw1->createStream( policy ) );
271 BOOST_REQUIRE( mr2->createStream( policy ) );
272 testPortBufferConnection();
275 testPortDisconnected();
281 BOOST_REQUIRE( mw1->createStream( policy ) );
282 BOOST_REQUIRE( mr2->createStream( policy ) );
283 testPortBufferConnection();
286 testPortDisconnected();
294 policy.name_id =
"/data1";
295 BOOST_REQUIRE( mr2->createStream( policy ) == false );
296 BOOST_CHECK( mr2->connected() == false );
302 policy.name_id =
"/buffer1";
303 BOOST_REQUIRE( mr2->createStream( policy ) == false );
304 BOOST_CHECK( mr2->connected() == false );
314 policy.name_id =
"data1";
315 BOOST_REQUIRE( mr2->createStream( policy ) == false );
316 BOOST_CHECK( mr2->connected() == false );
322 policy.name_id =
"buffer1";
323 BOOST_REQUIRE( mw2->createStream( policy ) == false );
324 BOOST_CHECK( mw2->connected() == false );
334 std::vector<double> data(20, 3.33);
343 for(
int i=0; i != 20; ++i)
344 BOOST_CHECK_CLOSE( data[i], 3.33, 0.01);
348 policy.name_id =
"/vdata1";
357 data.resize(10, 6.66);
358 for(
unsigned int i=0; i != data.size(); ++i)
359 BOOST_CHECK_CLOSE( data[i], 6.66, 0.01);
367 data.resize(20, 0.0);
375 BOOST_CHECK_EQUAL( data.size(), 10);
376 BOOST_CHECK_EQUAL( data.capacity(), 20);
377 for(
unsigned int i=0; i != data.size(); ++i)
378 BOOST_CHECK_CLOSE( data[i], 6.66, 0.01);
void setDataSample(const T &sample)
base::PortInterface & addPort(const std::string &name, base::PortInterface &port)
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
#define BOOST_AUTO_TEST_SUITE_END()
void testPortDisconnected()
int usleep(unsigned int us)
void testPortBufferConnection()
InputPort< double > * mr2
void rtos_disable_rt_warning()
BOOST_AUTO_TEST_CASE(testPortConnections)
#define ASSERT_PORT_SIGNALLING(code, read_port)
InputPort< double > * mr1
virtual bool createStream(ConnPolicy const &policy)
WriteStatus write(const T &sample)
static const int LOCK_FREE
OutputPort< double > * mw1
OutputPort< double > * mw2
void new_data_listener(PortInterface *port)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
PortInterface * signalled_port
PortInterface & doc(const std::string &desc)
void testPortDataConnection()
void rtos_enable_rt_warning()
T getLastWrittenValue() const
#define ORO_MQUEUE_PROTOCOL_ID