test: Support mocking with googletest
We should include gmock in our gtest dependencies so that we can use it
in future test cases. There is no harm in adding this depdency as we
should always build it with googletest and doesnt interfere with current
gtests.
Tested:
All of the tests still pass and newer tests using gmock will now
work.
Change-Id: Ie53f63f4926b88178c384cc1150b98555dafd7ec
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/configure.ac b/configure.ac
index a959d31..b1f7c70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,6 +92,7 @@
# Check/set gtest specific functions.
AS_IF([test "x$enable_tests" != "xno"], [
PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
+ PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
@@ -113,6 +114,17 @@
AC_LANG_POP([C++])
AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
+ AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
+ AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
+ AC_LANG_PUSH([C++])
+ AC_CHECK_HEADERS([gmock/gmock.h], [], [
+ AS_IF([test "x$enable_tests" = "xyes"], [
+ AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
+ ])
+ ])
+ AC_LANG_POP([C++])
+ AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
+
AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
AC_CHECK_LIB([gtest], [main], [
@@ -125,6 +137,19 @@
])
])
AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
+
+ AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
+ AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
+ AC_CHECK_LIB([gmock], [main], [
+ AS_IF([test "x$GMOCK_LIBS" = "x"], [
+ AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
+ ])
+ ], [
+ AS_IF([test "x$enable_tests" = "xyes"], [
+ AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
+ ])
+ ])
+ AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
])
# Code coverage