regulators: Add phase fault detection to schema
Add the following new JSON objects to the configuration file schema:
* i2c_capture_bytes
* log_phase_fault
* phase_fault_detection
Add new automated tests to verify the schema additions.
Also make the following enhancements to the automated schema tests:
* Add presence_detection rule to sample JSON
* Modify the function called by EXPECT_JSON_INVALID(). Support passing
an empty string as the expected first line written to stdout. This
value means the stdout line should be ignored. This helps in cases
where the output from jsonschema is very long, cryptic, and/or
dependent on the jsonschema version.
* Added a blank line between TEST functions to improve readability.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ie1dac1b9b2edaf055266c8b7868e017a57dda5fc
diff --git a/phosphor-regulators/schema/config_schema.json b/phosphor-regulators/schema/config_schema.json
index d18da6d..29a0e4d 100644
--- a/phosphor-regulators/schema/config_schema.json
+++ b/phosphor-regulators/schema/config_schema.json
@@ -56,6 +56,7 @@
"and": {"$ref": "#/definitions/actions" },
"compare_presence": {"$ref": "#/definitions/compare_presence" },
"compare_vpd": {"$ref": "#/definitions/compare_vpd" },
+ "i2c_capture_bytes": {"$ref": "#/definitions/i2c_capture_bytes" },
"i2c_compare_bit": {"$ref": "#/definitions/i2c_bit" },
"i2c_compare_byte": {"$ref": "#/definitions/i2c_byte" },
"i2c_compare_bytes": {"$ref": "#/definitions/i2c_bytes" },
@@ -63,6 +64,7 @@
"i2c_write_byte": {"$ref": "#/definitions/i2c_byte" },
"i2c_write_bytes": {"$ref": "#/definitions/i2c_bytes" },
"if": {"$ref": "#/definitions/if" },
+ "log_phase_fault": {"$ref": "#/definitions/log_phase_fault" },
"not": {"$ref": "#/definitions/action" },
"or": {"$ref": "#/definitions/actions" },
"pmbus_read_sensor": {"$ref": "#/definitions/pmbus_read_sensor" },
@@ -75,6 +77,7 @@
{"required": ["and"]},
{"required": ["compare_presence"]},
{"required": ["compare_vpd"]},
+ {"required": ["i2c_capture_bytes"]},
{"required": ["i2c_compare_bit"]},
{"required": ["i2c_compare_byte"]},
{"required": ["i2c_compare_bytes"]},
@@ -82,6 +85,7 @@
{"required": ["i2c_write_byte"]},
{"required": ["i2c_write_bytes"]},
{"required": ["if"]},
+ {"required": ["log_phase_fault"]},
{"required": ["not"]},
{"required": ["or"]},
{"required": ["pmbus_write_vout_command"]},
@@ -150,6 +154,18 @@
"type": "string"
},
+ "i2c_capture_bytes":
+ {
+ "type": "object",
+ "properties":
+ {
+ "register": {"$ref": "#/definitions/register" },
+ "count": {"$ref": "#/definitions/byte_count" }
+ },
+ "required": ["register", "count"],
+ "additionalProperties": false
+ },
+
"i2c_bit":
{
"type": "object",
@@ -208,6 +224,12 @@
"pattern": "^0x[0-9A-Fa-f]{2}$"
},
+ "byte_count":
+ {
+ "type": "integer",
+ "minimum": 1
+ },
+
"i2c_bytes":
{
"type": "object",
@@ -248,6 +270,23 @@
"additionalProperties": false
},
+ "log_phase_fault":
+ {
+ "type": "object",
+ "properties":
+ {
+ "type": {"$ref": "#/definitions/phase_fault_type" }
+ },
+ "required": ["type"],
+ "additionalProperties": false
+ },
+
+ "phase_fault_type":
+ {
+ "type": "string",
+ "enum": ["n+1", "n"]
+ },
+
"pmbus_write_vout_command":
{
"type": "object",
@@ -354,6 +393,7 @@
"i2c_interface": {"$ref": "#/definitions/i2c_interface" },
"presence_detection": {"$ref": "#/definitions/presence_detection" },
"configuration": {"$ref": "#/definitions/configuration" },
+ "phase_fault_detection": {"$ref": "#/definitions/phase_fault_detection" },
"rails": {"$ref": "#/definitions/rails" }
},
"required": ["id", "is_regulator", "fru", "i2c_interface"],
@@ -363,7 +403,12 @@
},
"then":
{
- "not" : { "required" : ["rails"] }
+ "not": {
+ "anyOf": [
+ { "required": ["phase_fault_detection"] },
+ { "required": ["rails"] }
+ ]
+ }
},
"additionalProperties": false
},
@@ -437,6 +482,23 @@
]
},
+ "phase_fault_detection":
+ {
+ "type": "object",
+ "properties":
+ {
+ "comments": {"$ref": "#/definitions/comments" },
+ "device_id": {"$ref": "#/definitions/id" },
+ "rule_id": {"$ref": "#/definitions/id" },
+ "actions": {"$ref": "#/definitions/actions" }
+ },
+ "additionalProperties": false,
+ "oneOf": [
+ {"required": ["rule_id"]},
+ {"required": ["actions"]}
+ ]
+ },
+
"rail":
{
"type": "object",