Fix simulation sent_time and add a test
It was hard-coded to the actual monotonic_clock::now() call, which
doesn't work well with actual simulation when you don't use fake time.
And we want to kill fake time.
Change-Id: If5785679d54100e5021bea86df763d98d44f7c3d
diff --git a/aos/events/shm-event-loop.cc b/aos/events/shm-event-loop.cc
index a70d6f3..c9ff6fd 100644
--- a/aos/events/shm-event-loop.cc
+++ b/aos/events/shm-event-loop.cc
@@ -71,6 +71,14 @@
bool Send(SendContext *msg) override {
assert(queue_ != NULL);
+ {
+ ::aos::Message *aos_msg = reinterpret_cast<Message *>(msg);
+ // TODO(austin): This lets multiple senders reorder messages since time
+ // isn't acquired with a lock held.
+ if (aos_msg->sent_time == monotonic_clock::min_time) {
+ aos_msg->sent_time = monotonic_clock::now();
+ }
+ }
return queue_->WriteMessage(msg, RawQueue::kOverride);
}