regulators: Add test cases for object 'set_device'.
*Valid: test set_device.
*Invalid: test set_device wrong type.
*Invalid: test set_device wrong format.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: Iaaa038f880100406a09abfb3f6a2ac9328e8a002
diff --git a/phosphor-regulators/test/validate-regulators-config_tests.cpp b/phosphor-regulators/test/validate-regulators-config_tests.cpp
index 41b991f..8aeeaef 100644
--- a/phosphor-regulators/test/validate-regulators-config_tests.cpp
+++ b/phosphor-regulators/test/validate-regulators-config_tests.cpp
@@ -1238,3 +1238,28 @@
"u'set_voltage_rule%' does not match u'^[A-Za-z0-9_]+$'");
}
}
+TEST(ValidateRegulatorsConfigTest, SetDevice)
+{
+ json setDeviceFile = validConfigFile;
+ setDeviceFile["rules"][0]["actions"][1]["set_device"] = "io_expander2";
+ // Valid: test set_device.
+ {
+ json configFile = setDeviceFile;
+ EXPECT_JSON_VALID(configFile);
+ }
+ // Invalid: test set_device wrong type.
+ {
+ json configFile = setDeviceFile;
+ configFile["rules"][0]["actions"][1]["set_device"] = true;
+ EXPECT_JSON_INVALID(configFile, "Validation failed.",
+ "True is not of type u'string'");
+ }
+ // Invalid: test set_device wrong format.
+ {
+ json configFile = setDeviceFile;
+ configFile["rules"][0]["actions"][1]["set_device"] = "io_expander2%";
+ EXPECT_JSON_INVALID(
+ configFile, "Validation failed.",
+ "u'io_expander2%' does not match u'^[A-Za-z0-9_]+$'");
+ }
+}