Test that get_stats() returns statistics when stats=True.
(self)
| 3519 | "Test only runs on Linux with process_vm_readv support", |
| 3520 | ) |
| 3521 | def test_get_stats(self): |
| 3522 | """Test that get_stats() returns statistics when stats=True.""" |
| 3523 | script_body = """\ |
| 3524 | sock.sendall(b"ready") |
| 3525 | sock.recv(16) |
| 3526 | """ |
| 3527 | |
| 3528 | with self._target_process(script_body) as (p, client_socket, _): |
| 3529 | unwinder = RemoteUnwinder(p.pid, all_threads=True, stats=True) |
| 3530 | _wait_for_signal(client_socket, b"ready") |
| 3531 | |
| 3532 | # Take a sample |
| 3533 | _get_stack_trace_with_retry(unwinder) |
| 3534 | |
| 3535 | stats = unwinder.get_stats() |
| 3536 | client_socket.sendall(b"done") |
| 3537 | |
| 3538 | # Verify expected keys exist |
| 3539 | expected_keys = [ |
| 3540 | "total_samples", |
| 3541 | "frame_cache_hits", |
| 3542 | "frame_cache_misses", |
| 3543 | "frame_cache_partial_hits", |
| 3544 | "frames_read_from_cache", |
| 3545 | "frames_read_from_memory", |
| 3546 | "frame_cache_hit_rate", |
| 3547 | ] |
| 3548 | for key in expected_keys: |
| 3549 | self.assertIn(key, stats) |
| 3550 | |
| 3551 | self.assertEqual(stats["total_samples"], 1) |
| 3552 | |
| 3553 | @skip_if_not_supported |
| 3554 | @unittest.skipIf( |
nothing calls this directly
no test coverage detected