Convert control loop tests over to simulated event loop

This makes it so that we properly only use ShmEventLoop for running in
realtime on a robot.  Very nice.

Change-Id: I46b770b336f59e08cfaf28511b3bd5689f72fff1
diff --git a/aos/events/event-loop_param_test.h b/aos/events/event-loop_param_test.h
index 26d869d..83f0b37 100644
--- a/aos/events/event-loop_param_test.h
+++ b/aos/events/event-loop_param_test.h
@@ -22,6 +22,9 @@
   // Runs the loops until they quit.
   virtual void Run() = 0;
 
+  // Quits the loops.
+  virtual void Exit() = 0;
+
   // Advances time by sleeping.  Can't be called from inside a loop.
   virtual void SleepFor(::std::chrono::nanoseconds duration) = 0;
 };
@@ -36,9 +39,19 @@
 
   void Run() { return factory_->Run(); }
 
+  void Exit() { return factory_->Exit(); }
+
   void SleepFor(::std::chrono::nanoseconds duration) {
     return factory_->SleepFor(duration);
   }
+
+  // Ends the given event loop at the given time from now.
+  void EndEventLoop(EventLoop *loop, ::std::chrono::milliseconds duration) {
+    auto end_timer = loop->AddTimer([this]() { this->Exit(); });
+    end_timer->Setup(loop->monotonic_now() +
+                     ::std::chrono::milliseconds(duration));
+  }
+
   // You can implement all the usual fixture class members here.
   // To access the test parameter, call GetParam() from class
   // TestWithParam<T>.