Add test case for ping and pong
This provides a simple example for how to test, and also provides a
staring point for the tests for the logger.
Change-Id: Ieac6858156627c0efcdbb739612e6a4efaf19b80
diff --git a/aos/events/pong.cc b/aos/events/pong.cc
index 1504bfb..339d4d7 100644
--- a/aos/events/pong.cc
+++ b/aos/events/pong.cc
@@ -1,47 +1,18 @@
-#include <chrono>
-
#include "aos/configuration.h"
-#include "aos/events/pingpong_generated.h"
+#include "aos/events/ping_generated.h"
+#include "aos/events/pong_generated.h"
+#include "aos/events/pong_lib.h"
#include "aos/events/shm_event_loop.h"
#include "aos/init.h"
-#include "aos/json_to_flatbuffer.h"
-#include "gflags/gflags.h"
#include "glog/logging.h"
-namespace aos {
-
-namespace chrono = std::chrono;
-
-class Pong {
- public:
- Pong(EventLoop *event_loop)
- : event_loop_(event_loop),
- sender_(event_loop_->MakeSender<examples::Pong>("/test")) {
- event_loop_->MakeWatcher("/test", [this](const examples::Ping &ping) {
- aos::Sender<examples::Pong>::Builder msg = sender_.MakeBuilder();
- examples::Pong::Builder builder = msg.MakeBuilder<examples::Pong>();
- builder.add_value(ping.value());
- builder.add_initial_send_time(ping.send_time());
- CHECK(msg.Send(builder.Finish()));
- });
-
- event_loop_->SetRuntimeRealtimePriority(5);
- }
-
- private:
- EventLoop *event_loop_;
- aos::Sender<examples::Pong> sender_;
-};
-
-} // namespace aos
-
int main(int argc, char **argv) {
FLAGS_logtostderr = true;
google::InitGoogleLogging(argv[0]);
::gflags::ParseCommandLineFlags(&argc, &argv, true);
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig("aos/events/config.fb.json");
+ aos::configuration::ReadConfig("aos/events/pingpong_config.json");
::aos::ShmEventLoop event_loop(&config.message());