use new connecT API
[oweals/gnunet.git] / src / integration-tests / test_integration_disconnect_nat.py.in
index 0130c618d2936d772970befdd94f66d4e9bbb154..c683ebcface55068b850c994d97b65305cd2fa8f 100755 (executable)
@@ -14,8 +14,8 @@
 #
 #    You should have received a copy of the GNU General Public License
 #    along with GNUnet; see the file COPYING.  If not, write to the
-#    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-#    Boston, MA 02111-1307, USA.
+#    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+#    Boston, MA 02110-1301, USA.
 #
 # 
 import sys
@@ -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)