Add channel method to fetchers and senders.
This makes it easy to figure out which channel a fetcher or sender
is connected to.
Also add a test to confirm that the channel pointer points to a channel
inside configuration() for the event loop.
Change-Id: Iee0edca66394ef825dac482d7e3f568c6ed3441f
diff --git a/aos/events/event_loop_param_test.cc b/aos/events/event_loop_param_test.cc
index 8a0f9b6..3cace56 100644
--- a/aos/events/event_loop_param_test.cc
+++ b/aos/events/event_loop_param_test.cc
@@ -6,8 +6,9 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "glog/logging.h"
#include "aos/events/test_message_generated.h"
+#include "aos/flatbuffer_merge.h"
+#include "glog/logging.h"
namespace aos {
namespace testing {
@@ -535,6 +536,31 @@
EXPECT_EQ(iteration_list.size(), 3);
}
+// Verifies that the event loop implementations detect when Channel is not a
+// pointer into confguration()
+TEST_P(AbstractEventLoopDeathTest, InvalidChannel) {
+ auto loop = MakePrimary();
+
+ const Channel *channel = loop->configuration()->channels()->Get(0);
+
+ FlatbufferDetachedBuffer<Channel> channel_copy = CopyFlatBuffer(channel);
+
+ EXPECT_DEATH(
+ { loop->MakeRawSender(&channel_copy.message()); },
+ "Channel pointer not found in configuration\\(\\)->channels\\(\\)");
+
+ EXPECT_DEATH(
+ { loop->MakeRawFetcher(&channel_copy.message()); },
+ "Channel pointer not found in configuration\\(\\)->channels\\(\\)");
+
+ EXPECT_DEATH(
+ {
+ loop->MakeRawWatcher(&channel_copy.message(),
+ [](const Context, const void *) {});
+ },
+ "Channel pointer not found in configuration\\(\\)->channels\\(\\)");
+}
+
// Verify that the send time on a message is roughly right.
TEST_P(AbstractEventLoopTest, MessageSendTime) {
auto loop1 = MakePrimary();