include(CTest)

add_executable(test_posixipc_h test_posixipc_h.c)
target_include_directories(test_posixipc_h PRIVATE
    "${CMAKE_SOURCE_DIR}/include")
posixipc_apply_warnings(test_posixipc_h)
add_test(NAME test_posixipc_h COMMAND test_posixipc_h)
set_tests_properties(test_posixipc_h PROPERTIES TIMEOUT 10)

add_executable(test_shm_protocol test_shm_protocol.c)
target_link_libraries(test_shm_protocol PRIVATE posixipc_core)
posixipc_apply_warnings(test_shm_protocol)
add_test(NAME test_shm_protocol COMMAND test_shm_protocol)
set_tests_properties(test_shm_protocol PROPERTIES TIMEOUT 60)

add_executable(test_robust_recovery test_robust_recovery.c)
target_link_libraries(test_robust_recovery PRIVATE posixipc_core)
posixipc_apply_warnings(test_robust_recovery)
add_test(NAME test_robust_recovery COMMAND test_robust_recovery)
set_tests_properties(test_robust_recovery PROPERTIES TIMEOUT 30)

add_executable(test_mutex_threads test_mutex_threads.c)
target_link_libraries(test_mutex_threads PRIVATE posixipc_core)
posixipc_apply_warnings(test_mutex_threads)
add_test(NAME test_mutex_threads COMMAND test_mutex_threads)
set_tests_properties(test_mutex_threads PROPERTIES TIMEOUT 30)

add_executable(test_rwlock_threads test_rwlock_threads.c)
target_link_libraries(test_rwlock_threads PRIVATE posixipc_core)
posixipc_apply_warnings(test_rwlock_threads)
add_test(NAME test_rwlock_threads COMMAND test_rwlock_threads)
set_tests_properties(test_rwlock_threads PROPERTIES TIMEOUT 30)

add_executable(test_cond_threads test_cond_threads.c)
target_link_libraries(test_cond_threads PRIVATE posixipc_core)
posixipc_apply_warnings(test_cond_threads)
add_test(NAME test_cond_threads COMMAND test_cond_threads)
set_tests_properties(test_cond_threads PROPERTIES TIMEOUT 30)

add_executable(test_sem_threads test_sem_threads.c)
target_link_libraries(test_sem_threads PRIVATE posixipc_core)
posixipc_apply_warnings(test_sem_threads)
add_test(NAME test_sem_threads COMMAND test_sem_threads)
set_tests_properties(test_sem_threads PROPERTIES TIMEOUT 30)

add_executable(test_barrier_threads test_barrier_threads.c)
target_link_libraries(test_barrier_threads PRIVATE posixipc_core)
posixipc_apply_warnings(test_barrier_threads)
add_test(NAME test_barrier_threads COMMAND test_barrier_threads)
set_tests_properties(test_barrier_threads PROPERTIES TIMEOUT 30)

add_executable(test_spin_threads test_spin_threads.c)
target_link_libraries(test_spin_threads PRIVATE posixipc_core)
posixipc_apply_warnings(test_spin_threads)
add_test(NAME test_spin_threads COMMAND test_spin_threads)
set_tests_properties(test_spin_threads PROPERTIES TIMEOUT 30)

add_executable(test_nsem test_nsem.c)
target_link_libraries(test_nsem PRIVATE posixipc_core)
posixipc_apply_warnings(test_nsem)
add_test(NAME test_nsem COMMAND test_nsem)
set_tests_properties(test_nsem PROPERTIES TIMEOUT 30)

add_executable(test_queue_ring test_queue_ring.c)
target_link_libraries(test_queue_ring PRIVATE posixipc_core)
posixipc_apply_warnings(test_queue_ring)
add_test(NAME test_queue_ring COMMAND test_queue_ring)
set_tests_properties(test_queue_ring PROPERTIES TIMEOUT 10)

add_executable(test_mq test_mq.c)
target_link_libraries(test_mq PRIVATE posixipc_core)
posixipc_apply_warnings(test_mq)
add_test(NAME test_mq COMMAND test_mq)
set_tests_properties(test_mq PROPERTIES TIMEOUT 10)

add_executable(test_futex test_futex.c)
target_link_libraries(test_futex PRIVATE posixipc_core)
posixipc_apply_warnings(test_futex)
add_test(NAME test_futex COMMAND test_futex)
set_tests_properties(test_futex PROPERTIES TIMEOUT 10)

add_executable(test_eventfd test_eventfd.c)
target_link_libraries(test_eventfd PRIVATE posixipc_core)
posixipc_apply_warnings(test_eventfd)
add_test(NAME test_eventfd COMMAND test_eventfd)
set_tests_properties(test_eventfd PROPERTIES TIMEOUT 10)

add_executable(test_memfd test_memfd.c)
target_link_libraries(test_memfd PRIVATE posixipc_core)
posixipc_apply_warnings(test_memfd)
add_test(NAME test_memfd COMMAND test_memfd)
set_tests_properties(test_memfd PROPERTIES TIMEOUT 10)

add_executable(test_futexq test_futexq.c)
target_link_libraries(test_futexq PRIVATE posixipc_core)
posixipc_apply_warnings(test_futexq)
add_test(NAME test_futexq COMMAND test_futexq)
set_tests_properties(test_futexq PROPERTIES TIMEOUT 10)
