From 349ca737f30ff0b6c3c71034f0930660663fa360 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 5 Mar 2011 12:39:12 -0800 Subject: [PATCH] Move testing framework out to its own library. --- .bzrignore | 1 + COPYING | 3 ++- Makefile.am | 1 + libtest/include.am | 20 +++++++++++++++++++ {tests => libtest}/server.c | 2 +- {tests => libtest}/server.h | 0 {tests => libtest}/test.c | 4 ++-- {tests => libtest}/test.h | 0 tests/atomsmasher.c | 4 ++-- tests/hash_plus.cc | 3 ++- tests/hashkit_functions.c | 2 +- tests/include.am | 40 +++++++++++++++++-------------------- tests/mem_functions.c | 5 +++-- tests/mem_plus.cc | 3 ++- tests/mem_udp.c | 5 ++--- tests/plus.cpp | 5 +++-- tests/start.c | 2 +- unittests/include.am | 2 +- 18 files changed, 62 insertions(+), 40 deletions(-) create mode 100644 libtest/include.am rename {tests => libtest}/server.c (99%) rename {tests => libtest}/server.h (100%) rename {tests => libtest}/test.c (99%) rename {tests => libtest}/test.h (100%) diff --git a/.bzrignore b/.bzrignore index 0ccaac97..87578c4b 100644 --- a/.bzrignore +++ b/.bzrignore @@ -186,3 +186,4 @@ tests/testplus tests/testudp unittests/unittests config/top.h +libmemcached/generated_probes.h diff --git a/COPYING b/COPYING index c18e2ae8..efbc4a88 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,7 @@ Software License Agreement (BSD License) -Copyright (c) 2007, TangentOrg (Brian Aker) +Copyright (c) 2011, Data Differential (http://datadifferential.com/) +Copyright (c) 2007-2010, TangentOrg (Brian Aker) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Makefile.am b/Makefile.am index 7b866d0c..31585120 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,6 +41,7 @@ test-docs: (cd docs && $(MAKE) test-docs) include libmemcached/include.am include clients/include.am +include libtest/include.am include libhashkit/include.am include unittests/include.am include tests/include.am diff --git a/libtest/include.am b/libtest/include.am new file mode 100644 index 00000000..d6d9b18a --- /dev/null +++ b/libtest/include.am @@ -0,0 +1,20 @@ +# vim:ft=automake +# Copyright (C) 2011 Data Differential (http://datadifferential.com/) +# All rights reserved. +# +# Use and distribution licensed under the BSD license. See +# the COPYING file in the parent directory for full text. +# +# included from Top Level Makefile.am +# All paths should be given relative to the root + +noinst_HEADERS+= \ + libtest/server.h \ + libtest/test.h + +noinst_LTLIBRARIES+= libtest/libserver.la +libtest_libserver_la_SOURCES= libtest/server.c + +noinst_LTLIBRARIES+= libtest/libtest.la +libtest_libtest_la_SOURCES= libtest/test.c + diff --git a/tests/server.c b/libtest/server.c similarity index 99% rename from tests/server.c rename to libtest/server.c index 84f15de0..4349a668 100644 --- a/tests/server.c +++ b/libtest/server.c @@ -32,7 +32,7 @@ #include #include -#include "server.h" +#include static struct timespec global_sleep_value= { .tv_sec= 0, .tv_nsec= 50000 }; diff --git a/tests/server.h b/libtest/server.h similarity index 100% rename from tests/server.h rename to libtest/server.h diff --git a/tests/test.c b/libtest/test.c similarity index 99% rename from tests/test.c rename to libtest/test.c index 348df72b..009c4be5 100644 --- a/tests/test.c +++ b/libtest/test.c @@ -24,9 +24,9 @@ #include #include -#include "libmemcached/memcached.h" +#include -#include "test.h" +#include static void world_stats_print(world_stats_st *stats) { diff --git a/tests/test.h b/libtest/test.h similarity index 100% rename from tests/test.h rename to libtest/test.h diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index fac6986c..5b4bcbe2 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -26,11 +26,11 @@ #include #include #include -#include "server.h" #include "../clients/generator.h" #include "../clients/execute.h" -#include "test.h" +#include +#include /* Number of items generated for tests */ #define GLOBAL_COUNT 100000 diff --git a/tests/hash_plus.cc b/tests/hash_plus.cc index 1d0b9e83..c148d3ef 100644 --- a/tests/hash_plus.cc +++ b/tests/hash_plus.cc @@ -1,7 +1,8 @@ /* C++ to libhashkit */ -#include "test.h" +#include + #include #include #include diff --git a/tests/hashkit_functions.c b/tests/hashkit_functions.c index deb5436a..0f2c42a9 100644 --- a/tests/hashkit_functions.c +++ b/tests/hashkit_functions.c @@ -15,7 +15,7 @@ #include -#include "test.h" +#include #include "hash_results.h" diff --git a/tests/include.am b/tests/include.am index b90a5ef7..f940caf8 100644 --- a/tests/include.am +++ b/tests/include.am @@ -1,8 +1,17 @@ # vim:ft=automake +# Copyright (C) 2011 Data Differential +# All rights reserved. +# +# Use and distribution licensed under the BSD license. See +# the COPYING file in the parent directory for full text. +# # included from Top Level Makefile.am # All paths should be given relative to the root -TESTS_LDADDS = libmemcached/libmemcached.la +TESTS_LDADDS= \ + libmemcached/libmemcached.la \ + libtest/libserver.la \ + libtest/libtest.la VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes --track-fds=yes @@ -22,9 +31,7 @@ noinst_HEADERS+= \ tests/hash_results.h \ tests/ketama_test_cases.h \ tests/ketama_test_cases_spy.h \ - tests/libmemcached_world.h \ - tests/server.h \ - tests/test.h + tests/libmemcached_world.h noinst_PROGRAMS+= \ tests/atomsmasher \ @@ -36,55 +43,44 @@ noinst_PROGRAMS+= \ tests/testplus \ tests/testudp -noinst_LTLIBRARIES+= tests/libserver.la -tests_libserver_la_SOURCES= tests/server.c - -noinst_LTLIBRARIES+= tests/libtest.la -tests_libtest_la_SOURCES= tests/test.c - tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_testapp_SOURCES= tests/mem_functions.c tests_testapp_DEPENDENCIES= \ $(BUILT_SOURCES) \ clients/libgenexec.la \ - tests/libserver.la \ - tests/libtest.la \ libmemcached/libmemcachedinternal.la \ $(TESTS_LDADDS) + tests_testapp_LDADD= clients/libgenexec.la \ - tests/libserver.la \ - tests/libtest.la \ libmemcached/libmemcachedinternal.la \ $(TESTS_LDADDS) $(LIBSASL) tests_testplus_SOURCES= tests/plus.cpp tests_testplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) -tests_testplus_DEPENDENCIES= tests/libtest.la tests/libserver.la $(TESTS_LDADDS) +tests_testplus_DEPENDENCIES= $(TESTS_LDADDS) tests_testplus_LDADD= $(tests_testplus_DEPENDENCIES) $(LIBSASL) tests_atomsmasher_SOURCES= tests/atomsmasher.c tests_atomsmasher_DEPENDENCIES= \ clients/libgenexec.la \ - tests/libserver.la \ - tests/libtest.la \ $(TESTS_LDADDS) + tests_atomsmasher_LDADD= $(tests_atomsmasher_DEPENDENCIES) $(LIBSASL) tests_testudp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_testudp_SOURCES= tests/mem_udp.c tests_testudp_DEPENDENCIES= \ clients/libgenexec.la \ - tests/libserver.la \ - tests/libtest.la \ $(TESTS_LDADDS) + tests_testudp_LDADD= $(tests_testudp_DEPENDENCIES) $(LIBSASL) tests_startservers_SOURCES= tests/start.c -tests_startservers_DEPENDENCIES= tests/libserver.la $(TESTS_LDADDS) +tests_startservers_DEPENDENCIES= $(TESTS_LDADDS) tests_startservers_LDADD= $(tests_startservers_DEPENDENCIES) $(LIBSASL) tests_testhashkit_SOURCES = tests/hashkit_functions.c -tests_testhashkit_DEPENDENCIES = tests/libtest.la libhashkit/libhashkit.la +tests_testhashkit_DEPENDENCIES = libtest/libtest.la libhashkit/libhashkit.la tests_testhashkit_LDADD = $(tests_testhashkit_DEPENDENCIES) $(LIBSASL) tests_hashplus_SOURCES = tests/hash_plus.cc @@ -94,7 +90,7 @@ tests_hashplus_LDADD = $(tests_testhashkit_DEPENDENCIES) $(LIBSASL) tests_memplus_SOURCES = tests/mem_plus.cc tests_memplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) -tests_memplus_DEPENDENCIES = tests/libtest.la tests/libserver.la libmemcached/libmemcached.la +tests_memplus_DEPENDENCIES = $(TESTS_LDADDS) tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES) $(LIBSASL) test: check diff --git a/tests/mem_functions.c b/tests/mem_functions.c index 871256cf..36c5717e 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -26,13 +26,14 @@ #include "libmemcached/common.h" -#include "server.h" +#include + #include "clients/generator.h" #include "clients/execute.h" #define SMALL_STRING_LEN 1024 -#include "test.h" +#include #ifdef HAVE_LIBMEMCACHEDUTIL diff --git a/tests/mem_plus.cc b/tests/mem_plus.cc index d62ae723..d9a76afb 100644 --- a/tests/mem_plus.cc +++ b/tests/mem_plus.cc @@ -1,7 +1,8 @@ /* C++ to libmemcit */ -#include "test.h" +#include + #include #include #include diff --git a/tests/mem_udp.c b/tests/mem_udp.c index 76aab981..01314dbd 100644 --- a/tests/mem_udp.c +++ b/tests/mem_udp.c @@ -26,9 +26,8 @@ #include #include -#include "server.h" - -#include "test.h" +#include +#include #define SERVERS_TO_CREATE 5 diff --git a/tests/plus.cpp b/tests/plus.cpp index 0d588749..c0c6bb95 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -12,9 +12,10 @@ #include #include #include -#include "server.h" -#include "test.h" +#include + +#include #include #include diff --git a/tests/start.c b/tests/start.c index e3f2a64c..ae9497f3 100644 --- a/tests/start.c +++ b/tests/start.c @@ -13,7 +13,7 @@ #include #include -#include "server.h" +#include int main(void) { diff --git a/unittests/include.am b/unittests/include.am index c1443418..b7ca5d26 100644 --- a/unittests/include.am +++ b/unittests/include.am @@ -12,7 +12,7 @@ unittests_unittests_SOURCES= \ unittests_unittests_CXXFLAGS= ${AM_CXXFLAGS} ${NO_WERROR} ${NO_EFF_CXX} unittests_unittests_LDADD= \ - tests/libserver.la \ + libtest/libserver.la \ libmemcached/libmemcachedinternal.la \ ${TESTS_LDADDS} ${LTLIBGTEST} # Shorthand -- 2.30.2