- log
[oweals/gnunet.git] / src / integration-tests / test_integration_disconnect_nat.py.in
index 350bfbe0744fedd1f8d3170c2b9e32f9c2c45d90..c7223c2ae6a0eb993ec7843306e9e56567ba5590 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_nat_client"), True)
+  shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), False, cleanup_onerror)
+  shutil.rmtree (os.path.join (tmp, "c_nat_client"), False, cleanup_onerror)
 
 
 def success_disconnect_cont (check):
@@ -142,7 +155,7 @@ def run ():
        nat_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)
@@ -157,6 +170,10 @@ def run ():
                        server.stop ()
                cleanup ()
                sys.exit(success)
+               
+       # Give the server time to start
+       time.sleep(5)
+               
        if (True != nat_client.start()):
                print 'Failed to start nat_client'
                if (None != server):