Fix some compilation bugs in different platforms
Summary: detect some problems when testing my 3rd party release tool.
This commit is contained in:
parent
99e4b40a55
commit
6ba1084f24
6
Makefile
6
Makefile
@ -12,6 +12,10 @@ OPT += -O2 -fno-omit-frame-pointer -momit-leaf-frame-pointer
|
|||||||
else
|
else
|
||||||
OPT += -fno-omit-frame-pointer -momit-leaf-frame-pointer
|
OPT += -fno-omit-frame-pointer -momit-leaf-frame-pointer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(MAKECMDGOALS),shared_lib)
|
||||||
|
PLATFORM_SHARED_LDFLAGS=-fPIC
|
||||||
|
endif
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
|
|
||||||
# detect what platform we're building on
|
# detect what platform we're building on
|
||||||
@ -135,7 +139,7 @@ $(SHARED2): $(SHARED3)
|
|||||||
ln -fs $(SHARED3) $(SHARED2)
|
ln -fs $(SHARED3) $(SHARED2)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(SHARED3): $(LIBOBJECTS)
|
$(SHARED3):
|
||||||
$(CXX) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(LDFLAGS) $(SOURCES) -o $@
|
$(CXX) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(LDFLAGS) $(SOURCES) -o $@
|
||||||
|
|
||||||
endif # PLATFORM_SHARED_EXT
|
endif # PLATFORM_SHARED_EXT
|
||||||
|
@ -245,7 +245,7 @@ TEST(AutoRollLoggerTest, InfoLogLevel) {
|
|||||||
InitTestDb();
|
InitTestDb();
|
||||||
|
|
||||||
size_t log_size = 8192;
|
size_t log_size = 8192;
|
||||||
int log_lines = 0;
|
size_t log_lines = 0;
|
||||||
// an extra-scope to force the AutoRollLogger to flush the log file when it
|
// an extra-scope to force the AutoRollLogger to flush the log file when it
|
||||||
// becomes out of scope.
|
// becomes out of scope.
|
||||||
{
|
{
|
||||||
@ -275,7 +275,7 @@ TEST(AutoRollLoggerTest, InfoLogLevel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::ifstream inFile(AutoRollLoggerTest::kLogFile.c_str());
|
std::ifstream inFile(AutoRollLoggerTest::kLogFile.c_str());
|
||||||
int lines = std::count(std::istreambuf_iterator<char>(inFile),
|
size_t lines = std::count(std::istreambuf_iterator<char>(inFile),
|
||||||
std::istreambuf_iterator<char>(), '\n');
|
std::istreambuf_iterator<char>(), '\n');
|
||||||
ASSERT_EQ(log_lines, lines);
|
ASSERT_EQ(log_lines, lines);
|
||||||
inFile.close();
|
inFile.close();
|
||||||
|
@ -103,7 +103,7 @@ TEST(ThreadLocalTest, UniqueIdTest) {
|
|||||||
|
|
||||||
TEST(ThreadLocalTest, SequentialReadWriteTest) {
|
TEST(ThreadLocalTest, SequentialReadWriteTest) {
|
||||||
// global id list carries over 3, 1, 2, 0
|
// global id list carries over 3, 1, 2, 0
|
||||||
ASSERT_EQ(IDChecker::PeekId(), 0);
|
ASSERT_EQ(IDChecker::PeekId(), 0u);
|
||||||
|
|
||||||
port::Mutex mu;
|
port::Mutex mu;
|
||||||
port::CondVar cv(&mu);
|
port::CondVar cv(&mu);
|
||||||
@ -133,7 +133,7 @@ TEST(ThreadLocalTest, SequentialReadWriteTest) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int iter = 0; iter < 1024; ++iter) {
|
for (int iter = 0; iter < 1024; ++iter) {
|
||||||
ASSERT_EQ(IDChecker::PeekId(), 1);
|
ASSERT_EQ(IDChecker::PeekId(), 1u);
|
||||||
// Another new thread, read/write should not see value from previous thread
|
// Another new thread, read/write should not see value from previous thread
|
||||||
env_->StartThread(func, static_cast<void*>(&p));
|
env_->StartThread(func, static_cast<void*>(&p));
|
||||||
mu.Lock();
|
mu.Lock();
|
||||||
@ -141,13 +141,13 @@ TEST(ThreadLocalTest, SequentialReadWriteTest) {
|
|||||||
cv.Wait();
|
cv.Wait();
|
||||||
}
|
}
|
||||||
mu.Unlock();
|
mu.Unlock();
|
||||||
ASSERT_EQ(IDChecker::PeekId(), 1);
|
ASSERT_EQ(IDChecker::PeekId(), 1u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ThreadLocalTest, ConcurrentReadWriteTest) {
|
TEST(ThreadLocalTest, ConcurrentReadWriteTest) {
|
||||||
// global id list carries over 3, 1, 2, 0
|
// global id list carries over 3, 1, 2, 0
|
||||||
ASSERT_EQ(IDChecker::PeekId(), 0);
|
ASSERT_EQ(IDChecker::PeekId(), 0u);
|
||||||
|
|
||||||
ThreadLocalPtr tls2;
|
ThreadLocalPtr tls2;
|
||||||
port::Mutex mu1;
|
port::Mutex mu1;
|
||||||
@ -226,11 +226,11 @@ TEST(ThreadLocalTest, ConcurrentReadWriteTest) {
|
|||||||
}
|
}
|
||||||
mu2.Unlock();
|
mu2.Unlock();
|
||||||
|
|
||||||
ASSERT_EQ(IDChecker::PeekId(), 3);
|
ASSERT_EQ(IDChecker::PeekId(), 3u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ThreadLocalTest, Unref) {
|
TEST(ThreadLocalTest, Unref) {
|
||||||
ASSERT_EQ(IDChecker::PeekId(), 0);
|
ASSERT_EQ(IDChecker::PeekId(), 0u);
|
||||||
|
|
||||||
auto unref = [](void* ptr) {
|
auto unref = [](void* ptr) {
|
||||||
auto& p = *static_cast<Params*>(ptr);
|
auto& p = *static_cast<Params*>(ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user