tracing_service_impl_unittest: Avoid internals in ScrapeOnDisconnect

This test is trying to simulate what happens with a remote producer when
it disconnects. The test however uses an in-process producer.

An in-process producer behaves quite differently (compared to a remote
producer). The shared memory arbiter (and the shared memory itself) is
owned by the producer endpoint. There's no way of disconnecting an
in-process producer without destroying its shared memory arbiter. But we
cannot destroy the shared memory arbiter, because the trace writer holds
references to it. We cannot destroy the trace writer, because it would
flush, and scraping will not be exercised.

This commit makes the test more realisting by using a "remote" producer:
* Producer `in_process` can be set to false.
* TestRefSharedMemory is a new type of shared memory that can be used to
  simulate two components having access to the same shared memory in
  tests.
* In order to simulate a disconnection, a ProxyProducerEndpoint can be
  configured to forward all the requests to a real proxy or to drop
  them, after disconnecting.

The test can now own the shared memory arbiter. TracingServiceImpl will
behave as it does with a remote producer and scrape its memory.

+ The production code doesn't contain test only code.
- There's a lot more test-only code required.
+ The test is more realistic.

Change-Id: I61121c6623f912c167876602e93ead39cd087c52
10 files changed
tree: 613c82d2768904058227ce2c61cbe66a0a323691
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. python/
  13. src/
  14. test/
  15. third_party/
  16. tools/
  17. ui/
  18. .bazelignore
  19. .bazelrc
  20. .clang-format
  21. .clang-tidy
  22. .git-blame-ignore-revs
  23. .gitattributes
  24. .gitignore
  25. .gn
  26. .style.yapf
  27. Android.bp
  28. Android.bp.extras
  29. BUILD
  30. BUILD.extras
  31. BUILD.gn
  32. CHANGELOG
  33. codereview.settings
  34. DIR_METADATA
  35. heapprofd.rc
  36. LICENSE
  37. meson.build
  38. METADATA
  39. MODULE_LICENSE_APACHE2
  40. OWNERS
  41. perfetto.rc
  42. PerfettoIntegrationTests.xml
  43. persistent_cfg.pbtxt
  44. PRESUBMIT.py
  45. README.chromium
  46. README.md
  47. TEST_MAPPING
  48. traced_perf.rc
  49. WATCHLISTS
  50. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.