cmake_minimum_required(VERSION 2.8...3.30)

project(vitastor)

### Test stubs

# stub_osd, stub_bench
add_executable(stub_osd stub_osd.cpp)
target_link_libraries(stub_osd util)
add_executable(stub_bench stub_bench.cpp)
target_link_libraries(stub_bench util)

# bindiff
add_executable(bindiff
	bindiff.c
)

# stub_uring_osd
add_executable(stub_uring_osd
	EXCLUDE_FROM_ALL
	stub_uring_osd.cpp
)
target_link_libraries(stub_uring_osd
	vitastor_net
	${LIBURING_LIBRARIES}
	${IBVERBS_LIBRARIES}
	${RDMACM_LIBRARIES}
)

# test_allocator
add_executable(test_allocator EXCLUDE_FROM_ALL test_allocator.cpp)
target_link_libraries(test_allocator util)
add_dependencies(build_tests test_allocator)
add_test(NAME test_allocator COMMAND test_allocator)

# test_heap
add_executable(test_heap
	EXCLUDE_FROM_ALL
	test_heap.cpp
	../blockstore/multilist.cpp
	../blockstore/blockstore_heap.cpp
	../blockstore/blockstore_disk.cpp
)
target_link_libraries(test_heap
	util
	crc32c
)
add_dependencies(build_tests test_heap)
add_test(NAME test_heap COMMAND test_heap)
target_compile_options(test_heap PRIVATE -coverage)
target_link_options(test_heap PRIVATE -coverage)

# test_cas
add_executable(test_cas
	test_cas.cpp
)
target_link_libraries(test_cas
	vitastor_client
)

# test_crc32
add_executable(test_crc32
	test_crc32.cpp
)

# test_blockstore
add_executable(test_blockstore EXCLUDE_FROM_ALL test_blockstore.cpp ringloop_mock.cpp)
add_dependencies(build_tests test_blockstore)
target_link_libraries(test_blockstore vitastor_blk vitastor_common)
add_test(NAME test_blockstore COMMAND test_blockstore)

# test_blockstore_v1
add_executable(test_blockstore_v1 EXCLUDE_FROM_ALL test_blockstore_v1.cpp ringloop_mock.cpp)
add_dependencies(build_tests test_blockstore_v1)
target_link_libraries(test_blockstore_v1 vitastor_blk vitastor_common)
add_test(NAME test_blockstore_v1 COMMAND test_blockstore_v1)

# test_blockstore_chaos
add_executable(test_blockstore_chaos EXCLUDE_FROM_ALL test_blockstore_chaos.cpp ringloop_mock.cpp)
add_dependencies(build_tests test_blockstore_chaos)
target_link_libraries(test_blockstore_chaos vitastor_blk vitastor_common)
add_test(NAME test_blockstore_chaos COMMAND test_blockstore_chaos)

## test_shit
#add_executable(test_shit test_shit.cpp osd_peering_pg.cpp)
#target_link_libraries(test_shit ${LIBURING_LIBRARIES} m)

# test_atomic
add_executable(test_atomic test_atomic.cpp)
target_link_libraries(test_atomic util)
