Skip to content
Snippets Groups Projects
Commit 2c83d92a authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#4123] Update outgoing IP2IP sip call unit test

parent 9196c0fb
No related branches found
No related tags found
No related merge requests found
...@@ -76,8 +76,9 @@ void SIPTest::tearDown() ...@@ -76,8 +76,9 @@ void SIPTest::tearDown()
// in order to stop any currently running threads // in order to stop any currently running threads
std::cout << "SIPTest: Clean all remaining sipp instances" << std::endl; std::cout << "SIPTest: Clean all remaining sipp instances" << std::endl;
system("killall sipp"); int ret = system("killall sipp");
if(!ret)
std::cout << "SIPTest: Error from system call, killall sipp" << std::endl;
} }
...@@ -86,7 +87,7 @@ void SIPTest::testSimpleOutgoingIpCall () ...@@ -86,7 +87,7 @@ void SIPTest::testSimpleOutgoingIpCall ()
pthread_t thethread; pthread_t thethread;
void *status; void *status;
// command to be executed by the thread // command to be executed by the thread, user agent server waiting for a call
std::string command("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1"); std::string command("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1");
int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command)); int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
...@@ -147,7 +148,7 @@ void SIPTest::testSimpleIncomingIpCall () ...@@ -147,7 +148,7 @@ void SIPTest::testSimpleIncomingIpCall ()
pthread_t thethread; pthread_t thethread;
void *status; void *status;
// command to be executed by the thread // command to be executed by the thread, user agent client which initiate a call and hangup
std::string command("sipp -sn uac 127.0.0.1 -i 127.0.0.1 -p 5062 -m 1"); std::string command("sipp -sn uac 127.0.0.1 -i 127.0.0.1 -p 5062 -m 1");
int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command)); int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
...@@ -155,23 +156,53 @@ void SIPTest::testSimpleIncomingIpCall () ...@@ -155,23 +156,53 @@ void SIPTest::testSimpleIncomingIpCall ()
std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl; std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
} }
// sleep a while to make sure that sipp insdtance is initialized and sflphoned received // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
// the incoming invite. // the incoming invite.
sleep(2); sleep(2);
// gtrab call id from sipvoiplink
SIPVoIPLink *siplink = SIPVoIPLink::instance (""); SIPVoIPLink *siplink = SIPVoIPLink::instance ("");
CPPUNIT_ASSERT(siplink->_callMap.size() == 1); CPPUNIT_ASSERT(siplink->_callMap.size() == 1);
CallMap::iterator iterCallId = siplink->_callMap.begin(); CallMap::iterator iterCallId = siplink->_callMap.begin();
std::string testcallid = iterCallId->first;
// TODO: hmmm, should IP2IP call be stored in call list.... // TODO: hmmm, should IP2IP call be stored in call list....
CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 0); CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 0);
std::string testcallid = iterCallId->first; // Answer this call
CPPUNIT_ASSERT(Manager::instance().answerCall(testcallid)); CPPUNIT_ASSERT(Manager::instance().answerCall(testcallid));
sleep(2); // This is useless since manager is not aware of incoming IP2IP sip calls
/*
sleep(1);
std::map<std::string, std::string>::iterator iterCallDetails;
std::map<std::string, std::string> callDetails = Manager::instance().getCallDetails (testcallid);
iterCallDetails = callDetails.find("ACCOUNTID");
std::cout << "---------------------- " << iterCallDetails->second << std::endl;
// CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == ""));
iterCallDetails = callDetails.find("PEER_NUMBER");
std::cout << "--------------------- " << iterCallDetails->second << std::endl;
// CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "<sip:test@127.0.0.1:5062>"));
iterCallDetails = callDetails.find("PEER_NAME");
std::cout << "--------------------- " << iterCallDetails->second << std::endl;
// CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == ""));
iterCallDetails = callDetails.find("DISPLAY_NAME");
std::cout << "-------------------- " << iterCallDetails->second << std::endl;
// CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == ""));
iterCallDetails = callDetails.find("CALL_STATE");
std::cout << "-------------------- " << iterCallDetails->second << std::endl;
// CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "CURRENT"));
iterCallDetails = callDetails.find("CALL_TYPE");
std::cout << "-------------------- " << iterCallDetails->second << std::endl;
// CPPUNIT_ASSERT((iterCallDetails != callDetails.end()) && (iterCallDetails->second == "1"));
*/
sleep(1);
rc = pthread_join(thethread, &status); rc = pthread_join(thethread, &status);
if (rc) { if (rc) {
...@@ -179,5 +210,4 @@ void SIPTest::testSimpleIncomingIpCall () ...@@ -179,5 +210,4 @@ void SIPTest::testSimpleIncomingIpCall ()
} }
else else
std::cout << "SIPTest: completed join with thread" << std::endl; std::cout << "SIPTest: completed join with thread" << std::endl;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment