2 # Copyright (C) 2011 Data Differential
5 # Use and distribution licensed under the BSD license. See
6 # the COPYING file in the parent directory for full text.
8 # included from Top Level Makefile.am
9 # All paths should be given relative to the root
12 libmemcached/libmemcached.la \
13 libtest/libserver.la \
16 VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
18 DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb
20 PAHOLE_COMMAND= $(LIBTOOL) --mode=execute pahole
22 if BUILD_LIBMEMCACHEDUTIL
23 TESTS_LDADDS+= libmemcached/libmemcachedutil.la
27 tests/cpp_example.cc \
32 tests/error_conditions.h \
33 tests/hash_results.h \
34 tests/ketama_test_cases.h \
35 tests/ketama_test_cases_spy.h \
36 tests/libmemcached_world.h \
44 tests/virtual_buckets.h
56 # Cycle should always run first
57 tests_cycle_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
58 tests_cycle_SOURCES= tests/cycle.cc
59 tests_cycle_DEPENDENCIES= $(TESTS_LDADDS)
60 tests_cycle_LDADD= $(tests_cycle_DEPENDENCIES)
61 check_PROGRAMS+= tests/cycle
64 tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
65 tests_testapp_SOURCES= \
68 tests/error_conditions.cc \
69 tests/mem_functions.cc \
74 tests/replication.cc \
76 tests/virtual_buckets.cc
77 tests_testapp_SOURCES+= clients/generator.cc clients/execute.cc
79 tests_testapp_DEPENDENCIES= \
82 libhashkit/libhashkit.la \
83 libmemcached/libmemcachedinternal.la
85 tests_testapp_LDADD= \
88 libhashkit/libhashkit.la \
89 libmemcached/libmemcachedinternal.la
90 check_PROGRAMS+= tests/testapp
92 tests_testplus_SOURCES= tests/plus.cpp
93 tests_testplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX)
94 tests_testplus_DEPENDENCIES= $(TESTS_LDADDS)
95 tests_testplus_LDADD= $(tests_testplus_DEPENDENCIES) $(LIBSASL)
96 check_PROGRAMS+= tests/testplus
98 tests_atomsmasher_SOURCES= \
99 tests/atomsmasher.cc \
100 clients/generator.cc \
102 tests_atomsmasher_DEPENDENCIES= $(TESTS_LDADDS)
103 tests_atomsmasher_LDADD= $(tests_atomsmasher_DEPENDENCIES) $(LIBSASL)
105 tests_testudp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
106 tests_testudp_SOURCES= tests/mem_udp.cc
107 tests_testudp_DEPENDENCIES= $(TESTS_LDADDS)
108 tests_testudp_LDADD= $(tests_testudp_DEPENDENCIES) $(LIBSASL)
109 check_PROGRAMS+= tests/testudp
111 tests_testhashkit_SOURCES = tests/hashkit_functions.cc
112 tests_testhashkit_DEPENDENCIES = libtest/libtest.la libhashkit/libhashkit.la
113 tests_testhashkit_LDADD = $(tests_testhashkit_DEPENDENCIES)
114 check_PROGRAMS+= tests/testhashkit
116 tests_hash_plus_SOURCES= tests/hash_plus.cc
117 tests_hash_plus_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX)
118 tests_hash_plus_DEPENDENCIES= $(tests_testhashkit_DEPENDENCIES)
119 tests_hash_plus_LDADD= $(tests_testhashkit_DEPENDENCIES)
120 check_PROGRAMS+= tests/hash_plus
124 check-local: tests/var $(TEST_DOCS) memcapable
125 @echo "Tests completed"
127 test-x: tests/var test-plus test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat
128 @echo "Tests completed"
130 memcapable: clients/memcapable
131 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
132 @clients/memcapable -p 12555 || echo "Your memcached server does not support all commands"
133 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
136 test-memcat: clients/memcat clients/memcp
137 @echo "Testing memcat"
138 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
139 @clients/memcp --servers="localhost:12555" `pwd`/clients/memcp
140 @clients/memcat --servers="localhost:12555" memcp > `pwd`/tests/scratch
141 @clients/memcat --servers="localhost:12555" --file=`pwd`/tests/scratch2 memcp
142 # @diff clients/memcp tests/scratch
143 @cat `pwd`/tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
144 @rm `pwd`/tests/Xumemc.pid
145 @rm `pwd`/tests/scratch
146 @rm `pwd`/tests/scratch2
148 valgrind-memcat: clients/memcat clients/memcp
149 @echo "Testing memcat"
150 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
151 @clients/memcp --servers="localhost:12555" clients/memcp
152 @$(VALGRIND_COMMAND) clients/memcat --servers="localhost:12555" memcp > tests/scratch
153 # @diff clients/memcp tests/scratch
154 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
158 test-memcp: clients/memcp
159 @echo "Testing memcp"
160 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
161 @clients/memcp --servers="localhost:12555" clients/memcp clients/memcat clients/memstat
162 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
165 valgrind-memcp: clients/memcat clients/memcp
166 @echo "Testing memcp"
167 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
168 @$(VALGRIND_COMMAND) clients/memcp --servers="localhost:12555" clients/memcp clients/memcat clients/memstat
169 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
172 test-memrm: clients/memrm clients/memcp
173 @echo "Testing memrm"
174 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
175 @clients/memcp --servers="localhost:12555" clients/memcat
176 @clients/memrm --servers="localhost:12555" memcat
177 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
180 valgrind-memrm: clients/memcat clients/memcp
181 @echo "Testing memrm"
182 @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
183 @clients/memcp --servers="localhost:12555" clients/memcat
184 @$(VALGRIND_COMMAND) clients/memrm --servers="localhost:12555" memcat
185 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
188 test-memflush: clients/memflush
189 @echo "Testing memflush"
190 @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
191 @clients/memflush --servers="localhost:12555"
192 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
195 valgrind-memflush: clients/memflush
196 @echo "Testing memflush"
197 @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
198 @$(VALGRIND_COMMAND) clients/memflush --servers="localhost:12555"
199 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
202 test-memdump: clients/memdump clients/memcp
203 @echo "Testing memdump"
204 @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
205 @clients/memcp --servers="localhost:12555" clients/memcat
206 @clients/memdump --servers="localhost:12555" > /dev/null
207 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
210 valgrind-memdump: clients/memcat clients/memcp
211 @echo "Testing memdump"
212 @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
213 @clients/memcp --servers="localhost:12555" clients/memcat
214 @$(VALGRIND_COMMAND) clients/memdump --servers="localhost:12555" > /dev/null
215 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
218 test-memstat: clients/memstat
219 @echo "Testing memstat"
220 @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
221 @clients/memstat --servers="localhost:12555" > /dev/null
222 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
225 valgrind-memstat: clients/memstat
226 @echo "Testing memstat"
227 @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
228 @$(VALGRIND_COMMAND) clients/memstat --servers="localhost:12555" > /dev/null
229 @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
232 test-memerror: clients/memerror
233 @echo "Testing memerror"
234 @clients/memerror 0 > /dev/null
236 valgrind-memerror: clients/memerror
237 @echo "Testing memerror"
238 @$(VALGRIND_COMMAND) clients/memerror 0 > /dev/null
244 MEMSLAP_COMMAND= clients/memslap $(COLLECTION) $(SUITE)
246 MEM_COMMAND= tests/testapp $(COLLECTION) $(SUITE)
248 TESTPLUS_COMMAND= tests/testplus $(COLLECTION) $(SUITE)
250 HASHPLUS_COMMAND= tests/hashplus $(COLLECTION) $(SUITE)
252 CYCLE_COMMAND= tests/cycle $(COLLECTION) $(SUITE)
254 ATOM_COMMAND= tests/atomsmasher $(COLLECTION) $(SUITE)
256 UDP_COMMAND= tests/testudp $(COLLECTION) $(SUITE)
258 HASH_COMMAND= tests/testhashkit $(COLLECTION) $(SUITE)
260 test-mem: tests/var tests/testapp
263 test-udp: tests/var tests/testudp
266 test-atom: tests/var tests/atomsmasher
269 test-plus: tests/var tests/testplus
272 test-hash: tests/var tests/testhashkit
275 test-hashplus: tests/var tests/hashplus
278 test-cycle: tests/var tests/cycle
281 pahole-mem: tests/testapp
282 $(PAHOLE_COMMAND) $(MEM_COMMAND)
284 gdb-mem: tests/testapp
285 $(DEBUG_COMMAND) $(MEM_COMMAND)
287 gdb-atom: tests/atomsmasher
288 $(DEBUG_COMMAND) $(UDP_COMMAND)
290 gdb-udp: tests/testudp
291 $(DEBUG_COMMAND) $(ATOM_COMMAND)
293 gdb-plus: tests/testplus
294 $(DEBUG_COMMAND) $(TESTPLUS_COMMAND)
296 gdb-hash: tests/testhashkit
297 $(DEBUG_COMMAND) $(HASH_COMMAND)
299 gdb-hashplus: tests/hashplus
300 $(DEBUG_COMMAND) $(HASHPLUS_COMMAND)
302 gdb-cycle: tests/cycle
303 $(DEBUG_COMMAND) $(CYCLE_COMMAND)
305 gdb-memslap: clients/memslap
306 $(DEBUG_COMMAND) $(MEMSLAP_COMMAND)
308 valgrind-mem: tests/testapp
309 $(VALGRIND_COMMAND) $(MEM_COMMAND)
311 valgrind-atom: tests/atomsmasher
312 $(VALGRIND_COMMAND) $(ATOM_COMMAND)
314 valgrind-udp: tests/testudp
315 $(VALGRIND_COMMAND) $(UDP_COMMAND)
317 valgrind-plus: tests/testplus
318 $(VALGRIND_COMMAND) $(TESTPLUS_COMMAND)
320 valgrind-hash: tests/testhashkit
321 $(VALGRIND_COMMAND) $(HASH_COMMAND)
323 valgrind-hashplus: tests/hashplus
324 $(VALGRIND_COMMAND) $(HASHPLUS_COMMAND)
326 valgrind-memslap: clients/memslap
327 $(VALGRIND_COMMAND) $(MEMSLAP_COMMAND)
330 valgrind: tests/testapp tests/testhashkit valgrind-mem valgrind-hash valgrind-memcat valgrind-memcp valgrind-memrm valgrind-memerror valgrind-memdump valgrind-memflush valgrind-memstat
333 CLEANFILES += tests/cachegrind.out
335 rm -f tests/cachegrind.out.*
336 $(LIBTOOL) --mode=execute valgrind --tool=cachegrind --cachegrind-out-file=tests/cachegrind.out.%p --branch-sim=yes tests/testapp
337 cg_annotate tests/cachegrind.out.* --auto=yes > tests/cachegrind.out
340 CLEANFILES += tests/callgrind.out
342 rm -f tests/callgrind.out.*
343 $(LIBTOOL) --mode=execute valgrind --tool=callgrind --callgrind-out-file=tests/callgrind.out.%p tests/testapp
344 callgrind_annotate tests/callgrind.out.* --auto=yes > tests/callgrind.out
347 CLEANFILES+= helgrind.out.*
350 $(LIBTOOL) --mode=execute valgrind --tool=helgrind tests/testapp
352 PHONY += helgrind-slap
354 $(LIBTOOL) --mode=execute valgrind --tool=helgrind clients/memslap --server=localhost --concurrency=30
356 test-no-outputdiff: test
358 hudson-valgrind: tests/testapp
359 $(VALGRIND_COMMAND) --log-file=tests/valgrind.out $(MEM_COMMAND)