Add config validator to y2023
Doesn't catch every error, but still worth having here so we keep adding
it in future years.
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
Change-Id: I78703b74aa8f80eed1840d78a1f84478e2f60f14
diff --git a/aos/util/config_validator.cc b/aos/util/config_validator.cc
index 78bd0b1..d5bd6ba 100644
--- a/aos/util/config_validator.cc
+++ b/aos/util/config_validator.cc
@@ -1,4 +1,5 @@
#include <chrono>
+
#include "aos/configuration.h"
#include "aos/events/logging/log_reader.h"
#include "aos/events/logging/log_writer.h"
@@ -9,8 +10,7 @@
#include "gflags/gflags.h"
#include "gtest/gtest.h"
-DEFINE_string(config, "",
- "Name of the config file to replay using.");
+DEFINE_string(config, "", "Name of the config file to replay using.");
/* This binary is used to validate that all of the
needed remote timestamps channels are in the config
to log the timestamps.
@@ -18,8 +18,8 @@
to confirm that the timestamps in the config are able to
replay all of the data in the log
This can be done by getting a list of all of the nodes and
- iterating through it with a for loop creating a logger for
- each one
+ iterating through it with a for loop creating a logger for
+ each one
Reference superstructure_lib_test.cc*/
TEST(ConfigValidatorTest, ReadConfig) {
ASSERT_TRUE(!FLAGS_config.empty());
@@ -30,3 +30,7 @@
factory.RunFor(std::chrono::seconds(1));
}
+
+// TODO(milind): add more tests, the above one doesn't
+// catch an error like forgetting to add a forwarded message to
+// the destination node's config.
diff --git a/aos/util/config_validator_macro.bzl b/aos/util/config_validator_macro.bzl
index 47ab240..453c5c2 100644
--- a/aos/util/config_validator_macro.bzl
+++ b/aos/util/config_validator_macro.bzl
@@ -1,4 +1,4 @@
-def config_validator_rule(name, config, visibility = None):
+def config_validator_rule(name, config, extension = ".bfbs", visibility = None):
'''
Macro to take a config and pass it to the config validator to validate that it will work on a real system.
@@ -8,12 +8,12 @@
name: name that the config validator uses, e.g. "test_config",
config: config rule that needs to be validated, e.g. "//aos/events:pingpong_config",
'''
- config_bfbs = config + ".bfbs"
+ config_file = config + extension
native.genrule(
name = name,
outs = [name + ".txt"],
- cmd = "$(location //aos/util:config_validator) --config $(location %s) > $@" % config_bfbs,
- srcs = [config_bfbs],
+ cmd = "$(location //aos/util:config_validator) --config $(location %s) > $@" % config_file,
+ srcs = [config_file],
tools = ["//aos/util:config_validator"],
testonly = True,
visibility = visibility,
diff --git a/y2023/BUILD b/y2023/BUILD
index f055fe4..d0ba061 100644
--- a/y2023/BUILD
+++ b/y2023/BUILD
@@ -2,6 +2,12 @@
load("//aos:config.bzl", "aos_config")
load("//tools/build_rules:template.bzl", "jinja2_template")
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+load("//aos/util:config_validator_macro.bzl", "config_validator_rule")
+
+config_validator_rule(
+ name = "config_validator_test",
+ config = "//y2023:aos_config",
+)
robot_downloader(
binaries = [