Add a sent too fast check for simulation and shm

Returns an error if more than queue_size (frequency *
channel_storage_duration) messages were sent in one
channel_storage_duration.

Signed-off-by: Eric Schmiedeberg <eric.schmiedeberg@bluerivertech.com>
Change-Id: Ie41205ba37b66930d8a9082f2d85d7dc3388e3bf
diff --git a/aos/ipc_lib/queue_racer.h b/aos/ipc_lib/queue_racer.h
index ea0238e..3e5ca94 100644
--- a/aos/ipc_lib/queue_racer.h
+++ b/aos/ipc_lib/queue_racer.h
@@ -10,11 +10,28 @@
 
 struct ThreadState;
 
+struct QueueRacerConfiguration {
+  // Number of threads that send messages
+  const int num_threads;
+  // Number of messages sent by each thread
+  const uint64_t num_messages;
+  // Allows QueueRacer to check for multiple returns from calling Send()
+  const std::vector<LocklessQueueSender::Result> expected_send_results = {
+      LocklessQueueSender::Result::GOOD};
+  // Channel Storage Duration for queue used by QueueRacer
+  const monotonic_clock::duration channel_storage_duration =
+      std::chrono::nanoseconds(1);
+  // Set to true if all writes and reads are expected to be successful
+  // This allows QueueRacer to be used for checking failure scenarios
+  const bool check_writes_and_reads;
+};
+
 // Class to test the queue by spinning up a bunch of writing threads and racing
 // them together to all write at once.
 class QueueRacer {
  public:
   QueueRacer(LocklessQueue queue, int num_threads, uint64_t num_messages);
+  QueueRacer(LocklessQueue queue, const QueueRacerConfiguration &config);
 
   // Runs an iteration of the race.
   //
@@ -52,7 +69,10 @@
   LocklessQueue queue_;
   const uint64_t num_threads_;
   const uint64_t num_messages_;
-
+  const monotonic_clock::duration channel_storage_duration_;
+  // Allows QueueRacer to check for multiple returns from calling Send()
+  const std::vector<LocklessQueueSender::Result> expected_send_results_;
+  const bool check_writes_and_reads_;
   // The overall number of writes executed will always be between the two of
   // these.  We can't atomically count writes, so we have to bound them.
   //