Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
ac4a8a89
Commit
ac4a8a89
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#4123] Move thread init from Unit test setUp to test method itself
parent
f4ba5dac
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/test/siptest.cpp
+20
-32
20 additions, 32 deletions
sflphone-common/test/siptest.cpp
sflphone-common/test/siptest.h
+2
-2
2 additions, 2 deletions
sflphone-common/test/siptest.h
with
22 additions
and
34 deletions
sflphone-common/test/siptest.cpp
+
20
−
32
View file @
ac4a8a89
...
@@ -42,12 +42,6 @@
...
@@ -42,12 +42,6 @@
using
std
::
cout
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
endl
;
pthread_t
thethread
;
void
*
sippThread
(
void
*
str
)
void
*
sippThread
(
void
*
str
)
{
{
...
@@ -66,8 +60,6 @@ void *sippThread(void *str)
...
@@ -66,8 +60,6 @@ void *sippThread(void *str)
CPPUNIT_ASSERT
(
i
==
0
);
CPPUNIT_ASSERT
(
i
==
0
);
delete
command
;
pthread_exit
(
NULL
);
pthread_exit
(
NULL
);
}
}
...
@@ -76,36 +68,29 @@ void *sippThread(void *str)
...
@@ -76,36 +68,29 @@ void *sippThread(void *str)
void
SIPTest
::
setUp
()
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
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"
);
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
::
testSimple
Outgoing
IpCall
()
{
{
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
testaccount
(
"IP2IP"
);
std
::
string
testcallid
(
"callid1234"
);
std
::
string
testcallid
(
"callid1234"
);
...
@@ -119,11 +104,10 @@ void SIPTest::testSimpleIpCall ()
...
@@ -119,11 +104,10 @@ void SIPTest::testSimpleIpCall ()
// must sleep here until receiving 180 and 200 message from peer
// must sleep here until receiving 180 and 200 message from peer
sleep
(
2
);
sleep
(
2
);
// call list should be empty for outgoing calls, only used for incoming calls
CPPUNIT_ASSERT
(
Manager
::
instance
().
getCallList
().
size
()
==
1
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getCallList
().
size
()
==
0
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
hasCurrentCall
());
CPPUNIT_ASSERT
(
Manager
::
instance
().
hasCurrentCall
());
CPPUNIT_ASSERT
(
Manager
::
instance
().
getCurrentCallId
()
==
testcallid
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getCurrentCallId
()
==
testcallid
);
std
::
map
<
std
::
string
,
std
::
string
>::
iterator
iterCallDetails
;
std
::
map
<
std
::
string
,
std
::
string
>::
iterator
iterCallDetails
;
...
@@ -144,8 +128,12 @@ void SIPTest::testSimpleIpCall ()
...
@@ -144,8 +128,12 @@ void SIPTest::testSimpleIpCall ()
Manager
::
instance
().
hangupCall
(
testcallid
);
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
;
}
This diff is collapsed.
Click to expand it.
sflphone-common/test/siptest.h
+
2
−
2
View file @
ac4a8a89
...
@@ -53,7 +53,7 @@ class SIPTest : public CppUnit::TestCase {
...
@@ -53,7 +53,7 @@ class SIPTest : public CppUnit::TestCase {
* Use cppunit library macros to add unit test the factory
* Use cppunit library macros to add unit test the factory
*/
*/
CPPUNIT_TEST_SUITE
(
SIPTest
);
CPPUNIT_TEST_SUITE
(
SIPTest
);
CPPUNIT_TEST
(
testSimpleIpCall
);
CPPUNIT_TEST
(
testSimple
Outgoing
IpCall
);
CPPUNIT_TEST_SUITE_END
();
CPPUNIT_TEST_SUITE_END
();
public:
public:
...
@@ -72,7 +72,7 @@ class SIPTest : public CppUnit::TestCase {
...
@@ -72,7 +72,7 @@ class SIPTest : public CppUnit::TestCase {
inline
void
tearDown
();
inline
void
tearDown
();
void
testSimpleIpCall
(
void
);
void
testSimple
Outgoing
IpCall
(
void
);
private
:
private
:
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment