Stephan Pleines | b117767 | 2024-05-27 17:48:32 -0700 | [diff] [blame] | 1 | #include <memory> |
| 2 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 3 | #include "absl/flags/flag.h" |
Stephan Pleines | b117767 | 2024-05-27 17:48:32 -0700 | [diff] [blame] | 4 | #include "gtest/gtest.h" |
| 5 | |
| 6 | #include "aos/configuration.h" |
| 7 | #include "aos/flatbuffers.h" |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 8 | #include "aos/json_to_flatbuffer.h" |
Stephan Pleines | b117767 | 2024-05-27 17:48:32 -0700 | [diff] [blame] | 9 | #include "aos/util/config_validator_config_generated.h" |
James Kuszmaul | 827bd21 | 2023-05-15 23:57:39 -0700 | [diff] [blame] | 10 | #include "aos/util/config_validator_lib.h" |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 11 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 12 | ABSL_FLAG(std::string, config, "", "Name of the config file to replay using."); |
| 13 | ABSL_FLAG(std::string, validation_config, "{}", |
| 14 | "JSON config to use to validate the config."); |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 15 | /* 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-u | c6e437a | 2023-03-01 23:40:40 -0800 | [diff] [blame] | 22 | iterating through it with a for loop creating a logger for |
| 23 | each one |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 24 | Reference superstructure_lib_test.cc*/ |
| 25 | TEST(ConfigValidatorTest, ReadConfig) { |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 26 | ASSERT_TRUE(!absl::GetFlag(FLAGS_config).empty()); |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 27 | const aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 28 | aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config)); |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 29 | |
James Kuszmaul | 827bd21 | 2023-05-15 23:57:39 -0700 | [diff] [blame] | 30 | const aos::FlatbufferDetachedBuffer<aos::util::ConfigValidatorConfig> |
| 31 | validator_config = |
| 32 | aos::JsonToFlatbuffer<aos::util::ConfigValidatorConfig>( |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 33 | absl::GetFlag(FLAGS_validation_config)); |
James Kuszmaul | 827bd21 | 2023-05-15 23:57:39 -0700 | [diff] [blame] | 34 | aos::util::ConfigIsValid(&config.message(), &validator_config.message()); |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 35 | } |
milind-u | c6e437a | 2023-03-01 23:40:40 -0800 | [diff] [blame] | 36 | |
| 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. |