# A bounded queue and three ways to test it: deterministic tests in one
# thread with a scripted condition variable, tests with real threads that
# wait for a state instead of a time, and a stress test. The two tests
# with threads are labelled concurrency, so `ctest --preset tsan` runs
# them under ThreadSanitizer.
find_package(Threads REQUIRED)

add_library(tst_shipping_queue INTERFACE)
target_include_directories(tst_shipping_queue INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(tst_shipping_queue INTERFACE Threads::Threads)

lld_add_example(tst_shipping_demo SOURCES main.cpp EXPECTED_OUTPUT expected_output.txt)
target_link_libraries(tst_shipping_demo PRIVATE tst_shipping_queue)

lld_add_test(tst_shipping_scripted_tests SOURCES tests/test_scripted.cpp LABELS unit)
target_link_libraries(tst_shipping_scripted_tests PRIVATE tst_shipping_queue)

lld_add_test(tst_shipping_thread_tests SOURCES tests/test_threads.cpp LABELS concurrency)
target_link_libraries(tst_shipping_thread_tests PRIVATE tst_shipping_queue)

lld_add_test(tst_shipping_stress_tests SOURCES tests/test_stress.cpp LABELS concurrency stress)
target_link_libraries(tst_shipping_stress_tests PRIVATE tst_shipping_queue)
