def t10(): pretty = '%s t10' % __file__ print(pretty) s,p = find_free_port() q = Pipe() c = MockControl(p, None, s, [], q) c.start() r = RemoteControl(('',p), None, timeout=5) r.sync_ping() c.terminate() try: q.get(timeout=1) except Exception, e: print('FAIL %s: never got oob message: %s' % (pretty, str(e))) c.kill() return False
def t08(): pretty = '%s t8' % __file__ print(pretty) s,p1 = find_free_port() q = Pipe() ctr1 = MockControl(p1, 'password', s, [], q) ctr1.start() s,p2 = find_free_port() ctr2 = MockControl(p2, None, s) ctr2.start() rem1 = RemoteControl(('',p1), 'password', timeout=5) rem1.connect_remote(('',p2), None) result = True ctr2.kill() try: msg = q.get(timeout=1) except Exception, e: print('FAIL %s: connection not lost: %s' % (pretty, str(e))) result = False
def t12(): pretty = '%s t12' % __file__ print(pretty) s,p1 = find_free_port() ctr1 = MockControl(p1, 'password', s) ctr1.start() s,p2 = find_free_port() q = Pipe() ctr2 = MockControl(p2, None, s, [], q) ctr2.start() # ask ctr1 to create a connection to ctr2 rem1 = RemoteControl(('',p1), 'password', timeout=5) msg = rem1.connect_remote(('',p2), None) if msg != 'pong': print('FAIL %s: bad connection established: %s' % (pretty, msg)) ctr1.terminate() ctr2.terminate() ctr1.join() ctr2.join() return False # kill ctr1 ctr1.kill() # check if ctr2 discovered the connection loss from ctr1 result = True try: msg = q.get(1) if type(msg) != list: # no way of knowing the exact content beforehand print('FAIL %s: wrong oob received: %s' % (pretty, msg)) result = False except Exception, e: print('FAIL %s: oob not received: %s' % (pretty, str(e))) result = False