Skip to content

Commit

Permalink
test: Fixing googletest build deps and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuotian Cheng committed May 7, 2016
1 parent bd6fc8a commit e958d8c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SUBDIRS = common

if TESTS
if GTEST
SUBDIRS += tests
endif
21 changes: 9 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AC_CHECK_LIB([hiredis], [redisConnect])
AC_CHECK_LIB([nl-genl-3], [genl_connect])

AC_ARG_ENABLE(debug,
[ --enable-debug Compile with debugging flags],
[ --enable-debug Compile with debugging flags],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
Expand All @@ -23,17 +23,14 @@ esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)


AC_ARG_WITH(gtest,
[ --with-gtest=<dir> Compiles tests using the location of google tests],
AC_MSG_NOTICE(Using gtest path from:$with_gtest), with_gtest="none")

GTEST_PATH=
if test "x$with_gtest" != xnone; then
GTEST_PATH=$with_gtest
fi
AC_SUBST(GTEST_PATH)
AM_CONDITIONAL(TESTS, test "x$with_gtest" != xnone)

AC_ARG_ENABLE(gtest,
[ --enable-gtest Compile with googletest flags],
[case "${enableval}" in
yes) gtest=true ;;
no) gtest=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gtest) ;;
esac],[gtest=false])
AM_CONDITIONAL(GTEST, test x$gtest = xtrue)

CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3"
AC_SUBST(CFLAGS_COMMON)
Expand Down
9 changes: 9 additions & 0 deletions get-gtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -ex

git clone https://github.com/google/googletest.git
cd googletest
mkdir build
cd build
cmake ..
cmake --build .
exit 0
8 changes: 4 additions & 4 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ else
DBGFLAGS = -g
endif

CFLAGS_GTEST = -I $(GTEST_PATH)/googletest/include
LDADD_GTEST = $(GTEST_PATH)/build/googletest/libgtest_main.a \
$(GTEST_PATH)/build/googletest/libgtest.a
CFLAGS_GTEST = -I $(top_srcdir)/googletest/googletest/include
LDADD_GTEST = $(top_srcdir)/googletest/build/googlemock/gtest/libgtest_main.a \
$(top_srcdir)/googletest/build/googlemock/gtest/libgtest.a

tests_SOURCES = redis_ut.cpp

tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST)
tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST)
tests_LDADD = $(LDADD_GTEST) -lnl-genl-3 -lhiredis -lhiredis -lpthread \
-L$(top_srcdir)/common -lswsscommon
-L$(top_srcdir)/common -lswsscommon

0 comments on commit e958d8c

Please sign in to comment.