Add 'test' version of the library

The test version defines STEAMNETWORKINGSOCKETS_ENABLE_MOCK
and has internal functions tests can use to mock up network
environments (network adapters, gateway/NAT behaviour, etc)
This commit is contained in:
Fletcher Dunn
2026-05-10 17:22:05 -07:00
parent f4787850e3
commit e47e9ff3f1
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -378,6 +378,20 @@ if (BUILD_STATIC_LIB)
set_clientlib_target_properties(GameNetworkingSockets_s)
endif()
# Test-only static library variant — includes the mock network framework.
# Never shipped; only built when tests are enabled. test_p2p links against
# this instead of the regular static library.
if (BUILD_TESTS AND BUILD_STATIC_LIB AND ENABLE_ICE)
add_library(GameNetworkingSockets_test_s STATIC "")
add_library(GameNetworkingSockets::static_mock ALIAS GameNetworkingSockets_test_s)
target_compile_definitions(GameNetworkingSockets_test_s INTERFACE STEAMNETWORKINGSOCKETS_STATIC_LINK)
set_clientlib_target_properties(GameNetworkingSockets_test_s)
target_compile_definitions(GameNetworkingSockets_test_s PUBLIC STEAMNETWORKINGSOCKETS_ENABLE_MOCK)
target_sources(GameNetworkingSockets_test_s PRIVATE
"steamnetworkingsockets/clientlib/steamnetworkingsockets_mock.cpp"
)
endif()
#
# Cert tool
#
+1 -1
View File
@@ -38,7 +38,7 @@ if(ENABLE_ICE)
test_p2p.cpp
../examples/trivial_signaling_client.cpp)
set_target_common_gns_properties( test_p2p )
target_link_libraries(test_p2p ${GAMENETWORKINGSOCKETS_LIB})
target_link_libraries(test_p2p GameNetworkingSockets::static_mock)
add_sanitizers(test_p2p)
# Publish the test script