# These are good warnings to turn on by default
if GCC
-AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
+ AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
endif
# These are x86-specific, having to do with frame-pointers
if X86_64
if ENABLE_FRAME_POINTERS
-AM_CXXFLAGS += -fno-omit-frame-pointer
+ AM_CXXFLAGS += -fno-omit-frame-pointer
else
# TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
# before setting this.
-AM_CXXFLAGS += -DNO_FRAME_POINTER
+ AM_CXXFLAGS += -DNO_FRAME_POINTER
endif
endif
## Add your documentation files (in doc/) in addition to these
## top-level boilerplate files. Also add a TODO file if you have one.
dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README \
- doc/designstyle.css doc/glog.html
+ doc/designstyle.css doc/glog.html
## The libraries (.so's) you want to install
lib_LTLIBRARIES =
# The libraries libglog depends on.
COMMON_LIBS = $(PTHREAD_LIBS) $(GFLAGS_LIBS) $(UNWIND_LIBS)
+# Compile switches for our unittest.
+TEST_CFLAGS = $(GTEST_CFLAGS) $(GMOCK_CFLAGS)
# Libraries for our unittest.
TEST_LIBS = $(GTEST_LIBS) $(GMOCK_LIBS)
TESTS += logging_unittest
logging_unittest_SOURCES = $(gloginclude_HEADERS) \
- src/logging_unittest.cc \
- src/config_for_unittests.h
+ src/logging_unittest.cc \
+ src/config_for_unittests.h
nodist_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
check_SCRIPTS += signalhandler_unittest_sh
noinst_SCRIPTS += src/signalhandler_unittest.sh
signalhandler_unittest_sh: signalhandler_unittest
- # force to create lt-signalhandler_unittest
- $(top_srcdir)/signalhandler_unittest
+ $(top_srcdir)/signalhandler_unittest # force to create lt-signalhandler_unittest
$(top_srcdir)/src/signalhandler_unittest.sh
TEST_BINARIES += logging_striptest0
demangle_unittest_SOURCES = $(gloginclude_HEADERS) \
src/demangle_unittest.cc
nodist_demangle_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
demangle_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
demangle_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
symbolize_unittest_SOURCES = $(gloginclude_HEADERS) \
src/symbolize_unittest.cc
nodist_symbolize_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
symbolize_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
symbolize_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
utilities_unittest_SOURCES = $(gloginclude_HEADERS) \
src/utilities_unittest.cc
nodist_utilities_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
utilities_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
utilities_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+if HAVE_GMOCK
+TESTS += mock_log_test
+mock_log_test_SOURCES = $(gloginclude_HEADERS) \
+ src/mock-log_test.cc
+nodist_mock_log_test_SOURCES = $(nodist_gloginclude_HEADERS)
+mock_log_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+mock_log_test_LDFLAGS = $(PTHREAD_CFLAGS)
+mock_log_test_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+endif
+
## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
lib_LTLIBRARIES += libglog.la
libglog_la_SOURCES = $(gloginclude_HEADERS) \
src/logging.cc src/raw_logging.cc src/vlog_is_on.cc \
src/utilities.cc src/utilities.h \
- src/demangle.cc src/demangle.h \
+ src/demangle.cc src/demangle.h \
src/stacktrace.h \
src/stacktrace_generic-inl.h \
src/stacktrace_libunwind-inl.h \
@ENABLE_FRAME_POINTERS_FALSE@@X86_64_TRUE@am__append_3 = -DNO_FRAME_POINTER
TESTS = logging_unittest$(EXEEXT) demangle_unittest$(EXEEXT) \
stacktrace_unittest$(EXEEXT) symbolize_unittest$(EXEEXT) \
- stl_logging_unittest$(EXEEXT) utilities_unittest$(EXEEXT)
-noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
+ stl_logging_unittest$(EXEEXT) utilities_unittest$(EXEEXT) \
+ $(am__EXEEXT_1)
+@HAVE_GMOCK_TRUE@am__append_4 = mock_log_test
+noinst_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
$(gloginclude_HEADERS) $(noinst_HEADERS) $(srcdir)/Makefile.am \
libglog_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libglog_la_CXXFLAGS) \
$(CXXFLAGS) $(libglog_la_LDFLAGS) $(LDFLAGS) -o $@
-am__EXEEXT_1 = logging_unittest$(EXEEXT) demangle_unittest$(EXEEXT) \
+@HAVE_GMOCK_TRUE@am__EXEEXT_1 = mock_log_test$(EXEEXT)
+am__EXEEXT_2 = logging_unittest$(EXEEXT) demangle_unittest$(EXEEXT) \
stacktrace_unittest$(EXEEXT) symbolize_unittest$(EXEEXT) \
- stl_logging_unittest$(EXEEXT) utilities_unittest$(EXEEXT)
-am__EXEEXT_2 = logging_striptest0$(EXEEXT) logging_striptest2$(EXEEXT) \
+ stl_logging_unittest$(EXEEXT) utilities_unittest$(EXEEXT) \
+ $(am__EXEEXT_1)
+am__EXEEXT_3 = logging_striptest0$(EXEEXT) logging_striptest2$(EXEEXT) \
logging_striptest10$(EXEEXT) signalhandler_unittest$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
am_demangle_unittest_OBJECTS = $(am__objects_1) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) \
$(logging_unittest_CXXFLAGS) $(CXXFLAGS) \
$(logging_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am__mock_log_test_SOURCES_DIST = src/glog/log_severity.h \
+ src/mock-log_test.cc
+@HAVE_GMOCK_TRUE@am_mock_log_test_OBJECTS = $(am__objects_1) \
+@HAVE_GMOCK_TRUE@ mock_log_test-mock-log_test.$(OBJEXT)
+@HAVE_GMOCK_TRUE@nodist_mock_log_test_OBJECTS = $(am__objects_1)
+mock_log_test_OBJECTS = $(am_mock_log_test_OBJECTS) \
+ $(nodist_mock_log_test_OBJECTS)
+@HAVE_GMOCK_TRUE@mock_log_test_DEPENDENCIES = libglog.la \
+@HAVE_GMOCK_TRUE@ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3)
+mock_log_test_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(mock_log_test_CXXFLAGS) \
+ $(CXXFLAGS) $(mock_log_test_LDFLAGS) $(LDFLAGS) -o $@
am_signalhandler_unittest_OBJECTS = $(am__objects_1) \
signalhandler_unittest-signalhandler_unittest.$(OBJEXT)
nodist_signalhandler_unittest_OBJECTS = $(am__objects_1)
$(logging_striptest2_SOURCES) \
$(nodist_logging_striptest2_SOURCES) \
$(logging_unittest_SOURCES) $(nodist_logging_unittest_SOURCES) \
+ $(mock_log_test_SOURCES) $(nodist_mock_log_test_SOURCES) \
$(signalhandler_unittest_SOURCES) \
$(nodist_signalhandler_unittest_SOURCES) \
$(stacktrace_unittest_SOURCES) \
DIST_SOURCES = $(libglog_la_SOURCES) $(demangle_unittest_SOURCES) \
$(logging_striptest0_SOURCES) $(logging_striptest10_SOURCES) \
$(logging_striptest2_SOURCES) $(logging_unittest_SOURCES) \
+ $(am__mock_log_test_SOURCES_DIST) \
$(signalhandler_unittest_SOURCES) \
$(stacktrace_unittest_SOURCES) $(stl_logging_unittest_SOURCES) \
$(symbolize_unittest_SOURCES) $(utilities_unittest_SOURCES)
F77 = @F77@
FFLAGS = @FFLAGS@
GFLAGS_LIBS = @GFLAGS_LIBS@
+GMOCK_CFLAGS = @GMOCK_CFLAGS@
+GMOCK_CONFIG = @GMOCK_CONFIG@
GMOCK_LIBS = @GMOCK_LIBS@
GREP = @GREP@
+GTEST_CFLAGS = @GTEST_CFLAGS@
+GTEST_CONFIG = @GTEST_CONFIG@
GTEST_LIBS = @GTEST_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
nodist_gloginclude_HEADERS = src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h
noinst_HEADERS = src/glog/logging.h.in src/glog/raw_logging.h.in src/glog/vlog_is_on.h.in src/glog/stl_logging.h.in
dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README \
- doc/designstyle.css doc/glog.html
+ doc/designstyle.css doc/glog.html
lib_LTLIBRARIES = libglog.la
# The libraries libglog depends on.
COMMON_LIBS = $(PTHREAD_LIBS) $(GFLAGS_LIBS) $(UNWIND_LIBS)
+# Compile switches for our unittest.
+TEST_CFLAGS = $(GTEST_CFLAGS) $(GMOCK_CFLAGS)
# Libraries for our unittest.
TEST_LIBS = $(GTEST_LIBS) $(GMOCK_LIBS)
TESTS_ENVIRONMENT =
TEST_BINARIES = logging_striptest0 logging_striptest2 \
logging_striptest10 signalhandler_unittest
logging_unittest_SOURCES = $(gloginclude_HEADERS) \
- src/logging_unittest.cc \
- src/config_for_unittests.h
+ src/logging_unittest.cc \
+ src/config_for_unittests.h
nodist_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
logging_striptest0_SOURCES = $(gloginclude_HEADERS) \
src/demangle_unittest.cc
nodist_demangle_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
demangle_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
demangle_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
stacktrace_unittest_SOURCES = $(gloginclude_HEADERS) \
src/symbolize_unittest.cc
nodist_symbolize_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
symbolize_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
symbolize_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
stl_logging_unittest_SOURCES = $(gloginclude_HEADERS) \
src/utilities_unittest.cc
nodist_utilities_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
-utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
+utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
utilities_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
utilities_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+@HAVE_GMOCK_TRUE@mock_log_test_SOURCES = $(gloginclude_HEADERS) \
+@HAVE_GMOCK_TRUE@ src/mock-log_test.cc
+
+@HAVE_GMOCK_TRUE@nodist_mock_log_test_SOURCES = $(nodist_gloginclude_HEADERS)
+@HAVE_GMOCK_TRUE@mock_log_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+@HAVE_GMOCK_TRUE@mock_log_test_LDFLAGS = $(PTHREAD_CFLAGS)
+@HAVE_GMOCK_TRUE@mock_log_test_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
libglog_la_SOURCES = $(gloginclude_HEADERS) \
src/logging.cc src/raw_logging.cc src/vlog_is_on.cc \
src/utilities.cc src/utilities.h \
- src/demangle.cc src/demangle.h \
+ src/demangle.cc src/demangle.h \
src/stacktrace.h \
src/stacktrace_generic-inl.h \
src/stacktrace_libunwind-inl.h \
logging_unittest$(EXEEXT): $(logging_unittest_OBJECTS) $(logging_unittest_DEPENDENCIES)
@rm -f logging_unittest$(EXEEXT)
$(logging_unittest_LINK) $(logging_unittest_OBJECTS) $(logging_unittest_LDADD) $(LIBS)
+mock_log_test$(EXEEXT): $(mock_log_test_OBJECTS) $(mock_log_test_DEPENDENCIES)
+ @rm -f mock_log_test$(EXEEXT)
+ $(mock_log_test_LINK) $(mock_log_test_OBJECTS) $(mock_log_test_LDADD) $(LIBS)
signalhandler_unittest$(EXEEXT): $(signalhandler_unittest_OBJECTS) $(signalhandler_unittest_DEPENDENCIES)
@rm -f signalhandler_unittest$(EXEEXT)
$(signalhandler_unittest_LINK) $(signalhandler_unittest_OBJECTS) $(signalhandler_unittest_LDADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logging_striptest10-logging_striptest10.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logging_striptest2-logging_striptest2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logging_unittest-logging_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mock_log_test-mock-log_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Po@am__quote@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_unittest_CXXFLAGS) $(CXXFLAGS) -c -o logging_unittest-logging_unittest.obj `if test -f 'src/logging_unittest.cc'; then $(CYGPATH_W) 'src/logging_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_unittest.cc'; fi`
+mock_log_test-mock-log_test.o: src/mock-log_test.cc
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -MT mock_log_test-mock-log_test.o -MD -MP -MF $(DEPDIR)/mock_log_test-mock-log_test.Tpo -c -o mock_log_test-mock-log_test.o `test -f 'src/mock-log_test.cc' || echo '$(srcdir)/'`src/mock-log_test.cc
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/mock_log_test-mock-log_test.Tpo $(DEPDIR)/mock_log_test-mock-log_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/mock-log_test.cc' object='mock_log_test-mock-log_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -c -o mock_log_test-mock-log_test.o `test -f 'src/mock-log_test.cc' || echo '$(srcdir)/'`src/mock-log_test.cc
+
+mock_log_test-mock-log_test.obj: src/mock-log_test.cc
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -MT mock_log_test-mock-log_test.obj -MD -MP -MF $(DEPDIR)/mock_log_test-mock-log_test.Tpo -c -o mock_log_test-mock-log_test.obj `if test -f 'src/mock-log_test.cc'; then $(CYGPATH_W) 'src/mock-log_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/mock-log_test.cc'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/mock_log_test-mock-log_test.Tpo $(DEPDIR)/mock_log_test-mock-log_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/mock-log_test.cc' object='mock_log_test-mock-log_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -c -o mock_log_test-mock-log_test.obj `if test -f 'src/mock-log_test.cc'; then $(CYGPATH_W) 'src/mock-log_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/mock-log_test.cc'; fi`
+
signalhandler_unittest-signalhandler_unittest.o: src/signalhandler_unittest.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(signalhandler_unittest_CXXFLAGS) $(CXXFLAGS) -MT signalhandler_unittest-signalhandler_unittest.o -MD -MP -MF $(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Tpo -c -o signalhandler_unittest-signalhandler_unittest.o `test -f 'src/signalhandler_unittest.cc' || echo '$(srcdir)/'`src/signalhandler_unittest.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Tpo $(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Po
$(top_srcdir)/demangle_unittest # force to create lt-demangle_unittest
$(top_srcdir)/src/demangle_unittest.sh
signalhandler_unittest_sh: signalhandler_unittest
- # force to create lt-signalhandler_unittest
- $(top_srcdir)/signalhandler_unittest
+ $(top_srcdir)/signalhandler_unittest # force to create lt-signalhandler_unittest
$(top_srcdir)/src/signalhandler_unittest.sh
rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
PTHREAD_CC
PTHREAD_LIBS
PTHREAD_CFLAGS
+GTEST_CONFIG
+GMOCK_CONFIG
+HAVE_GMOCK_TRUE
+HAVE_GMOCK_FALSE
UNWIND_LIBS
ac_google_start_namespace
ac_google_end_namespace
ac_cv_have___uint16
ac_cv_have_libgflags
GFLAGS_LIBS
+GTEST_CFLAGS
+GMOCK_CFLAGS
GTEST_LIBS
GMOCK_LIBS
LIBOBJS
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 5069 "configure"' > conftest.$ac_ext
+ echo '#line 5075 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7424: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7430: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7428: \$? = $ac_status" >&5
+ echo "$as_me:7434: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7714: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7720: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7718: \$? = $ac_status" >&5
+ echo "$as_me:7724: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7818: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7824: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7822: \$? = $ac_status" >&5
+ echo "$as_me:7828: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 10195 "configure"
+#line 10201 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 10295 "configure"
+#line 10301 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12696: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12702: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:12700: \$? = $ac_status" >&5
+ echo "$as_me:12706: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12800: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12806: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:12804: \$? = $ac_status" >&5
+ echo "$as_me:12810: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14398: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14404: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14402: \$? = $ac_status" >&5
+ echo "$as_me:14408: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14502: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14508: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14506: \$? = $ac_status" >&5
+ echo "$as_me:14512: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16722: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16728: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16726: \$? = $ac_status" >&5
+ echo "$as_me:16732: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17012: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17018: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:17016: \$? = $ac_status" >&5
+ echo "$as_me:17022: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17116: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17122: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:17120: \$? = $ac_status" >&5
+ echo "$as_me:17126: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
GFLAGS_LIBS=
fi
-# Check if there is gtest library installed.
-{ echo "$as_me:$LINENO: checking for main in -lgtest" >&5
-echo $ECHO_N "checking for main in -lgtest... $ECHO_C" >&6; }
-if test "${ac_cv_lib_gtest_main+set}" = set; then
+# TODO(hamaji): Use official m4 macros provided by testing libraries
+# once the m4 macro of Google Mocking becomes ready.
+# Check if there is Google Test library installed.
+# Extract the first word of "gtest-config", so it can be a program name with args.
+set dummy gtest-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_GTEST_CONFIG+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgtest $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_lib_gtest_main=yes
+ if test -n "$GTEST_CONFIG"; then
+ ac_cv_prog_GTEST_CONFIG="$GTEST_CONFIG" # Let the user override the test.
else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_GTEST_CONFIG=""yes""
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
- ac_cv_lib_gtest_main=no
fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_gtest_main" >&5
-echo "${ECHO_T}$ac_cv_lib_gtest_main" >&6; }
-if test $ac_cv_lib_gtest_main = yes; then
- ac_cv_have_libgtest=1
+GTEST_CONFIG=$ac_cv_prog_GTEST_CONFIG
+if test -n "$GTEST_CONFIG"; then
+ { echo "$as_me:$LINENO: result: $GTEST_CONFIG" >&5
+echo "${ECHO_T}$GTEST_CONFIG" >&6; }
else
- ac_cv_have_libgtest=0
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
fi
-if test x"$ac_cv_have_libgtest" = x"1"; then
- GTEST_LIBS=-lgtest
+
+if test x"$GTEST_CONFIG" = "xyes"; then
+ GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
+ GTEST_LIBS=`gtest-config --ldflags --libs`
cat >>confdefs.h <<\_ACEOF
#define HAVE_LIB_GTEST 1
_ACEOF
- # Check if there is gmock library installed.
- { echo "$as_me:$LINENO: checking for main in -lgmock" >&5
-echo $ECHO_N "checking for main in -lgmock... $ECHO_C" >&6; }
-if test "${ac_cv_lib_gmock_main+set}" = set; then
+ # Check if there is Google Mocking library installed.
+ # Extract the first word of "gmock-config", so it can be a program name with args.
+set dummy gmock-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_GMOCK_CONFIG+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgmock $GTEST_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_lib_gmock_main=yes
+ if test -n "$GMOCK_CONFIG"; then
+ ac_cv_prog_GMOCK_CONFIG="$GMOCK_CONFIG" # Let the user override the test.
else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_GMOCK_CONFIG=""yes""
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
- ac_cv_lib_gmock_main=no
fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_gmock_main" >&5
-echo "${ECHO_T}$ac_cv_lib_gmock_main" >&6; }
-if test $ac_cv_lib_gmock_main = yes; then
- ac_cv_have_libgmock=1
+GMOCK_CONFIG=$ac_cv_prog_GMOCK_CONFIG
+if test -n "$GMOCK_CONFIG"; then
+ { echo "$as_me:$LINENO: result: $GMOCK_CONFIG" >&5
+echo "${ECHO_T}$GMOCK_CONFIG" >&6; }
else
- ac_cv_have_libgmock=0
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
fi
- if test x"$ac_cv_have_libgmock" = x"1"; then
- GMOCK_LIBS=-lgmock
+
+ if test x"$GMOCK_CONFIG" = "xyes"; then
+ GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
+ GMOCK_LIBS=`gmock-config --ldflags --libs`
cat >>confdefs.h <<\_ACEOF
#define HAVE_LIB_GMOCK 1
_ACEOF
else
+ # We don't run test cases which use Google Mocking framework.
+ GMOCK_CFLAGS=
GMOCK_LIBS=
fi
else
+ # We'll use src/googletest.h for our unittests.
+ GTEST_CFLAGS=
GTEST_LIBS=
fi
+ if test x"$GMOCK_CONFIG" = "xyes"; then
+ HAVE_GMOCK_TRUE=
+ HAVE_GMOCK_FALSE='#'
+else
+ HAVE_GMOCK_TRUE='#'
+ HAVE_GMOCK_FALSE=
+fi
+
# We want to link in libunwind if it exists
UNWIND_LIBS=
+
+
# Write generated configuration file
ac_config_files="$ac_config_files Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h"
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${HAVE_GMOCK_TRUE}" && test -z "${HAVE_GMOCK_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"HAVE_GMOCK\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"HAVE_GMOCK\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
PTHREAD_CC!$PTHREAD_CC$ac_delim
PTHREAD_LIBS!$PTHREAD_LIBS$ac_delim
PTHREAD_CFLAGS!$PTHREAD_CFLAGS$ac_delim
+GTEST_CONFIG!$GTEST_CONFIG$ac_delim
+GMOCK_CONFIG!$GMOCK_CONFIG$ac_delim
+HAVE_GMOCK_TRUE!$HAVE_GMOCK_TRUE$ac_delim
+HAVE_GMOCK_FALSE!$HAVE_GMOCK_FALSE$ac_delim
UNWIND_LIBS!$UNWIND_LIBS$ac_delim
ac_google_start_namespace!$ac_google_start_namespace$ac_delim
ac_google_end_namespace!$ac_google_end_namespace$ac_delim
ac_cv_have___uint16!$ac_cv_have___uint16$ac_delim
ac_cv_have_libgflags!$ac_cv_have_libgflags$ac_delim
GFLAGS_LIBS!$GFLAGS_LIBS$ac_delim
+GTEST_CFLAGS!$GTEST_CFLAGS$ac_delim
+GMOCK_CFLAGS!$GMOCK_CFLAGS$ac_delim
GTEST_LIBS!$GTEST_LIBS$ac_delim
GMOCK_LIBS!$GMOCK_LIBS$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 39; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 45; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
GFLAGS_LIBS=
fi
-# Check if there is gtest library installed.
-AC_CHECK_LIB(gtest, main, ac_cv_have_libgtest=1, ac_cv_have_libgtest=0)
-if test x"$ac_cv_have_libgtest" = x"1"; then
- GTEST_LIBS=-lgtest
+# TODO(hamaji): Use official m4 macros provided by testing libraries
+# once the m4 macro of Google Mocking becomes ready.
+# Check if there is Google Test library installed.
+AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes")
+if test x"$GTEST_CONFIG" = "xyes"; then
+ GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
+ GTEST_LIBS=`gtest-config --ldflags --libs`
AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library])
- # Check if there is gmock library installed.
- AC_CHECK_LIB(gmock, main, ac_cv_have_libgmock=1, ac_cv_have_libgmock=0,
- [$GTEST_LIBS])
- if test x"$ac_cv_have_libgmock" = x"1"; then
- GMOCK_LIBS=-lgmock
+ # Check if there is Google Mocking library installed.
+ AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes")
+ if test x"$GMOCK_CONFIG" = "xyes"; then
+ GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
+ GMOCK_LIBS=`gmock-config --ldflags --libs`
AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library])
else
+ # We don't run test cases which use Google Mocking framework.
+ GMOCK_CFLAGS=
GMOCK_LIBS=
fi
else
+ # We'll use src/googletest.h for our unittests.
+ GTEST_CFLAGS=
GTEST_LIBS=
fi
+AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes")
# We want to link in libunwind if it exists
UNWIND_LIBS=
AC_SUBST(ac_cv_have___uint16)
AC_SUBST(ac_cv_have_libgflags)
AC_SUBST(GFLAGS_LIBS)
+AC_SUBST(GTEST_CFLAGS)
+AC_SUBST(GMOCK_CFLAGS)
AC_SUBST(GTEST_LIBS)
AC_SUBST(GMOCK_LIBS)
--- /dev/null
+// Copyright (c) 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Zhanyong Wan
+//
+// Defines the ScopedMockLog class (using Google C++ Mocking
+// Framework), which is convenient for testing code that uses LOG().
+
+#ifndef GLOG_SRC_MOCK_LOG_H_
+#define GLOG_SRC_MOCK_LOG_H_
+
+// For GOOGLE_NAMESPACE. This must go first so we get _XOPEN_SOURCE.
+#include "utilities.h"
+
+#include <string>
+
+#include <gmock/gmock.h>
+
+#include "glog/logging.h"
+
+_START_GOOGLE_NAMESPACE_
+namespace glog_testing {
+
+// A ScopedMockLog object intercepts LOG() messages issued during its
+// lifespan. Using this together with Google C++ Mocking Framework,
+// it's very easy to test how a piece of code calls LOG(). The
+// typical usage:
+//
+// TEST(FooTest, LogsCorrectly) {
+// ScopedMockLog log;
+//
+// // We expect the WARNING "Something bad!" exactly twice.
+// EXPECT_CALL(log, Log(WARNING, _, "Something bad!"))
+// .Times(2);
+//
+// // We allow foo.cc to call LOG(INFO) any number of times.
+// EXPECT_CALL(log, Log(INFO, HasSubstr("/foo.cc"), _))
+// .Times(AnyNumber());
+//
+// Foo(); // Exercises the code under test.
+// }
+class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
+ public:
+ // When a ScopedMockLog object is constructed, it starts to
+ // intercept logs.
+ ScopedMockLog() { AddLogSink(this); }
+
+ // When the object is destructed, it stops intercepting logs.
+ virtual ~ScopedMockLog() { RemoveLogSink(this); }
+
+ // Implements the mock method:
+ //
+ // void Log(LogSeverity severity, const string& file_path,
+ // const string& message);
+ //
+ // The second argument to Send() is the full path of the source file
+ // in which the LOG() was issued.
+ //
+ // Note, that in a multi-threaded environment, all LOG() messages from a
+ // single thread will be handled in sequence, but that cannot be guaranteed
+ // for messages from different threads. In fact, if the same or multiple
+ // expectations are matched on two threads concurrently, their actions will
+ // be executed concurrently as well and may interleave.
+ MOCK_METHOD3(Log, void(GOOGLE_NAMESPACE::LogSeverity severity,
+ const std::string& file_path,
+ const std::string& message));
+
+ private:
+ // Implements the send() virtual function in class LogSink.
+ // Whenever a LOG() statement is executed, this function will be
+ // invoked with information presented in the LOG().
+ //
+ // The method argument list is long and carries much information a
+ // test usually doesn't care about, so we trim the list before
+ // forwarding the call to Log(), which is much easier to use in
+ // tests.
+ //
+ // We still cannot call Log() directly, as it may invoke other LOG()
+ // messages, either due to Invoke, or due to an error logged in
+ // Google C++ Mocking Framework code, which would trigger a deadlock
+ // since a lock is held during send().
+ //
+ // Hence, we save the message for WaitTillSent() which will be called after
+ // the lock on send() is released, and we'll call Log() inside
+ // WaitTillSent(). Since while a single send() call may be running at a
+ // time, multiple WaitTillSent() calls (along with the one send() call) may
+ // be running simultaneously, we ensure thread-safety of the exchange between
+ // send() and WaitTillSent(), and that for each message, LOG(), send(),
+ // WaitTillSent() and Log() are executed in the same thread.
+ virtual void send(GOOGLE_NAMESPACE::LogSeverity severity,
+ const char* full_filename,
+ const char* base_filename, int line, const tm* tm_time,
+ const char* message, size_t message_len) {
+ // We are only interested in the log severity, full file name, and
+ // log message.
+ message_info_.severity = severity;
+ message_info_.file_path = full_filename;
+ message_info_.message = std::string(message, message_len);
+ }
+
+ // Implements the WaitTillSent() virtual function in class LogSink.
+ // It will be executed after send() and after the global logging lock is
+ // released, so calls within it (or rather within the Log() method called
+ // within) may also issue LOG() statements.
+ //
+ // LOG(), send(), WaitTillSent() and Log() will occur in the same thread for
+ // a given log message.
+ virtual void WaitTillSent() {
+ // First, and very importantly, we save a copy of the message being
+ // processed before calling Log(), since Log() may indirectly call send()
+ // and WaitTillSent() in the same thread again.
+ MessageInfo message_info = message_info_;
+ Log(message_info.severity, message_info.file_path, message_info.message);
+ }
+
+ // All relevant information about a logged message that needs to be passed
+ // from send() to WaitTillSent().
+ struct MessageInfo {
+ GOOGLE_NAMESPACE::LogSeverity severity;
+ std::string file_path;
+ std::string message;
+ };
+ MessageInfo message_info_;
+};
+
+} // namespace glog_testing
+_END_GOOGLE_NAMESPACE_
+
+#endif // GLOG_SRC_MOCK_LOG_H_
--- /dev/null
+// Copyright (c) 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Zhanyong Wan
+
+// Tests the ScopedMockLog class.
+
+#include "mock-log.h"
+
+#include <string>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+namespace {
+
+using GOOGLE_NAMESPACE::INFO;
+using GOOGLE_NAMESPACE::WARNING;
+using GOOGLE_NAMESPACE::ERROR;
+using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog;
+using std::string;
+using testing::_;
+using testing::HasSubstr;
+using testing::InSequence;
+using testing::InvokeWithoutArgs;
+
+// Tests that ScopedMockLog intercepts LOG()s when it's alive.
+TEST(ScopedMockLogTest, InterceptsLog) {
+ ScopedMockLog log;
+
+ InSequence s;
+ EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_test.cc"), "Fishy."));
+ EXPECT_CALL(log, Log(INFO, _, "Working..."))
+ .Times(2);
+ EXPECT_CALL(log, Log(ERROR, _, "Bad!!"));
+
+ LOG(WARNING) << "Fishy.";
+ LOG(INFO) << "Working...";
+ LOG(INFO) << "Working...";
+ LOG(ERROR) << "Bad!!";
+}
+
+void LogBranch() {
+ LOG(INFO) << "Logging a branch...";
+}
+
+void LogTree() {
+ LOG(INFO) << "Logging the whole tree...";
+}
+
+void LogForest() {
+ LOG(INFO) << "Logging the entire forest.";
+ LOG(INFO) << "Logging the entire forest..";
+ LOG(INFO) << "Logging the entire forest...";
+}
+
+// The purpose of the following test is to verify that intercepting logging
+// continues to work properly if a LOG statement is executed within the scope
+// of a mocked call.
+TEST(ScopedMockLogTest, LogDuringIntercept) {
+ ScopedMockLog log;
+ InSequence s;
+ EXPECT_CALL(log, Log(INFO, __FILE__, "Logging a branch..."))
+ .WillOnce(InvokeWithoutArgs(LogTree));
+ EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the whole tree..."))
+ .WillOnce(InvokeWithoutArgs(LogForest));
+ EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest."));
+ EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest.."));
+ EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest..."));
+ LogBranch();
+}
+
+} // namespace
+
+int main(int argc, char **argv) {
+ GOOGLE_NAMESPACE::InitGoogleLogging(argv[0]);
+ testing::InitGoogleMock(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}