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 | |
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')
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 | |||
54 | 54 | ||
55 | if os.name == "nt": | 55 | if os.name == "nt": |
56 | tmp = os.getenv ("TEMP") | 56 | tmp = os.getenv ("TEMP") |
57 | signals = [signal.SIGTERM, signal.SIGINT] | ||
57 | else: | 58 | else: |
58 | tmp = "/tmp" | 59 | tmp = "/tmp" |
60 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
61 | |||
62 | def cleanup_onerror (function, path, excinfo): | ||
63 | import stat | ||
64 | if not os.path.exists (path): | ||
65 | pass | ||
66 | elif not os.access(path, os.W_OK): | ||
67 | # Is the error an access error ? | ||
68 | os.chmod (path, stat.S_IWUSR) | ||
69 | function (path) | ||
70 | else: | ||
71 | raise | ||
59 | 72 | ||
60 | def cleanup (): | 73 | def cleanup (): |
61 | retries = 10 | 74 | retries = 10 |
62 | path = os.path.join (tmp, "c_bootstrap_server") | 75 | path = os.path.join (tmp, "c_bootstrap_server") |
63 | test.p ("Removing " + path) | 76 | test.p ("Removing " + path) |
64 | while ((os.path.exists(path)) and (retries > 0)): | 77 | while ((os.path.exists(path)) and (retries > 0)): |
65 | shutil.rmtree ((path), False) | 78 | shutil.rmtree ((path), False, cleanup_onerror) |
66 | time.sleep (1) | 79 | time.sleep (1) |
67 | retries -= 1 | 80 | retries -= 1 |
68 | if (os.path.exists(path)): | 81 | if (os.path.exists(path)): |
@@ -73,7 +86,7 @@ def cleanup (): | |||
73 | path = os.path.join (tmp, "c_no_nat_client") | 86 | path = os.path.join (tmp, "c_no_nat_client") |
74 | test.p ("Removing " + path) | 87 | test.p ("Removing " + path) |
75 | while ((os.path.exists(path)) and (retries > 0)): | 88 | while ((os.path.exists(path)) and (retries > 0)): |
76 | shutil.rmtree ((path), False) | 89 | shutil.rmtree ((path), False, cleanup_onerror) |
77 | time.sleep (1) | 90 | time.sleep (1) |
78 | retries -= 1 | 91 | retries -= 1 |
79 | if (os.path.exists(path)): | 92 | if (os.path.exists(path)): |
@@ -135,7 +148,7 @@ def run (): | |||
135 | client = None | 148 | client = None |
136 | success = False | 149 | success = False |
137 | 150 | ||
138 | for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: | 151 | for sig in signals: |
139 | signal.signal(sig, SigHandler) | 152 | signal.signal(sig, SigHandler) |
140 | 153 | ||
141 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) | 154 | 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" | |||
49 | verbose = True | 49 | verbose = True |
50 | check_timeout = 180 | 50 | check_timeout = 180 |
51 | 51 | ||
52 | def cleanup_onerror (function, path, excinfo): | ||
53 | import stat | ||
54 | if not os.path.exists (path): | ||
55 | pass | ||
56 | elif not os.access(path, os.W_OK): | ||
57 | # Is the error an access error ? | ||
58 | os.chmod (path, stat.S_IWUSR) | ||
59 | function (path) | ||
60 | else: | ||
61 | raise | ||
52 | 62 | ||
53 | def cleanup (): | 63 | def cleanup (): |
54 | retries = 10 | 64 | retries = 10 |
55 | path = os.path.join (tmp, "c_bootstrap_server") | 65 | path = os.path.join (tmp, "c_bootstrap_server") |
56 | test.p ("Removing " + path) | 66 | test.p ("Removing " + path) |
57 | while ((os.path.exists(path)) and (retries > 0)): | 67 | while ((os.path.exists(path)) and (retries > 0)): |
58 | shutil.rmtree ((path), False) | 68 | shutil.rmtree ((path), False, cleanup_onerror) |
59 | time.sleep (1) | 69 | time.sleep (1) |
60 | retries -= 1 | 70 | retries -= 1 |
61 | if (os.path.exists(path)): | 71 | if (os.path.exists(path)): |
@@ -64,7 +74,7 @@ def cleanup (): | |||
64 | path = os.path.join (tmp, "c_no_nat_client") | 74 | path = os.path.join (tmp, "c_no_nat_client") |
65 | test.p ("Removing " + path) | 75 | test.p ("Removing " + path) |
66 | while ((os.path.exists(path)) and (retries > 0)): | 76 | while ((os.path.exists(path)) and (retries > 0)): |
67 | shutil.rmtree ((path), False) | 77 | shutil.rmtree ((path), False, cleanup_onerror) |
68 | time.sleep (1) | 78 | time.sleep (1) |
69 | retries -= 1 | 79 | retries -= 1 |
70 | if (os.path.exists(path)): | 80 | if (os.path.exists(path)): |
@@ -73,7 +83,7 @@ def cleanup (): | |||
73 | path = os.path.join (tmp, "c_nat_client") | 83 | path = os.path.join (tmp, "c_nat_client") |
74 | test.p ("Removing " + path) | 84 | test.p ("Removing " + path) |
75 | while ((os.path.exists(path)) and (retries > 0)): | 85 | while ((os.path.exists(path)) and (retries > 0)): |
76 | shutil.rmtree ((path), False) | 86 | shutil.rmtree ((path), False, cleanup_onerror) |
77 | time.sleep (1) | 87 | time.sleep (1) |
78 | retries -= 1 | 88 | retries -= 1 |
79 | if (os.path.exists(path)): | 89 | 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 | |||
48 | 48 | ||
49 | if os.name == "nt": | 49 | if os.name == "nt": |
50 | tmp = os.getenv ("TEMP") | 50 | tmp = os.getenv ("TEMP") |
51 | signals = [signal.SIGTERM, signal.SIGINT] | ||
51 | else: | 52 | else: |
52 | tmp = "/tmp" | 53 | tmp = "/tmp" |
54 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
55 | |||
56 | def cleanup_onerror (function, path, excinfo): | ||
57 | import stat | ||
58 | if not os.path.exists (path): | ||
59 | pass | ||
60 | elif not os.access(path, os.W_OK): | ||
61 | # Is the error an access error ? | ||
62 | os.chmod (path, stat.S_IWUSR) | ||
63 | function (path) | ||
64 | else: | ||
65 | raise | ||
53 | 66 | ||
54 | def cleanup (): | 67 | def cleanup (): |
55 | shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), True) | 68 | shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), False, cleanup_onerror) |
56 | shutil.rmtree (os.path.join (tmp, "c_no_nat_client"), True) | 69 | shutil.rmtree (os.path.join (tmp, "c_no_nat_client"), False, cleanup_onerror) |
57 | 70 | ||
58 | 71 | ||
59 | def success_disconnect_cont (check): | 72 | def success_disconnect_cont (check): |
@@ -138,7 +151,7 @@ def run (): | |||
138 | client = None | 151 | client = None |
139 | success = False | 152 | success = False |
140 | 153 | ||
141 | for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: | 154 | for sig in signals: |
142 | signal.signal(sig, SigHandler) | 155 | signal.signal(sig, SigHandler) |
143 | 156 | ||
144 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) | 157 | 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 | |||
48 | 48 | ||
49 | if os.name == "nt": | 49 | if os.name == "nt": |
50 | tmp = os.getenv ("TEMP") | 50 | tmp = os.getenv ("TEMP") |
51 | signals = [signal.SIGTERM, signal.SIGINT] | ||
51 | else: | 52 | else: |
52 | tmp = "/tmp" | 53 | tmp = "/tmp" |
54 | signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT] | ||
55 | |||
56 | def cleanup_onerror (function, path, excinfo): | ||
57 | import stat | ||
58 | if not os.path.exists (path): | ||
59 | pass | ||
60 | elif not os.access(path, os.W_OK): | ||
61 | # Is the error an access error ? | ||
62 | os.chmod (path, stat.S_IWUSR) | ||
63 | function (path) | ||
64 | else: | ||
65 | raise | ||
53 | 66 | ||
54 | def cleanup (): | 67 | def cleanup (): |
55 | shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), True) | 68 | shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), False, cleanup_onerror) |
56 | shutil.rmtree (os.path.join (tmp, "c_nat_client"), True) | 69 | shutil.rmtree (os.path.join (tmp, "c_nat_client"), False, cleanup_onerror) |
57 | 70 | ||
58 | 71 | ||
59 | def success_disconnect_cont (check): | 72 | def success_disconnect_cont (check): |
@@ -142,7 +155,7 @@ def run (): | |||
142 | nat_client = None | 155 | nat_client = None |
143 | success = False | 156 | success = False |
144 | 157 | ||
145 | for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: | 158 | for sig in signals: |
146 | signal.signal(sig, SigHandler) | 159 | signal.signal(sig, SigHandler) |
147 | 160 | ||
148 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) | 161 | 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 | |||
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_no_nat_client") | 81 | path = os.path.join (tmp, "c_no_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 | ||
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 | ||