forked from frc971/971-Robot-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_validator.cc
39 lines (34 loc) · 1.56 KB
/
config_validator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <memory>
#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "aos/configuration.h"
#include "aos/flatbuffers.h"
#include "aos/json_to_flatbuffer.h"
#include "aos/util/config_validator_config_generated.h"
#include "aos/util/config_validator_lib.h"
ABSL_FLAG(std::string, config, "", "Name of the config file to replay using.");
ABSL_FLAG(std::string, validation_config, "{}",
"JSON config to use to validate the config.");
/* This binary is used to validate that all of the
needed remote timestamps channels are in the config
to log the timestamps.
Future versions of the validator will provide the option
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
Reference superstructure_lib_test.cc*/
TEST(ConfigValidatorTest, ReadConfig) {
ASSERT_TRUE(!absl::GetFlag(FLAGS_config).empty());
const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
const aos::FlatbufferDetachedBuffer<aos::util::ConfigValidatorConfig>
validator_config =
aos::JsonToFlatbuffer<aos::util::ConfigValidatorConfig>(
absl::GetFlag(FLAGS_validation_config));
aos::util::ConfigIsValid(&config.message(), &validator_config.message());
}
// 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.