From 6d14d67719b6057939b1dd948e4e74663a1c19e8 Mon Sep 17 00:00:00 2001 From: LRN Date: Mon, 23 Dec 2013 13:35:18 +0000 Subject: [PATCH] W32-compatible integartion tests, try to handle rmtree()ing of read-only files --- ...st_integration_bootstrap_and_connect.py.in | 19 ++++++++++++++++--- .../test_integration_clique.py.in | 16 +++++++++++++--- .../test_integration_disconnect.py.in | 19 ++++++++++++++++--- .../test_integration_disconnect_nat.py.in | 19 ++++++++++++++++--- .../test_integration_reconnect.py.in | 19 ++++++++++++++++--- .../test_integration_reconnect_nat.py.in | 19 ++++++++++++++++--- 6 files changed, 93 insertions(+), 18 deletions(-) diff --git a/src/integration-tests/test_integration_bootstrap_and_connect.py.in b/src/integration-tests/test_integration_bootstrap_and_connect.py.in index c3e2da73d..d086bcc53 100755 --- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in +++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in @@ -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) diff --git a/src/integration-tests/test_integration_clique.py.in b/src/integration-tests/test_integration_clique.py.in index 85da2f803..12f99a837 100755 --- a/src/integration-tests/test_integration_clique.py.in +++ b/src/integration-tests/test_integration_clique.py.in @@ -49,13 +49,23 @@ testname = "test_integration_clique" verbose = True check_timeout = 180 +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)): @@ -64,7 +74,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)): @@ -73,7 +83,7 @@ def cleanup (): path = os.path.join (tmp, "c_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)): diff --git a/src/integration-tests/test_integration_disconnect.py.in b/src/integration-tests/test_integration_disconnect.py.in index 38bc7b059..eba75fb75 100755 --- a/src/integration-tests/test_integration_disconnect.py.in +++ b/src/integration-tests/test_integration_disconnect.py.in @@ -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): @@ -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) diff --git a/src/integration-tests/test_integration_disconnect_nat.py.in b/src/integration-tests/test_integration_disconnect_nat.py.in index 0130c618d..c7223c2ae 100755 --- a/src/integration-tests/test_integration_disconnect_nat.py.in +++ b/src/integration-tests/test_integration_disconnect_nat.py.in @@ -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) diff --git a/src/integration-tests/test_integration_reconnect.py.in b/src/integration-tests/test_integration_reconnect.py.in index 5a38b3f63..7e04554b3 100755 --- a/src/integration-tests/test_integration_reconnect.py.in +++ b/src/integration-tests/test_integration_reconnect.py.in @@ -49,15 +49,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)): @@ -68,7 +81,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)): @@ -167,7 +180,7 @@ def run (): server = None client = None - for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: + for sig in signals: signal.signal(sig, SigHandler) diff --git a/src/integration-tests/test_integration_reconnect_nat.py.in b/src/integration-tests/test_integration_reconnect_nat.py.in index 726b00390..145d42b45 100755 --- a/src/integration-tests/test_integration_reconnect_nat.py.in +++ b/src/integration-tests/test_integration_reconnect_nat.py.in @@ -49,15 +49,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)): @@ -68,7 +81,7 @@ def cleanup (): path = os.path.join (tmp, "c_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)): @@ -167,7 +180,7 @@ def run (): server = None client = None - for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: + for sig in signals: signal.signal(sig, SigHandler) -- 2.25.1