diff --git a/sflphone-common/test/siptest.cpp b/sflphone-common/test/siptest.cpp index 0c2915e56391b62220f223e3ac0c238fd416a6f3..a61b95721ca4af5852841c025d8f962373bf5459 100644 --- a/sflphone-common/test/siptest.cpp +++ b/sflphone-common/test/siptest.cpp @@ -42,12 +42,6 @@ using std::cout; using std::endl; -pthread_t thethread; - - - - - void *sippThread(void *str) { @@ -66,8 +60,6 @@ void *sippThread(void *str) CPPUNIT_ASSERT(i==0); - delete command; - pthread_exit(NULL); } @@ -75,38 +67,31 @@ void *sippThread(void *str) void SIPTest::setUp() { - - std::string *command = new std::string("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1"); - - int rc = pthread_create(&thethread, NULL, sippThread, (void *)command); - if (rc) { - std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl; - } } void SIPTest::tearDown() { - void *status; - + // in order to stop any currently running threads + std::cout << "SIPTest: Clean all remaining sipp instances" << std::endl; system("killall sipp"); - int rc = pthread_join(thethread, &status); - if (rc) { - std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl; - } - else - std::cout << " SIPTest: completed join with thread" << std::endl; - } -void SIPTest::testSimpleIpCall () +void SIPTest::testSimpleOutgoingIpCall () { + pthread_t thethread; + void *status; - + std::string command("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1"); + int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command)); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl; + } + std::string testaccount("IP2IP"); std::string testcallid("callid1234"); std::string testcallnumber("sip:test@127.0.0.1:5062"); @@ -119,11 +104,10 @@ void SIPTest::testSimpleIpCall () // must sleep here until receiving 180 and 200 message from peer sleep(2); - - CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 1); + // call list should be empty for outgoing calls, only used for incoming calls + CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 0); CPPUNIT_ASSERT(Manager::instance().hasCurrentCall()); - CPPUNIT_ASSERT(Manager::instance().getCurrentCallId() == testcallid); std::map<std::string, std::string>::iterator iterCallDetails; @@ -144,8 +128,12 @@ void SIPTest::testSimpleIpCall () Manager::instance().hangupCall(testcallid); -} - - + rc = pthread_join(thethread, &status); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl; + } + else + std::cout << "SIPTest: completed join with thread" << std::endl; +} diff --git a/sflphone-common/test/siptest.h b/sflphone-common/test/siptest.h index 7f110210492bf9beb03d92097b44e1afdb348816..11b48a44cc6d25fa353c4f104cd66787e3690b7c 100644 --- a/sflphone-common/test/siptest.h +++ b/sflphone-common/test/siptest.h @@ -53,7 +53,7 @@ class SIPTest : public CppUnit::TestCase { * Use cppunit library macros to add unit test the factory */ CPPUNIT_TEST_SUITE( SIPTest ); - CPPUNIT_TEST ( testSimpleIpCall ); + CPPUNIT_TEST ( testSimpleOutgoingIpCall ); CPPUNIT_TEST_SUITE_END(); public: @@ -72,7 +72,7 @@ class SIPTest : public CppUnit::TestCase { inline void tearDown (); - void testSimpleIpCall(void); + void testSimpleOutgoingIpCall(void); private: };