Test that we can retrieve the thread state of a single process. This test is specially useful to run under valgrind or similar tools and to quickly check that the very basic functionality works as expected.
(method, blocking, use_process_vm_readv, tmpdir, monkeypatch)
| 42 | "use_process_vm_readv", [True, False], ids=["process_vm_readv", "/proc/PID/mem"] |
| 43 | ) |
| 44 | def test_simple_execution(method, blocking, use_process_vm_readv, tmpdir, monkeypatch): |
| 45 | """Test that we can retrieve the thread state of a single process. |
| 46 | |
| 47 | This test is specially useful to run under valgrind or similar tools and to |
| 48 | quickly check that the very basic functionality works as expected. |
| 49 | """ |
| 50 | |
| 51 | # GIVEN |
| 52 | env_var = "_PYSTACK_NO_PROCESS_VM_READV" |
| 53 | if use_process_vm_readv: |
| 54 | monkeypatch.delenv(env_var, raising=False) |
| 55 | else: |
| 56 | monkeypatch.setenv(env_var, "1") |
| 57 | |
| 58 | # WHEN |
| 59 | with spawn_child_process( |
| 60 | sys.executable, TEST_SINGLE_THREAD_FILE, tmpdir |
| 61 | ) as child_process: |
| 62 | with xfail_on_expected_exceptions(method): |
| 63 | threads = list( |
| 64 | get_process_threads( |
| 65 | child_process.pid, method=method, stop_process=blocking |
| 66 | ) |
| 67 | ) |
| 68 | |
| 69 | # THEN |
| 70 | assert threads is not None |
| 71 | |
| 72 | |
| 73 | @pytest.mark.parametrize("method", STACK_METHODS) |
nothing calls this directly
no test coverage detected