~mm-yuhu/gearmand/server-funcs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# vim:ft=automake
# Gearman server and library
# Copyright (C) 2008 Brian Aker, Eric Day
# All rights reserved.
#
# Use and distribution licensed under the BSD license.  See
# the COPYING file in the parent directory for full text.

noinst_LTLIBRARIES+= tests/libtest.la
tests_libtest_la_SOURCES= tests/test.c tests/test_gearmand.c


VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes

TEST_LDADD= \
	    tests/libtest.la \
	    libgearman/libgearman.la \
	    libgearman-server/libgearman-server.la

if HAVE_LIBMEMCACHED
if HAVE_MEMCACHED
LIBMEMCACHED_PIDFILE = ${abs_top_builddir}/tests/Xumemc.pid
LIBMEMCACHED_TEST= tests/memcached_test
# Note, SETUP should do a test for existance and then kill if it exists.
LIBMEMCACHED_SETUP= $(MEMCACHED_BINARY) -d -P ${LIBMEMCACHED_PIDFILE} -p 12555
LIBMEMCACHED_TEARDOWN= \
		       cat ${LIBMEMCACHED_PIDFILE} | xargs kill; \
		       rm ${LIBMEMCACHED_PIDFILE}

noinst_PROGRAMS += tests/memcached_test
endif
endif

tests_memcached_test_SOURCES= tests/memcached_test.c
tests_memcached_test_LDADD= ${TEST_LDADD}

if HAVE_LIBSQLITE3
SQLITE_TEST= tests/sqlite_test
SQLITE_RM= rm -f tests/gearman.sql tests/gearman.sql-journal
CLEANFILES+= tests/gearman.sql tests/gearman.sql-journal
noinst_PROGRAMS += tests/sqlite_test
endif

tests_sqlite_test_SOURCES= tests/sqlite_test.c
tests_sqlite_test_LDADD= ${TEST_LDADD}

if HAVE_LIBTOKYOCABINET
TOKYOCABINET_TEST= tests/tokyocabinet_test
TOKYOCABINET_RM= rm -f tests/gearman.tcb
CLEANFILES+= tests/gearman.tcb
noinst_PROGRAMS += tests/tokyocabinet_test
endif

tests_tokyocabinet_test_SOURCES= tests/tokyocabinet_test.c
tests_tokyocabinet_test_LDADD= ${TEST_LDADD}

noinst_PROGRAMS+= \
		tests/client_test \
		tests/cpp_test \
		tests/internals_test \
		tests/regression_test \
		tests/worker_test

noinst_HEADERS+= \
	      tests/test.h \
	      tests/test_gearmand.h \
	      tests/test_worker.h

tests_client_test_SOURCES= tests/test_worker.c tests/client_test.c
tests_client_test_LDADD= ${TEST_LDADD}

tests_internals_test_SOURCES= tests/internals.c
tests_internals_test_LDADD= ${TEST_LDADD} libgearman/libgearmancore.la

tests_regression_test_SOURCES= tests/regression.c
tests_regression_test_LDADD= ${TEST_LDADD} libgearman/libgearmancore.la

tests_worker_test_SOURCES= tests/worker_test.c
tests_worker_test_LDADD= ${TEST_LDADD}

# Test linking with C++ application
tests_cpp_test_SOURCES= tests/cpp_test.cc
tests_cpp_test_LDADD= ${TEST_LDADD}

test-client:
	tests/client_test $(ARG1) $(ARG2)

test-worker:
	tests/worker_test $(ARG1) $(ARG2)

test-internals:
	tests/internals_test $(ARG1) $(ARG2)

test-libmemcached:
	$(LIBMEMCACHED_SETUP)
	$(LIBMEMCACHED_TEST) $(ARG1) $(ARG2)
	$(LIBMEMCACHED_TEARDOWN)

test-sqlite:
	$(SQLITE_TEST) $(ARG1) $(ARG2)
	$(SQLITE_RM)

test-tokyocabinet:
	$(TOKYOCABINET_TEST) $(ARG1) $(ARG2)
	$(TOKYOCABINET_RM)

check-local: test-client test-worker test-internals test-libmemcached test-sqlite test-tokyocabinet

gdb-client: ${noinst_PROGRAMS}
	$(LIBTOOL) --mode=execute gdb tests/client_test

gdb-worker: ${noinst_PROGRAMS}
	$(LIBTOOL) --mode=execute gdb tests/worker_test

gdb-internals: ${noinst_PROGRAMS}
	$(LIBTOOL) --mode=execute gdb tests/internals_test

valgrind-client:
	$(VALGRIND_COMMAND) tests/client_test $(ARG1) $(ARG2)

valgrind-worker:
	$(VALGRIND_COMMAND) tests/worker_test $(ARG1) $(ARG2)

valgrind-internals:
	$(VALGRIND_COMMAND) tests/internals_test $(ARG1) $(ARG2)

valgrind-libmemcached:
	$(LIBMEMCACHED_SETUP)
	$(VALGRIND_COMMAND) $(LIBMEMCACHED_TEST) $(ARG1) $(ARG2)
	$(LIBMEMCACHED_TEARDOWN)

valgrind-sqlite:
	$(VALGRIND_COMMAND) $(SQLITE_TEST) $(ARG1) $(ARG2)
	$(SQLITE_RM)

valgrind-tokyocabinet:
	$(VALGRIND_COMMAND) $(TOKYOCABINET_TEST) $(ARG1) $(ARG2)
	$(TOKYOCABINET_RM)

GEARMAN_CLIENT_TEST= bin/gearman
GEARMAN_PIDFILE = ${abs_top_builddir}/tests/Xugear.pid

client-test: $(GEARMAN_CLIENT_TEST)
	@$(GEARMAN_CLIENT_TEST) -H 2>&1 > /dev/null
	@$(GEARMAN_CLIENT_TEST) -w -f true -d -i $(GEARMAN_PIDFILE) -- false
	cat $(GEARMAN_PIDFILE) | xargs kill
	@echo "gearman client success"

valgrind: ${noinst_PROGRAMS} valgrind-client valgrind-worker valgrind-internals valgrind-sqlite valgrind-tokyocabinetn