25 #include <cppunit/ui/text/TestRunner.h> 26 #include <cppunit/TextOutputter.h> 27 #include <cppunit/extensions/TestFactoryRegistry.h> 28 #include <cppunit/extensions/HelperMacros.h> 29 #include <cppunit/TestAssert.h> 32 #include <coil/Task.h> 33 #include <coil/Time.h> 42 :
public CppUnit::TestFixture ,
68 for (ic=0; ic<256; ic++)
109 std::cout<<
"/"<<std::endl;
113 if(m_statflag !=
true)
117 m_threadcnt[m_tasknumber-1]++;
121 std::cout<<
"/"<<std::endl;
122 for(ic=0;ic<10;ic++){
146 CPPUNIT_ASSERT_MESSAGE(
"open", (iret == 0) );
150 CPPUNIT_ASSERT_MESSAGE(
"close", (iret == 0) );
163 time_t tmstart, tmend;
166 if ( m_statflag ==
true )
173 for (ic=0; ic<10; ic++)
181 if(difftime(tmend,tmstart)>=1.0)
186 sprintf(cstr,
"counter:%d ", m_tasknumber);
188 CPPUNIT_ASSERT_MESSAGE(cstr , (m_tasknumber == 1) );
202 time_t tmstart, tmend;
205 if ( m_statflag ==
true )
212 for (ic=0; ic<10; ic++)
220 if(difftime(tmend,tmstart)>=1.0)
225 sprintf(cstr,
"m_tasknumber:%d (ic+1):%d", m_tasknumber,ic+1);
227 CPPUNIT_ASSERT_MESSAGE(cstr , (m_tasknumber == ic+1) );
255 CPPUNIT_ASSERT_MESSAGE(
"suspend", (iret == 0) );
268 CPPUNIT_ASSERT_MESSAGE(
"resume", (iret == 0) );
279 int main(
int argc,
char* argv[])
281 CppUnit::TextUi::TestRunner runner;
282 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
283 CppUnit::Outputter* outputter =
284 new CppUnit::TextOutputter(&runner.result(), std::cout);
285 runner.setOutputter(outputter);
int main(int argc, char **argv)
int svc(void)
Execute thread.
virtual void tearDown()
Test finalization.
virtual int wait(void)
Waiting for the thread terminate.
virtual int suspend(void)
Suspending the task.
virtual int resume(void)
Resuming the suspended task.
virtual void setUp()
Test initialization.
CPPUNIT_TEST(test_open_close)
void test_activate2()
activate()
std::string sprintf(char const *__restrict fmt,...)
Convert it into a format given with an argumen.
virtual int open(void *args=0)
Task open.
CPPUNIT_TEST_SUITE_REGISTRATION(Task::TaskTests)
virtual int close(unsigned long flags=0)
Task close.
CPPUNIT_TEST_SUITE(TaskTests)
virtual void activate()
Create a thread.