- htons => htonl
[oweals/gnunet.git] / src / integration-tests / test_integration_disconnect.py.in
index c2d3102c792385795c1431b6abdd57403d95803a..eba75fb7587cf71d695c884a98c16df6297b370f 100755 (executable)
@@ -48,12 +48,25 @@ check_timeout = 180
 
 if os.name == "nt":
   tmp = os.getenv ("TEMP")
+  signals = [signal.SIGTERM, signal.SIGINT]
 else:
   tmp = "/tmp"
+  signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
+
+def cleanup_onerror (function, path, excinfo):
+  import stat
+  if not os.path.exists (path):
+    pass
+  elif not os.access(path, os.W_OK):
+    # Is the error an access error ?
+    os.chmod (path, stat.S_IWUSR)
+    function (path)
+  else:
+    raise
 
 def cleanup ():
-  shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), True)
-  shutil.rmtree (os.path.join (tmp, "c_no_nat_client"), True)
+  shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), False, cleanup_onerror)
+  shutil.rmtree (os.path.join (tmp, "c_no_nat_client"), False, cleanup_onerror)
 
 
 def success_disconnect_cont (check):
@@ -106,7 +119,7 @@ def check_connect ():
   check.add (StatisticsCondition (server, 'core', '# neighbour entries allocated',1))  
   check.add (StatisticsCondition (server, 'core', '# peers connected',1))
   check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
-  check.add (StatisticsCondition (client, 'dht', '# peers connected',1))
+  check.add (StatisticsCondition (server, 'dht', '# peers connected',1))
   check.add (StatisticsCondition (server, 'fs', '# peers connected',1))  
   
   check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
@@ -138,7 +151,7 @@ def run ():
        client = None
        success = False  
        
-       for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
+       for sig in signals:
                signal.signal(sig, SigHandler)
 
        test = Test ('test_integration_bootstrap_and_connect.py', verbose)
@@ -153,6 +166,10 @@ def run ():
                        server.stop ()
                cleanup ()
                sys.exit(success)
+               
+       # Give the server time to start
+       time.sleep(5)           
+               
        if (True != client.start()):
                print 'Failed to start client'
                if (None != server):