|
@@ 338-358 (lines=21) @@
|
| 335 |
|
|
| 336 |
|
|
| 337 |
|
def test_with_fork(): |
| 338 |
|
with TestProcess(sys.executable, '-u', HELPER, 'test_with_fork') as proc: |
| 339 |
|
with dump_on_error(proc.read): |
| 340 |
|
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') |
| 341 |
|
uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0] |
| 342 |
|
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') |
| 343 |
|
for _ in range(2): |
| 344 |
|
proc.reset() |
| 345 |
|
assert_manhole_running(proc, uds_path) |
| 346 |
|
|
| 347 |
|
proc.reset() |
| 348 |
|
wait_for_strings(proc.read, TIMEOUT, 'Fork detected') |
| 349 |
|
wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') |
| 350 |
|
new_uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0] |
| 351 |
|
assert uds_path != new_uds_path |
| 352 |
|
|
| 353 |
|
wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') |
| 354 |
|
for _ in range(2): |
| 355 |
|
proc.reset() |
| 356 |
|
assert_manhole_running(proc, new_uds_path) |
| 357 |
|
|
| 358 |
|
|
| 359 |
|
@mark.skipif(hasattr(sys, 'pypy_version_info'), reason="pypy doesn't support forkpty") |
| 360 |
|
def test_with_forkpty(): |
| 361 |
|
with TestProcess(sys.executable, '-u', HELPER, 'test_with_forkpty') as proc: |
|
@@ 316-335 (lines=20) @@
|
| 313 |
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
| 314 |
|
sock.settimeout(0.05) |
| 315 |
|
sock.connect(uds_path) |
| 316 |
|
with TestSocket(sock) as client: |
| 317 |
|
with dump_on_error(client.read): |
| 318 |
|
wait_for_strings(client.read, TIMEOUT, "ThreadID", "ProcessID", ">>>") |
| 319 |
|
sock.send(b"print('FOOBAR')\n") |
| 320 |
|
wait_for_strings(client.read, TIMEOUT, "FOOBAR") |
| 321 |
|
|
| 322 |
|
wait_for_strings(proc.read, TIMEOUT, 'UID:%s' % os.getuid()) |
| 323 |
|
sock.shutdown(socket.SHUT_WR) |
| 324 |
|
select.select([sock], [], [], 5) |
| 325 |
|
sock.recv(1024) |
| 326 |
|
try: |
| 327 |
|
sock.shutdown(socket.SHUT_RD) |
| 328 |
|
except Exception as exc: |
| 329 |
|
print("Failed to SHUT_RD: %s" % exc) |
| 330 |
|
try: |
| 331 |
|
sock.close() |
| 332 |
|
except Exception as exc: |
| 333 |
|
print("Failed to close socket: %s" % exc) |
| 334 |
|
wait_for_strings(proc.read, TIMEOUT, 'DONE.', 'Cleaned up.', 'Waiting for new connection') |
| 335 |
|
|
| 336 |
|
|
| 337 |
|
def test_with_fork(): |
| 338 |
|
with TestProcess(sys.executable, '-u', HELPER, 'test_with_fork') as proc: |