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
f4b97bbb
Commit
f4b97bbb
authored
7 years ago
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove UT's deps on gmock & fix UT
parent
5b817802
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
110 additions
and
284 deletions
+110
-284
Makefile
Makefile
+16
-7
config_brpc.sh
config_brpc.sh
+0
-16
getting_started.md
docs/cn/getting_started.md
+2
-9
sampler.cpp
src/bvar/detail/sampler.cpp
+4
-6
Makefile
test/Makefile
+8
-9
bind_unittest.cc
test/bind_unittest.cc
+0
-0
brpc_builtin_service_unittest.cpp
test/brpc_builtin_service_unittest.cpp
+5
-5
brpc_channel_unittest.cpp
test/brpc_channel_unittest.cpp
+1
-1
brpc_http_message_unittest.cpp
test/brpc_http_message_unittest.cpp
+1
-1
brpc_http_rpc_protocol_unittest.cpp
test/brpc_http_rpc_protocol_unittest.cpp
+1
-1
brpc_hulu_pbrpc_protocol_unittest.cpp
test/brpc_hulu_pbrpc_protocol_unittest.cpp
+1
-1
brpc_memcache_unittest.cpp
test/brpc_memcache_unittest.cpp
+4
-1
brpc_naming_service_unittest.cpp
test/brpc_naming_service_unittest.cpp
+1
-1
brpc_nova_pbrpc_protocol_unittest.cpp
test/brpc_nova_pbrpc_protocol_unittest.cpp
+1
-1
brpc_proto_unittest.cpp
test/brpc_proto_unittest.cpp
+1
-1
brpc_public_pbrpc_protocol_unittest.cpp
test/brpc_public_pbrpc_protocol_unittest.cpp
+1
-1
brpc_redis_unittest.cpp
test/brpc_redis_unittest.cpp
+3
-1
brpc_server_unittest.cpp
test/brpc_server_unittest.cpp
+3
-3
brpc_snappy_compress_unittest.cpp
test/brpc_snappy_compress_unittest.cpp
+1
-1
brpc_sofa_pbrpc_protocol_unittest.cpp
test/brpc_sofa_pbrpc_protocol_unittest.cpp
+1
-1
brpc_streaming_rpc_unittest.cpp
test/brpc_streaming_rpc_unittest.cpp
+1
-1
butil_unittest_main.cpp
test/butil_unittest_main.cpp
+1
-1
bvar_status_unittest.cpp
test/bvar_status_unittest.cpp
+0
-7
bvar_variable_unittest.cpp
test/bvar_variable_unittest.cpp
+0
-4
logging_unittest.cc
test/logging_unittest.cc
+0
-106
run_tests.sh
test/run_tests.sh
+28
-0
scoped_locale.cc
test/scoped_locale.cc
+1
-1
shared_memory_unittest.cc
test/shared_memory_unittest.cc
+2
-2
string_split_unittest.cc
test/string_split_unittest.cc
+20
-14
string_util_unittest.cc
test/string_util_unittest.cc
+0
-3
sys_string_conversions_unittest.cc
test/sys_string_conversions_unittest.cc
+1
-1
test_switches.cc
test/test_switches.cc
+1
-1
xdg_util_unittest.cc
test/xdg_util_unittest.cc
+0
-76
No files found.
Makefile
View file @
f4b97bbb
...
@@ -9,6 +9,7 @@ include config.mk
...
@@ -9,6 +9,7 @@ include config.mk
CPPFLAGS
+=
-DBTHREAD_USE_FAST_PTHREAD_MUTEX
-D__const__
=
-D_GNU_SOURCE
-DUSE_SYMBOLIZE
-DNO_TCMALLOC
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
-DBRPC_REVISION
=
\"
$(
shell
git rev-parse
--short
HEAD
)
\"
CPPFLAGS
+=
-DBTHREAD_USE_FAST_PTHREAD_MUTEX
-D__const__
=
-D_GNU_SOURCE
-DUSE_SYMBOLIZE
-DNO_TCMALLOC
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
-DBRPC_REVISION
=
\"
$(
shell
git rev-parse
--short
HEAD
)
\"
CXXFLAGS
+=
$(CPPFLAGS)
-g
-O2
-pipe
-Wall
-W
-fPIC
-fstrict-aliasing
-Wno-invalid-offsetof
-Wno-unused-parameter
-fno-omit-frame-pointer
-std
=
c++0x
CXXFLAGS
+=
$(CPPFLAGS)
-g
-O2
-pipe
-Wall
-W
-fPIC
-fstrict-aliasing
-Wno-invalid-offsetof
-Wno-unused-parameter
-fno-omit-frame-pointer
-std
=
c++0x
CFLAGS
+=
$(CPPFLAGS)
-g
-O2
-pipe
-Wall
-W
-fPIC
-fstrict-aliasing
-Wno-unused-parameter
-fno-omit-frame-pointer
CFLAGS
+=
$(CPPFLAGS)
-g
-O2
-pipe
-Wall
-W
-fPIC
-fstrict-aliasing
-Wno-unused-parameter
-fno-omit-frame-pointer
DEBUG_CXXFLAGS
=
$(CXXFLAGS)
-DUNIT_TEST
-DBVAR_NOT_LINK_DEFAULT_VARIABLES
HDRPATHS
=
-I
./src
$
(
addprefix
-I
,
$(HDRS)
)
HDRPATHS
=
-I
./src
$
(
addprefix
-I
,
$(HDRS)
)
LIBPATHS
=
$
(
addprefix
-L
,
$(LIBS)
)
LIBPATHS
=
$
(
addprefix
-L
,
$(LIBS)
)
COMMA
=
,
COMMA
=
,
...
@@ -168,13 +169,15 @@ MCPACK2PB_SOURCES = \
...
@@ -168,13 +169,15 @@ MCPACK2PB_SOURCES = \
MCPACK2PB_OBJS
=
src/idl_options.pb.o
$
(
addsuffix .o,
$
(
basename
$(MCPACK2PB_SOURCES)
))
MCPACK2PB_OBJS
=
src/idl_options.pb.o
$
(
addsuffix .o,
$
(
basename
$(MCPACK2PB_SOURCES)
))
OBJS
=
$(BUTIL_OBJS)
$(BVAR_OBJS)
$(BTHREAD_OBJS)
$(JSON2PB_OBJS)
$(MCPACK2PB_OBJS)
$(BRPC_OBJS)
OBJS
=
$(BUTIL_OBJS)
$(BVAR_OBJS)
$(BTHREAD_OBJS)
$(JSON2PB_OBJS)
$(MCPACK2PB_OBJS)
$(BRPC_OBJS)
BVAR_DEBUG_OBJS
=
$
(
BUTIL_OBJS:.o
=
.dbg.o
)
$
(
BVAR_OBJS:.o
=
.dbg.o
)
DEBUG_OBJS
=
$
(
OBJS:.o
=
.dbg.o
)
DEBUG_OBJS
=
$
(
OBJS:.o
=
.dbg.o
)
.PHONY
:
all
.PHONY
:
all
all
:
protoc-gen-mcpack libbrpc.a libbrpc.so output/include output/lib output/bin
all
:
protoc-gen-mcpack libbrpc.a libbrpc.so output/include output/lib output/bin
.PHONY
:
debug
.PHONY
:
debug
debug
:
libbrpc.dbg.a
debug
:
libbrpc.dbg.a
libbvar.dbg.a
.PHONY
:
clean
.PHONY
:
clean
clean
:
clean_debug
clean
:
clean_debug
...
@@ -183,7 +186,9 @@ clean:clean_debug
...
@@ -183,7 +186,9 @@ clean:clean_debug
.PHONY
:
clean_debug
.PHONY
:
clean_debug
clean_debug
:
clean_debug
:
@
rm
-rf
libbrpc.dbg.a
$(DEBUG_OBJS)
@
rm
-rf
libbrpc.dbg.a libbvar.dbg.a
$(DEBUG_OBJS)
.PRECIOUS
:
%.o
protoc-gen-mcpack
:
src/idl_options.pb.cc src/mcpack2pb/generator.o libbrpc.a
protoc-gen-mcpack
:
src/idl_options.pb.cc src/mcpack2pb/generator.o libbrpc.a
@
echo
"Linking
$@
"
@
echo
"Linking
$@
"
...
@@ -192,15 +197,19 @@ protoc-gen-mcpack: src/idl_options.pb.cc src/mcpack2pb/generator.o libbrpc.a
...
@@ -192,15 +197,19 @@ protoc-gen-mcpack: src/idl_options.pb.cc src/mcpack2pb/generator.o libbrpc.a
# force generation of pb headers before compiling to avoid fail-to-import issues in compiling pb.cc
# force generation of pb headers before compiling to avoid fail-to-import issues in compiling pb.cc
libbrpc.a
:
$(BRPC_PROTOS:.proto=.pb.h) $(OBJS)
libbrpc.a
:
$(BRPC_PROTOS:.proto=.pb.h) $(OBJS)
@
echo
"Packing
$@
"
@
echo
"Packing
$@
"
@
ar crs
$@
$(
OBJS
)
@
ar crs
$@
$
(
filter %.o,
$^
)
libbrpc.so
:
$(BRPC_PROTOS:.proto=.pb.h) $(OBJS)
libbrpc.so
:
$(BRPC_PROTOS:.proto=.pb.h) $(OBJS)
@
echo
"Linking
$@
"
@
echo
"Linking
$@
"
$(CXX)
-shared
-o
$@
$(HDRPATHS)
$(LIBPATHS)
$(SOPATHS)
-Xlinker
"-("
$(OBJS)
-Xlinker
"-)"
$(STATIC_LINKINGS)
$(DYNAMIC_LINKINGS)
$(CXX)
-shared
-o
$@
$(LIBPATHS)
$(SOPATHS)
-Xlinker
"-("
$
(
filter %.o,
$^
)
-Xlinker
"-)"
$(STATIC_LINKINGS)
$(DYNAMIC_LINKINGS)
libbvar.dbg.a
:
$(BVAR_DEBUG_OBJS)
@
echo
"Packing
$@
"
@
ar crs
$@
$^
libbrpc.dbg.a
:
$(BRPC_PROTOS:.proto=.pb.h) $(DEBUG_OBJS)
libbrpc.dbg.a
:
$(BRPC_PROTOS:.proto=.pb.h) $(DEBUG_OBJS)
@
echo
"Packing
$@
"
@
echo
"Packing
$@
"
@
ar crs
$@
$(
DEBUG_OBJS
)
@
ar crs
$@
$
(
filter %.o,
$^
)
.PHONY
:
output/include
.PHONY
:
output/include
output/include
:
output/include
:
...
@@ -231,7 +240,7 @@ output/bin:protoc-gen-mcpack
...
@@ -231,7 +240,7 @@ output/bin:protoc-gen-mcpack
%.dbg.o
:
%.cpp
%.dbg.o
:
%.cpp
@
echo
"Compiling
$@
"
@
echo
"Compiling
$@
"
@
$(CXX)
-c
$(HDRPATHS)
$(
CXXFLAGS)
-DBVAR_NOT_LINK_DEFAULT_VARIABLES
$<
-o
$@
@
$(CXX)
-c
$(HDRPATHS)
$(
DEBUG_CXXFLAGS)
$<
-o
$@
%.o
:
%.cc
%.o
:
%.cc
@
echo
"Compiling
$@
"
@
echo
"Compiling
$@
"
...
@@ -239,7 +248,7 @@ output/bin:protoc-gen-mcpack
...
@@ -239,7 +248,7 @@ output/bin:protoc-gen-mcpack
%.dbg.o
:
%.cc
%.dbg.o
:
%.cc
@
echo
"Compiling
$@
"
@
echo
"Compiling
$@
"
@
$(CXX)
-c
$(HDRPATHS)
$(CXXFLAGS)
$<
-o
$@
@
$(CXX)
-c
$(HDRPATHS)
$(
DEBUG_
CXXFLAGS)
$<
-o
$@
%.o
:
%.c
%.o
:
%.c
@
echo
"Compiling
$@
"
@
echo
"Compiling
$@
"
...
...
This diff is collapsed.
Click to expand it.
config_brpc.sh
View file @
f4b97bbb
...
@@ -324,22 +324,6 @@ else
...
@@ -324,22 +324,6 @@ else
fi
fi
append_to_output
"endif"
append_to_output
"endif"
#gmock
GMOCK_LIB
=
$(
find_dir_of_lib gmock
)
HDRS
=
$OLD_HDRS
LIBS
=
$OLD_LIBS
append_to_output
"ifeq (
\$
(NEED_GMOCK), 1)"
if
[
-z
"
$GMOCK_LIB
"
]
;
then
append_to_output
"
\$
(error
\"
Fail to find gmock
\"
)"
else
GMOCK_HDR
=
$(
find_dir_of_header_or_die gmock/gmock.h
)
append_to_output_libs
$GMOCK_LIB
" "
append_to_output_headers
$GMOCK_HDR
" "
append_to_output_linkings
$GMOCK_LIB
gmock
" "
append_to_output_linkings
$GMOCK_LIB
gmock_main
" "
fi
append_to_output
"endif"
# generate src/butil/config.h
# generate src/butil/config.h
cat
<<
EOF
> src/butil/config.h
cat
<<
EOF
> src/butil/config.h
// This file is auto-generated by
$(
basename
"
$0
"
)
. DON'T edit it!
// This file is auto-generated by
$(
basename
"
$0
"
)
. DON'T edit it!
...
...
This diff is collapsed.
Click to expand it.
docs/cn/getting_started.md
View file @
f4b97bbb
...
@@ -36,15 +36,8 @@ Examples link brpc statically, if you need to link the shared version, `make cle
...
@@ -36,15 +36,8 @@ Examples link brpc statically, if you need to link the shared version, `make cle
To run examples with cpu/heap profilers, install
`libgoogle-perftools-dev`
and re-run
`config_brpc.sh`
before compiling
To run examples with cpu/heap profilers, install
`libgoogle-perftools-dev`
and re-run
`config_brpc.sh`
before compiling
### compile tests
### compile tests
Install gmock and gtest, use the gtest embedded in gmock and don't install libgtest-dev
Install libgtest-dev
```
$ sudo apt-get install google-mock
$ cd /usr/src
$ sudo cmake .
$ sudo make
$ sudo mv lib*.a gtest/lib*.a /usr/lib
$ sudo mv gtest/include/gtest /usr/include/
```
Rerun config_brpc.sh and run make in test/
Rerun config_brpc.sh and run make in test/
## Fedora/CentOS
## Fedora/CentOS
...
...
This diff is collapsed.
Click to expand it.
src/bvar/detail/sampler.cpp
View file @
f4b97bbb
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
namespace
bvar
{
namespace
bvar
{
namespace
detail
{
namespace
detail
{
// set to true in UT. Not using gflags since users hardly need to change it.
bool
FLAGS_show_sampler_usage
=
true
;
const
int
WARN_NOSLEEP_THRESHOLD
=
2
;
const
int
WARN_NOSLEEP_THRESHOLD
=
2
;
// Combine two circular linked list into one.
// Combine two circular linked list into one.
...
@@ -94,11 +92,11 @@ private:
...
@@ -94,11 +92,11 @@ private:
void
SamplerCollector
::
run
()
{
void
SamplerCollector
::
run
()
{
butil
::
LinkNode
<
Sampler
>
root
;
butil
::
LinkNode
<
Sampler
>
root
;
int
consecutive_nosleep
=
0
;
int
consecutive_nosleep
=
0
;
#ifndef UNIT_TEST
PassiveStatus
<
double
>
cumulated_time
(
get_cumulated_time
,
this
);
PassiveStatus
<
double
>
cumulated_time
(
get_cumulated_time
,
this
);
bvar
::
PerSecond
<
bvar
::
PassiveStatus
<
double
>
>
usage
(
&
cumulated_time
,
10
);
bvar
::
PerSecond
<
bvar
::
PassiveStatus
<
double
>
>
usage
(
if
(
FLAGS_show_sampler_usage
)
{
"bvar_sampler_collector_usage"
,
&
cumulated_time
,
10
);
usage
.
expose
(
"bvar_sampler_collector_usage"
);
#endif
}
while
(
!
_stop
)
{
while
(
!
_stop
)
{
int64_t
abstime
=
butil
::
gettimeofday_us
();
int64_t
abstime
=
butil
::
gettimeofday_us
();
Sampler
*
s
=
this
->
reset
();
Sampler
*
s
=
this
->
reset
();
...
...
This diff is collapsed.
Click to expand it.
test/Makefile
View file @
f4b97bbb
NEED_GPERFTOOLS
=
1
NEED_GPERFTOOLS
=
1
NEED_GTEST
=
1
NEED_GTEST
=
1
NEED_GMOCK
=
1
include
../config.mk
include
../config.mk
CPPFLAGS
+=
-DBTHREAD_USE_FAST_PTHREAD_MUTEX
-D__const__
=
-D_GNU_SOURCE
-DUSE_SYMBOLIZE
-DNO_TCMALLOC
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
CPPFLAGS
+=
-DBTHREAD_USE_FAST_PTHREAD_MUTEX
-D__const__
=
-D_GNU_SOURCE
-DUSE_SYMBOLIZE
-DNO_TCMALLOC
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
CPPFLAGS
+=
-DUNIT_TEST
-Dprivate
=
public
-Dprotected
=
public
-DBVAR_NOT_LINK_DEFAULT_VARIABLES
--include
sstream_workaround.h
CPPFLAGS
+=
-DUNIT_TEST
-Dprivate
=
public
-Dprotected
=
public
-DBVAR_NOT_LINK_DEFAULT_VARIABLES
--include
sstream_workaround.h
...
@@ -15,8 +14,8 @@ ifeq ($(shell test $(GCC_VERSION) -ge 70000; echo $$?),0)
...
@@ -15,8 +14,8 @@ ifeq ($(shell test $(GCC_VERSION) -ge 70000; echo $$?),0)
CXXFLAGS
+=
-Wno-aligned-new
CXXFLAGS
+=
-Wno-aligned-new
endif
endif
HDRPATHS
=
-I
.
-I
..
-I
..
/src
$
(
addprefix
-I
,
$(HDRS)
)
HDRPATHS
=
-I
.
-I
../src
$
(
addprefix
-I
,
$(HDRS)
)
LIBPATHS
=
$
(
addprefix
-L
,
$(LIBS)
)
LIBPATHS
=
-L
..
$
(
addprefix
-L
,
$(LIBS)
)
TEST_BUTIL_SOURCES
=
\
TEST_BUTIL_SOURCES
=
\
at_exit_unittest.cc
\
at_exit_unittest.cc
\
...
@@ -137,7 +136,7 @@ TEST_BINS = test_butil test_bvar $(TEST_BTHREAD_SOURCES:.cpp=) $(TEST_BRPC_SOURC
...
@@ -137,7 +136,7 @@ TEST_BINS = test_butil test_bvar $(TEST_BTHREAD_SOURCES:.cpp=) $(TEST_BRPC_SOURC
all
:
$(TEST_BINS)
all
:
$(TEST_BINS)
.PHONY
:
clean
.PHONY
:
clean
clean
:
clean_bins clean_d
b
g
clean
:
clean_bins clean_d
ebu
g
@
echo
"Cleaning"
@
echo
"Cleaning"
@
rm
-rf
$(TEST_BUTIL_OBJS)
$(TEST_BVAR_OBJS)
$(TEST_BTHREAD_OBJS)
\
@
rm
-rf
$(TEST_BUTIL_OBJS)
$(TEST_BVAR_OBJS)
$(TEST_BTHREAD_OBJS)
\
$(TEST_BRPC_OBJS)
$(TEST_PROTO_OBJS)
$(TEST_BRPC_OBJS)
$(TEST_PROTO_OBJS)
...
@@ -146,12 +145,12 @@ clean:clean_bins clean_dbg
...
@@ -146,12 +145,12 @@ clean:clean_bins clean_dbg
clean_bins
:
clean_bins
:
@
rm
-rf
$(TEST_BINS)
@
rm
-rf
$(TEST_BINS)
.PHONY
:
clean_d
b
g
.PHONY
:
clean_d
ebu
g
clean_d
b
g
:
clean_d
ebu
g
:
@
$(MAKE)
-C
.. clean_debug
@
$(MAKE)
-C
.. clean_debug
../libbrpc.dbg.a
:
FORCE
../libbrpc.dbg.a
../libbvar.dbg.a
:
FORCE
@
$(MAKE)
-C
..
libbrpc.dbg.a
@
$(MAKE)
-C
..
debug
FORCE
:
FORCE
:
...
@@ -161,7 +160,7 @@ test_butil:$(TEST_BUTIL_OBJS) ../libbrpc.dbg.a
...
@@ -161,7 +160,7 @@ test_butil:$(TEST_BUTIL_OBJS) ../libbrpc.dbg.a
@
echo
"Linking
$@
"
@
echo
"Linking
$@
"
@
$(CXX)
-o
$@
$(LIBPATHS)
-Xlinker
"-("
$^
-Wl
,-Bstatic
$(STATIC_LINKINGS)
-Wl
,-Bdynamic
-Xlinker
"-)"
$(DYNAMIC_LINKINGS)
@
$(CXX)
-o
$@
$(LIBPATHS)
-Xlinker
"-("
$^
-Wl
,-Bstatic
$(STATIC_LINKINGS)
-Wl
,-Bdynamic
-Xlinker
"-)"
$(DYNAMIC_LINKINGS)
test_bvar
:
$(TEST_BVAR_OBJS) ../libb
rpc
.dbg.a
test_bvar
:
$(TEST_BVAR_OBJS) ../libb
var
.dbg.a
@
echo
"Linking
$@
"
@
echo
"Linking
$@
"
@
$(CXX)
-o
$@
$(LIBPATHS)
-Xlinker
"-("
$^
-Wl
,-Bstatic
$(STATIC_LINKINGS)
-Wl
,-Bdynamic
-Xlinker
"-)"
$(DYNAMIC_LINKINGS)
@
$(CXX)
-o
$@
$(LIBPATHS)
-Xlinker
"-("
$^
-Wl
,-Bstatic
$(STATIC_LINKINGS)
-Wl
,-Bdynamic
-Xlinker
"-)"
$(DYNAMIC_LINKINGS)
...
...
This diff is collapsed.
Click to expand it.
test/bind_unittest.cc
deleted
100644 → 0
View file @
5b817802
This diff is collapsed.
Click to expand it.
test/brpc_builtin_service_unittest.cpp
View file @
f4b97bbb
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
#include "brpc/builtin/sockets_service.h" // SocketsService
#include "brpc/builtin/sockets_service.h" // SocketsService
#include "brpc/builtin/common.h"
#include "brpc/builtin/common.h"
#include "brpc/builtin/bad_method_service.h"
#include "brpc/builtin/bad_method_service.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
DEFINE_bool
(
foo
,
false
,
"Flags for UT"
);
DEFINE_bool
(
foo
,
false
,
"Flags for UT"
);
BRPC_VALIDATE_GFLAG
(
foo
,
brpc
::
PassValidate
);
BRPC_VALIDATE_GFLAG
(
foo
,
brpc
::
PassValidate
);
...
@@ -194,7 +194,7 @@ protected:
...
@@ -194,7 +194,7 @@ protected:
service
.
default_method
(
&
cntl
,
&
req
,
&
res
,
&
done
);
service
.
default_method
(
&
cntl
,
&
req
,
&
res
,
&
done
);
EXPECT_FALSE
(
cntl
.
Failed
());
EXPECT_FALSE
(
cntl
.
Failed
());
EXPECT_EQ
(
expect_type
,
cntl
.
http_response
().
content_type
());
EXPECT_EQ
(
expect_type
,
cntl
.
http_response
().
content_type
());
CheckContent
(
cntl
,
"
test_builtin_service
"
);
CheckContent
(
cntl
,
"
brpc_builtin_service_unittest
"
);
#endif
#endif
}
}
...
@@ -655,8 +655,8 @@ TEST_F(BuiltinServiceTest, pprof) {
...
@@ -655,8 +655,8 @@ TEST_F(BuiltinServiceTest, pprof) {
ClosureChecker
done
;
ClosureChecker
done
;
brpc
::
Controller
cntl
;
brpc
::
Controller
cntl
;
service
.
growth
(
&
cntl
,
NULL
,
NULL
,
&
done
);
service
.
growth
(
&
cntl
,
NULL
,
NULL
,
&
done
);
//
MUST fail since tcmalloc hasn't been linked in
//
linked tcmalloc in UT
EXPECT_EQ
(
brpc
::
ENOMETHOD
,
cntl
.
ErrorCode
());
EXPECT_EQ
(
0
,
cntl
.
ErrorCode
());
}
}
{
{
ClosureChecker
done
;
ClosureChecker
done
;
...
@@ -670,7 +670,7 @@ TEST_F(BuiltinServiceTest, pprof) {
...
@@ -670,7 +670,7 @@ TEST_F(BuiltinServiceTest, pprof) {
brpc
::
Controller
cntl
;
brpc
::
Controller
cntl
;
service
.
cmdline
(
&
cntl
,
NULL
,
NULL
,
&
done
);
service
.
cmdline
(
&
cntl
,
NULL
,
NULL
,
&
done
);
EXPECT_FALSE
(
cntl
.
Failed
());
EXPECT_FALSE
(
cntl
.
Failed
());
CheckContent
(
cntl
,
"
test_builtin_service
"
);
CheckContent
(
cntl
,
"
brpc_builtin_service_unittest
"
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
test/brpc_channel_unittest.cpp
View file @
f4b97bbb
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "brpc/selective_channel.h"
#include "brpc/selective_channel.h"
#include "brpc/socket_map.h"
#include "brpc/socket_map.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
#include "brpc/options.pb.h"
#include "brpc/options.pb.h"
namespace
brpc
{
namespace
brpc
{
...
...
This diff is collapsed.
Click to expand it.
test/brpc_http_message_unittest.cpp
View file @
f4b97bbb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "brpc/server.h"
#include "brpc/server.h"
#include "brpc/details/http_message.h"
#include "brpc/details/http_message.h"
#include "brpc/policy/http_rpc_protocol.h"
#include "brpc/policy/http_rpc_protocol.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
namespace
brpc
{
namespace
brpc
{
namespace
policy
{
namespace
policy
{
...
...
This diff is collapsed.
Click to expand it.
test/brpc_http_rpc_protocol_unittest.cpp
View file @
f4b97bbb
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "brpc/channel.h"
#include "brpc/channel.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
#include "brpc/policy/http_rpc_protocol.h"
#include "brpc/policy/http_rpc_protocol.h"
#include "json2pb/pb_to_json.h"
#include "json2pb/pb_to_json.h"
#include "json2pb/json_to_pb.h"
#include "json2pb/json_to_pb.h"
...
...
This diff is collapsed.
Click to expand it.
test/brpc_hulu_pbrpc_protocol_unittest.cpp
View file @
f4b97bbb
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "brpc/policy/hulu_pbrpc_protocol.h"
#include "brpc/policy/hulu_pbrpc_protocol.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
test/brpc_memcache_unittest.cpp
View file @
f4b97bbb
// Copyright (c) 2014 Baidu, Inc.
// Copyright (c) 2014 Baidu, Inc.
// Date: Thu Jun 11 14:30:07 CST 2015
// Date: Thu Jun 11 14:30:07 CST 2015
#i
nclude <iostream>
#i
fdef BAIDU_INTERNAL
#include <iostream>
#include "butil/time.h"
#include "butil/time.h"
#include "butil/logging.h"
#include "butil/logging.h"
#include <brpc/memcache.h>
#include <brpc/memcache.h>
...
@@ -164,3 +165,5 @@ TEST_F(MemcacheTest, version) {
...
@@ -164,3 +165,5 @@ TEST_F(MemcacheTest, version) {
std
::
cout
<<
"version="
<<
version
<<
std
::
endl
;
std
::
cout
<<
"version="
<<
version
<<
std
::
endl
;
}
}
}
//namespace
}
//namespace
#endif // BAIDU_INTERNAL
This diff is collapsed.
Click to expand it.
test/brpc_naming_service_unittest.cpp
View file @
f4b97bbb
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include "brpc/policy/file_naming_service.h"
#include "brpc/policy/file_naming_service.h"
#include "brpc/policy/list_naming_service.h"
#include "brpc/policy/list_naming_service.h"
#include "brpc/policy/remote_file_naming_service.h"
#include "brpc/policy/remote_file_naming_service.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
#include "brpc/server.h"
#include "brpc/server.h"
namespace
{
namespace
{
...
...
This diff is collapsed.
Click to expand it.
test/brpc_nova_pbrpc_protocol_unittest.cpp
View file @
f4b97bbb
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include "brpc/policy/nova_pbrpc_protocol.h"
#include "brpc/policy/nova_pbrpc_protocol.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
namespace
{
namespace
{
void
*
RunClosure
(
void
*
arg
)
{
void
*
RunClosure
(
void
*
arg
)
{
...
...
This diff is collapsed.
Click to expand it.
test/brpc_proto_unittest.cpp
View file @
f4b97bbb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/dynamic_message.h>
#include "brpc/policy/baidu_rpc_meta.pb.h"
#include "brpc/policy/baidu_rpc_meta.pb.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
namespace
{
namespace
{
using
namespace
google
::
protobuf
;
using
namespace
google
::
protobuf
;
...
...
This diff is collapsed.
Click to expand it.
test/brpc_public_pbrpc_protocol_unittest.cpp
View file @
f4b97bbb
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "brpc/policy/public_pbrpc_protocol.h"
#include "brpc/policy/public_pbrpc_protocol.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
test/brpc_redis_unittest.cpp
View file @
f4b97bbb
// Copyright (c) 2014 Baidu, Inc.
// Copyright (c) 2014 Baidu, Inc.
// Date: Thu Jun 11 14:30:07 CST 2015
// Date: Thu Jun 11 14:30:07 CST 2015
#i
nclude <iostream>
#i
fdef BAIDU_INTERNAL
#include <iostream>
#include "butil/time.h"
#include "butil/time.h"
#include "butil/logging.h"
#include "butil/logging.h"
#include <brpc/redis.h>
#include <brpc/redis.h>
...
@@ -234,3 +235,4 @@ TEST_F(RedisTest, by_components) {
...
@@ -234,3 +235,4 @@ TEST_F(RedisTest, by_components) {
ASSERT_EQ
(
-
10
,
response
.
reply
(
3
).
integer
());
ASSERT_EQ
(
-
10
,
response
.
reply
(
3
).
integer
());
}
}
}
//namespace
}
//namespace
#endif // BAIDU_INTERNAL
This diff is collapsed.
Click to expand it.
test/brpc_server_unittest.cpp
View file @
f4b97bbb
...
@@ -37,9 +37,9 @@
...
@@ -37,9 +37,9 @@
#include "brpc/channel.h"
#include "brpc/channel.h"
#include "brpc/socket_map.h"
#include "brpc/socket_map.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
#include "
test/
v1.pb.h"
#include "v1.pb.h"
#include "
test/
v2.pb.h"
#include "v2.pb.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
test/brpc_snappy_compress_unittest.cpp
View file @
f4b97bbb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "butil/macros.h"
#include "butil/macros.h"
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "butil/time.h"
#include "butil/time.h"
#include "
test/
snappy_message.pb.h"
#include "snappy_message.pb.h"
#include "brpc/policy/snappy_compress.h"
#include "brpc/policy/snappy_compress.h"
#include "brpc/policy/gzip_compress.h"
#include "brpc/policy/gzip_compress.h"
...
...
This diff is collapsed.
Click to expand it.
test/brpc_sofa_pbrpc_protocol_unittest.cpp
View file @
f4b97bbb
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "brpc/policy/sofa_pbrpc_protocol.h"
#include "brpc/policy/sofa_pbrpc_protocol.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
test/brpc_streaming_rpc_unittest.cpp
View file @
f4b97bbb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "brpc/channel.h"
#include "brpc/channel.h"
#include "brpc/stream_impl.h"
#include "brpc/stream_impl.h"
#include "
test/
echo.pb.h"
#include "echo.pb.h"
class
AfterAcceptStream
{
class
AfterAcceptStream
{
public
:
public
:
...
...
This diff is collapsed.
Click to expand it.
test/butil_unittest_main.cpp
View file @
f4b97bbb
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#include "butil/base_switches.h"
#include "butil/base_switches.h"
#include "butil/at_exit.h"
#include "butil/at_exit.h"
#include "butil/logging.h"
#include "butil/logging.h"
#include "
test/
multiprocess_func_list.h"
#include "multiprocess_func_list.h"
// Disable coredumps by default to avoid generating a lot of coredumps
// Disable coredumps by default to avoid generating a lot of coredumps
// after running death tests.
// after running death tests.
...
...
This diff is collapsed.
Click to expand it.
test/bvar_status_unittest.cpp
View file @
f4b97bbb
...
@@ -14,17 +14,10 @@
...
@@ -14,17 +14,10 @@
#include "bvar/bvar.h"
#include "bvar/bvar.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
namespace
bvar
{
namespace
detail
{
extern
bool
FLAGS_show_sampler_usage
;
}
}
namespace
{
namespace
{
class
StatusTest
:
public
testing
::
Test
{
class
StatusTest
:
public
testing
::
Test
{
protected
:
protected
:
void
SetUp
()
{
void
SetUp
()
{
bvar
::
detail
::
FLAGS_show_sampler_usage
=
false
;
}
}
void
TearDown
()
{
void
TearDown
()
{
ASSERT_EQ
(
0UL
,
bvar
::
Variable
::
count_exposed
());
ASSERT_EQ
(
0UL
,
bvar
::
Variable
::
count_exposed
());
...
...
This diff is collapsed.
Click to expand it.
test/bvar_variable_unittest.cpp
View file @
f4b97bbb
...
@@ -19,9 +19,6 @@
...
@@ -19,9 +19,6 @@
namespace
bvar
{
namespace
bvar
{
DECLARE_bool
(
bvar_log_dumpped
);
DECLARE_bool
(
bvar_log_dumpped
);
namespace
detail
{
extern
bool
FLAGS_show_sampler_usage
;
}
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -41,7 +38,6 @@ namespace {
...
@@ -41,7 +38,6 @@ namespace {
class
VariableTest
:
public
testing
::
Test
{
class
VariableTest
:
public
testing
::
Test
{
protected
:
protected
:
void
SetUp
()
{
void
SetUp
()
{
bvar
::
detail
::
FLAGS_show_sampler_usage
=
false
;
}
}
void
TearDown
()
{
void
TearDown
()
{
ASSERT_EQ
(
0UL
,
bvar
::
Variable
::
count_exposed
());
ASSERT_EQ
(
0UL
,
bvar
::
Variable
::
count_exposed
());
...
...
This diff is collapsed.
Click to expand it.
test/logging_unittest.cc
View file @
f4b97bbb
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#include "butil/basictypes.h"
#include "butil/basictypes.h"
#include "butil/logging.h"
#include "butil/logging.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <gflags/gflags.h>
#include <gflags/gflags.h>
...
@@ -17,8 +16,6 @@ DECLARE_int32(v);
...
@@ -17,8 +16,6 @@ DECLARE_int32(v);
namespace
{
namespace
{
using
::
testing
::
Return
;
// Needs to be global since log assert handlers can't maintain state.
// Needs to be global since log assert handlers can't maintain state.
int
log_sink_call_count
=
0
;
int
log_sink_call_count
=
0
;
...
@@ -65,44 +62,6 @@ private:
...
@@ -65,44 +62,6 @@ private:
LogStateSaver
log_state_saver_
;
LogStateSaver
log_state_saver_
;
};
};
class
MockLogSource
{
public
:
MOCK_METHOD0
(
Log
,
const
char
*
());
};
TEST_F
(
LoggingTest
,
BasicLogging
)
{
MockLogSource
mock_log_source
;
EXPECT_CALL
(
mock_log_source
,
Log
()).
Times
(
DEBUG_MODE
?
16
:
8
).
WillRepeatedly
(
Return
(
"log message"
));
SetMinLogLevel
(
BLOG_INFO
);
EXPECT_TRUE
(
LOG_IS_ON
(
INFO
));
// As of g++-4.5, the first argument to EXPECT_EQ cannot be a
// constant expression.
const
bool
kIsDebugMode
=
(
DEBUG_MODE
!=
0
);
EXPECT_TRUE
(
kIsDebugMode
==
DLOG_IS_ON
(
INFO
));
EXPECT_TRUE
(
VLOG_IS_ON
(
0
));
LOG
(
INFO
)
<<
mock_log_source
.
Log
();
LOG_IF
(
INFO
,
true
)
<<
mock_log_source
.
Log
();
PLOG
(
INFO
)
<<
mock_log_source
.
Log
();
PLOG_IF
(
INFO
,
true
)
<<
mock_log_source
.
Log
();
VLOG
(
0
)
<<
mock_log_source
.
Log
();
VLOG_IF
(
0
,
true
)
<<
mock_log_source
.
Log
();
VPLOG
(
0
)
<<
mock_log_source
.
Log
();
VPLOG_IF
(
0
,
true
)
<<
mock_log_source
.
Log
();
DLOG
(
INFO
)
<<
mock_log_source
.
Log
();
DLOG_IF
(
INFO
,
true
)
<<
mock_log_source
.
Log
();
DPLOG
(
INFO
)
<<
mock_log_source
.
Log
();
DPLOG_IF
(
INFO
,
true
)
<<
mock_log_source
.
Log
();
DVLOG
(
0
)
<<
mock_log_source
.
Log
();
DVLOG_IF
(
0
,
true
)
<<
mock_log_source
.
Log
();
DVPLOG
(
0
)
<<
mock_log_source
.
Log
();
DVPLOG_IF
(
0
,
true
)
<<
mock_log_source
.
Log
();
}
TEST_F
(
LoggingTest
,
LogIsOn
)
{
TEST_F
(
LoggingTest
,
LogIsOn
)
{
#if defined(NDEBUG)
#if defined(NDEBUG)
const
bool
kDfatalIsFatal
=
false
;
const
bool
kDfatalIsFatal
=
false
;
...
@@ -140,56 +99,6 @@ TEST_F(LoggingTest, LogIsOn) {
...
@@ -140,56 +99,6 @@ TEST_F(LoggingTest, LogIsOn) {
EXPECT_TRUE
(
kDfatalIsFatal
==
LOG_IS_ON
(
DFATAL
));
EXPECT_TRUE
(
kDfatalIsFatal
==
LOG_IS_ON
(
DFATAL
));
}
}
TEST_F
(
LoggingTest
,
LoggingIsLazy
)
{
MockLogSource
mock_log_source
;
EXPECT_CALL
(
mock_log_source
,
Log
()).
Times
(
0
);
SetMinLogLevel
(
BLOG_WARNING
);
EXPECT_FALSE
(
LOG_IS_ON
(
INFO
));
EXPECT_FALSE
(
DLOG_IS_ON
(
INFO
));
EXPECT_FALSE
(
VLOG_IS_ON
(
1
));
LOG
(
INFO
)
<<
mock_log_source
.
Log
();
LOG_IF
(
INFO
,
false
)
<<
mock_log_source
.
Log
();
PLOG
(
INFO
)
<<
mock_log_source
.
Log
();
PLOG_IF
(
INFO
,
false
)
<<
mock_log_source
.
Log
();
VLOG
(
1
)
<<
mock_log_source
.
Log
();
VLOG_IF
(
1
,
true
)
<<
mock_log_source
.
Log
();
VPLOG
(
1
)
<<
mock_log_source
.
Log
();
VPLOG_IF
(
1
,
true
)
<<
mock_log_source
.
Log
();
DLOG
(
INFO
)
<<
mock_log_source
.
Log
();
DLOG_IF
(
INFO
,
true
)
<<
mock_log_source
.
Log
();
DPLOG
(
INFO
)
<<
mock_log_source
.
Log
();
DPLOG_IF
(
INFO
,
true
)
<<
mock_log_source
.
Log
();
DVLOG
(
1
)
<<
mock_log_source
.
Log
();
DVLOG_IF
(
1
,
true
)
<<
mock_log_source
.
Log
();
DVPLOG
(
1
)
<<
mock_log_source
.
Log
();
DVPLOG_IF
(
1
,
true
)
<<
mock_log_source
.
Log
();
}
// Official builds have CHECKs directly call BreakDebugger.
#if !defined(OFFICIAL_BUILD)
TEST_F
(
LoggingTest
,
CheckStreamsAreLazy
)
{
MockLogSource
mock_log_source
,
uncalled_mock_log_source
;
EXPECT_CALL
(
mock_log_source
,
Log
()).
Times
(
8
).
WillRepeatedly
(
Return
(
"check message"
));
EXPECT_CALL
(
uncalled_mock_log_source
,
Log
()).
Times
(
0
);
SetLogAssertHandler
(
&
LogSink
);
CHECK
(
mock_log_source
.
Log
())
<<
uncalled_mock_log_source
.
Log
();
PCHECK
(
!
mock_log_source
.
Log
())
<<
mock_log_source
.
Log
();
CHECK_EQ
(
mock_log_source
.
Log
(),
mock_log_source
.
Log
())
<<
uncalled_mock_log_source
.
Log
();
CHECK_NE
(
mock_log_source
.
Log
(),
mock_log_source
.
Log
())
<<
mock_log_source
.
Log
();
}
#endif
TEST_F
(
LoggingTest
,
DebugLoggingReleaseBehavior
)
{
TEST_F
(
LoggingTest
,
DebugLoggingReleaseBehavior
)
{
#if !defined(NDEBUG)
#if !defined(NDEBUG)
int
debug_only_variable
=
1
;
int
debug_only_variable
=
1
;
...
@@ -202,21 +111,6 @@ TEST_F(LoggingTest, DebugLoggingReleaseBehavior) {
...
@@ -202,21 +111,6 @@ TEST_F(LoggingTest, DebugLoggingReleaseBehavior) {
DVLOG_IF
(
1
,
debug_only_variable
)
<<
"test"
;
DVLOG_IF
(
1
,
debug_only_variable
)
<<
"test"
;
}
}
TEST_F
(
LoggingTest
,
DcheckStreamsAreLazy
)
{
MockLogSource
mock_log_source
;
EXPECT_CALL
(
mock_log_source
,
Log
()).
Times
(
0
);
#if DCHECK_IS_ON()
DCHECK
(
true
)
<<
mock_log_source
.
Log
();
DCHECK_EQ
(
0
,
0
)
<<
mock_log_source
.
Log
();
#else
DCHECK
(
mock_log_source
.
Log
())
<<
mock_log_source
.
Log
();
DPCHECK
(
mock_log_source
.
Log
())
<<
mock_log_source
.
Log
();
DCHECK_EQ
(
0
,
0
)
<<
mock_log_source
.
Log
();
DCHECK_EQ
(
mock_log_source
.
Log
(),
static_cast
<
const
char
*>
(
NULL
))
<<
mock_log_source
.
Log
();
#endif
}
TEST_F
(
LoggingTest
,
Dcheck
)
{
TEST_F
(
LoggingTest
,
Dcheck
)
{
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
// Release build.
// Release build.
...
...
This diff is collapsed.
Click to expand it.
test/run_tests.sh
0 → 100755
View file @
f4b97bbb
#/bin/bash -f
test_num
=
0
failed_test
=
""
rc
=
0
make
-j8
test_bins
=
"test_butil test_bvar bthread*unittest brpc*unittest"
for
test_bin
in
$test_bins
;
do
test_num
=
$((
test_num
+
1
))
>
&2
echo
"[runtest]
$test_bin
"
./
$test_bin
rc
=
$?
if
[[
$rc
-ne
0
]]
;
then
failed_test
=
"
$test_bin
"
break
;
fi
done
if
[[
$test_num
-eq
0
]]
;
then
>
&2
echo
"[runtest] Cannot find any tests"
exit
1
fi
if
[[
-z
"
$failed_test
"
]]
;
then
>
&2
echo
"[runtest]
$test_num
succeeded"
elif
[[
$test_num
-gt
1
]]
;
then
>
&2
echo
"[runtest] '
$failed_test
' failed,
$((
test_num-1
))
succeeded"
else
>
&2
echo
"[runtest] '
$failed_test
' failed"
fi
exit
$rc
This diff is collapsed.
Click to expand it.
test/scoped_locale.cc
View file @
f4b97bbb
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
#include "
test/
scoped_locale.h"
#include "scoped_locale.h"
#include <locale.h>
#include <locale.h>
...
...
This diff is collapsed.
Click to expand it.
test/shared_memory_unittest.cc
View file @
f4b97bbb
...
@@ -9,11 +9,11 @@
...
@@ -9,11 +9,11 @@
#include "butil/rand_util.h"
#include "butil/rand_util.h"
#include "butil/strings/string_number_conversions.h"
#include "butil/strings/string_number_conversions.h"
#include "butil/sys_info.h"
#include "butil/sys_info.h"
#include "
test/
multiprocess_test.h"
#include "multiprocess_test.h"
#include "butil/threading/platform_thread.h"
#include "butil/threading/platform_thread.h"
#include "butil/time/time.h"
#include "butil/time/time.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include "
test/
multiprocess_func_list.h"
#include "multiprocess_func_list.h"
#if defined(OS_MACOSX)
#if defined(OS_MACOSX)
#include "butil/mac/scoped_nsautorelease_pool.h"
#include "butil/mac/scoped_nsautorelease_pool.h"
...
...
This diff is collapsed.
Click to expand it.
test/string_split_unittest.cc
View file @
f4b97bbb
...
@@ -5,15 +5,21 @@
...
@@ -5,15 +5,21 @@
#include "butil/strings/string_split.h"
#include "butil/strings/string_split.h"
#include "butil/strings/utf_string_conversions.h"
#include "butil/strings/utf_string_conversions.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
using
::
testing
::
ElementsAre
;
namespace
butil
{
namespace
butil
{
namespace
{
namespace
{
void
AssertElements
(
std
::
vector
<
std
::
string
>&
result
,
const
char
*
const
expected_data
[],
size_t
data_size
)
{
ASSERT_EQ
(
data_size
,
result
.
size
());
for
(
size_t
i
=
0
;
i
<
data_size
;
++
i
)
{
ASSERT_STREQ
(
expected_data
[
i
],
result
[
i
].
c_str
());
}
}
#if !defined(WCHAR_T_IS_UTF16)
#if !defined(WCHAR_T_IS_UTF16)
// Overload SplitString with a wide-char version to make it easier to
// Overload SplitString with a wide-char version to make it easier to
// test the string16 version with wide character literals.
// test the string16 version with wide character literals.
...
@@ -165,8 +171,8 @@ TEST_F(SplitStringIntoKeyValuePairsTest, DelimiterInValue) {
...
@@ -165,8 +171,8 @@ TEST_F(SplitStringIntoKeyValuePairsTest, DelimiterInValue) {
TEST
(
SplitStringUsingSubstrTest
,
EmptyString
)
{
TEST
(
SplitStringUsingSubstrTest
,
EmptyString
)
{
std
::
vector
<
std
::
string
>
results
;
std
::
vector
<
std
::
string
>
results
;
SplitStringUsingSubstr
(
std
::
string
(),
"DELIMITER"
,
&
results
);
SplitStringUsingSubstr
(
std
::
string
(),
"DELIMITER"
,
&
results
);
ASSERT_EQ
(
1u
,
results
.
size
())
;
const
char
*
const
expected
[]
=
{
""
}
;
EXPECT_THAT
(
results
,
ElementsAre
(
""
));
AssertElements
(
results
,
expected
,
arraysize
(
expected
));
}
}
TEST
(
StringUtilTest
,
SplitString
)
{
TEST
(
StringUtilTest
,
SplitString
)
{
...
@@ -236,8 +242,8 @@ TEST(StringUtilTest, SplitString) {
...
@@ -236,8 +242,8 @@ TEST(StringUtilTest, SplitString) {
TEST
(
SplitStringUsingSubstrTest
,
StringWithNoDelimiter
)
{
TEST
(
SplitStringUsingSubstrTest
,
StringWithNoDelimiter
)
{
std
::
vector
<
std
::
string
>
results
;
std
::
vector
<
std
::
string
>
results
;
SplitStringUsingSubstr
(
"alongwordwithnodelimiter"
,
"DELIMITER"
,
&
results
);
SplitStringUsingSubstr
(
"alongwordwithnodelimiter"
,
"DELIMITER"
,
&
results
);
ASSERT_EQ
(
1u
,
results
.
size
())
;
const
char
*
const
expected
[]
=
{
"alongwordwithnodelimiter"
}
;
EXPECT_THAT
(
results
,
ElementsAre
(
"alongwordwithnodelimiter"
));
AssertElements
(
results
,
expected
,
arraysize
(
expected
));
}
}
TEST
(
SplitStringUsingSubstrTest
,
LeadingDelimitersSkipped
)
{
TEST
(
SplitStringUsingSubstrTest
,
LeadingDelimitersSkipped
)
{
...
@@ -246,8 +252,8 @@ TEST(SplitStringUsingSubstrTest, LeadingDelimitersSkipped) {
...
@@ -246,8 +252,8 @@ TEST(SplitStringUsingSubstrTest, LeadingDelimitersSkipped) {
"DELIMITERDELIMITERDELIMITERoneDELIMITERtwoDELIMITERthree"
,
"DELIMITERDELIMITERDELIMITERoneDELIMITERtwoDELIMITERthree"
,
"DELIMITER"
,
"DELIMITER"
,
&
results
);
&
results
);
ASSERT_EQ
(
6u
,
results
.
size
())
;
const
char
*
const
expected
[]
=
{
""
,
""
,
""
,
"one"
,
"two"
,
"three"
}
;
EXPECT_THAT
(
results
,
ElementsAre
(
""
,
""
,
""
,
"one"
,
"two"
,
"three"
));
AssertElements
(
results
,
expected
,
arraysize
(
expected
));
}
}
TEST
(
SplitStringUsingSubstrTest
,
ConsecutiveDelimitersSkipped
)
{
TEST
(
SplitStringUsingSubstrTest
,
ConsecutiveDelimitersSkipped
)
{
...
@@ -256,8 +262,9 @@ TEST(SplitStringUsingSubstrTest, ConsecutiveDelimitersSkipped) {
...
@@ -256,8 +262,9 @@ TEST(SplitStringUsingSubstrTest, ConsecutiveDelimitersSkipped) {
"unoDELIMITERDELIMITERDELIMITERdosDELIMITERtresDELIMITERDELIMITERcuatro"
,
"unoDELIMITERDELIMITERDELIMITERdosDELIMITERtresDELIMITERDELIMITERcuatro"
,
"DELIMITER"
,
"DELIMITER"
,
&
results
);
&
results
);
ASSERT_EQ
(
7u
,
results
.
size
());
const
char
*
const
expected
[]
=
{
"uno"
,
""
,
""
,
"dos"
,
"tres"
,
""
,
"cuatro"
};
EXPECT_THAT
(
results
,
ElementsAre
(
"uno"
,
""
,
""
,
"dos"
,
"tres"
,
""
,
"cuatro"
));
AssertElements
(
results
,
expected
,
arraysize
(
expected
));
}
}
TEST
(
SplitStringUsingSubstrTest
,
TrailingDelimitersSkipped
)
{
TEST
(
SplitStringUsingSubstrTest
,
TrailingDelimitersSkipped
)
{
...
@@ -266,9 +273,8 @@ TEST(SplitStringUsingSubstrTest, TrailingDelimitersSkipped) {
...
@@ -266,9 +273,8 @@ TEST(SplitStringUsingSubstrTest, TrailingDelimitersSkipped) {
"unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER"
,
"unDELIMITERdeuxDELIMITERtroisDELIMITERquatreDELIMITERDELIMITERDELIMITER"
,
"DELIMITER"
,
"DELIMITER"
,
&
results
);
&
results
);
ASSERT_EQ
(
7u
,
results
.
size
());
const
char
*
const
expected
[]
=
{
"un"
,
"deux"
,
"trois"
,
"quatre"
,
""
,
""
,
""
};
EXPECT_THAT
(
AssertElements
(
results
,
expected
,
arraysize
(
expected
));
results
,
ElementsAre
(
"un"
,
"deux"
,
"trois"
,
"quatre"
,
""
,
""
,
""
));
}
}
TEST
(
StringSplitTest
,
StringSplitDontTrim
)
{
TEST
(
StringSplitTest
,
StringSplitDontTrim
)
{
...
...
This diff is collapsed.
Click to expand it.
test/string_util_unittest.cc
View file @
f4b97bbb
...
@@ -12,11 +12,8 @@
...
@@ -12,11 +12,8 @@
#include "butil/basictypes.h"
#include "butil/basictypes.h"
#include "butil/strings/string16.h"
#include "butil/strings/string16.h"
#include "butil/strings/utf_string_conversions.h"
#include "butil/strings/utf_string_conversions.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
using
::
testing
::
ElementsAre
;
namespace
butil
{
namespace
butil
{
static
const
struct
trim_case
{
static
const
struct
trim_case
{
...
...
This diff is collapsed.
Click to expand it.
test/sys_string_conversions_unittest.cc
View file @
f4b97bbb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include "butil/strings/string_piece.h"
#include "butil/strings/string_piece.h"
#include "butil/strings/sys_string_conversions.h"
#include "butil/strings/sys_string_conversions.h"
#include "butil/strings/utf_string_conversions.h"
#include "butil/strings/utf_string_conversions.h"
#include "
test/
scoped_locale.h"
#include "scoped_locale.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#ifdef WCHAR_T_IS_UTF32
#ifdef WCHAR_T_IS_UTF32
...
...
This diff is collapsed.
Click to expand it.
test/test_switches.cc
View file @
f4b97bbb
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
#include "test
/test
_switches.h"
#include "test_switches.h"
// Time (in milliseconds) that the tests should wait before timing out.
// Time (in milliseconds) that the tests should wait before timing out.
// TODO(phajdan.jr): Clean up the switch names.
// TODO(phajdan.jr): Clean up the switch names.
...
...
This diff is collapsed.
Click to expand it.
test/xdg_util_unittest.cc
deleted
100644 → 0
View file @
5b817802
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "butil/nix/xdg_util.h"
#include "butil/environment.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using
::
testing
::
_
;
using
::
testing
::
Return
;
using
::
testing
::
SetArgumentPointee
;
using
::
testing
::
StrEq
;
namespace
butil
{
namespace
nix
{
namespace
{
class
MockEnvironment
:
public
Environment
{
public
:
MOCK_METHOD2
(
GetVar
,
bool
(
const
char
*
,
std
::
string
*
result
));
MOCK_METHOD2
(
SetVar
,
bool
(
const
char
*
,
const
std
::
string
&
new_value
));
MOCK_METHOD1
(
UnSetVar
,
bool
(
const
char
*
));
};
const
char
*
kGnome
=
"gnome"
;
const
char
*
kKDE4
=
"kde4"
;
const
char
*
kKDE
=
"kde"
;
const
char
*
kXFCE
=
"xfce"
;
}
// namespace
TEST
(
XDGUtilTest
,
GetDesktopEnvironmentGnome
)
{
MockEnvironment
getter
;
EXPECT_CALL
(
getter
,
GetVar
(
_
,
_
)).
WillRepeatedly
(
Return
(
false
));
EXPECT_CALL
(
getter
,
GetVar
(
StrEq
(
"DESKTOP_SESSION"
),
_
))
.
WillOnce
(
DoAll
(
SetArgumentPointee
<
1
>
(
kGnome
),
Return
(
true
)));
EXPECT_EQ
(
DESKTOP_ENVIRONMENT_GNOME
,
GetDesktopEnvironment
(
&
getter
));
}
TEST
(
XDGUtilTest
,
GetDesktopEnvironmentKDE4
)
{
MockEnvironment
getter
;
EXPECT_CALL
(
getter
,
GetVar
(
_
,
_
)).
WillRepeatedly
(
Return
(
false
));
EXPECT_CALL
(
getter
,
GetVar
(
StrEq
(
"DESKTOP_SESSION"
),
_
))
.
WillOnce
(
DoAll
(
SetArgumentPointee
<
1
>
(
kKDE4
),
Return
(
true
)));
EXPECT_EQ
(
DESKTOP_ENVIRONMENT_KDE4
,
GetDesktopEnvironment
(
&
getter
));
}
TEST
(
XDGUtilTest
,
GetDesktopEnvironmentKDE3
)
{
MockEnvironment
getter
;
EXPECT_CALL
(
getter
,
GetVar
(
_
,
_
)).
WillRepeatedly
(
Return
(
false
));
EXPECT_CALL
(
getter
,
GetVar
(
StrEq
(
"DESKTOP_SESSION"
),
_
))
.
WillOnce
(
DoAll
(
SetArgumentPointee
<
1
>
(
kKDE
),
Return
(
true
)));
EXPECT_EQ
(
DESKTOP_ENVIRONMENT_KDE3
,
GetDesktopEnvironment
(
&
getter
));
}
TEST
(
XDGUtilTest
,
GetDesktopEnvironmentXFCE
)
{
MockEnvironment
getter
;
EXPECT_CALL
(
getter
,
GetVar
(
_
,
_
)).
WillRepeatedly
(
Return
(
false
));
EXPECT_CALL
(
getter
,
GetVar
(
StrEq
(
"DESKTOP_SESSION"
),
_
))
.
WillOnce
(
DoAll
(
SetArgumentPointee
<
1
>
(
kXFCE
),
Return
(
true
)));
EXPECT_EQ
(
DESKTOP_ENVIRONMENT_XFCE
,
GetDesktopEnvironment
(
&
getter
));
}
}
// namespace nix
}
// namespace butil
This diff is collapsed.
Click to expand it.
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