28 #include <rtt-config.h> 32 #include <boost/test/unit_test.hpp> 33 #include <boost/test/floating_point_comparison.hpp> 64 assert(0 != fd_activity);
66 fd_activity->
watch(fd[0]);
85 assert(0 != fd_activity);
103 int rc = read(fd[0], &ch,
sizeof(ch));
114 if (-1 != fd[0]) close(fd[0]);
115 if (-1 != fd[1]) close(fd[1]);
132 BOOST_CHECK( mtask.
isActive() == false );
133 BOOST_CHECK( mtask.
isRunning() == false );
145 BOOST_CHECK( mtask.
thread() != m2task.thread() );
148 BOOST_CHECK( mtask.
start() == true );
149 BOOST_CHECK( mtask.
isRunning() == false );
150 BOOST_CHECK( m2task.isRunning() == false );
151 BOOST_CHECK( m2task.start() == true );
152 BOOST_CHECK( m2task.isRunning() == false );
157 BOOST_CHECK( mtask.
stop() == true );
158 BOOST_CHECK( mtask.
isRunning() == false );
159 BOOST_CHECK( m2task.isRunning() == false );
160 BOOST_CHECK( m2task.stop() == true );
161 BOOST_CHECK( m2task.isRunning() == false );
164 BOOST_CHECK( mtask.
thread()->
stop() == false );
166 BOOST_CHECK( mtask.
start() );
167 BOOST_CHECK( mtask.
isRunning() == false );
179 BOOST_CHECK( mtask->
hasError() == false );
182 BOOST_CHECK( mcomp.
configure() == true );
183 BOOST_CHECK( mtask->
isWatched(mcomp.
fd[0]) == true );
185 BOOST_CHECK( mcomp.
start() == true );
186 BOOST_CHECK( mtask->
hasError() == false );
197 rc = write(mcomp.
fd[1], &ch,
sizeof(ch));
198 if (1 != rc) std::cerr <<
"rc=" << rc <<
" errno=" << errno <<
":" << strerror(errno) <<
std::endl;
199 BOOST_CHECK_EQUAL( 1, rc );
207 rc = write(mcomp.
fd[1], &ch,
sizeof(ch));
208 if (1 != rc) std::cerr <<
"rc=" << rc <<
" errno=" << errno <<
":" << strerror(errno) <<
std::endl;
209 BOOST_CHECK_EQUAL( 1, rc );
217 BOOST_CHECK( mtask->
isWatched(mcomp.
fd[0]) == true );
219 BOOST_CHECK( mtask->
isWatched(mcomp.
fd[0]) == false );
222 rc = write(mcomp.
fd[1], &ch,
sizeof(ch));
223 if (1 != rc) std::cerr <<
"rc=" << rc <<
" errno=" << errno <<
":" << strerror(errno) <<
std::endl;
224 BOOST_CHECK_EQUAL( 1, rc );
233 (void)close(mcomp.
fd[1]);
243 BOOST_CHECK( mtask->
stop() == true );
248 if(std::getenv(
"CI") != NULL) {
249 BOOST_TEST_MESSAGE(
"Skipping testFileDescriptor_Timeout because it can fail on integration servers.");
258 static const int RATE = 10;
259 static const int timeout_ms = 1000 / RATE;
261 BOOST_CHECK( mcomp.
configure() == true );
263 BOOST_CHECK( timeout_ms == mtask->
getTimeout() );
264 BOOST_CHECK( mcomp.
start() == true );
267 usleep(1000000 / RATE * 4.5);
274 rc = write(mcomp.
fd[1], &ch,
sizeof(ch));
275 if (1 != rc) std::cerr <<
"rc=" << rc <<
" errno=" << errno <<
":" << strerror(errno) <<
std::endl;
276 BOOST_CHECK_EQUAL( 1, rc );
277 usleep(1000000 / RATE * 1.5);
284 usleep(1000000 / RATE * 3);
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
virtual void cleanupHook()
virtual int getScheduler() const =0
virtual int getPriority() const =0
virtual void updateHook()
virtual bool configureHook()
virtual os::ThreadInterface * thread()
#define BOOST_AUTO_TEST_SUITE_END()
virtual bool isRunning() const =0
int usleep(unsigned int us)
bool CheckPriority(int &sched_type, int &priority)
bool setActivity(base::ActivityInterface *new_act)
virtual Seconds getPeriod() const =0
TestFileDescriptor(std::string name)
basic_ostreams & endl(basic_ostreams &s)
virtual ~TestFileDescriptor()
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual bool isActive() const
base::ActivityInterface * getActivity()
BOOST_AUTO_TEST_CASE(testFileDescriptor)