@@ 234-247 (lines=14) @@ | ||
231 | sock = connect_to_manhole(SOCKET_PATH) |
|
232 | with TestSocket(sock) as client: |
|
233 | with dump_on_error(client.read): |
|
234 | wait_for_strings(client.read, 1, ">>>") |
|
235 | client.reset() |
|
236 | sock.send(b"import sys\n" |
|
237 | b"sys.stderr.write('OK')\n") |
|
238 | wait_for_strings(client.read, 1, "OK") |
|
239 | ||
240 | ||
241 | def test_redirect_stderr_default_dump_stacktraces(): |
|
242 | with TestProcess(sys.executable, HELPER, 'test_redirect_stderr_default') as proc: |
|
243 | with dump_on_error(proc.read): |
|
244 | wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') |
|
245 | check_dump_stacktraces(SOCKET_PATH) |
|
246 | ||
247 | ||
248 | def test_redirect_stderr_default_print_tracebacks(): |
|
249 | with TestProcess(sys.executable, HELPER, 'test_redirect_stderr_default') as proc: |
|
250 | with dump_on_error(proc.read): |
|
@@ 206-217 (lines=12) @@ | ||
203 | def test_socket_path(): |
|
204 | with TestProcess(sys.executable, HELPER, 'test_socket_path') as proc: |
|
205 | with dump_on_error(proc.read): |
|
206 | wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') |
|
207 | proc.reset() |
|
208 | assert_manhole_running(proc, SOCKET_PATH) |
|
209 | ||
210 | ||
211 | def test_socket_path_with_fork(): |
|
212 | with TestProcess(sys.executable, '-u', HELPER, 'test_socket_path_with_fork') as proc: |
|
213 | with dump_on_error(proc.read): |
|
214 | wait_for_strings(proc.read, TIMEOUT, 'Not patching os.fork and os.forkpty. Using user socket path') |
|
215 | wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') |
|
216 | sock = connect_to_manhole(SOCKET_PATH) |
|
217 | with TestSocket(sock) as client: |
|
218 | with dump_on_error(client.read): |
|
219 | wait_for_strings(client.read, TIMEOUT, "ProcessID", "ThreadID", ">>>") |
|
220 | sock.send(b"print('BEFORE FORK')\n") |
|
@@ 484-499 (lines=16) @@ | ||
481 | def test_interrupt_on_accept(): |
|
482 | with TestProcess(sys.executable, '-u', HELPER, 'test_interrupt_on_accept') as proc: |
|
483 | with dump_on_error(proc.read): |
|
484 | wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') |
|
485 | uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0] |
|
486 | only_on_old_python = ['Waiting for new connection'] if sys.version_info < (3, 5) else [] |
|
487 | wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection', 'Sending signal to manhole thread', |
|
488 | *only_on_old_python) |
|
489 | assert_manhole_running(proc, uds_path) |
|
490 | ||
491 | ||
492 | def test_environ_variable_activation(): |
|
493 | with TestProcess(sys.executable, '-u', HELPER, 'test_environ_variable_activation', |
|
494 | env=dict(os.environ, PYTHONMANHOLE="oneshot_on='USR2'")) as proc: |
|
495 | with dump_on_error(proc.read): |
|
496 | wait_for_strings(proc.read, TIMEOUT, |
|
497 | 'Not patching os.fork and os.forkpty. Oneshot activation is done by signal') |
|
498 | proc.signal(signal.SIGUSR2) |
|
499 | wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') |
|
500 | uds_path = re.findall(r"(/tmp/manhole-\d+)", proc.read())[0] |
|
501 | wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') |
|
502 | assert_manhole_running(proc, uds_path, oneshot=True) |