blob: 0ee10189584660259640341f6a4ec80c90de492d [file] [log] [blame]
Stephan Pleinesb1177672024-05-27 17:48:32 -07001#include <memory>
2
3#include "gflags/gflags.h"
4#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
milind-uc6e437a2023-03-01 23:40:40 -080012DEFINE_string(config, "", "Name of the config file to replay using.");
James Kuszmaul827bd212023-05-15 23:57:39 -070013DEFINE_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) {
26 ASSERT_TRUE(!FLAGS_config.empty());
27 const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
28 aos::configuration::ReadConfig(FLAGS_config);
29
James Kuszmaul827bd212023-05-15 23:57:39 -070030 const aos::FlatbufferDetachedBuffer<aos::util::ConfigValidatorConfig>
31 validator_config =
32 aos::JsonToFlatbuffer<aos::util::ConfigValidatorConfig>(
33 FLAGS_validation_config);
34 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.