Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
9cce98de
Commit
9cce98de
authored
Oct 24, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove warnings on abs under clang
parent
9e71ef74
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
20 deletions
+18
-20
brpc_channel_unittest.cpp
test/brpc_channel_unittest.cpp
+8
-8
brpc_server_unittest.cpp
test/brpc_server_unittest.cpp
+3
-3
bthread_butex_unittest.cpp
test/bthread_butex_unittest.cpp
+6
-6
bthread_cond_unittest.cpp
test/bthread_cond_unittest.cpp
+0
-2
bthread_unittest.cpp
test/bthread_unittest.cpp
+1
-1
No files found.
test/brpc_channel_unittest.cpp
View file @
9cce98de
...
...
@@ -854,7 +854,7 @@ protected:
tm
.
start
();
CallMethod
(
&
channel
,
&
cntl
,
&
req
,
&
res
,
async
);
tm
.
stop
();
EXPECT_LT
(
abs
(
tm
.
u_elapsed
()
-
carg
.
sleep_before_cancel_us
),
10000
);
EXPECT_LT
(
l
abs
(
tm
.
u_elapsed
()
-
carg
.
sleep_before_cancel_us
),
10000
);
ASSERT_EQ
(
0
,
pthread_join
(
th
,
NULL
));
EXPECT_EQ
(
ECANCELED
,
cntl
.
ErrorCode
());
EXPECT_EQ
(
0
,
cntl
.
sub_count
());
...
...
@@ -895,14 +895,14 @@ protected:
tm
.
start
();
CallMethod
(
&
channel
,
&
cntl
,
&
req
,
&
res
,
async
);
tm
.
stop
();
EXPECT_LT
(
abs
(
tm
.
u_elapsed
()
-
carg
.
sleep_before_cancel_us
),
10000
);
EXPECT_LT
(
l
abs
(
tm
.
u_elapsed
()
-
carg
.
sleep_before_cancel_us
),
10000
);
ASSERT_EQ
(
0
,
pthread_join
(
th
,
NULL
));
EXPECT_EQ
(
ECANCELED
,
cntl
.
ErrorCode
());
EXPECT_EQ
(
NCHANS
,
(
size_t
)
cntl
.
sub_count
());
for
(
int
i
=
0
;
i
<
cntl
.
sub_count
();
++
i
)
{
EXPECT_EQ
(
ECANCELED
,
cntl
.
sub
(
i
)
->
ErrorCode
())
<<
"i="
<<
i
;
}
EXPECT_LT
(
abs
(
cntl
.
latency_us
()
-
carg
.
sleep_before_cancel_us
),
10000
);
EXPECT_LT
(
l
abs
(
cntl
.
latency_us
()
-
carg
.
sleep_before_cancel_us
),
10000
);
StopAndJoin
();
}
...
...
@@ -937,7 +937,7 @@ protected:
tm
.
start
();
CallMethod
(
&
channel
,
&
cntl
,
&
req
,
&
res
,
async
);
tm
.
stop
();
EXPECT_LT
(
abs
(
tm
.
u_elapsed
()
-
carg
.
sleep_before_cancel_us
),
10000
);
EXPECT_LT
(
l
abs
(
tm
.
u_elapsed
()
-
carg
.
sleep_before_cancel_us
),
10000
);
ASSERT_EQ
(
0
,
pthread_join
(
th
,
NULL
));
EXPECT_EQ
(
ECANCELED
,
cntl
.
ErrorCode
());
EXPECT_EQ
(
1
,
cntl
.
sub_count
());
...
...
@@ -1120,7 +1120,7 @@ protected:
CallMethod
(
&
channel
,
&
cntl
,
&
req
,
&
res
,
async
);
tm
.
stop
();
EXPECT_EQ
(
brpc
::
ERPCTIMEDOUT
,
cntl
.
ErrorCode
())
<<
cntl
.
ErrorText
();
EXPECT_LT
(
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
EXPECT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
StopAndJoin
();
}
...
...
@@ -1156,7 +1156,7 @@ protected:
for
(
int
i
=
0
;
i
<
cntl
.
sub_count
();
++
i
)
{
EXPECT_EQ
(
ECANCELED
,
cntl
.
sub
(
i
)
->
ErrorCode
())
<<
"i="
<<
i
;
}
EXPECT_LT
(
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
EXPECT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
StopAndJoin
();
}
...
...
@@ -1209,7 +1209,7 @@ protected:
EXPECT_EQ
(
0
,
cntl
.
sub
(
i
)
->
ErrorCode
());
}
}
EXPECT_LT
(
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
EXPECT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
StopAndJoin
();
}
...
...
@@ -1242,7 +1242,7 @@ protected:
EXPECT_EQ
(
brpc
::
ERPCTIMEDOUT
,
cntl
.
ErrorCode
())
<<
cntl
.
ErrorText
();
EXPECT_EQ
(
1
,
cntl
.
sub_count
());
EXPECT_EQ
(
brpc
::
ERPCTIMEDOUT
,
cntl
.
sub
(
0
)
->
ErrorCode
());
EXPECT_LT
(
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
EXPECT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
cntl
.
timeout_ms
()),
10
);
StopAndJoin
();
}
...
...
test/brpc_server_unittest.cpp
View file @
9cce98de
...
...
@@ -1043,7 +1043,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
ASSERT_EQ
(
0
,
server
.
Stop
(
-
1
));
ASSERT_EQ
(
0
,
server
.
Join
());
timer
.
stop
();
EXPECT_TRUE
(
abs
(
timer
.
m_elapsed
()
-
100
)
<
10
)
<<
timer
.
m_elapsed
();
EXPECT_TRUE
(
l
abs
(
timer
.
m_elapsed
()
-
100
)
<
10
)
<<
timer
.
m_elapsed
();
bthread_join
(
tid
,
NULL
);
}
...
...
@@ -1089,7 +1089,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
timer
.
stop
();
// Assertion will fail since EchoServiceImpl::Echo is holding
// additional reference to the `Socket'
// EXPECT_TRUE(abs(timer.m_elapsed() - 50) < 10) << timer.m_elapsed();
// EXPECT_TRUE(
l
abs(timer.m_elapsed() - 50) < 10) << timer.m_elapsed();
bthread_join
(
tid
,
NULL
);
}
...
...
@@ -1109,7 +1109,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
ASSERT_EQ
(
0
,
server
.
Stop
(
1000
));
ASSERT_EQ
(
0
,
server
.
Join
());
timer
.
stop
();
EXPECT_TRUE
(
abs
(
timer
.
m_elapsed
()
-
100
)
<
10
)
<<
timer
.
m_elapsed
();
EXPECT_TRUE
(
l
abs
(
timer
.
m_elapsed
()
-
100
)
<
10
)
<<
timer
.
m_elapsed
();
bthread_join
(
tid
,
NULL
);
}
}
...
...
test/bthread_butex_unittest.cpp
View file @
9cce98de
...
...
@@ -208,7 +208,7 @@ TEST(ButexTest, wait_without_stop) {
ASSERT_EQ
(
0
,
bthread_join
(
th
,
NULL
));
tm
.
stop
();
ASSERT_LT
(
abs
(
tm
.
m_elapsed
()
-
WAIT_MSEC
),
20
);
ASSERT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
WAIT_MSEC
),
20
);
}
bthread
::
butex_destroy
(
butex
);
}
...
...
@@ -232,7 +232,7 @@ TEST(ButexTest, stop_after_running) {
ASSERT_EQ
(
0
,
bthread_join
(
th
,
NULL
));
tm
.
stop
();
ASSERT_LT
(
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
10
);
ASSERT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
10
);
// ASSERT_TRUE(bthread::get_task_control()->
// timer_thread()._idset.empty());
ASSERT_EQ
(
EINVAL
,
bthread_stop
(
th
));
...
...
@@ -319,9 +319,9 @@ TEST(ButexTest, stop_after_slept) {
ASSERT_EQ
(
0
,
bthread_join
(
th
,
NULL
));
tm
.
stop
();
if
(
attr
.
stack_type
==
BTHREAD_STACKTYPE_PTHREAD
)
{
ASSERT_LT
(
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
15
);
ASSERT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
15
);
}
else
{
ASSERT_LT
(
abs
(
tm
.
m_elapsed
()
-
WAIT_MSEC
),
15
);
ASSERT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
WAIT_MSEC
),
15
);
}
// ASSERT_TRUE(bthread::get_task_control()->
// timer_thread()._idset.empty());
...
...
@@ -344,7 +344,7 @@ TEST(ButexTest, stop_just_when_sleeping) {
ASSERT_EQ
(
0
,
bthread_join
(
th
,
NULL
));
tm
.
stop
();
if
(
attr
.
stack_type
==
BTHREAD_STACKTYPE_PTHREAD
)
{
ASSERT_LT
(
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
15
);
ASSERT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
15
);
}
else
{
ASSERT_LT
(
tm
.
m_elapsed
(),
15
);
}
...
...
@@ -372,7 +372,7 @@ TEST(ButexTest, stop_before_sleeping) {
tm
.
stop
();
if
(
attr
.
stack_type
==
BTHREAD_STACKTYPE_PTHREAD
)
{
ASSERT_LT
(
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
10
);
ASSERT_LT
(
l
abs
(
tm
.
m_elapsed
()
-
SLEEP_MSEC
),
10
);
}
else
{
ASSERT_LT
(
tm
.
m_elapsed
(),
10
);
}
...
...
test/bthread_cond_unittest.cpp
View file @
9cce98de
...
...
@@ -108,8 +108,6 @@ TEST(CondTest, sanity) {
++
count
[
wake_tid
[
i
]];
}
EXPECT_EQ
(
NW
,
count
.
size
());
for
(
size_t
i
=
0
;
i
<
NW
;
++
i
)
{
}
int
avg_count
=
(
int
)(
wake_tid
.
size
()
/
count
.
size
());
for
(
std
::
map
<
bthread_t
,
int
>::
iterator
it
=
count
.
begin
();
it
!=
count
.
end
();
++
it
)
{
...
...
test/bthread_unittest.cpp
View file @
9cce98de
...
...
@@ -407,7 +407,7 @@ TEST_F(BthreadTest, stop_sleep) {
ASSERT_EQ
(
0
,
bthread_stop
(
th
));
ASSERT_EQ
(
0
,
bthread_join
(
th
,
NULL
));
tm
.
stop
();
ASSERT_LE
(
abs
(
tm
.
m_elapsed
()
-
10
),
5
);
ASSERT_LE
(
l
abs
(
tm
.
m_elapsed
()
-
10
),
5
);
}
TEST_F
(
BthreadTest
,
bthread_exit
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment