James Kuszmaul | 827bd21 | 2023-05-15 23:57:39 -0700 | [diff] [blame^] | 1 | def config_validator_rule(name, config, logger_sets = [{}], check_for_not_logged_channels = False, extension = ".bfbs", visibility = None): |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 2 | ''' |
| 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-u | c6e437a | 2023-03-01 23:40:40 -0800 | [diff] [blame] | 11 | config_file = config + extension |
James Kuszmaul | 827bd21 | 2023-05-15 23:57:39 -0700 | [diff] [blame^] | 12 | config_json = json.encode({"logging": {"all_channels_logged": check_for_not_logged_channels, "logger_sets": logger_sets}}) |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 13 | native.genrule( |
| 14 | name = name, |
| 15 | outs = [name + ".txt"], |
James Kuszmaul | 827bd21 | 2023-05-15 23:57:39 -0700 | [diff] [blame^] | 16 | cmd = "$(location //aos/util:config_validator) --config $(location %s) --validation_config='%s' && touch $@" % (config_file, config_json), |
milind-u | c6e437a | 2023-03-01 23:40:40 -0800 | [diff] [blame] | 17 | srcs = [config_file], |
Milo Lin | 0ddb778 | 2022-08-17 20:40:43 -0700 | [diff] [blame] | 18 | tools = ["//aos/util:config_validator"], |
| 19 | testonly = True, |
| 20 | visibility = visibility, |
| 21 | ) |