blob: 660a7bda09142816b6f0d45f5659614af417bb22 [file] [log] [blame]
Stephan Pleinesb1177672024-05-27 17:48:32 -07001#include <memory>
2
Austin Schuh99f7c6a2024-06-25 22:07:44 -07003#include "absl/flags/flag.h"
Stephan Pleinesb1177672024-05-27 17:48:32 -07004#include "gtest/gtest.h"
5
6#include "aos/configuration.h"
7#include "aos/flatbuffers.h"
Milo Lin0ddb7782022-08-17 20:40:43 -07008#include "aos/json_to_flatbuffer.h"
Stephan Pleinesb1177672024-05-27 17:48:32 -07009#include "aos/util/config_validator_config_generated.h"
James Kuszmaul827bd212023-05-15 23:57:39 -070010#include "aos/util/config_validator_lib.h"
Milo Lin0ddb7782022-08-17 20:40:43 -070011
Austin Schuh99f7c6a2024-06-25 22:07:44 -070012ABSL_FLAG(std::string, config, "", "Name of the config file to replay using.");
13ABSL_FLAG(std::string, validation_config, "{}",
14 "JSON config to use to validate the config.");
Milo Lin0ddb7782022-08-17 20:40:43 -070015/* This binary is used to validate that all of the
16 needed remote timestamps channels are in the config
17 to log the timestamps.
18 Future versions of the validator will provide the option
19 to confirm that the timestamps in the config are able to
20 replay all of the data in the log
21 This can be done by getting a list of all of the nodes and
milind-uc6e437a2023-03-01 23:40:40 -080022 iterating through it with a for loop creating a logger for
23 each one
Milo Lin0ddb7782022-08-17 20:40:43 -070024 Reference superstructure_lib_test.cc*/
25TEST(ConfigValidatorTest, ReadConfig) {
Austin Schuh99f7c6a2024-06-25 22:07:44 -070026 ASSERT_TRUE(!absl::GetFlag(FLAGS_config).empty());
Milo Lin0ddb7782022-08-17 20:40:43 -070027 const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
Austin Schuh99f7c6a2024-06-25 22:07:44 -070028 aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
Milo Lin0ddb7782022-08-17 20:40:43 -070029
James Kuszmaul827bd212023-05-15 23:57:39 -070030 const aos::FlatbufferDetachedBuffer<aos::util::ConfigValidatorConfig>
31 validator_config =
32 aos::JsonToFlatbuffer<aos::util::ConfigValidatorConfig>(
Austin Schuh99f7c6a2024-06-25 22:07:44 -070033 absl::GetFlag(FLAGS_validation_config));
James Kuszmaul827bd212023-05-15 23:57:39 -070034 aos::util::ConfigIsValid(&config.message(), &validator_config.message());
Milo Lin0ddb7782022-08-17 20:40:43 -070035}
milind-uc6e437a2023-03-01 23:40:40 -080036
37// TODO(milind): add more tests, the above one doesn't
38// catch an error like forgetting to add a forwarded message to
39// the destination node's config.