#definitions
testname = "test_integration_disconnect"
-verbose = False
+verbose = True
check_timeout = 30
def cleanup ():
if os.name == "nt":
- shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True)
+ shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_bootstrap_server"), True)
shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client"), True)
else:
shutil.rmtree ("/tmp/c_bootstrap_server/", True)
def fail_disconnect_cont (check):
global success
success = False;
- check.eval(True)
+ check.evaluate(True)
def check_disconnect ():
def fail_connect_cont (check):
global success
success= False;
- check.eval(True)
+ check.evaluate(True)
def check_connect ():
check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
check.add (StatisticsCondition (server, 'fs', '# peers connected',1))
- check.run_blocking (10, success_connect_cont, fail_connect_cont)
+ check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
#
# Test execution
#
-#
-# Test execution
-#
-success = False
-
-test = Test ('test_integration_disconnect', verbose)
-
-server = Peer(test, './confs/c_bootstrap_server.conf');
-server.start();
-
-client = Peer(test, './confs/c_no_nat_client.conf');
-client.start();
-
-
-if ((client.started == True) and (server.started == True)):
- test.p ('Peers started, running check')
- check_connect ()
+def run ():
+ global success
+ global test
+ global server
+ global client
-server.stop ()
-client.stop ()
-
-cleanup ()
+ success = False
+
+ test = Test ('test_integration_disconnect', verbose)
+
+ server = Peer(test, './confs/c_bootstrap_server.conf');
+ server.start();
+
+ client = Peer(test, './confs/c_no_nat_client.conf');
+ client.start();
+
+
+ if ((client.started == True) and (server.started == True)):
+ test.p ('Peers started, running check')
+ check_connect ()
+
+ server.stop ()
+ client.stop ()
+
+ cleanup ()
+
+ if (success == False):
+ print ('Test failed')
+ return True
+ else:
+ return False
+
+try:
+ run ()
+except (KeyboardInterrupt, SystemExit):
+ print 'Test interrupted'
+ server.stop ()
+ client.stop ()
+ cleanup ()
if (success == False):
- print ('Test failed')
- exit (1)
+ sys.exit(1)
else:
- exit (0)
+ sys.exit(0)
+
\ No newline at end of file