Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef TEST_TEST_HELPER_H_ |
| 18 | #define TEST_TEST_HELPER_H_ |
| 19 | |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <stdlib.h> |
| 22 | |
| 23 | #include "perfetto/ext/base/optional.h" |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 24 | #include "perfetto/ext/base/scoped_file.h" |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 25 | #include "perfetto/ext/base/thread_task_runner.h" |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 26 | #include "perfetto/ext/base/utils.h" |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 27 | #include "perfetto/ext/tracing/core/consumer.h" |
Eric Seckler | 526921b | 2020-02-18 11:44:30 +0000 | [diff] [blame] | 28 | #include "perfetto/ext/tracing/core/shared_memory_arbiter.h" |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 29 | #include "perfetto/ext/tracing/core/trace_packet.h" |
| 30 | #include "perfetto/ext/tracing/ipc/consumer_ipc_client.h" |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 31 | #include "perfetto/ext/tracing/ipc/service_ipc_host.h" |
Primiano Tucci | 0f9e022 | 2019-06-05 09:36:41 +0100 | [diff] [blame] | 32 | #include "perfetto/tracing/core/trace_config.h" |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 33 | #include "src/base/test/test_task_runner.h" |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 34 | #include "test/fake_producer.h" |
| 35 | |
| 36 | #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) |
Primiano Tucci | 5f3008e | 2021-05-19 21:34:45 +0100 | [diff] [blame] | 37 | #include "src/tracing/ipc/shared_memory_windows.h" |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 38 | #else |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 39 | #include "src/traced/probes/probes_producer.h" |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 40 | #include "src/tracing/ipc/posix_shared_memory.h" |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 41 | #endif |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 42 | |
Primiano Tucci | fe502c4 | 2019-12-11 01:00:27 +0000 | [diff] [blame] | 43 | #include "protos/perfetto/trace/trace_packet.gen.h" |
Primiano Tucci | 07e104d | 2018-04-03 20:45:35 +0200 | [diff] [blame] | 44 | |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 45 | namespace perfetto { |
| 46 | |
Primiano Tucci | 5d6f1b5 | 2020-10-27 10:29:21 +0100 | [diff] [blame] | 47 | // This value has been bumped to 10s in Oct 2020 because the x86 cuttlefish |
| 48 | // emulator is sensibly slower (up to 10x) than real hw and caused flakes. |
| 49 | // See bugs duped against b/171771440. |
| 50 | constexpr uint32_t kDefaultTestTimeoutMs = 10000; |
| 51 | |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 52 | // This is used only in daemon starting integrations tests. |
| 53 | class ServiceThread { |
| 54 | public: |
| 55 | ServiceThread(const std::string& producer_socket, |
| 56 | const std::string& consumer_socket) |
| 57 | : producer_socket_(producer_socket), consumer_socket_(consumer_socket) {} |
| 58 | |
| 59 | ~ServiceThread() { |
| 60 | if (!runner_) |
| 61 | return; |
| 62 | runner_->PostTaskAndWaitForTesting([this]() { svc_.reset(); }); |
| 63 | } |
| 64 | |
| 65 | void Start() { |
| 66 | runner_ = base::ThreadTaskRunner::CreateAndStart("perfetto.svc"); |
| 67 | runner_->PostTaskAndWaitForTesting([this]() { |
| 68 | svc_ = ServiceIPCHost::CreateInstance(runner_->get()); |
Florian Mayer | 67b2685 | 2021-02-04 19:13:01 +0000 | [diff] [blame] | 69 | if (remove(producer_socket_.c_str()) == -1) { |
| 70 | if (errno != ENOENT) |
| 71 | PERFETTO_FATAL("Failed to remove %s", producer_socket_.c_str()); |
| 72 | } |
| 73 | if (remove(consumer_socket_.c_str()) == -1) { |
| 74 | if (errno != ENOENT) |
| 75 | PERFETTO_FATAL("Failed to remove %s", consumer_socket_.c_str()); |
| 76 | } |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 77 | base::SetEnv("PERFETTO_PRODUCER_SOCK_NAME", producer_socket_); |
| 78 | base::SetEnv("PERFETTO_CONSUMER_SOCK_NAME", consumer_socket_); |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 79 | bool res = |
| 80 | svc_->Start(producer_socket_.c_str(), consumer_socket_.c_str()); |
Florian Mayer | 67b2685 | 2021-02-04 19:13:01 +0000 | [diff] [blame] | 81 | if (!res) { |
| 82 | PERFETTO_FATAL("Failed to start service listening on %s and %s", |
| 83 | producer_socket_.c_str(), consumer_socket_.c_str()); |
| 84 | } |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 85 | }); |
| 86 | } |
| 87 | |
| 88 | base::ThreadTaskRunner* runner() { return runner_ ? &*runner_ : nullptr; } |
| 89 | |
| 90 | private: |
| 91 | base::Optional<base::ThreadTaskRunner> runner_; // Keep first. |
| 92 | |
| 93 | std::string producer_socket_; |
| 94 | std::string consumer_socket_; |
| 95 | std::unique_ptr<ServiceIPCHost> svc_; |
| 96 | }; |
| 97 | |
| 98 | // This is used only in daemon starting integrations tests. |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 99 | #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) |
| 100 | // On Windows we don't have any traced_probes, make this a no-op to avoid |
| 101 | // propagating #ifdefs to the outer test. |
| 102 | class ProbesProducerThread { |
| 103 | public: |
| 104 | ProbesProducerThread(const std::string& /*producer_socket*/) {} |
| 105 | void Connect() {} |
| 106 | }; |
| 107 | #else |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 108 | class ProbesProducerThread { |
| 109 | public: |
| 110 | ProbesProducerThread(const std::string& producer_socket) |
| 111 | : producer_socket_(producer_socket) {} |
| 112 | |
| 113 | ~ProbesProducerThread() { |
| 114 | if (!runner_) |
| 115 | return; |
| 116 | runner_->PostTaskAndWaitForTesting([this]() { producer_.reset(); }); |
| 117 | } |
| 118 | |
| 119 | void Connect() { |
| 120 | runner_ = base::ThreadTaskRunner::CreateAndStart("perfetto.prd.probes"); |
| 121 | runner_->PostTaskAndWaitForTesting([this]() { |
| 122 | producer_.reset(new ProbesProducer()); |
| 123 | producer_->ConnectWithRetries(producer_socket_.c_str(), runner_->get()); |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | private: |
| 128 | base::Optional<base::ThreadTaskRunner> runner_; // Keep first. |
| 129 | |
| 130 | std::string producer_socket_; |
| 131 | std::unique_ptr<ProbesProducer> producer_; |
| 132 | }; |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 133 | #endif // !OS_WIN |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 134 | |
| 135 | class FakeProducerThread { |
| 136 | public: |
| 137 | FakeProducerThread(const std::string& producer_socket, |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 138 | std::function<void()> connect_callback, |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 139 | std::function<void()> setup_callback, |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 140 | std::function<void()> start_callback) |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 141 | : producer_socket_(producer_socket), |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 142 | connect_callback_(std::move(connect_callback)), |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 143 | setup_callback_(std::move(setup_callback)), |
Eric Seckler | 526921b | 2020-02-18 11:44:30 +0000 | [diff] [blame] | 144 | start_callback_(std::move(start_callback)) { |
| 145 | runner_ = base::ThreadTaskRunner::CreateAndStart("perfetto.prd.fake"); |
| 146 | runner_->PostTaskAndWaitForTesting([this]() { |
| 147 | producer_.reset( |
| 148 | new FakeProducer("android.perfetto.FakeProducer", runner_->get())); |
| 149 | }); |
| 150 | } |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 151 | |
| 152 | ~FakeProducerThread() { |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 153 | runner_->PostTaskAndWaitForTesting([this]() { producer_.reset(); }); |
| 154 | } |
| 155 | |
| 156 | void Connect() { |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 157 | runner_->PostTaskAndWaitForTesting([this]() { |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 158 | producer_->Connect(producer_socket_.c_str(), std::move(connect_callback_), |
| 159 | std::move(setup_callback_), std::move(start_callback_), |
| 160 | std::move(shm_), std::move(shm_arbiter_)); |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 161 | }); |
| 162 | } |
| 163 | |
| 164 | base::ThreadTaskRunner* runner() { return runner_ ? &*runner_ : nullptr; } |
| 165 | |
| 166 | FakeProducer* producer() { return producer_.get(); } |
| 167 | |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 168 | void CreateProducerProvidedSmb() { |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 169 | #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) |
Primiano Tucci | 5f3008e | 2021-05-19 21:34:45 +0100 | [diff] [blame] | 170 | SharedMemoryWindows::Factory factory; |
Primiano Tucci | 10c9e9e | 2021-01-08 13:04:40 +0100 | [diff] [blame] | 171 | #else |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 172 | PosixSharedMemory::Factory factory; |
Primiano Tucci | 5f3008e | 2021-05-19 21:34:45 +0100 | [diff] [blame] | 173 | #endif |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 174 | shm_ = factory.CreateSharedMemory(1024 * 1024); |
Primiano Tucci | 90d6930 | 2020-08-20 17:22:12 +0200 | [diff] [blame] | 175 | shm_arbiter_ = SharedMemoryArbiter::CreateUnboundInstance(shm_.get(), 4096); |
Eric Seckler | 526921b | 2020-02-18 11:44:30 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void ProduceStartupEventBatch(const protos::gen::TestConfig& config, |
| 179 | std::function<void()> callback) { |
| 180 | PERFETTO_CHECK(shm_arbiter_); |
| 181 | producer_->ProduceStartupEventBatch(config, shm_arbiter_.get(), callback); |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 184 | private: |
| 185 | base::Optional<base::ThreadTaskRunner> runner_; // Keep first. |
| 186 | |
| 187 | std::string producer_socket_; |
| 188 | std::unique_ptr<FakeProducer> producer_; |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 189 | std::function<void()> connect_callback_; |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 190 | std::function<void()> setup_callback_; |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 191 | std::function<void()> start_callback_; |
| 192 | std::unique_ptr<SharedMemory> shm_; |
Eric Seckler | 526921b | 2020-02-18 11:44:30 +0000 | [diff] [blame] | 193 | std::unique_ptr<SharedMemoryArbiter> shm_arbiter_; |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 194 | }; |
| 195 | |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 196 | class TestHelper : public Consumer { |
| 197 | public: |
Florian Mayer | 67b2685 | 2021-02-04 19:13:01 +0000 | [diff] [blame] | 198 | enum class Mode { |
| 199 | kStartDaemons, |
| 200 | kUseSystemService, |
| 201 | }; |
| 202 | static Mode kDefaultMode; |
Primiano Tucci | 106605c | 2019-01-08 21:12:58 +0000 | [diff] [blame] | 203 | |
Florian Mayer | 67b2685 | 2021-02-04 19:13:01 +0000 | [diff] [blame] | 204 | static const char* GetDefaultModeConsumerSocketName(); |
| 205 | static const char* GetDefaultModeProducerSocketName(); |
| 206 | |
| 207 | explicit TestHelper(base::TestTaskRunner* task_runner) |
| 208 | : TestHelper(task_runner, kDefaultMode) {} |
| 209 | |
| 210 | explicit TestHelper(base::TestTaskRunner* task_runner, Mode mode); |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 211 | |
| 212 | // Consumer implementation. |
| 213 | void OnConnect() override; |
| 214 | void OnDisconnect() override; |
Primiano Tucci | df44031 | 2020-10-30 16:43:58 +0100 | [diff] [blame] | 215 | void OnTracingDisabled(const std::string& error) override; |
Florian Mayer | 709de7f | 2021-01-28 21:41:14 +0000 | [diff] [blame] | 216 | virtual void ReadTraceData(std::vector<TracePacket> packets); |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 217 | void OnTraceData(std::vector<TracePacket> packets, bool has_more) override; |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 218 | void OnDetach(bool) override; |
| 219 | void OnAttach(bool, const TraceConfig&) override; |
Eric Seckler | eaf29ed | 2019-01-23 09:53:55 +0000 | [diff] [blame] | 220 | void OnTraceStats(bool, const TraceStats&) override; |
Eric Seckler | 7b0c945 | 2019-03-18 13:14:36 +0000 | [diff] [blame] | 221 | void OnObservableEvents(const ObservableEvents&) override; |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 222 | |
Florian Mayer | 67b2685 | 2021-02-04 19:13:01 +0000 | [diff] [blame] | 223 | // Starts the tracing service if in kStartDaemons mode. |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 224 | void StartServiceIfRequired(); |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 225 | |
| 226 | // Connects the producer and waits that the service has seen the |
| 227 | // RegisterDataSource() call. |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 228 | FakeProducer* ConnectFakeProducer(); |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 229 | |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 230 | void ConnectConsumer(); |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 231 | void StartTracing(const TraceConfig& config, |
| 232 | base::ScopedFile = base::ScopedFile()); |
Primiano Tucci | c185530 | 2018-12-06 10:36:55 +0000 | [diff] [blame] | 233 | void DisableTracing(); |
| 234 | void FlushAndWait(uint32_t timeout_ms); |
Lalit Maganti | 3f0b7c6 | 2018-04-18 19:10:09 +0100 | [diff] [blame] | 235 | void ReadData(uint32_t read_count = 0); |
Stephen Nusko | 1af720e | 2020-11-18 14:04:16 -0500 | [diff] [blame] | 236 | void FreeBuffers(); |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 237 | void DetachConsumer(const std::string& key); |
| 238 | bool AttachConsumer(const std::string& key); |
Primiano Tucci | 40207fe | 2020-12-03 18:27:55 +0100 | [diff] [blame] | 239 | bool SaveTraceForBugreportAndWait(); |
Eric Seckler | 326a3d3 | 2020-02-04 11:24:56 +0000 | [diff] [blame] | 240 | void CreateProducerProvidedSmb(); |
| 241 | bool IsShmemProvidedByProducer(); |
Eric Seckler | 526921b | 2020-02-18 11:44:30 +0000 | [diff] [blame] | 242 | void ProduceStartupEventBatch(const protos::gen::TestConfig& config); |
Lalit Maganti | 36557d8 | 2018-04-11 14:36:17 +0100 | [diff] [blame] | 243 | |
| 244 | void WaitForConsumerConnect(); |
Stephen Nusko | e823811 | 2019-04-09 18:37:00 +0100 | [diff] [blame] | 245 | void WaitForProducerSetup(); |
Lalit Maganti | 36557d8 | 2018-04-11 14:36:17 +0100 | [diff] [blame] | 246 | void WaitForProducerEnabled(); |
Primiano Tucci | 5d6f1b5 | 2020-10-27 10:29:21 +0100 | [diff] [blame] | 247 | void WaitForTracingDisabled(uint32_t timeout_ms = kDefaultTestTimeoutMs); |
| 248 | void WaitForReadData(uint32_t read_count = 0, |
| 249 | uint32_t timeout_ms = kDefaultTestTimeoutMs); |
Primiano Tucci | bbe68be | 2020-04-16 22:17:12 +0100 | [diff] [blame] | 250 | void SyncAndWaitProducer(); |
Primiano Tucci | 9c41ceb | 2020-04-14 13:23:01 +0100 | [diff] [blame] | 251 | TracingServiceState QueryServiceStateAndWait(); |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 252 | |
Florian Mayer | 05a87c9 | 2019-01-30 13:17:51 +0000 | [diff] [blame] | 253 | std::string AddID(const std::string& checkpoint) { |
| 254 | return checkpoint + "." + std::to_string(instance_num_); |
| 255 | } |
| 256 | |
| 257 | std::function<void()> CreateCheckpoint(const std::string& checkpoint) { |
| 258 | return task_runner_->CreateCheckpoint(AddID(checkpoint)); |
| 259 | } |
| 260 | |
| 261 | void RunUntilCheckpoint(const std::string& checkpoint, |
Primiano Tucci | 5d6f1b5 | 2020-10-27 10:29:21 +0100 | [diff] [blame] | 262 | uint32_t timeout_ms = kDefaultTestTimeoutMs) { |
Florian Mayer | 05a87c9 | 2019-01-30 13:17:51 +0000 | [diff] [blame] | 263 | return task_runner_->RunUntilCheckpoint(AddID(checkpoint), timeout_ms); |
| 264 | } |
| 265 | |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 266 | std::function<void()> WrapTask(const std::function<void()>& function); |
| 267 | |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 268 | base::ThreadTaskRunner* service_thread() { return service_thread_.runner(); } |
| 269 | base::ThreadTaskRunner* producer_thread() { |
| 270 | return fake_producer_thread_.runner(); |
| 271 | } |
Florian Mayer | 51016d3 | 2020-09-17 11:34:44 +0100 | [diff] [blame] | 272 | const std::vector<protos::gen::TracePacket>& full_trace() { |
| 273 | return full_trace_; |
| 274 | } |
Primiano Tucci | fe502c4 | 2019-12-11 01:00:27 +0000 | [diff] [blame] | 275 | const std::vector<protos::gen::TracePacket>& trace() { return trace_; } |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 276 | |
| 277 | private: |
Florian Mayer | 05a87c9 | 2019-01-30 13:17:51 +0000 | [diff] [blame] | 278 | static uint64_t next_instance_num_; |
| 279 | uint64_t instance_num_; |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 280 | base::TestTaskRunner* task_runner_ = nullptr; |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 281 | int cur_consumer_num_ = 0; |
Stephen Nusko | 1af720e | 2020-11-18 14:04:16 -0500 | [diff] [blame] | 282 | uint64_t trace_count_ = 0; |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 283 | |
Lalit Maganti | 36557d8 | 2018-04-11 14:36:17 +0100 | [diff] [blame] | 284 | std::function<void()> on_connect_callback_; |
| 285 | std::function<void()> on_packets_finished_callback_; |
| 286 | std::function<void()> on_stop_tracing_callback_; |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 287 | std::function<void()> on_detach_callback_; |
| 288 | std::function<void(bool)> on_attach_callback_; |
Lalit Maganti | 36557d8 | 2018-04-11 14:36:17 +0100 | [diff] [blame] | 289 | |
Florian Mayer | 51016d3 | 2020-09-17 11:34:44 +0100 | [diff] [blame] | 290 | std::vector<protos::gen::TracePacket> full_trace_; |
Primiano Tucci | fe502c4 | 2019-12-11 01:00:27 +0000 | [diff] [blame] | 291 | std::vector<protos::gen::TracePacket> trace_; |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 292 | |
Florian Mayer | 67b2685 | 2021-02-04 19:13:01 +0000 | [diff] [blame] | 293 | Mode mode_; |
| 294 | const char* producer_socket_; |
| 295 | const char* consumer_socket_; |
Lalit Maganti | 9782f49 | 2020-01-10 18:13:13 +0000 | [diff] [blame] | 296 | ServiceThread service_thread_; |
| 297 | FakeProducerThread fake_producer_thread_; |
| 298 | |
Florian Mayer | 6a1a4d5 | 2018-06-08 16:47:07 +0100 | [diff] [blame] | 299 | std::unique_ptr<TracingService::ConsumerEndpoint> endpoint_; // Keep last. |
Lalit Maganti | c4c3ceb | 2018-03-29 20:38:13 +0100 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | } // namespace perfetto |
| 303 | |
| 304 | #endif // TEST_TEST_HELPER_H_ |