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
136b0408
Commit
136b0408
authored
Apr 08, 2018
by
zyearn
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cmake_support' of github.com:brpc/brpc into cmake_support
parents
694b0290
a0c02eef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
15 deletions
+36
-15
key.cpp
src/bthread/key.cpp
+3
-4
CMakeLists.txt
test/CMakeLists.txt
+27
-11
brpc_builtin_service_unittest.cpp
test/brpc_builtin_service_unittest.cpp
+6
-0
No files found.
src/bthread/key.cpp
View file @
136b0408
...
@@ -233,9 +233,8 @@ void return_keytable(bthread_keytable_pool_t* pool, KeyTable* kt) {
...
@@ -233,9 +233,8 @@ void return_keytable(bthread_keytable_pool_t* pool, KeyTable* kt) {
pool
->
free_keytables
=
kt
;
pool
->
free_keytables
=
kt
;
}
}
static
void
cleanup_pthread
()
{
static
void
cleanup_pthread
(
void
*
arg
)
{
KeyTable
*
kt
=
tls_bls
.
keytable
;
KeyTable
*
kt
=
static_cast
<
KeyTable
*>
(
arg
);
//TODO(zhujiashun): thread local storage not works in macos using clang
if
(
kt
)
{
if
(
kt
)
{
delete
kt
;
delete
kt
;
// After deletion: tls may be set during deletion.
// After deletion: tls may be set during deletion.
...
@@ -447,7 +446,7 @@ int bthread_setspecific(bthread_key_t key, void* data) {
...
@@ -447,7 +446,7 @@ int bthread_setspecific(bthread_key_t key, void* data) {
}
}
if
(
!
bthread
::
tls_ever_created_keytable
)
{
if
(
!
bthread
::
tls_ever_created_keytable
)
{
bthread
::
tls_ever_created_keytable
=
true
;
bthread
::
tls_ever_created_keytable
=
true
;
CHECK_EQ
(
0
,
butil
::
thread_atexit
(
bthread
::
cleanup_pthread
));
CHECK_EQ
(
0
,
butil
::
thread_atexit
(
bthread
::
cleanup_pthread
,
kt
));
}
}
}
}
return
kt
->
set_data
(
key
,
data
);
return
kt
->
set_data
(
key
,
data
);
...
...
test/CMakeLists.txt
View file @
136b0408
...
@@ -143,32 +143,48 @@ SET(TEST_BUTIL_SOURCES ${TEST_BUTIL_SOURCES}
...
@@ -143,32 +143,48 @@ SET(TEST_BUTIL_SOURCES ${TEST_BUTIL_SOURCES}
${
CMAKE_SOURCE_DIR
}
/test/test_file_util_linux.cc
)
${
CMAKE_SOURCE_DIR
}
/test/test_file_util_linux.cc
)
endif
()
endif
()
# bthread_* functions are used in logging.cc, and they need to be marked as
# weak symbols explicitly in Darwin system.
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
"-Wl,-U,_bthread_getspecific"
"-Wl,-U,_bthread_setspecific"
"-Wl,-U,_bthread_key_create"
)
endif
()
# create executable
add_library
(
TEST_PROTO_OBJ OBJECT
${
TEST_PROTO_SRCS
}
)
add_executable
(
test_butil
${
TEST_BUTIL_SOURCES
}
${
CMAKE_CURRENT_BINARY_DIR
}
/iobuf.pb.cc
$<TARGET_OBJECTS:BUTIL_LIB>
)
target_link_libraries
(
test_butil
${
GTEST_LIB
}
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
# -DBVAR_NOT_LINK_DEFAULT_VARIABLES not work for gcc >= 5.0, just remove the file to prevent linking into unit tests
# -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
${
CMAKE_SOURCE_DIR
}
/src/bvar/default_variables.cpp
)
list
(
REMOVE_ITEM BVAR_SOURCES
${
CMAKE_SOURCE_DIR
}
/src/bvar/default_variables.cpp
)
add_library
(
BVAR_OBJ OBJECT
${
BVAR_SOURCES
}
)
file
(
GLOB TEST_BVAR_SRCS
"bvar_*_unittest.cpp"
)
file
(
GLOB TEST_BVAR_SRCS
"bvar_*_unittest.cpp"
)
add_executable
(
test_bvar $<TARGET_OBJECTS:BUTIL_LIB>
add_executable
(
test_bvar $<TARGET_OBJECTS:BUTIL_LIB>
${
BTHREAD_SOURCES
}
$<TARGET_OBJECTS:BVAR_OBJ>
${
BVAR_SOURCES
}
${
TEST_BVAR_SRCS
}
)
${
TEST_BVAR_SRCS
}
)
target_link_libraries
(
test_bvar
${
GTEST_LIB
}
target_link_libraries
(
test_bvar
${
GTEST_LIB
}
${
GPERFTOOLS_LIBRARIES
}
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
${
DYNAMIC_LIB
}
)
add_library
(
TEST_PROTO_OBJ OBJECT
${
TEST_PROTO_SRCS
}
)
add_library
(
BTHREAD_OBJ OBJECT
${
BTHREAD_SOURCES
}
)
add_executable
(
test_butil
${
TEST_BUTIL_SOURCES
}
add_library
(
PROTO_OBJ OBJECT
${
PROTO_SRCS
}
)
$<TARGET_OBJECTS:TEST_PROTO_OBJ>
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
)
target_link_libraries
(
test_butil
${
GTEST_LIB
}
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
file
(
GLOB BTHREAD_UNITTESTS
"bthread*unittest.cpp"
)
file
(
GLOB BTHREAD_UNITTESTS
"bthread*unittest.cpp"
)
foreach
(
BTHREAD_UT
${
BTHREAD_UNITTESTS
}
)
foreach
(
BTHREAD_UT
${
BTHREAD_UNITTESTS
}
)
get_filename_component
(
BTHREAD_UT_WE
${
BTHREAD_UT
}
NAME_WE
)
get_filename_component
(
BTHREAD_UT_WE
${
BTHREAD_UT
}
NAME_WE
)
add_executable
(
${
BTHREAD_UT_WE
}
${
BTHREAD_UT
}
add_executable
(
${
BTHREAD_UT_WE
}
${
BTHREAD_UT
}
$<TARGET_OBJECTS:TEST_PROTO_OBJ>
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
)
$<TARGET_OBJECTS:BVAR_OBJ>
$<TARGET_OBJECTS:BTHREAD_OBJ>
$<TARGET_OBJECTS:PROTO_OBJ>
$<TARGET_OBJECTS:TEST_PROTO_OBJ>
)
target_link_libraries
(
${
BTHREAD_UT_WE
}
target_link_libraries
(
${
BTHREAD_UT_WE
}
${
GTEST_MAIN_LIB
}
${
GTEST_MAIN_LIB
}
${
GTEST_LIB
}
${
GTEST_LIB
}
...
...
test/brpc_builtin_service_unittest.cpp
View file @
136b0408
...
@@ -664,6 +664,7 @@ TEST_F(BuiltinServiceTest, pprof) {
...
@@ -664,6 +664,7 @@ TEST_F(BuiltinServiceTest, pprof) {
EXPECT_FALSE
(
cntl
.
Failed
());
EXPECT_FALSE
(
cntl
.
Failed
());
CheckContent
(
cntl
,
"num_symbols"
);
CheckContent
(
cntl
,
"num_symbols"
);
}
}
#if defined(OS_LINUX)
{
{
ClosureChecker
done
;
ClosureChecker
done
;
brpc
::
Controller
cntl
;
brpc
::
Controller
cntl
;
...
@@ -671,6 +672,7 @@ TEST_F(BuiltinServiceTest, pprof) {
...
@@ -671,6 +672,7 @@ TEST_F(BuiltinServiceTest, pprof) {
EXPECT_FALSE
(
cntl
.
Failed
());
EXPECT_FALSE
(
cntl
.
Failed
());
CheckContent
(
cntl
,
"brpc_builtin_service_unittest"
);
CheckContent
(
cntl
,
"brpc_builtin_service_unittest"
);
}
}
#endif
}
}
TEST_F
(
BuiltinServiceTest
,
dir
)
{
TEST_F
(
BuiltinServiceTest
,
dir
)
{
...
@@ -695,7 +697,11 @@ TEST_F(BuiltinServiceTest, dir) {
...
@@ -695,7 +697,11 @@ TEST_F(BuiltinServiceTest, dir) {
cntl
.
http_request
().
_unresolved_path
=
"/usr/include/errno.h"
;
cntl
.
http_request
().
_unresolved_path
=
"/usr/include/errno.h"
;
service
.
default_method
(
&
cntl
,
&
req
,
&
res
,
&
done
);
service
.
default_method
(
&
cntl
,
&
req
,
&
res
,
&
done
);
EXPECT_FALSE
(
cntl
.
Failed
());
EXPECT_FALSE
(
cntl
.
Failed
());
#if defined(OS_LINUX)
CheckContent
(
cntl
,
"ERRNO_H"
);
CheckContent
(
cntl
,
"ERRNO_H"
);
#elif defined(OS_MACOSX)
CheckContent
(
cntl
,
"sys/errno.h"
);
#endif
}
}
{
{
// Open a file that doesn't exist
// Open a file that doesn't exist
...
...
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