Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 1 | #ifndef _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_ |
| 2 | #define _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_ |
| 3 | |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 4 | #include <initializer_list> |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 5 | #include <string_view> |
Neil Balch | 229001a | 2018-01-07 18:22:52 -0800 | [diff] [blame] | 6 | #include <vector> |
| 7 | |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 8 | #include "gtest/gtest.h" |
| 9 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 10 | #include "aos/events/event_loop.h" |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 11 | #include "aos/events/test_message_generated.h" |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 12 | #include "aos/events/test_message_schema.h" |
| 13 | #include "aos/events/timing_report_schema.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 14 | #include "aos/flatbuffers.h" |
| 15 | #include "aos/json_to_flatbuffer.h" |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 16 | #include "aos/logging/log_message_schema.h" |
| 17 | #include "aos/network/message_bridge_client_schema.h" |
| 18 | #include "aos/network/message_bridge_server_schema.h" |
| 19 | #include "aos/network/timestamp_schema.h" |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 20 | |
| 21 | namespace aos { |
| 22 | namespace testing { |
| 23 | |
| 24 | class EventLoopTestFactory { |
| 25 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 26 | EventLoopTestFactory() |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 27 | : flatbuffer_(configuration::AddSchema( |
| 28 | R"config({ |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 29 | "channels": [ |
| 30 | { |
| 31 | "name": "/aos", |
| 32 | "type": "aos.logging.LogMessageFbs" |
| 33 | }, |
| 34 | { |
| 35 | "name": "/aos", |
| 36 | "type": "aos.timing.Report" |
| 37 | }, |
| 38 | { |
| 39 | "name": "/test", |
milind | 945708b | 2021-07-03 13:30:15 -0700 | [diff] [blame] | 40 | "type": "aos.TestMessage", |
| 41 | "frequency": 800 |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 42 | }, |
| 43 | { |
| 44 | "name": "/test1", |
| 45 | "type": "aos.TestMessage" |
| 46 | }, |
| 47 | { |
| 48 | "name": "/test2", |
| 49 | "type": "aos.TestMessage" |
| 50 | } |
| 51 | ] |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 52 | })config", |
| 53 | {aos::FlatbufferSpan<reflection::Schema>( |
| 54 | logging::LogMessageFbsSchema()), |
| 55 | aos::FlatbufferSpan<reflection::Schema>(timing::ReportSchema()), |
| 56 | aos::FlatbufferSpan<reflection::Schema>(TestMessageSchema())})) {} |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 57 | |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 58 | virtual ~EventLoopTestFactory() {} |
| 59 | |
Austin Schuh | 44019f9 | 2019-05-19 19:58:27 -0700 | [diff] [blame] | 60 | // Makes a connected event loop. |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 61 | virtual std::unique_ptr<EventLoop> Make(std::string_view name) = 0; |
Austin Schuh | 44019f9 | 2019-05-19 19:58:27 -0700 | [diff] [blame] | 62 | // Makes a primary event loop. This is the one the tests will try to use for |
| 63 | // anything blocking. |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 64 | virtual std::unique_ptr<EventLoop> MakePrimary(std::string_view name) = 0; |
Austin Schuh | 44019f9 | 2019-05-19 19:58:27 -0700 | [diff] [blame] | 65 | |
| 66 | // Runs the loops until they quit. |
| 67 | virtual void Run() = 0; |
Austin Schuh | 52d325c | 2019-06-23 18:59:06 -0700 | [diff] [blame] | 68 | |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 69 | // Quits the loops. |
| 70 | virtual void Exit() = 0; |
| 71 | |
Austin Schuh | 52d325c | 2019-06-23 18:59:06 -0700 | [diff] [blame] | 72 | // Advances time by sleeping. Can't be called from inside a loop. |
| 73 | virtual void SleepFor(::std::chrono::nanoseconds duration) = 0; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 74 | |
Austin Schuh | d54780b | 2020-10-03 16:26:02 -0700 | [diff] [blame] | 75 | // Sets the config to a config with a max size with an invalid alignment. |
| 76 | void InvalidChannelAlignment() { |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 77 | flatbuffer_ = configuration::AddSchema( |
| 78 | R"config({ |
Austin Schuh | d54780b | 2020-10-03 16:26:02 -0700 | [diff] [blame] | 79 | "channels": [ |
| 80 | { |
| 81 | "name": "/aos", |
| 82 | "type": "aos.logging.LogMessageFbs" |
| 83 | }, |
| 84 | { |
| 85 | "name": "/aos", |
| 86 | "type": "aos.timing.Report" |
| 87 | }, |
| 88 | { |
| 89 | "name": "/test", |
| 90 | "type": "aos.TestMessage", |
| 91 | "max_size": 13 |
| 92 | }, |
| 93 | { |
| 94 | "name": "/test1", |
| 95 | "type": "aos.TestMessage" |
| 96 | }, |
| 97 | { |
| 98 | "name": "/test2", |
| 99 | "type": "aos.TestMessage" |
| 100 | } |
| 101 | ] |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 102 | })config", |
| 103 | {aos::FlatbufferSpan<reflection::Schema>( |
| 104 | logging::LogMessageFbsSchema()), |
| 105 | aos::FlatbufferSpan<reflection::Schema>(timing::ReportSchema()), |
| 106 | aos::FlatbufferSpan<reflection::Schema>(TestMessageSchema())}); |
Austin Schuh | d54780b | 2020-10-03 16:26:02 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 109 | void PinReads() { |
| 110 | static const std::string kJson = R"config({ |
| 111 | "channels": [ |
| 112 | { |
| 113 | "name": "/aos", |
| 114 | "type": "aos.logging.LogMessageFbs", |
| 115 | "read_method": "PIN", |
| 116 | "num_readers": 10 |
| 117 | }, |
| 118 | { |
| 119 | "name": "/aos", |
| 120 | "type": "aos.timing.Report", |
| 121 | "read_method": "PIN", |
| 122 | "num_readers": 10 |
| 123 | }, |
| 124 | { |
| 125 | "name": "/test", |
| 126 | "type": "aos.TestMessage", |
| 127 | "read_method": "PIN", |
milind | 945708b | 2021-07-03 13:30:15 -0700 | [diff] [blame] | 128 | "num_readers": 10, |
| 129 | "frequency": 800 |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 130 | }, |
| 131 | { |
| 132 | "name": "/test1", |
| 133 | "type": "aos.TestMessage", |
| 134 | "read_method": "PIN", |
| 135 | "num_readers": 10 |
| 136 | }, |
| 137 | { |
| 138 | "name": "/test2", |
| 139 | "type": "aos.TestMessage", |
| 140 | "read_method": "PIN", |
| 141 | "num_readers": 10 |
| 142 | } |
| 143 | ] |
| 144 | })config"; |
| 145 | |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 146 | flatbuffer_ = configuration::AddSchema( |
| 147 | kJson, {aos::FlatbufferSpan<reflection::Schema>( |
| 148 | logging::LogMessageFbsSchema()), |
| 149 | aos::FlatbufferSpan<reflection::Schema>(timing::ReportSchema()), |
| 150 | aos::FlatbufferSpan<reflection::Schema>(TestMessageSchema())}); |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 153 | void EnableNodes(std::string_view my_node) { |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 154 | static const std::string kJson = R"config({ |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 155 | "channels": [ |
| 156 | { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 157 | "name": "/me/aos", |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 158 | "type": "aos.logging.LogMessageFbs", |
| 159 | "source_node": "me" |
| 160 | }, |
| 161 | { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 162 | "name": "/them/aos", |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 163 | "type": "aos.logging.LogMessageFbs", |
| 164 | "source_node": "them" |
| 165 | }, |
| 166 | { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 167 | "name": "/me/aos", |
| 168 | "type": "aos.message_bridge.Timestamp", |
| 169 | "source_node": "me", |
| 170 | "destination_nodes": [ |
| 171 | { |
| 172 | "name": "them" |
| 173 | } |
| 174 | ] |
| 175 | }, |
| 176 | { |
| 177 | "name": "/them/aos", |
| 178 | "type": "aos.message_bridge.Timestamp", |
| 179 | "source_node": "them", |
| 180 | "destination_nodes": [ |
| 181 | { |
| 182 | "name": "me" |
| 183 | } |
| 184 | ] |
| 185 | }, |
| 186 | { |
| 187 | "name": "/me/aos", |
| 188 | "type": "aos.message_bridge.ServerStatistics", |
| 189 | "source_node": "me", |
| 190 | "frequency": 2 |
| 191 | }, |
| 192 | { |
| 193 | "name": "/them/aos", |
| 194 | "type": "aos.message_bridge.ServerStatistics", |
| 195 | "source_node": "them", |
| 196 | "frequency": 2 |
| 197 | }, |
| 198 | { |
| 199 | "name": "/me/aos", |
| 200 | "type": "aos.message_bridge.ClientStatistics", |
| 201 | "source_node": "me", |
| 202 | "frequency": 2 |
| 203 | }, |
| 204 | { |
| 205 | "name": "/them/aos", |
| 206 | "type": "aos.message_bridge.ClientStatistics", |
| 207 | "source_node": "them", |
| 208 | "frequency": 2 |
| 209 | }, |
| 210 | { |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 211 | "name": "/aos", |
| 212 | "type": "aos.timing.Report", |
| 213 | "source_node": "me" |
| 214 | }, |
| 215 | { |
| 216 | "name": "/test", |
| 217 | "type": "aos.TestMessage", |
| 218 | "source_node": "me" |
| 219 | }, |
| 220 | { |
| 221 | "name": "/test1", |
| 222 | "type": "aos.TestMessage", |
| 223 | "source_node": "me" |
| 224 | }, |
| 225 | { |
| 226 | "name": "/test2", |
| 227 | "type": "aos.TestMessage", |
| 228 | "source_node": "me" |
Brian Silverman | 631b626 | 2021-11-10 12:25:08 -0800 | [diff] [blame] | 229 | }, |
| 230 | { |
| 231 | "name": "/test_forward", |
| 232 | "type": "aos.TestMessage", |
| 233 | "source_node": "them", |
| 234 | "destination_nodes": [ |
| 235 | { |
| 236 | "name": "me" |
| 237 | } |
| 238 | ] |
| 239 | }, |
| 240 | { |
| 241 | "name": "/test_noforward", |
| 242 | "type": "aos.TestMessage", |
| 243 | "source_node": "them" |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 244 | } |
| 245 | ], |
| 246 | "nodes": [ |
| 247 | { |
Austin Schuh | 898f497 | 2020-01-11 17:21:25 -0800 | [diff] [blame] | 248 | "name": "me", |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 249 | "hostname": "myhostname" |
Austin Schuh | 898f497 | 2020-01-11 17:21:25 -0800 | [diff] [blame] | 250 | }, |
| 251 | { |
| 252 | "name": "them", |
| 253 | "hostname": "themhostname" |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 254 | } |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 255 | ], |
| 256 | "maps": [ |
| 257 | { |
| 258 | "match": { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 259 | "name": "/aos*", |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 260 | "source_node": "me" |
| 261 | }, |
| 262 | "rename": { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 263 | "name": "/me/aos" |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 264 | } |
| 265 | }, |
| 266 | { |
| 267 | "match": { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 268 | "name": "/aos*", |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 269 | "source_node": "them" |
| 270 | }, |
| 271 | "rename": { |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 272 | "name": "/them/aos" |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 273 | } |
| 274 | } |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 275 | ] |
| 276 | })config"; |
| 277 | |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 278 | flatbuffer_ = configuration::MergeConfiguration( |
Austin Schuh | a9df9ad | 2021-06-16 14:49:39 -0700 | [diff] [blame] | 279 | configuration::MergeConfiguration( |
| 280 | aos::FlatbufferDetachedBuffer<Configuration>( |
| 281 | JsonToFlatbuffer<Configuration>(kJson))), |
| 282 | {aos::FlatbufferSpan<reflection::Schema>( |
| 283 | logging::LogMessageFbsSchema()), |
| 284 | aos::FlatbufferSpan<reflection::Schema>(timing::ReportSchema()), |
| 285 | aos::FlatbufferSpan<reflection::Schema>(TestMessageSchema()), |
| 286 | aos::FlatbufferSpan<reflection::Schema>( |
| 287 | message_bridge::ClientStatisticsSchema()), |
| 288 | aos::FlatbufferSpan<reflection::Schema>( |
| 289 | message_bridge::ServerStatisticsSchema()), |
| 290 | aos::FlatbufferSpan<reflection::Schema>( |
| 291 | message_bridge::TimestampSchema())}); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 292 | |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 293 | my_node_ = configuration::GetNode(&flatbuffer_.message(), my_node); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 294 | } |
| 295 | |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 296 | const Node *my_node() const { return my_node_; } |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 297 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 298 | const Configuration *configuration() { return &flatbuffer_.message(); } |
| 299 | |
| 300 | private: |
| 301 | FlatbufferDetachedBuffer<Configuration> flatbuffer_; |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 302 | |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 303 | const Node *my_node_ = nullptr; |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 304 | }; |
| 305 | |
Austin Schuh | 6bae825 | 2021-02-07 22:01:49 -0800 | [diff] [blame] | 306 | enum class DoTimingReports { kYes, kNo }; |
| 307 | |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 308 | class AbstractEventLoopTest |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 309 | : public ::testing::TestWithParam< |
Austin Schuh | 6bae825 | 2021-02-07 22:01:49 -0800 | [diff] [blame] | 310 | std::tuple<std::function<EventLoopTestFactory *()>, ReadMethod, |
| 311 | DoTimingReports>> { |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 312 | public: |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 313 | AbstractEventLoopTest() : factory_(std::get<0>(GetParam())()) { |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 314 | if (read_method() == ReadMethod::PIN) { |
| 315 | factory_->PinReads(); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | ReadMethod read_method() const { return std::get<1>(GetParam()); } |
Austin Schuh | 6bae825 | 2021-02-07 22:01:49 -0800 | [diff] [blame] | 320 | DoTimingReports do_timing_reports() const { return std::get<2>(GetParam()); } |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 321 | |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 322 | ::std::unique_ptr<EventLoop> Make(std::string_view name = ""); |
| 323 | |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 324 | ::std::unique_ptr<EventLoop> MakePrimary(std::string_view name = "primary") { |
| 325 | ++event_loop_count_; |
Austin Schuh | 6bae825 | 2021-02-07 22:01:49 -0800 | [diff] [blame] | 326 | auto result = factory_->MakePrimary(name); |
| 327 | if (do_timing_reports() == DoTimingReports::kNo) { |
| 328 | result->SkipTimingReport(); |
| 329 | } |
| 330 | return result; |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 331 | } |
Austin Schuh | 44019f9 | 2019-05-19 19:58:27 -0700 | [diff] [blame] | 332 | |
Austin Schuh | d54780b | 2020-10-03 16:26:02 -0700 | [diff] [blame] | 333 | void InvalidChannelAlignment() { factory_->InvalidChannelAlignment(); } |
| 334 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 335 | void EnableNodes(std::string_view my_node) { factory_->EnableNodes(my_node); } |
| 336 | |
Austin Schuh | 44019f9 | 2019-05-19 19:58:27 -0700 | [diff] [blame] | 337 | void Run() { return factory_->Run(); } |
Austin Schuh | 52d325c | 2019-06-23 18:59:06 -0700 | [diff] [blame] | 338 | |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 339 | void Exit() { return factory_->Exit(); } |
| 340 | |
Austin Schuh | 52d325c | 2019-06-23 18:59:06 -0700 | [diff] [blame] | 341 | void SleepFor(::std::chrono::nanoseconds duration) { |
| 342 | return factory_->SleepFor(duration); |
| 343 | } |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 344 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 345 | const Configuration *configuration() { return factory_->configuration(); } |
| 346 | |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 347 | const Node *my_node() const { return factory_->my_node(); } |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 348 | |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 349 | // Ends the given event loop at the given time from now. |
| 350 | void EndEventLoop(EventLoop *loop, ::std::chrono::milliseconds duration) { |
| 351 | auto end_timer = loop->AddTimer([this]() { this->Exit(); }); |
Philipp Schrader | a671252 | 2023-07-05 20:25:11 -0700 | [diff] [blame^] | 352 | end_timer->Schedule(loop->monotonic_now() + duration); |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 353 | end_timer->set_name("end"); |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 356 | // Verifies that the buffer_index values for all of the given objects are |
| 357 | // consistent. |
| 358 | void VerifyBuffers( |
| 359 | int number_buffers, |
| 360 | std::vector<std::reference_wrapper<const Fetcher<TestMessage>>> fetchers, |
| 361 | std::vector<std::reference_wrapper<const Sender<TestMessage>>> senders); |
| 362 | |
Eric Schmiedeberg | ef44b8a | 2022-02-28 17:30:38 -0700 | [diff] [blame] | 363 | // Helper function for testing the sent too fast check using a PhasedLoop with |
| 364 | // an interval that sends exactly at the frequency of the channel |
| 365 | void TestSentTooFastCheckEdgeCase( |
| 366 | const std::function<RawSender::Error(int, int)> expected_err, |
| 367 | const bool send_twice_at_end); |
| 368 | |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 369 | private: |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 370 | const ::std::unique_ptr<EventLoopTestFactory> factory_; |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 371 | |
| 372 | int event_loop_count_ = 0; |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 373 | }; |
| 374 | |
Brian Silverman | 4f4e061 | 2020-08-12 19:54:41 -0700 | [diff] [blame] | 375 | using AbstractEventLoopDeathTest = AbstractEventLoopTest; |
Austin Schuh | 6b6dfa5 | 2019-06-12 20:16:20 -0700 | [diff] [blame] | 376 | |
Eric Schmiedeberg | ef44b8a | 2022-02-28 17:30:38 -0700 | [diff] [blame] | 377 | // Returns the frequency of the /test TestMessage channel |
| 378 | int TestChannelFrequency(EventLoop *event_loop); |
| 379 | // Returns the queue size of the /test TestMessage channel |
| 380 | int TestChannelQueueSize(EventLoop *event_loop); |
| 381 | // Sends a test message with value 0 with the given sender |
| 382 | RawSender::Error SendTestMessage(aos::Sender<TestMessage> &sender); |
| 383 | |
Parker Schuh | e4a70d6 | 2017-12-27 20:10:20 -0800 | [diff] [blame] | 384 | } // namespace testing |
| 385 | } // namespace aos |
| 386 | |
| 387 | #endif // _AOS_EVENTS_EVENT_LOOP_PARAM_TEST_H_ |