mirror of
https://github.com/ValveSoftware/GameNetworkingSockets.git
synced 2026-05-29 16:20:34 +00:00
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:
@@ -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
|
||||
#
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user