diff options
author | LRN <lrn1986@gmail.com> | 2013-12-23 13:35:18 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-12-23 13:35:18 +0000 |
commit | 6d14d67719b6057939b1dd948e4e74663a1c19e8 (patch) | |
tree | 5a0ceff12c7bf8cd1e5033faa4971ef09d0574ab /src/integration-tests/test_integration_reconnect_nat.py.in | |
parent | f07469475bb254bae5b66a894087bad7d2d600bb (diff) | |
download | gnunet-6d14d67719b6057939b1dd948e4e74663a1c19e8.tar.gz gnunet-6d14d67719b6057939b1dd948e4e74663a1c19e8.zip |
W32-compatible integartion tests, try to handle rmtree()ing of read-only files
Diffstat (limited to 'src/integration-tests/test_integration_reconnect_nat.py.in')
-rwxr-xr-x | src/integration-tests/test_integration_reconnect_nat.py.in | 19 |
1 files changed, 16 insertions, 3 deletions
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 | |||
49 | 49 | ||
50 | if os.name == "nt": | 50 | if os.name == "nt": |
51 | tmp = os.getenv ("TEMP") | 51 | tmp = os.getenv ("TEMP") |
52 | signals = [signal.SIGTERM, signal.SIGINT] | ||
52 | else: | 53 | else: |
53 | tmp = "/tmp" | 54 | tmp = "/tmp" |
55 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
56 | |||
57 | def cleanup_onerror (function, path, excinfo): | ||
58 | import stat | ||
59 | if not os.path.exists (path): | ||
60 | pass | ||
61 | elif not os.access(path, os.W_OK): | ||
62 | # Is the error an access error ? | ||
63 | os.chmod (path, stat.S_IWUSR) | ||
64 | function (path) | ||
65 | else: | ||
66 | raise | ||
54 | 67 | ||
55 | def cleanup (): | 68 | def cleanup (): |
56 | retries = 10 | 69 | retries = 10 |
57 | path = os.path.join (tmp, "c_bootstrap_server") | 70 | path = os.path.join (tmp, "c_bootstrap_server") |
58 | test.p ("Removing " + path) | 71 | test.p ("Removing " + path) |
59 | while ((os.path.exists(path)) and (retries > 0)): | 72 | while ((os.path.exists(path)) and (retries > 0)): |
60 | shutil.rmtree ((path), False) | 73 | shutil.rmtree ((path), False, cleanup_onerror) |
61 | time.sleep (1) | 74 | time.sleep (1) |
62 | retries -= 1 | 75 | retries -= 1 |
63 | if (os.path.exists(path)): | 76 | if (os.path.exists(path)): |
@@ -68,7 +81,7 @@ def cleanup (): | |||
68 | path = os.path.join (tmp, "c_nat_client") | 81 | path = os.path.join (tmp, "c_nat_client") |
69 | test.p ("Removing " + path) | 82 | test.p ("Removing " + path) |
70 | while ((os.path.exists(path)) and (retries > 0)): | 83 | while ((os.path.exists(path)) and (retries > 0)): |
71 | shutil.rmtree ((path), False) | 84 | shutil.rmtree ((path), False, cleanup_onerror) |
72 | time.sleep (1) | 85 | time.sleep (1) |
73 | retries -= 1 | 86 | retries -= 1 |
74 | if (os.path.exists(path)): | 87 | if (os.path.exists(path)): |
@@ -167,7 +180,7 @@ def run (): | |||
167 | server = None | 180 | server = None |
168 | client = None | 181 | client = None |
169 | 182 | ||
170 | for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: | 183 | for sig in signals: |
171 | signal.signal(sig, SigHandler) | 184 | signal.signal(sig, SigHandler) |
172 | 185 | ||
173 | 186 | ||