File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ target_link_libraries(lsl_test_internal PRIVATE lslobj lslboost common catch_mai
7979# Pretend that lsl_test_internal is part of a shared lib so that it can use the __export symbols lslobj. REQ by MinGW.
8080target_compile_definitions (lsl_test_internal PRIVATE LIBLSL_EXPORTS )
8181
82+ # runtime_config test needs a fresh api_config singleton, so it lives in its own executable.
83+ add_executable (lsl_test_runtime_config int/runtime_config.cpp )
84+ target_link_libraries (lsl_test_runtime_config PRIVATE lslobj lslboost common catch_main )
85+ target_compile_definitions (lsl_test_runtime_config PRIVATE LIBLSL_EXPORTS )
86+
8287if (LSL_BENCHMARKS)
8388 # to get somewhat reproducible performance numbers:
8489 # /usr/bin/time -v testing/lsl_test_exported --benchmark-samples 100 bounce
@@ -94,7 +99,7 @@ if(LSL_BENCHMARKS)
9499 )
95100endif ()
96101
97- set (LSL_TESTS lsl_test_exported lsl_test_internal)
102+ set (LSL_TESTS lsl_test_exported lsl_test_internal lsl_test_runtime_config )
98103foreach (lsltest ${LSL_TESTS} )
99104 add_test (NAME ${lsltest} COMMAND ${lsltest} --wait-for-keypress never )
100105 if (LSL_INSTALL)
Original file line number Diff line number Diff line change 1+ #include " api_config.h"
2+ #include < catch2/catch_test_macros.hpp>
3+
4+ // Verifies that configuration provided via the runtime-config API is picked up
5+ // on singleton initialization. Because api_config::get_instance() is guarded by
6+ // std::call_once, only the first configuration wins per-process. This test
7+ // therefore lives in its own executable so the singleton starts fresh.
8+
9+ TEST_CASE (" runtime config content overrides defaults" , " [api_config][runtime_config]" ) {
10+ lsl::api_config::set_api_config_content (
11+ " [lab]\n "
12+ " SessionID = runtime_config_test\n "
13+ " [ports]\n "
14+ " BasePort = 30000\n "
15+ " [tuning]\n "
16+ " UseProtocolVersion = 100\n " );
17+
18+ const auto *cfg = lsl::api_config::get_instance ();
19+ REQUIRE (cfg != nullptr );
20+ CHECK (cfg->session_id () == " runtime_config_test" );
21+ CHECK (cfg->base_port () == 30000 );
22+ CHECK (cfg->use_protocol_version () == 100 );
23+ }
You can’t perform that action at this time.
0 commit comments