blob: 16861c6cd23a52d7884f35975895a573dc8112b9 [file] [log] [blame]
James Kuszmaul827bd212023-05-15 23:57:39 -07001def config_validator_rule(name, config, logger_sets = [{}], check_for_not_logged_channels = False, extension = ".bfbs", visibility = None):
Milo Lin0ddb7782022-08-17 20:40:43 -07002 '''
3 Macro to take a config and pass it to the config validator to validate that it will work on a real system.
4
5 Currently just checks that the system can startup, but will check that timestamp channels are properly logged in the future.
6
7 Args:
8 name: name that the config validator uses, e.g. "test_config",
9 config: config rule that needs to be validated, e.g. "//aos/events:pingpong_config",
10 '''
milind-uc6e437a2023-03-01 23:40:40 -080011 config_file = config + extension
James Kuszmaul827bd212023-05-15 23:57:39 -070012 config_json = json.encode({"logging": {"all_channels_logged": check_for_not_logged_channels, "logger_sets": logger_sets}})
Milo Lin0ddb7782022-08-17 20:40:43 -070013 native.genrule(
14 name = name,
15 outs = [name + ".txt"],
James Kuszmaul827bd212023-05-15 23:57:39 -070016 cmd = "$(location //aos/util:config_validator) --config $(location %s) --validation_config='%s' && touch $@" % (config_file, config_json),
milind-uc6e437a2023-03-01 23:40:40 -080017 srcs = [config_file],
Milo Lin0ddb7782022-08-17 20:40:43 -070018 tools = ["//aos/util:config_validator"],
19 testonly = True,
20 visibility = visibility,
21 )