Commit 9cce98de authored by gejun's avatar gejun

Remove warnings on abs under clang

parent 9e71ef74
......@@ -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(labs(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(labs(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(labs(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(labs(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(labs(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(labs(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(labs(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(labs(tm.m_elapsed() - cntl.timeout_ms()), 10);
StopAndJoin();
}
......
......@@ -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(labs(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(labs(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(labs(timer.m_elapsed() - 100) < 10) << timer.m_elapsed();
bthread_join(tid, NULL);
}
}
......
......@@ -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(labs(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(labs(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(labs(tm.m_elapsed() - SLEEP_MSEC), 15);
} else {
ASSERT_LT(abs(tm.m_elapsed() - WAIT_MSEC), 15);
ASSERT_LT(labs(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(labs(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(labs(tm.m_elapsed() - SLEEP_MSEC), 10);
} else {
ASSERT_LT(tm.m_elapsed(), 10);
}
......
......@@ -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) {
......
......@@ -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(labs(tm.m_elapsed() - 10), 5);
}
TEST_F(BthreadTest, bthread_exit) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment