doxygen fix
[oweals/gnunet.git] / src / integration-tests / test_integration_disconnect.py.in
index 0397fafd231fc2e4ae6a4de9a276042b27f8f30c..5e137cfff294787fa0657930350bdc6b8001781a 100755 (executable)
@@ -43,13 +43,13 @@ from gnunet_testing import *
 #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)
@@ -64,7 +64,7 @@ def success_disconnect_cont (check):
 def fail_disconnect_cont (check):    
     global success 
     success = False;
-    check.eval(True)   
+    check.evaluate(True)   
   
 
 def check_disconnect ():
@@ -86,7 +86,7 @@ def success_connect_cont (check):
 def fail_connect_cont (check):    
     global success 
     success= False;
-    check.eval(True)
+    check.evaluate(True)
 
 
 def check_connect ():
@@ -103,37 +103,54 @@ 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