From d74eed71be1b77f3502fb8d07b1702d115a6f6c3 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 29 Jun 2010 09:50:25 -0700 Subject: [PATCH] Added gtest unittest support. --- Makefile.am | 3 +++ configure.ac | 1 + tests/include.am | 11 +++++++++++ tests/main.cc | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 tests/main.cc diff --git a/Makefile.am b/Makefile.am index d2acebaa..d855c8f4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,7 @@ noinst_LTLIBRARIES = noinst_PROGRAMS = include_HEADERS = nobase_include_HEADERS = +check_PROGRAMS = EXTRA_HEADERS = BUILT_SOURCES= EXTRA_DIST= \ @@ -41,6 +42,8 @@ include tests/include.am include example/include.am include support/include.am +TESTS += ${check_PROGRAMS} + check-local: test-no-outputdiff diff --git a/configure.ac b/configure.ac index 2e0a5a93..0db99759 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,7 @@ AC_SEARCH_LIBS(gethostbyname, nsl) AC_CHECK_FUNCS([getline]) +PANDORA_HAVE_LIBGTEST PANDORA_HAVE_LIBEVENT PANDORA_REQUIRE_PTHREAD PANDORA_CXX_DEMANGLE diff --git a/tests/include.am b/tests/include.am index d82538b9..21450f6d 100644 --- a/tests/include.am +++ b/tests/include.am @@ -10,6 +10,10 @@ DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb PAHOLE_COMMAND= $(LIBTOOL) --mode=execute pahole +if HAVE_LIBGTEST +check_PROGRAMS += tests/unittests +endif + if BUILD_LIBMEMCACHEDUTIL TESTS_LDADDS+= libmemcached/libmemcachedutil.la endif @@ -38,6 +42,13 @@ tests_libserver_la_SOURCES= tests/server.c noinst_LTLIBRARIES+= tests/libtest.la tests_libtest_la_SOURCES= tests/test.c +tests_unittests_SOURCES= \ + tests/main.cc +tests_unittests_LDADD= \ + tests/libserver.la \ + libmemcached/libmemcachedinternal.la \ + ${TESTS_LDADDS} ${LTLIBGTEST} + tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_testapp_SOURCES= tests/mem_functions.c tests_testapp_DEPENDENCIES= \ diff --git a/tests/main.cc b/tests/main.cc new file mode 100644 index 00000000..7e575c30 --- /dev/null +++ b/tests/main.cc @@ -0,0 +1,21 @@ +/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Copyright (C) 2010 Monty Taylor + * + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + */ + +#include "config.h" + +#include + + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} -- 2.30.2