MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / ClientServerExpectedFailureTest

Function ClientServerExpectedFailureTest

tests/test_p2p.py:387–425  ·  view source on GitHub ↗

Run a test where both sides are expected to fail to connect.

( server_extra_args=[], client_extra_args=[], ice_impl=1,
                                     stun=_DEFAULT_STUN, turn=_DEFAULT_TURN,
                                     expected_counters=None, expected_candidates=None )

Source from the content-addressed store, hash-verified

385
386
387def ClientServerExpectedFailureTest( server_extra_args=[], client_extra_args=[], ice_impl=1,
388 stun=_DEFAULT_STUN, turn=_DEFAULT_TURN,
389 expected_counters=None, expected_candidates=None ):
390 """Run a test where both sides are expected to fail to connect."""
391 global g_failed
392 impl_args = [ '--ice-implementation', str(ice_impl) ]
393 fail_args = [ '--expect-failure' ]
394 server = StartClientInThread( "server", "peer_server", "peer_client",
395 server_extra_args + impl_args + fail_args,
396 stun=stun, turn=turn )
397 client = StartClientInThread( "client", "peer_client", "peer_server",
398 client_extra_args + impl_args + fail_args,
399 stun=stun, turn=turn )
400
401 server.join( timeout=30 )
402 client.join( timeout=30 )
403
404 if expected_counters is not None and g_repeat == 1:
405 for peer, thread in [ ( 'server', server ), ( 'client', client ) ]:
406 for name, (lo, hi) in expected_counters.items():
407 val = thread.counters.get( name, 0 )
408 if lo is not None and val < lo:
409 print( "ERROR: %s TEST_ICE_ctr_%s=%d, expected >= %d" % ( peer, name, val, lo ) )
410 g_failed = True
411 if hi is not None and val > hi:
412 print( "ERROR: %s TEST_ICE_ctr_%s=%d, expected <= %d" % ( peer, name, val, hi ) )
413 g_failed = True
414
415 if g_repeat == 1:
416 srv_local, srv_remote = _parse_candidate_log( "peer_server.verbose.log" )
417 cli_local, cli_remote = _parse_candidate_log( "peer_client.verbose.log" )
418 if expected_candidates is not None:
419 exp_srv, exp_cli = expected_candidates
420 if exp_srv is not None and srv_local != exp_srv:
421 print( "ERROR: server gathered %s, expected %s" % ( srv_local, exp_srv ) )
422 g_failed = True
423 if exp_cli is not None and cli_local != exp_cli:
424 print( "ERROR: client gathered %s, expected %s" % ( cli_local, exp_cli ) )
425 g_failed = True
426
427
428# Failure test cases: ( description, server_args, client_args, kwargs_for_failure_test )

Callers 1

test_p2p.pyFile · 0.85

Calls 3

StartClientInThreadFunction · 0.85
_parse_candidate_logFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected