# vim:ft=automake
# Gearman server and library
# Copyright (C) 2011 Data Differential, http://datadifferential.com/
# 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_HEADERS+= \
		 tests/basic.h \
		 tests/context.h \
		 tests/do.h \
		 tests/do_background.h \
		 tests/execute.h \
		 tests/gearman_client_do_job_handle.h \
		 tests/gearman_execute_partition.h \
		 tests/limits.h \
		 tests/ports.h \
		 tests/protocol.h \
		 tests/regression.h \
		 tests/server_options.h \
		 tests/start_worker.h \
		 tests/task.h \
		 tests/unique.h \
		 tests/workers.h \
		 tests/workers_v1.h

noinst_LTLIBRARIES+= tests/libstartworker.la
tests_libstartworker_la_CXXFLAGS=
tests_libstartworker_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
tests_libstartworker_la_LIBADD= $(PTHREAD_LIBS)
tests_libstartworker_la_SOURCES= tests/start_worker.cc
tests_libstartworker_la_SOURCES+= util/instance.cc
tests_libstartworker_la_SOURCES+= util/operation.cc

CLIENT_LDADD= \
	      libgearman/libgearman.la \
	      libtest/libtest.la \
	      tests/libstartworker.la

tests_killall_SOURCES= tests/killall.cc
tests_killall_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_killall_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+=tests/killall
noinst_PROGRAMS+=tests/killall

tests_cycle_SOURCES= tests/cycle.cc
tests_cycle_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_cycle_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+=tests/cycle
noinst_PROGRAMS+=tests/cycle


tests_client_test_SOURCES= \
			   tests/client_test.cc \
			   tests/do.cc \
			   tests/do_background.cc \
			   tests/execute.cc \
			   tests/gearman_client_do_job_handle.cc \
			   tests/gearman_execute_partition.cc \
			   tests/limits.cc \
			   tests/protocol.cc \
			   tests/server_options.cc \
			   tests/task.cc \
			   tests/unique.cc \
			   tests/workers.cc \
			   tests/workers_v1.cc
tests_client_test_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_client_test_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+=tests/client_test
noinst_PROGRAMS+=tests/client_test

tests_cli_SOURCES= tests/cli.cc
tests_cli_SOURCES+= tests/workers.cc
tests_cli_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand bin/gearman bin/gearadmin
tests_cli_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+= tests/cli
noinst_PROGRAMS+= tests/cli

tests_gearmand_SOURCES= tests/gearmand.cc
tests_gearmand_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_gearmand_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+= tests/gearmand
noinst_PROGRAMS+= tests/gearmand

tests_blobslap_client_SOURCES= tests/blobslap_client.cc
tests_blobslap_client_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_blobslap_client_LDADD= ${CLIENT_LDADD}
noinst_PROGRAMS+= tests/blobslap_client

tests_internals_test_SOURCES= \
			      tests/internals.cc \
			      tests/regression.cc

tests_internals_test_DEPENDENCIES= ${CLIENT_LDADD} libgearman/libgearmancore.la gearmand/gearmand
tests_internals_test_LDADD= ${CLIENT_LDADD} libgearman/libgearmancore.la
check_PROGRAMS+= tests/internals_test
noinst_PROGRAMS+= tests/internals_test

tests_round_robin_test_SOURCES= tests/round_robin.cc
tests_round_robin_test_DEPENDENCIES= ${CLIENT_LDADD} libgearman/libgearmancore.la gearmand/gearmand
tests_round_robin_test_LDADD= ${CLIENT_LDADD} libgearman/libgearmancore.la
check_PROGRAMS+= tests/round_robin_test
noinst_PROGRAMS+= tests/round_robin_test

tests_worker_test_SOURCES= tests/worker_test.cc
tests_worker_test_DEPENDENCIES= ${CLIENT_LDADD} libgearman/libgearmancore.la gearmand/gearmand
tests_worker_test_LDADD= ${CLIENT_LDADD} libgearman/libgearmancore.la
check_PROGRAMS+=tests/worker_test
noinst_PROGRAMS+=tests/worker_test

if TARGET_LINUX
tests_hostileworker_test_SOURCES= tests/stress_worker.cc \
				  tests/workers.cc
tests_hostileworker_test_DEPENDENCIES= ${CLIENT_LDADD} libhostile/libhostile.la gearmand/gearmand
tests_hostileworker_test_LDADD= ${CLIENT_LDADD}
tests_hostileworker_test_LDADD+= libhostile/libhostile.la
tests_hostileworker_test_LDADD+= -ldl
noinst_PROGRAMS+=tests/hostileworker_test
endif

# Test linking with C++ application
tests_cpp_test_SOURCES= tests/cpp_test.cc
tests_cpp_test_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_cpp_test_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+=tests/cpp_test
noinst_PROGRAMS+=tests/cpp_test

# Test linking with C application
tests_c_test_SOURCES= tests/c_test.c
tests_c_test_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_c_test_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+=tests/c_test
noinst_PROGRAMS+=tests/c_test

tests_burnin_test_SOURCES= tests/burnin.cc
tests_burnin_test_DEPENDENCIES= ${CLIENT_LDADD} gearmand/gearmand
tests_burnin_test_LDADD= ${CLIENT_LDADD}
check_PROGRAMS+=tests/burnin_test
noinst_PROGRAMS+=tests/burnin_test

test-burnin: tests/burnin_test
	@tests/burnin_test

test-cycle: tests/cycle
	@tests/cycle

test-cli: tests/cli
	@tests/cli

test-gearmand: tests/gearmand
	@tests/gearmand

tests-blobslap_client: tests/blobslap_client
	@tests/blobslap_client

test-client: tests/client_test
	@tests/client_test

test-round-robin: tests/round_robin_test
	@tests/round_robin_test

test-worker: tests/worker_test
	@tests/worker_test

test-internals: tests/internals_test
	@tests/internals_test

check-local:

gdb-client: tests/client_test
	@$(GDB_COMMAND) tests/client_test

gdb-round-robin: tests/round_robin_test
	@$(GDB_COMMAND) tests/round_robin_test

gdb-worker: tests/worker_test
	@$(GDB_COMMAND) tests/worker_test

gdb-internals: tests/internals_test
	@$(GDB_COMMAND) tests/internals_test

gdb-burnin: tests/burnin_test
	@$(GDB_COMMAND) tests/burnin_test

gdb-cli: tests/cli
	@$(GDB_COMMAND) tests/cli

gdb-blobslap_client: tests/blobslap_client
	@$(GDB_COMMAND) tests/blobslap_client

gdb-cycle: tests/cycle
	@$(GDB_COMMAND) tests/cycle

gdb-all: gdb-cycle gdb-client gdb-round-robin gdb-worker gdb-internals gdb-sqlite gdb-tokyocabinet gdb-burnin

valgrind-client: tests/client_test
	@$(VALGRIND_COMMAND) tests/client_test

valgrind-round-robin: tests/round_robin_test
	@$(VALGRIND_COMMAND) tests/round_robin_test

valgrind-worker: tests/worker_test
	@$(VALGRIND_COMMAND) tests/worker_test

valgrind-internals: tests/internals_test
	@$(VALGRIND_COMMAND) tests/internals_test

valgrind-burnin: tests/burnin_test
	@$(VALGRIND_COMMAND) tests/burnin_test

valgrind-cycle: tests/cycle
	@$(VALGRIND_COMMAND) tests/cycle

helgrind-client: tests/client_test
	@$(HELGRIND_COMMAND) tests/client_test

helgrind-round-robin: tests/round_robin_test
	@$(HELGRIND_COMMAND) tests/round_robin_test

helgrind-worker: tests/worker_test
	@$(HELGRIND_COMMAND) tests/worker_test

helgrind-internals: tests/internals_test
	@$(HELGRIND_COMMAND) tests/internals_test

helgrind-burnin: tests/burnin_test
	@$(HELGRIND_COMMAND) tests/burnin_test

helgrind-cycle: tests/cycle
	@$(HELGRIND_COMMAND) tests/cycle

drd-cycle: tests/cycle
	@$(DRD_COMMAND) tests/cycle

helgrind-test: helgrind-cycle helgrind-client helgrind-round-robin helgrind-worker helgrind-internals helgrind-sqlite helgrind-tokyocabinet helgrind-burnin

include tests/libdrizzle.am
include tests/libmemcached.am
include tests/postgres.am
include tests/sqlite.am
include tests/tokyocabinet.am

bogus:

