Commit 9f61b4c8 authored by gejun's avatar gejun

fix warnings/errors of UT in fedora 26

parent 0ae9fe7c
syntax="proto2";
package addressbook;
message Person {
required string name = 1;
......
syntax="proto2";
message Ext {
optional fixed32 age = 2;
required bytes databyte = 3;
......
syntax="proto2";
message ExtEncDec {
optional fixed32 Aa_ge_Z040_ = 2;
optional bytes databyte_Z040_std_Z058__Z058_string_Z041_ = 3;
......
syntax="proto2";
message AddressNoMap {
required string addr = 1;
}
......
......@@ -43,7 +43,6 @@ void SendRpcResponse(int64_t correlation_id, Controller* cntl,
} // policy
} // brpc
namespace {
int main(int argc, char* argv[]) {
brpc::FLAGS_idle_timeout_second = 0;
brpc::FLAGS_max_connection_pool_size = 0;
......@@ -52,6 +51,7 @@ int main(int argc, char* argv[]) {
return RUN_ALL_TESTS();
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
......
......@@ -27,11 +27,6 @@ int main(int argc, char* argv[]) {
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -40,11 +40,6 @@ int main(int argc, char* argv[]) {
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -28,11 +28,6 @@ int main(int argc, char* argv[]) {
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -29,11 +29,6 @@ int main(int argc, char* argv[]) {
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -21,11 +21,6 @@
#include "echo.pb.h"
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -28,11 +28,6 @@ int main(int argc, char* argv[]) {
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -18,17 +18,6 @@ DECLARE_int32(max_connection_pool_size);
namespace {
butil::EndPoint g_endpoint;
int main(int argc, char* argv[]) {
butil::str2endpoint("127.0.0.1:12345", &g_endpoint);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
void* worker(void*) {
const int ROUND = 2;
......@@ -136,3 +125,9 @@ TEST_F(SocketMapTest, max_pool_size) {
}
}
} //namespace
int main(int argc, char* argv[]) {
butil::str2endpoint("127.0.0.1:12345", &g_endpoint);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
......@@ -28,11 +28,6 @@ int main(int argc, char* argv[]) {
}
namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
return NULL;
}
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
......
......@@ -456,10 +456,7 @@ TEST(URITest, query_remover_no_modify) {
++qr;
++qr;
ASSERT_FALSE(qr);
ASSERT_EQ(qr.modified_query(), "key1=value1&key2=value2&key3=value3");
// if the query string is not modified, the returned value
// should be a reference to the original string
ASSERT_EQ(qr.modified_query().data(), query.data());
ASSERT_EQ(qr.modified_query(), query);
}
TEST(URITest, query_remover_key_value_not_changed_after_modified_query) {
......
......@@ -43,7 +43,7 @@ void* joiner(void* arg) {
LOG(FATAL) << "fail to join thread_" << th - (bthread_t*)arg;
}
long elp = butil::gettimeofday_us() - t1;
EXPECT_LE(labs(elp - (th - (bthread_t*)arg + 1) * 100000L), 5000L)
EXPECT_LE(labs(elp - (th - (bthread_t*)arg + 1) * 100000L), 10000L)
<< "timeout when joining thread_" << th - (bthread_t*)arg;
LOG(INFO) << "Joined thread " << *th << " at " << elp << "us ["
<< bthread_self() << "]";
......
......@@ -25,15 +25,6 @@ std::vector<long> wake_time;
volatile bool stop = false;
const long SIGNAL_INTERVAL_US = 10000;
std::ostream& operator<<(std::ostream& os,
const std::vector<bthread_t>& wake_tid) {
for (size_t i = 0; i < wake_tid.size(); ++i) {
os << i << ":" << wake_tid[i] << ' ';
}
return os;
}
void* signaler(void* void_arg) {
Arg* a = (Arg*)void_arg;
signal_start_time = butil::gettimeofday_us();
......@@ -105,7 +96,7 @@ TEST(CondTest, sanity) {
long delta = wake_time[i] - last_time - SIGNAL_INTERVAL_US;
EXPECT_GT(wake_time[i], last_time);
square_sum += delta * delta;
EXPECT_LT(abs(delta), 2000L) << "error[" << i << "]=" << delta << "="
EXPECT_LT(labs(delta), 2000L) << "error[" << i << "]=" << delta << "="
<< wake_time[i] << " - " << last_time;
}
printf("Average error is %fus\n", sqrt(square_sum / std::max(nbeforestop, 1UL)));
......@@ -118,7 +109,7 @@ TEST(CondTest, sanity) {
EXPECT_EQ(NW, count.size());
for (size_t i = 0; i < NW; ++i) {
}
size_t avg_count = wake_tid.size() / count.size();
int avg_count = (int)(wake_tid.size() / count.size());
for (std::map<bthread_t, int>::iterator
it = count.begin(); it != count.end(); ++it) {
ASSERT_LE(abs(it->second - avg_count), 1)
......
......@@ -70,8 +70,6 @@ TEST_F(ExecutionQueueTest, single_thread) {
ASSERT_TRUE(stopped);
}
const static int OPS_PER_THREAD = 1000000;
struct PushArg {
bthread::ExecutionQueueId<LongIntTask> id;
butil::atomic<int64_t> total_num;
......
......@@ -160,7 +160,7 @@ TEST(PingPongTest, ping_pong) {
if (!FLAGS_use_futex && !FLAGS_use_butex) {
// send the seed data.
char seed = 255;
unsigned char seed = 255;
ASSERT_EQ(1L, write(pipe1[1], &seed, 1));
} else if (FLAGS_use_futex) {
++*arg1->wait_addr;
......
......@@ -239,17 +239,6 @@ TEST_F(BthreadTest, bthread_join) {
ASSERT_EQ(0, bthread_start_urgent(&th, NULL, join_self, NULL));
}
void* small_func(void*) {
LOG(INFO) << "hello";
return NULL;
}
void* small_but_sleep_awhile_func(void*) {
LOG(INFO) << "hello2";
bthread_usleep(1000);
return NULL;
}
void* change_errno(void* arg) {
errno = (intptr_t)arg;
return NULL;
......
......@@ -21,8 +21,12 @@ namespace bvar {
DECLARE_bool(bvar_log_dumpped);
}
namespace {
// overloading for operator<< does not work for gflags>=2.1
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
std::string vec2string(const std::vector<T>& vec) {
std::ostringstream os;
os << '[';
if (!vec.empty()) {
os << vec[0];
......@@ -31,10 +35,9 @@ std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
}
}
os << ']';
return os;
return os.str();
}
namespace {
class VariableTest : public testing::Test {
protected:
void SetUp() {
......@@ -307,7 +310,7 @@ TEST_F(VariableTest, latency_recorder) {
std::vector<std::string> names;
bvar::Variable::list_exposed(&names);
std::sort(names.begin(), names.end());
ASSERT_EQ(11UL, names.size()) << names;
ASSERT_EQ(11UL, names.size()) << vec2string(names);
ASSERT_EQ("foo_bar_count", names[0]);
ASSERT_EQ("foo_bar_latency", names[1]);
ASSERT_EQ("foo_bar_latency_50", names[2]);
......
......@@ -176,15 +176,6 @@ TEST_F(FlatMapTest, seek_by_string_piece) {
ASSERT_TRUE(m.seek(k3) == NULL);
}
inline int my_strcaseequal(const char* s1, const char* s2, size_t n) {
for (size_t i = 0; i < n; ++i) {
if (butil::ascii_tolower(s1[i]) != butil::ascii_tolower(s2[i])) {
return -1;
}
}
return 0;
}
TEST_F(FlatMapTest, to_lower) {
for (int c = -128; c < 128; ++c) {
ASSERT_EQ((char)::tolower(c), butil::ascii_tolower(c)) << "c=" << c;
......
......@@ -1324,7 +1324,7 @@ void* cut_into_fd(void* arg) {
butil::IOBuf out;
out.append(&to_write, sizeof(int));
CHECK_EQ(out.pcut_into_file_descriptor(fd, offset + sizeof(int) * i),
sizeof(int));
(ssize_t)sizeof(int));
}
return NULL;
}
......
syntax="proto2";
package gss.message;
//------------------------------------gss_src_req_t---------------------------------
......
syntax="proto2";
message Dummy {}
message RepeatedMessage {
......
......@@ -155,6 +155,11 @@ TEST(SecurityTest, TCMALLOC_TEST(MemoryAllocationRestrictionsNewArray)) {
#define DISABLE_ON_IOS_AND_WIN_AND_TSAN(function) function
#endif
// FIXME(gejun): following logic of the case, it definitely should crash, I don't
// know why it's judged as failure.
#if defined(FixedNewOverflow)
// There are platforms where these tests are known to fail. We would like to
// be able to easily check the status on the bots, but marking tests as
// FAILS_ is too clunky.
......@@ -173,9 +178,6 @@ void OverflowTestsSoftExpectTrue(bool overflow_detected) {
}
}
// FIXME(gejun): following logic of the case, it definitely should crash, I don't
// know why it's judged as failure.
#if defined(FixedNewOverflow)
// Test array[TooBig][X] and array[X][TooBig] allocations for int overflows.
// IOS doesn't honor nothrow, so disable the test there.
// Crashes on Windows Dbg builds, disable there as well.
......
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