- htons => htonl
[oweals/gnunet.git] / src / integration-tests / test_integration_bootstrap_and_connect.py.in
index 1ba4c3c59065e3b1123f09d7d0b6e1ee340d8d3c..d086bcc53db884bf7003ed516d793f6a5bebf294 100755 (executable)
@@ -54,15 +54,28 @@ 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 ():
     retries = 10
     path = os.path.join (tmp, "c_bootstrap_server")  
     test.p ("Removing " + path)      
     while ((os.path.exists(path)) and (retries > 0)):
-        shutil.rmtree ((path), False)
+        shutil.rmtree ((path), False, cleanup_onerror)
         time.sleep (1)
         retries -= 1
     if (os.path.exists(path)):
@@ -73,7 +86,7 @@ def cleanup ():
     path = os.path.join (tmp, "c_no_nat_client")    
     test.p ("Removing " + path)    
     while ((os.path.exists(path)) and (retries > 0)):
-        shutil.rmtree ((path), False)
+        shutil.rmtree ((path), False, cleanup_onerror)
         time.sleep (1)
         retries -= 1
     if (os.path.exists(path)):
@@ -135,7 +148,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)
@@ -152,6 +165,10 @@ def run ():
                        client.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):