# This should use LIBMDS_TYPES once it exists
ceph_dencoder_SOURCES = \
	test/encoding/ceph_dencoder.cc \
	$(DENCODER_SOURCES)
ceph_dencoder_LDADD = \
	$(LIBRGW) \
	$(LIBRADOS) \
	$(LIBRBD_TYPES) \
	$(LIBOSD_TYPES) \
	$(LIBOS_TYPES) \
	$(LIBMON_TYPES) \
	$(DENCODER_DEPS) \
	$(CEPH_GLOBAL)

# These should always use explicit _CFLAGS/_CXXFLAGS so avoid basename conflicts
ceph_dencoder_CFLAGS = ${AM_CFLAGS}
ceph_dencoder_CXXFLAGS = ${AM_CXXFLAGS}

if COMPILER_HAS_VTA
ceph_dencoder_CFLAGS += -fno-var-tracking-assignments
ceph_dencoder_CXXFLAGS += -fno-var-tracking-assignments
endif

if WITH_RBD
ceph_dencoder_CXXFLAGS += -DWITH_RBD
endif
if WITH_RADOSGW
ceph_dencoder_CXXFLAGS += -DWITH_RADOSGW
endif


bin_PROGRAMS += ceph-dencoder

noinst_HEADERS += \
	test/encoding/test_ceph_time.h

if WITH_RADOS

libradostest_la_SOURCES = \
	test/librados/test.cc \
	test/librados/TestCase.cc
noinst_LTLIBRARIES += libradostest.la
libradostest_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
RADOS_TEST_LDADD = libradostest.la $(LIBCOMMON) $(CRYPTO_LIBS)

ceph_test_rados_SOURCES = \
	test/osd/TestRados.cc \
	test/osd/TestOpStat.cc \
	test/osd/Object.cc \
	test/osd/RadosModel.cc
ceph_test_rados_LDADD = $(LIBRADOS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_test_rados

ceph_test_mutate_SOURCES = test/test_mutate.cc
ceph_test_mutate_LDADD = $(LIBRADOS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_test_mutate

if WITH_BUILD_TESTS
test_build_librados_SOURCES = \
	test/buildtest_skeleton.cc \
	$(librados_la_SOURCES)
test_build_librados_LDADD = \
	$(LIBRADOS_DEPS) \
	$(PTHREAD_LIBS) $(CRYPTO_LIBS) $(EXTRALIBS)
test_build_librados_LDFLAGS = -static-libtool-libs
test_build_librados_CFLAGS = $(AM_CFLAGS)
test_build_librados_CXXFLAGS = $(AM_CXXFLAGS)
bin_DEBUGPROGRAMS += test_build_librados
endif # WITH_BUILD_TESTS

ceph_smalliobench_SOURCES = \
	test/bench/small_io_bench.cc \
	test/bench/rados_backend.cc \
	test/bench/detailed_stat_collector.cc \
	test/bench/bencher.cc
ceph_smalliobench_LDADD = $(LIBRADOS) $(BOOST_PROGRAM_OPTIONS_LIBS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_smalliobench

ceph_omapbench_SOURCES = test/omap_bench.cc
ceph_omapbench_LDADD = $(LIBRADOS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_omapbench

ceph_objectstore_bench_SOURCES = test/objectstore_bench.cc
ceph_objectstore_bench_LDADD = $(LIBOS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_objectstore_bench

if LINUX
ceph_kvstorebench_SOURCES = \
	test/kv_store_bench.cc \
	key_value_store/kv_flat_btree_async.cc
ceph_kvstorebench_LDADD = $(LIBRADOS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_kvstorebench
endif

if LINUX
ceph_test_rados_list_parallel_SOURCES = \
	test/system/rados_list_parallel.cc \
	test/system/st_rados_create_pool.cc \
	test/system/st_rados_list_objects.cc
ceph_test_rados_list_parallel_LDADD = $(LIBRADOS) libsystest.la $(PTHREAD_LIBS)
bin_DEBUGPROGRAMS += ceph_test_rados_list_parallel

ceph_test_rados_open_pools_parallel_SOURCES = \
	test/system/rados_open_pools_parallel.cc \
	test/system/st_rados_create_pool.cc
ceph_test_rados_open_pools_parallel_LDADD = $(LIBRADOS) libsystest.la $(PTHREAD_LIBS)
bin_DEBUGPROGRAMS += ceph_test_rados_open_pools_parallel

ceph_test_rados_delete_pools_parallel_SOURCES = \
	test/system/rados_delete_pools_parallel.cc \
	test/system/st_rados_create_pool.cc \
	test/system/st_rados_delete_pool.cc \
	test/system/st_rados_list_objects.cc
ceph_test_rados_delete_pools_parallel_LDADD = $(LIBRADOS) libsystest.la $(PTHREAD_LIBS)
bin_DEBUGPROGRAMS += ceph_test_rados_delete_pools_parallel

ceph_test_rados_watch_notify_SOURCES = \
	test/system/rados_watch_notify.cc \
	test/system/st_rados_create_pool.cc \
	test/system/st_rados_delete_pool.cc \
	test/system/st_rados_delete_objs.cc \
	test/system/st_rados_watch.cc \
	test/system/st_rados_notify.cc
ceph_test_rados_watch_notify_LDADD = $(LIBRADOS) libsystest.la $(PTHREAD_LIBS)
bin_DEBUGPROGRAMS += ceph_test_rados_watch_notify
endif # LINUX

unittest_librados_SOURCES = test/librados/librados.cc
unittest_librados_LDADD = $(LIBRADOS) $(CEPH_GLOBAL) $(UNITTEST_LDADD)
unittest_librados_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_librados

unittest_librados_config_SOURCES = test/librados/librados_config.cc
unittest_librados_config_LDADD = $(LIBRADOS) $(CEPH_GLOBAL) $(UNITTEST_LDADD)
unittest_librados_config_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_librados_config

ceph_multi_stress_watch_SOURCES = test/multi_stress_watch.cc
ceph_multi_stress_watch_LDADD = $(LIBRADOS) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
bin_DEBUGPROGRAMS += ceph_multi_stress_watch


ceph_test_cls_rbd_SOURCES = test/cls_rbd/test_cls_rbd.cc
ceph_test_cls_rbd_LDADD = \
	$(LIBRADOS) libcls_rbd_client.la libcls_lock_client.la \
	$(LIBCOMMON) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) $(CRYPTO_LIBS) \
	$(EXTRALIBS)
ceph_test_cls_rbd_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_rbd

ceph_test_cls_refcount_SOURCES = test/cls_refcount/test_cls_refcount.cc
ceph_test_cls_refcount_LDADD = $(LIBRADOS) libcls_refcount_client.la $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_cls_refcount_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_refcount

ceph_test_cls_version_SOURCES = test/cls_version/test_cls_version.cc
ceph_test_cls_version_LDADD = $(LIBRADOS) libcls_version_client.la $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_cls_version_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_version

ceph_test_cls_log_SOURCES = test/cls_log/test_cls_log.cc
ceph_test_cls_log_LDADD = $(LIBRADOS) libcls_log_client.la $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_cls_log_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_log

ceph_test_cls_statelog_SOURCES = test/cls_statelog/test_cls_statelog.cc
ceph_test_cls_statelog_LDADD = $(LIBRADOS) libcls_statelog_client.la $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_cls_statelog_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_statelog

ceph_test_cls_replica_log_SOURCES = test/cls_replica_log/test_cls_replica_log.cc
ceph_test_cls_replica_log_LDADD = \
	$(LIBRADOS) libcls_replica_log_client.la \
	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_cls_replica_log_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_replica_log

ceph_test_cls_lock_SOURCES = test/cls_lock/test_cls_lock.cc
ceph_test_cls_lock_LDADD = \
	$(LIBRADOS) libcls_lock_client.la \
	$(LIBCOMMON) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_cls_lock_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_lock

ceph_test_cls_hello_SOURCES = test/cls_hello/test_cls_hello.cc
ceph_test_cls_hello_LDADD = \
	$(LIBRADOS) $(CRYPTO_LIBS) \
	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_cls_hello_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_hello

ceph_test_cls_numops_SOURCES = test/cls_numops/test_cls_numops.cc
ceph_test_cls_numops_LDADD = \
    $(LIBRADOS) libcls_numops_client.la \
    $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_cls_numops_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_numops

ceph_test_cls_journal_SOURCES = test/cls_journal/test_cls_journal.cc
ceph_test_cls_journal_LDADD = \
        libcls_journal_client.la $(LIBRADOS) \
        $(LIBCOMMON) $(CRYPTO_LIBS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) -luuid
ceph_test_cls_journal_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_journal

ceph_test_rados_api_cmd_SOURCES = test/librados/cmd.cc
ceph_test_rados_api_cmd_LDADD = \
	$(LIBCOMMON) $(LIBRADOS) $(CRYPTO_LIBS) \
	$(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_cmd_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_cmd

ceph_test_rados_api_io_SOURCES = test/librados/io.cc
ceph_test_rados_api_io_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_io_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_io

ceph_test_rados_api_c_write_operations_SOURCES = \
	test/librados/c_write_operations.cc
ceph_test_rados_api_c_write_operations_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_c_write_operations_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_c_write_operations

ceph_test_rados_api_c_read_operations_SOURCES = \
	test/librados/c_read_operations.cc
ceph_test_rados_api_c_read_operations_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_c_read_operations_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_c_read_operations

ceph_test_rados_api_aio_SOURCES = test/librados/aio.cc
ceph_test_rados_api_aio_LDADD = \
	$(LIBRADOS) $(LIBCOMMON) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_aio_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_aio

ceph_test_rados_api_list_SOURCES = test/librados/list.cc
ceph_test_rados_api_list_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) $(CEPH_GLOBAL)
ceph_test_rados_api_list_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_list

ceph_test_rados_api_nlist_SOURCES = test/librados/nlist.cc
ceph_test_rados_api_nlist_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_nlist_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_nlist

ceph_test_rados_api_pool_SOURCES = test/librados/pool.cc
ceph_test_rados_api_pool_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_pool_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_pool

ceph_test_rados_api_stat_SOURCES = test/librados/stat.cc
ceph_test_rados_api_stat_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_stat_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_stat

ceph_test_rados_api_watch_notify_SOURCES = test/librados/watch_notify.cc
ceph_test_rados_api_watch_notify_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_watch_notify_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_watch_notify

ceph_test_rados_api_snapshots_SOURCES = test/librados/snapshots.cc
ceph_test_rados_api_snapshots_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_snapshots_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_snapshots

ceph_test_rados_api_cls_SOURCES = test/librados/cls.cc
ceph_test_rados_api_cls_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_cls_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_cls

ceph_test_rados_api_misc_SOURCES = test/librados/misc.cc
ceph_test_rados_api_misc_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_rados_api_misc_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_misc

ceph_test_rados_api_tier_SOURCES = \
	test/librados/tier.cc \
	osd/HitSet.cc
ceph_test_rados_api_tier_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_rados_api_tier_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_tier

ceph_test_rados_api_lock_SOURCES = test/librados/lock.cc
ceph_test_rados_api_lock_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_rados_api_lock_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_lock

ceph_test_rados_api_tmap_migrate_SOURCES = test/librados/tmap_migrate.cc tools/cephfs/DataScan.cc tools/cephfs/MDSUtility.cc
ceph_test_rados_api_tmap_migrate_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(LIBMDS) libcls_cephfs_client.la  $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_rados_api_tmap_migrate_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_api_tmap_migrate


ceph_test_stress_watch_SOURCES = test/test_stress_watch.cc
ceph_test_stress_watch_LDADD = \
	$(LIBRADOS) $(LIBCOMMON) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
ceph_test_stress_watch_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_stress_watch

librados_test_stub_la_SOURCES = \
	test/librados_test_stub/LibradosTestStub.cc \
	test/librados_test_stub/TestClassHandler.cc \
	test/librados_test_stub/TestIoCtxImpl.cc \
	test/librados_test_stub/TestMemIoCtxImpl.cc \
	test/librados_test_stub/TestMemRadosClient.cc \
	test/librados_test_stub/TestRadosClient.cc \
	test/librados_test_stub/TestWatchNotify.cc
noinst_HEADERS += \
	test/librados_test_stub/LibradosTestStub.h \
	test/librados_test_stub/MockTestMemIoCtxImpl.h \
	test/librados_test_stub/MockTestMemRadosClient.h \
	test/librados_test_stub/TestClassHandler.h \
	test/librados_test_stub/TestRadosClient.h \
	test/librados_test_stub/TestMemRadosClient.h \
	test/librados_test_stub/TestWatchNotify.h \
	test/librados_test_stub/TestMemIoCtxImpl.h \
	test/librados_test_stub/TestIoCtxImpl.h
noinst_LTLIBRARIES += librados_test_stub.la

libjournal_test_mock_la_SOURCES = \
	test/journal/mock/MockJournaler.cc
noinst_HEADERS += \
	test/journal/mock/MockJournaler.h
libjournal_test_mock_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
noinst_LTLIBRARIES += libjournal_test_mock.la

unittest_journal_SOURCES = \
	test/journal/test_main.cc \
        test/journal/test_Entry.cc \
	test/journal/test_FutureImpl.cc \
	test/journal/test_Journaler.cc \
	test/journal/test_JournalMetadata.cc \
	test/journal/test_JournalPlayer.cc \
	test/journal/test_JournalRecorder.cc \
	test/journal/test_JournalTrimmer.cc \
	test/journal/test_ObjectPlayer.cc \
	test/journal/test_ObjectRecorder.cc \
	test/journal/RadosTestFixture.cc
unittest_journal_CXXFLAGS = $(UNITTEST_CXXFLAGS)
unittest_journal_LDADD = \
	libjournal.la libcls_journal_client.la \
	librados_test_stub.la librados_internal.la \
	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD) $(LIBRADOS)
check_TESTPROGRAMS += unittest_journal

if WITH_RBD
ceph_smalliobenchrbd_SOURCES = \
	test/bench/small_io_bench_rbd.cc \
	test/bench/rbd_backend.cc \
	test/bench/detailed_stat_collector.cc \
	test/bench/bencher.cc
ceph_smalliobenchrbd_LDADD = $(LIBRBD) $(LIBRADOS) $(BOOST_PROGRAM_OPTIONS_LIBS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_smalliobenchrbd

unittest_rbd_replay_SOURCES = test/test_rbd_replay.cc
unittest_rbd_replay_LDADD = $(LIBRBD) \
	$(LIBRADOS) \
	$(CEPH_GLOBAL) \
	librbd_replay.la \
	librbd_replay_ios.la \
	$(UNITTEST_LDADD)
unittest_rbd_replay_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_rbd_replay

librbd_test_la_SOURCES = \
	test/librbd/test_fixture.cc \
	test/librbd/test_support.cc \
	test/librbd/test_librbd.cc \
	test/librbd/test_ImageWatcher.cc \
	test/librbd/test_internal.cc \
	test/librbd/test_mirroring.cc \
	test/librbd/test_MirroringWatcher.cc \
	test/librbd/test_ObjectMap.cc \
	test/librbd/journal/test_Entries.cc \
	test/librbd/journal/test_Replay.cc
librbd_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
noinst_LTLIBRARIES += librbd_test.la

librbd_test_mock_la_SOURCES = \
	test/librbd/mock/MockImageCtx.cc \
	test/librbd/mock/MockJournal.cc
librbd_test_mock_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
noinst_LTLIBRARIES += librbd_test_mock.la

unittest_librbd_SOURCES = \
        test/librbd/test_main.cc \
	test/librbd/test_mock_fixture.cc \
	test/librbd/test_mock_ExclusiveLock.cc \
	test/librbd/test_mock_Journal.cc \
	test/librbd/test_mock_ObjectWatcher.cc \
	test/librbd/exclusive_lock/test_mock_AcquireRequest.cc \
	test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc \
	test/librbd/image/test_mock_RefreshRequest.cc \
	test/librbd/journal/test_mock_Replay.cc \
	test/librbd/object_map/test_mock_InvalidateRequest.cc \
	test/librbd/object_map/test_mock_LockRequest.cc \
	test/librbd/object_map/test_mock_RefreshRequest.cc \
	test/librbd/object_map/test_mock_ResizeRequest.cc \
	test/librbd/object_map/test_mock_SnapshotCreateRequest.cc \
	test/librbd/object_map/test_mock_SnapshotRemoveRequest.cc \
	test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc \
	test/librbd/object_map/test_mock_UnlockRequest.cc \
	test/librbd/object_map/test_mock_UpdateRequest.cc \
	test/librbd/operation/test_mock_ResizeRequest.cc \
	test/librbd/operation/test_mock_SnapshotCreateRequest.cc \
	test/librbd/operation/test_mock_SnapshotProtectRequest.cc \
	test/librbd/operation/test_mock_SnapshotRemoveRequest.cc \
	test/librbd/operation/test_mock_SnapshotRollbackRequest.cc \
	test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
unittest_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
unittest_librbd_LDADD = \
	librbd_test.la libjournal_test_mock.la librbd_test_mock.la \
	librbd_api.la librbd_internal.la $(LIBRBD_TYPES) \
	libcls_rbd_client.la libcls_lock_client.la \
	libjournal.la libcls_journal_client.la \
	librados_test_stub.la librados_internal.la \
	$(LIBRADOS) $(LIBOSDC) $(UNITTEST_LDADD) \
	$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
check_PROGRAMS += unittest_librbd
check_SCRIPTS += test/run-rbd-unit-tests.sh

ceph_test_librbd_SOURCES = \
        test/librbd/test_main.cc
ceph_test_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
ceph_test_librbd_LDADD = \
	librbd_test.la librbd_api.la librbd_internal.la $(LIBRBD_TYPES) \
	libcls_rbd_client.la libcls_lock_client.la \
	libjournal.la libcls_journal_client.la \
	librados_api.la $(LIBRADOS_DEPS) $(UNITTEST_LDADD) \
	$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
bin_DEBUGPROGRAMS += ceph_test_librbd

ceph_test_librbd_api_SOURCES = \
	test/librbd/test_support.cc \
	test/librbd/test_librbd.cc \
	test/librbd/test_main.cc
ceph_test_librbd_api_CXXFLAGS = $(UNITTEST_CXXFLAGS)
ceph_test_librbd_api_LDADD = \
	$(LIBRBD) $(LIBRADOS) $(LIBCOMMON) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD)
bin_DEBUGPROGRAMS += ceph_test_librbd_api

noinst_HEADERS += \
	test/librbd/test_fixture.h \
	test/librbd/test_mock_fixture.h \
	test/librbd/test_support.h \
	test/librbd/mock/MockAioImageRequestWQ.h \
	test/librbd/mock/MockContextWQ.h \
	test/librbd/mock/MockExclusiveLock.h \
	test/librbd/mock/MockImageCtx.h \
	test/librbd/mock/MockImageState.h \
	test/librbd/mock/MockImageWatcher.h \
	test/librbd/mock/MockJournal.h \
	test/librbd/mock/MockJournalPolicy.h \
	test/librbd/mock/MockObjectMap.h \
	test/librbd/mock/MockOperations.h \
	test/librbd/mock/MockReadahead.h \
	test/librbd/object_map/mock/MockInvalidateRequest.h

librbd_mirror_test_la_SOURCES = \
	test/rbd_mirror/test_ClusterWatcher.cc \
	test/rbd_mirror/test_PoolWatcher.cc \
	test/rbd_mirror/test_ImageReplayer.cc \
        test/rbd_mirror/test_ImageDeleter.cc \
	test/rbd_mirror/test_ImageSync.cc \
	test/rbd_mirror/test_fixture.cc

noinst_HEADERS += \
	test/rbd_mirror/test_fixture.h \
	test/rbd_mirror/test_mock_fixture.h

librbd_mirror_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
noinst_LTLIBRARIES += librbd_mirror_test.la

unittest_rbd_mirror_SOURCES = \
	test/rbd_mirror/test_main.cc \
	test/rbd_mirror/test_mock_fixture.cc \
	test/rbd_mirror/test_mock_ImageReplayer.cc \
	test/rbd_mirror/test_mock_ImageSync.cc \
	test/rbd_mirror/test_mock_ImageSyncThrottler.cc \
	test/rbd_mirror/image_replayer/test_mock_BootstrapRequest.cc \
	test/rbd_mirror/image_replayer/test_mock_CreateImageRequest.cc \
	test/rbd_mirror/image_replayer/test_mock_EventPreprocessor.cc \
	test/rbd_mirror/image_sync/test_mock_ImageCopyRequest.cc \
	test/rbd_mirror/image_sync/test_mock_ObjectCopyRequest.cc \
	test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc \
	test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc \
	test/rbd_mirror/image_sync/test_mock_SyncPointCreateRequest.cc \
	test/rbd_mirror/image_sync/test_mock_SyncPointPruneRequest.cc
unittest_rbd_mirror_CXXFLAGS = $(UNITTEST_CXXFLAGS)
unittest_rbd_mirror_LDADD = \
	librbd_mirror_test.la \
	libjournal_test_mock.la \
	librbd_test_mock.la \
	librados_test_stub.la \
	librbd_mirror_internal.la \
	librbd_internal.la \
	librbd_api.la \
	libjournal.la \
	librados_internal.la \
	libcls_rbd_client.la \
	libcls_lock_client.la \
	libcls_journal_client.la \
	$(LIBRBD_TYPES) \
	$(LIBRADOS) $(LIBOSDC) $(UNITTEST_LDADD) \
	$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
check_PROGRAMS += unittest_rbd_mirror

ceph_test_rbd_mirror_SOURCES = \
        test/rbd_mirror/test_main.cc
ceph_test_rbd_mirror_CXXFLAGS = $(UNITTEST_CXXFLAGS)
ceph_test_rbd_mirror_LDADD = \
	librbd_mirror_test.la \
	librbd_mirror_internal.la \
	librbd_internal.la \
	librbd_api.la \
	libjournal.la \
	librados_internal.la \
	libcls_rbd_client.la \
	libcls_lock_client.la \
	libcls_journal_client.la \
	$(LIBRBD_TYPES) \
	librados_api.la $(LIBRADOS_DEPS) \
	$(LIBOSDC) $(UNITTEST_LDADD) \
	$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
bin_DEBUGPROGRAMS += ceph_test_rbd_mirror

ceph_test_rbd_mirror_random_write_SOURCES = \
	test/rbd_mirror/random_write.cc
ceph_test_rbd_mirror_random_write_CXXFLAGS = $(UNITTEST_CXXFLAGS)
ceph_test_rbd_mirror_random_write_LDADD = \
	$(LIBRBD) $(LIBRADOS) $(CEPH_GLOBAL)
bin_DEBUGPROGRAMS += ceph_test_rbd_mirror_random_write

if LINUX
ceph_test_librbd_fsx_SOURCES = test/librbd/fsx.cc
ceph_test_librbd_fsx_LDADD = \
	libjournal.la libcls_journal_client.la \
	$(LIBKRBD) $(LIBRBD) $(LIBRADOS) \
	$(CRYPTO_LIBS) $(PTHREAD_LIBS)
ceph_test_librbd_fsx_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_librbd_fsx
endif
endif # WITH_RBD


if WITH_RADOSSTRIPER
libradosstripertest_la_SOURCES = test/libradosstriper/TestCase.cc
noinst_LTLIBRARIES += libradosstripertest.la
libradosstripertest_la_LIBADD = $(RADOS_TEST_LDADD)
libradosstripertest_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
RADOS_STRIPER_TEST_LDADD = libradosstripertest.la

ceph_test_rados_striper_api_io_SOURCES = test/libradosstriper/io.cc
ceph_test_rados_striper_api_io_LDADD = \
	$(LIBRADOS) $(LIBRADOSSTRIPER) $(LIBCOMMON) \
	$(UNITTEST_LDADD) $(RADOS_STRIPER_TEST_LDADD)
ceph_test_rados_striper_api_io_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_striper_api_io

ceph_test_rados_striper_api_aio_SOURCES = test/libradosstriper/aio.cc
ceph_test_rados_striper_api_aio_LDADD = $(LIBRADOS) $(LIBRADOSSTRIPER) $(UNITTEST_LDADD) $(RADOS_STRIPER_TEST_LDADD)
ceph_test_rados_striper_api_aio_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_striper_api_aio

ceph_test_rados_striper_api_striping_SOURCES = test/libradosstriper/striping.cc
ceph_test_rados_striper_api_striping_LDADD = $(LIBRADOS) $(LIBRADOSSTRIPER) $(UNITTEST_LDADD) $(RADOS_STRIPER_TEST_LDADD)
ceph_test_rados_striper_api_striping_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rados_striper_api_striping

endif # WITH_RADOSSTRIPER


if WITH_CEPHFS

if WITH_BUILD_TESTS
# I dont get this one... testing the osdc build but link in libcephfs?
test_build_libcephfs_SOURCES = \
	test/buildtest_skeleton.cc \
	$(libosdc_la_SOURCES)
test_build_libcephfs_LDADD = \
	$(LIBCEPHFS) -lexpat \
	$(PTHREAD_LIBS) $(CRYPTO_LIBS) $(EXTRALIBS)
test_build_libcephfs_LDFLAGS = -static-libtool-libs
test_build_libcephfs_CFLAGS = $(AM_CFLAGS)
test_build_libcephfs_CXXFLAGS = $(AM_CXXFLAGS)
bin_DEBUGPROGRAMS += test_build_libcephfs
endif # WITH_BUILD_TESTS

unittest_encoding_LDADD = $(LIBCEPHFS) $(LIBRADOS) $(CEPH_GLOBAL) -lm $(UNITTEST_LDADD)
unittest_encoding_CXXFLAGS = $(UNITTEST_CXXFLAGS) -fno-strict-aliasing
check_TESTPROGRAMS += unittest_encoding

unittest_base64_SOURCES = test/base64.cc
unittest_base64_LDADD = $(LIBCEPHFS) $(CEPH_GLOBAL) -lm $(UNITTEST_LDADD)
unittest_base64_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_base64

unittest_run_cmd_SOURCES = test/run_cmd.cc
unittest_run_cmd_LDADD = $(LIBCEPHFS) $(CEPH_GLOBAL) $(UNITTEST_LDADD)
unittest_run_cmd_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_run_cmd

unittest_simple_spin_SOURCES = test/simple_spin.cc
unittest_simple_spin_LDADD = $(LIBCEPHFS) $(CEPH_GLOBAL) $(UNITTEST_LDADD)
unittest_simple_spin_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_simple_spin

unittest_libcephfs_config_SOURCES = test/libcephfs_config.cc
unittest_libcephfs_config_LDADD = $(LIBCEPHFS) $(CEPH_GLOBAL) $(UNITTEST_LDADD)
unittest_libcephfs_config_CXXFLAGS = $(UNITTEST_CXXFLAGS)
check_TESTPROGRAMS += unittest_libcephfs_config

ceph_test_libcephfs_SOURCES = \
	test/libcephfs/test.cc \
	test/libcephfs/readdir_r_cb.cc \
	test/libcephfs/caps.cc \
	test/libcephfs/multiclient.cc \
	test/libcephfs/access.cc \
	test/libcephfs/acl.cc

if LINUX
ceph_test_libcephfs_SOURCES += test/libcephfs/flock.cc
endif # LINUX

ceph_test_libcephfs_LDADD = $(LIBRADOS) $(LIBCEPHFS) $(LIBCOMMON) $(UNITTEST_LDADD)
ceph_test_libcephfs_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_libcephfs

unittest_encoding_SOURCES = test/encoding.cc

ceph_test_c_headers_SOURCES = test/test_c_headers.c
ceph_test_c_headers_LDADD = $(LIBRADOS) $(LIBCEPHFS)
ceph_test_c_headers_CFLAGS = $(AM_CFLAGS) \
	-Wstrict-prototypes \
	-Wredundant-decls \
	-Wall \
	-Wundef \
	-Wwrite-strings \
	-Wmissing-prototypes \
	-Wendif-labels \
	-Wmissing-include-dirs \
	-Wempty-body \
	-Wnested-externs \
	-Wformat-security \
	-Wformat-y2k \
	-Winit-self \
	-Wignored-qualifiers \
	-Wold-style-definition \
	-Wtype-limits
if !CLANG
ceph_test_c_headers_CFLAGS += -Werror -Wold-style-declaration
endif # !CLANG
bin_DEBUGPROGRAMS += ceph_test_c_headers

endif # WITH_CEPHFS


if WITH_RADOSGW

if WITH_BUILD_TESTS
test_build_librgw_SOURCES = \
	test/buildtest_skeleton.cc \
	$(librgw_la_SOURCES)
test_build_librgw_LDADD = \
	$(LIBRGW_DEPS) \
	$(PTHREAD_LIBS) $(CRYPTO_LIBS) $(EXTRALIBS) \
	$(CEPH_GLOBAL)
test_build_librgw_LDFLAGS = -static-libtool-libs
test_build_librgw_CFLAGS = $(AM_CFLAGS)
test_build_librgw_CXXFLAGS = $(AM_CXXFLAGS)
bin_DEBUGPROGRAMS += test_build_librgw
endif # WITH_BUILD_TESTS

ceph_test_cors_SOURCES = test/test_cors.cc
ceph_test_cors_LDADD = \
	$(LIBRADOS) $(LIBRGW) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) \
	-lcurl -lexpat
ceph_test_cors_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cors

ceph_test_rgw_manifest_SOURCES = test/rgw/test_rgw_manifest.cc
ceph_test_rgw_manifest_LDADD = \
	$(LIBRADOS) $(LIBRGW) $(LIBRGW_DEPS) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) $(CRYPTO_LIBS) \
	-lcurl -lexpat

ceph_test_rgw_manifest_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rgw_manifest

ceph_test_rgw_period_history_SOURCES = test/rgw/test_rgw_period_history.cc
ceph_test_rgw_period_history_LDADD = \
	$(LIBRADOS) $(LIBRGW) $(LIBRGW_DEPS) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) $(CRYPTO_LIBS) -lcurl -lexpat
ceph_test_rgw_period_history_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rgw_period_history

ceph_test_rgw_obj_SOURCES = test/rgw/test_rgw_obj.cc
ceph_test_rgw_obj_LDADD = \
	$(LIBRADOS) $(LIBRGW) $(LIBRGW_DEPS) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) $(CRYPTO_LIBS) \
	-lcurl -luuid -lexpat

ceph_test_rgw_obj_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_rgw_obj

ceph_test_cls_rgw_meta_SOURCES = test/test_rgw_admin_meta.cc
ceph_test_cls_rgw_meta_LDADD = \
	$(LIBRGW) $(LIBRADOS) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) $(CRYPTO_LIBS) \
	-lcurl -lexpat \
	libcls_timeindex_client.la \
	libcls_version_client.la libcls_log_client.la \
	libcls_statelog_client.la libcls_refcount_client.la \
	libcls_rgw_client.la libcls_user_client.la libcls_lock_client.la
ceph_test_cls_rgw_meta_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_rgw_meta

ceph_test_cls_rgw_log_SOURCES = test/test_rgw_admin_log.cc
ceph_test_cls_rgw_log_LDADD = \
	$(LIBRADOS) $(LIBRGW) $(LIBRGW_DEPS) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) $(CRYPTO_LIBS) \
	-lcurl -lexpat \
	libcls_version_client.la libcls_log_client.la \
	libcls_statelog_client.la libcls_refcount_client.la \
	libcls_rgw_client.la libcls_user_client.la libcls_lock_client.la
ceph_test_cls_rgw_log_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_rgw_log

ceph_test_cls_rgw_opstate_SOURCES = test/test_rgw_admin_opstate.cc
ceph_test_cls_rgw_opstate_LDADD = \
	$(LIBRADOS) $(LIBRGW) $(CEPH_GLOBAL) \
	$(UNITTEST_LDADD) $(CRYPTO_LIBS) \
	-lcurl -lexpat \
	libcls_version_client.la libcls_log_client.la \
	libcls_timeindex_client.la \
	libcls_statelog_client.la libcls_refcount_client.la \
	libcls_rgw_client.la libcls_user_client.la libcls_lock_client.la \
	$(LIBRADOS)
ceph_test_cls_rgw_opstate_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_rgw_opstate

ceph_test_cls_rgw_SOURCES = test/cls_rgw/test_cls_rgw.cc
ceph_test_cls_rgw_LDADD = \
	$(LIBRADOS) $(CRYPTO_LIBS) libcls_rgw_client.la \
	$(LIBCOMMON) $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
ceph_test_cls_rgw_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_cls_rgw

# librgw/RGW-NFS
librgw_file_SOURCES = test/librgw_file.cc
librgw_file_CXXFLAGS = -I$(srcdir)/xxHash $(UNITTEST_CXXFLAGS)
librgw_file_LDADD = $(UNITTEST_LDADD)  \
	librgw.la librados.la $(PTHREAD_LIBS) $(CEPH_GLOBAL) $(EXTRALIBS) 
bin_DEBUGPROGRAMS += librgw_file

librgw_file_cd_SOURCES = test/librgw_file_cd.cc
librgw_file_cd_CXXFLAGS = -I$(srcdir)/xxHash $(UNITTEST_CXXFLAGS)
librgw_file_cd_LDADD = $(UNITTEST_LDADD) \
	librgw.la librados.la $(PTHREAD_LIBS) $(CEPH_GLOBAL) $(EXTRALIBS)
bin_DEBUGPROGRAMS += librgw_file_cd

librgw_file_gp_SOURCES = test/librgw_file_gp.cc
librgw_file_gp_CXXFLAGS = -I$(srcdir)/xxHash $(UNITTEST_CXXFLAGS)
librgw_file_gp_LDADD = $(UNITTEST_LDADD) \
	librgw.la librados.la $(PTHREAD_LIBS) $(CEPH_GLOBAL) $(EXTRALIBS)
bin_DEBUGPROGRAMS += librgw_file_gp

librgw_file_aw_SOURCES = test/librgw_file_aw.cc
librgw_file_aw_CXXFLAGS = -I$(srcdir)/xxHash $(UNITTEST_CXXFLAGS)
librgw_file_aw_LDADD = $(UNITTEST_LDADD) \
	librgw.la librados.la $(PTHREAD_LIBS) $(CEPH_GLOBAL) $(EXTRALIBS)
bin_DEBUGPROGRAMS += librgw_file_aw

librgw_file_nfsns_SOURCES = test/librgw_file_nfsns.cc
librgw_file_nfsns_CXXFLAGS = -I$(srcdir)/xxHash $(UNITTEST_CXXFLAGS)
librgw_file_nfsns_LDADD = $(UNITTEST_LDADD) \
	librgw.la librados.la $(PTHREAD_LIBS) $(CEPH_GLOBAL) $(EXTRALIBS)
bin_DEBUGPROGRAMS += librgw_file_nfsns

# 
# test_rgw_token_SOURCES = test/test_rgw_token.cc
# test_rgw_token_CXXFLAGS = $(UNITTEST_CXXFLAGS)
# test_rgw_token_LDADD = $(UNITTEST_LDADD) \
# 	librgw.la $(PTHREAD_LIBS) $(LIBOS) $(CEPH_GLOBAL) $(EXTRALIBS)
# bin_DEBUGPROGRAMS += test_rgw_token

# test_rgw_ldap_SOURCES = rgw/rgw_ldap.cc test/test_rgw_ldap.cc
# test_rgw_ldap_CXXFLAGS = $(UNITTEST_CXXFLAGS)
# test_rgw_ldap_LDADD = $(UNITTEST_LDADD) \
# 	librados.la $(PTHREAD_LIBS) $(LIBOS) $(CEPH_GLOBAL) ${OPENLDAP_LIBS}
# 	$(EXTRALIBS)
# bin_DEBUGPROGRAMS += test_rgw_ldap

endif # WITH_RADOSGW


endif # WITH_RADOS
