regulators: Add device_id to validation tool

Enhance the configuration file validation tool to verify that any
"device_id" properties refer to a valid device ID.  This property exists
in the new phase_fault_detection object.

Add the following new automated tests
* Test where phase_fault_detection object specifies an invalid rule_id
* Test where phase_fault_detection object specifies an invalid device_id

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I242ced0a2d0c4483d0dd7c4d36781a9f588a7e4f
diff --git a/phosphor-regulators/test/validate-regulators-config_tests.cpp b/phosphor-regulators/test/validate-regulators-config_tests.cpp
index 8faf6b8..18eef6f 100644
--- a/phosphor-regulators/test/validate-regulators-config_tests.cpp
+++ b/phosphor-regulators/test/validate-regulators-config_tests.cpp
@@ -3211,7 +3211,15 @@
     {
         json configFile = validConfigFile;
         configFile["chassis"][0]["devices"][0]["presence_detection"]
-                  ["rule_id"] = "set_voltage_rule2";
+                  ["rule_id"] = "detect_presence_rule2";
+        EXPECT_JSON_INVALID(configFile, "Error: Rule ID does not exist.", "");
+    }
+    // Invalid: test rule_id property in phase_fault_detection specifies a rule
+    // ID that does not exist.
+    {
+        json configFile = validConfigFile;
+        configFile["chassis"][0]["devices"][0]["phase_fault_detection"]
+                  ["rule_id"] = "detect_phase_faults_rule2";
         EXPECT_JSON_INVALID(configFile, "Error: Rule ID does not exist.", "");
     }
     // Invalid: test rule_id property in sensor_monitoring specifies a rule ID
@@ -3219,11 +3227,25 @@
     {
         json configFile = validConfigFile;
         configFile["chassis"][0]["devices"][0]["rails"][0]["sensor_monitoring"]
-                  ["rule_id"] = "set_voltage_rule2";
+                  ["rule_id"] = "read_sensors_rule2";
         EXPECT_JSON_INVALID(configFile, "Error: Rule ID does not exist.", "");
     }
 }
 
+TEST(ValidateRegulatorsConfigTest, DeviceIDExists)
+{
+    // Invalid: test device_id property in phase_fault_detection specifies a
+    // device ID that does not exist.
+    {
+        json configFile = validConfigFile;
+        configFile["chassis"][0]["devices"][0]["phase_fault_detection"]
+                  ["device_id"] = "vdd_regulator2";
+        configFile["chassis"][0]["devices"][0]["phase_fault_detection"]
+                  ["rule_id"] = "detect_phase_faults_rule";
+        EXPECT_JSON_INVALID(configFile, "Error: Device ID does not exist.", "");
+    }
+}
+
 TEST(ValidateRegulatorsConfigTest, NumberOfElementsInMasks)
 {
     // Invalid: test number of elements in masks not equal to number in values