Commit 8c4554f8 authored by Jason S Zang's avatar Jason S Zang

Revert to obj lib for some tests that rely on differtly built non-test objects.…

Revert to obj lib for some tests that rely on differtly built non-test objects. Make ctest work right.
parent 2a1718e1
......@@ -391,6 +391,7 @@ set(SOURCES
add_subdirectory(src)
if(BUILD_UNIT_TESTS)
enable_testing()
add_subdirectory(test)
endif()
add_subdirectory(tools)
......
......@@ -179,28 +179,35 @@ target_link_libraries(test_butil brpc-shared
gtest
${GPERFTOOLS_LIBRARIES}
${DYNAMIC_LIB})
add_test(NAME test_butil COMMAND test_butil)
# -DBVAR_NOT_LINK_DEFAULT_VARIABLES not work for gcc >= 5.0, just remove the file to prevent linking into unit tests
list(REMOVE_ITEM BVAR_SOURCES ${PROJECT_SOURCE_DIR}/src/bvar/default_variables.cpp)
add_library(BVAR_OBJ OBJECT ${BVAR_SOURCES})
file(GLOB TEST_BVAR_SRCS "bvar_*_unittest.cpp")
add_executable(test_bvar ${TEST_BVAR_SRCS})
target_link_libraries(test_bvar brpc-shared
gtest
add_executable(test_bvar ${TEST_BVAR_SRCS} $<TARGET_OBJECTS:BVAR_OBJ> $<TARGET_OBJECTS:BUTIL_LIB>)
target_link_libraries(test_bvar gtest
${GPERFTOOLS_LIBRARIES}
${DYNAMIC_LIB})
add_test(NAME test_bvar COMMAND test_bvar)
add_library(BTHREAD_OBJ OBJECT ${BTHREAD_SOURCES})
add_library(PROTO_OBJ OBJECT ${PROTO_SRCS})
file(GLOB BTHREAD_UNITTESTS "bthread*unittest.cpp")
foreach(BTHREAD_UT ${BTHREAD_UNITTESTS})
get_filename_component(BTHREAD_UT_WE ${BTHREAD_UT} NAME_WE)
add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT} $<TARGET_OBJECTS:TEST_PROTO_LIB>)
target_link_libraries(${BTHREAD_UT_WE} brpc-shared
gtest_main
add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT}
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:BVAR_OBJ>
$<TARGET_OBJECTS:BTHREAD_OBJ>
$<TARGET_OBJECTS:PROTO_LIB>
$<TARGET_OBJECTS:TEST_PROTO_LIB>
)
target_link_libraries(${BTHREAD_UT_WE} gtest_main
${GPERFTOOLS_LIBRARIES}
${DYNAMIC_LIB})
add_test(NAME ${BTHREAD_UT_WE} COMMAND ${BTHREAD_UT_WE})
endforeach()
file(GLOB BRPC_UNITTESTS "brpc_*_unittest.cpp")
......@@ -212,4 +219,5 @@ foreach(BRPC_UT ${BRPC_UNITTESTS})
${GPERFTOOLS_LIBRARIES}
${GTEST_LIB}
${DYNAMIC_LIB})
add_test(NAME ${BRPC_UT_WE} COMMAND ${BRPC_UT_WE})
endforeach()
......@@ -1158,7 +1158,7 @@ TEST_F(ServerTest, serving_requests) {
TEST_F(ServerTest, create_pid_file) {
{
brpc::Server server;
server._options.pid_file = "$PWD//pid_dir/sub_dir/./.server.pid";
server._options.pid_file = "./pid_dir/sub_dir/./.server.pid";
server.PutPidFileIfNeeded();
pid_t pid = getpid();
std::ifstream fin("./pid_dir/sub_dir/.server.pid");
......
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