Skip to content

Commit ad1f08c

Browse files
committed
Skip test_signalfd_weirdness_negative on gevent/eventlet - it cannot pass as there are no threads.
1 parent 5622c81 commit ad1f08c

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

tests/test_manhole.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import atexit
44
import errno
5+
import imp
56
import logging
67
import os
78
import re
@@ -24,7 +25,14 @@
2425
TIMEOUT = int(os.getenv('MANHOLE_TEST_TIMEOUT', 10))
2526

2627

27-
def assertManholeRunning(proc, uds_path, oneshot=False, extra=None):
28+
def is_module_available(mod):
29+
try:
30+
return imp.find_module(mod)
31+
except ImportError:
32+
return False
33+
34+
35+
def assert_manhole_running(proc, uds_path, oneshot=False, extra=None):
2836
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
2937
sock.settimeout(0.5)
3038
for i in range(TIMEOUT):
@@ -60,7 +68,7 @@ def test_simple(count):
6068
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
6169
for _ in range(count):
6270
proc.reset()
63-
assertManholeRunning(proc, uds_path)
71+
assert_manhole_running(proc, uds_path)
6472

6573

6674
def test_exit_with_grace():
@@ -102,7 +110,7 @@ def test_with_fork():
102110
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
103111
for _ in range(2):
104112
proc.reset()
105-
assertManholeRunning(proc, uds_path)
113+
assert_manhole_running(proc, uds_path)
106114

107115
proc.reset()
108116
wait_for_strings(proc.read, TIMEOUT, 'Fork detected')
@@ -113,7 +121,7 @@ def test_with_fork():
113121
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
114122
for _ in range(2):
115123
proc.reset()
116-
assertManholeRunning(proc, new_uds_path)
124+
assert_manhole_running(proc, new_uds_path)
117125

118126

119127
if not hasattr(sys, 'pypy_version_info'):
@@ -125,7 +133,7 @@ def test_with_forkpty():
125133
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
126134
for _ in range(2):
127135
proc.reset()
128-
assertManholeRunning(proc, uds_path)
136+
assert_manhole_running(proc, uds_path)
129137

130138
proc.reset()
131139
wait_for_strings(proc.read, TIMEOUT, 'Fork detected')
@@ -136,7 +144,7 @@ def test_with_forkpty():
136144
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
137145
for _ in range(2):
138146
proc.reset()
139-
assertManholeRunning(proc, new_uds_path)
147+
assert_manhole_running(proc, new_uds_path)
140148

141149

142150
def test_auth_fail():
@@ -173,17 +181,17 @@ def test_signalfd_weirdness():
173181
wait_for_strings(proc.read, 25 * TIMEOUT, *[
174182
'[%s] read from signalfd:' % j for j in range(200)
175183
])
176-
assertManholeRunning(proc, uds_path)
177-
184+
assert_manhole_running(proc, uds_path)
178185

179-
def test_signalfd_weirdness_negative():
180-
with TestProcess(sys.executable, '-u', __file__, 'daemon', 'test_signalfd_weirdness_negative') as proc:
181-
with dump_on_error(proc.read):
182-
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
183-
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
184-
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
185-
wait_for_strings(proc.read, TIMEOUT, 'reading from signalfd failed')
186-
assertManholeRunning(proc, uds_path)
186+
if not is_module_available('gevent') and not is_module_available('eventlet'):
187+
def test_signalfd_weirdness_negative():
188+
with TestProcess(sys.executable, '-u', __file__, 'daemon', 'test_signalfd_weirdness_negative') as proc:
189+
with dump_on_error(proc.read):
190+
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
191+
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
192+
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
193+
wait_for_strings(proc.read, TIMEOUT, 'reading from signalfd failed')
194+
assert_manhole_running(proc, uds_path)
187195

188196

189197
def test_activate_on_usr2():
@@ -195,7 +203,7 @@ def test_activate_on_usr2():
195203
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
196204
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
197205
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
198-
assertManholeRunning(proc, uds_path)
206+
assert_manhole_running(proc, uds_path)
199207

200208

201209
def test_activate_on_with_oneshot_on():
@@ -213,7 +221,7 @@ def test_oneshot_on_usr2():
213221
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
214222
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
215223
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
216-
assertManholeRunning(proc, uds_path, oneshot=True)
224+
assert_manhole_running(proc, uds_path, oneshot=True)
217225

218226

219227
def test_fail_to_cry():
@@ -240,14 +248,14 @@ def test_oneshot_on_usr2_error():
240248
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
241249
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
242250
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
243-
assertManholeRunning(proc, uds_path, oneshot=True, extra=lambda sock: sock.send(b"raise SystemExit()\n"))
251+
assert_manhole_running(proc, uds_path, oneshot=True, extra=lambda sock: sock.send(b"raise SystemExit()\n"))
244252

245253
proc.reset()
246254
proc.signal(signal.SIGUSR2)
247255
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
248256
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
249257
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection')
250-
assertManholeRunning(proc, uds_path, oneshot=True)
258+
assert_manhole_running(proc, uds_path, oneshot=True)
251259

252260

253261
def test_interrupt_on_accept():
@@ -256,7 +264,7 @@ def test_interrupt_on_accept():
256264
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-')
257265
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0]
258266
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection', 'Sending signal to manhole thread', 'Waiting for new connection')
259-
assertManholeRunning(proc, uds_path)
267+
assert_manhole_running(proc, uds_path)
260268

261269

262270
def setup_greenthreads(patch_threads=False):

0 commit comments

Comments
 (0)