regulators: Enhance config file parser

Enhance JSON config file parser to convert relative inventory paths to
absolute form.

Tested:
Run local CI with -Dlong-tests=enabled to enable tests for
validate-regulators-config.py.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I80237a673f9c5918898db15363847722141388e6
diff --git a/phosphor-regulators/test/validate-regulators-config_tests.cpp b/phosphor-regulators/test/validate-regulators-config_tests.cpp
index 42038d1..fb1a40e 100644
--- a/phosphor-regulators/test/validate-regulators-config_tests.cpp
+++ b/phosphor-regulators/test/validate-regulators-config_tests.cpp
@@ -80,7 +80,7 @@
               "comments": [ "IR35221 regulator producing the Vdd rail" ],
               "id": "vdd_regulator",
               "is_regulator": true,
-              "fru": "/system/chassis/motherboard/regulator1",
+              "fru": "system/chassis/motherboard/regulator1",
               "i2c_interface": {
                 "bus": 1,
                 "address": "0x70"
@@ -262,7 +262,7 @@
     {
         json configFile = validConfigFile;
         configFile["rules"][0]["actions"][1]["compare_presence"]["fru"] =
-            "/system/chassis/motherboard/regulator2";
+            "system/chassis/motherboard/regulator2";
         configFile["rules"][0]["actions"][1]["compare_presence"]["value"] =
             true;
         EXPECT_JSON_VALID(configFile);
@@ -271,7 +271,7 @@
     {
         json configFile = validConfigFile;
         configFile["rules"][0]["actions"][1]["compare_vpd"]["fru"] =
-            "/system/chassis/motherboard/regulator2";
+            "system/chassis/motherboard/regulator2";
         configFile["rules"][0]["actions"][1]["compare_vpd"]["keyword"] = "CCIN";
         configFile["rules"][0]["actions"][1]["compare_vpd"]["value"] = "2D35";
         EXPECT_JSON_VALID(configFile);
@@ -574,7 +574,7 @@
 {
     json comparePresenceFile = validConfigFile;
     comparePresenceFile["rules"][0]["actions"][1]["compare_presence"]["fru"] =
-        "/system/chassis/motherboard/regulator2";
+        "system/chassis/motherboard/regulator2";
     comparePresenceFile["rules"][0]["actions"][1]["compare_presence"]["value"] =
         true;
     // Valid.
@@ -627,7 +627,7 @@
 {
     json compareVpdFile = validConfigFile;
     compareVpdFile["rules"][0]["actions"][1]["compare_vpd"]["fru"] =
-        "/system/chassis/motherboard/regulator2";
+        "system/chassis/motherboard/regulator2";
     compareVpdFile["rules"][0]["actions"][1]["compare_vpd"]["keyword"] = "CCIN";
     compareVpdFile["rules"][0]["actions"][1]["compare_vpd"]["value"] = "2D35";
 
@@ -811,7 +811,7 @@
             "rule_id");
         configFile["chassis"][0]["devices"][0]["configuration"]["actions"][0]
                   ["compare_presence"]["fru"] =
-                      "/system/chassis/motherboard/cpu3";
+                      "system/chassis/motherboard/cpu3";
         configFile["chassis"][0]["devices"][0]["configuration"]["actions"][0]
                   ["compare_presence"]["value"] = true;
         EXPECT_JSON_VALID(configFile);
@@ -852,13 +852,13 @@
         json configFile = configurationFile;
         configFile["chassis"][0]["devices"][0]["configuration"]["actions"][0]
                   ["compare_presence"]["fru"] =
-                      "/system/chassis/motherboard/cpu3";
+                      "system/chassis/motherboard/cpu3";
         configFile["chassis"][0]["devices"][0]["configuration"]["actions"][0]
                   ["compare_presence"]["value"] = true;
         EXPECT_JSON_INVALID(
             configFile, "Validation failed.",
             "{'actions': [{'compare_presence': {'fru': "
-            "'/system/chassis/motherboard/cpu3', 'value': True}}], 'comments': "
+            "'system/chassis/motherboard/cpu3', 'value': True}}], 'comments': "
             "['Set rail to 1.25V using standard rule'], 'rule_id': "
             "'set_voltage_rule', 'volts': 1.25} is valid under each of "
             "{'required': ['actions']}, {'required': ['rule_id']}");
@@ -2284,7 +2284,7 @@
             "rule_id");
         configFile["chassis"][0]["devices"][0]["presence_detection"]["actions"]
                   [0]["compare_presence"]["fru"] =
-                      "/system/chassis/motherboard/cpu3";
+                      "system/chassis/motherboard/cpu3";
         configFile["chassis"][0]["devices"][0]["presence_detection"]["actions"]
                   [0]["compare_presence"]["value"] = true;
         configFile["chassis"][0]["devices"][0]["presence_detection"].erase(
@@ -2296,13 +2296,13 @@
         json configFile = presenceDetectionFile;
         configFile["chassis"][0]["devices"][0]["presence_detection"]["actions"]
                   [0]["compare_presence"]["fru"] =
-                      "/system/chassis/motherboard/cpu3";
+                      "system/chassis/motherboard/cpu3";
         configFile["chassis"][0]["devices"][0]["presence_detection"]["actions"]
                   [0]["compare_presence"]["value"] = true;
         EXPECT_JSON_INVALID(
             configFile, "Validation failed.",
             "{'actions': [{'compare_presence': {'fru': "
-            "'/system/chassis/motherboard/cpu3', 'value': True}}], 'comments': "
+            "'system/chassis/motherboard/cpu3', 'value': True}}], 'comments': "
             "['Regulator is only present on the FooBar backplane'], 'rule_id': "
             "'set_voltage_rule'} is valid under each of {'required': "
             "['actions']}, {'required': ['rule_id']}");
@@ -2564,7 +2564,7 @@
             .erase("rule_id");
         configFile["chassis"][0]["devices"][0]["rails"][0]["sensor_monitoring"]
                   ["actions"][0]["compare_presence"]["fru"] =
-                      "/system/chassis/motherboard/cpu3";
+                      "system/chassis/motherboard/cpu3";
         configFile["chassis"][0]["devices"][0]["rails"][0]["sensor_monitoring"]
                   ["actions"][0]["compare_presence"]["value"] = true;
         configFile["chassis"][0]["devices"][0]["rails"][0]["sensor_monitoring"]
@@ -2577,13 +2577,13 @@
         json configFile = validConfigFile;
         configFile["chassis"][0]["devices"][0]["rails"][0]["sensor_monitoring"]
                   ["actions"][0]["compare_presence"]["fru"] =
-                      "/system/chassis/motherboard/cpu3";
+                      "system/chassis/motherboard/cpu3";
         configFile["chassis"][0]["devices"][0]["rails"][0]["sensor_monitoring"]
                   ["actions"][0]["compare_presence"]["value"] = true;
         EXPECT_JSON_INVALID(
             configFile, "Validation failed.",
             "{'actions': [{'compare_presence': {'fru': "
-            "'/system/chassis/motherboard/cpu3', 'value': True}}], 'rule_id': "
+            "'system/chassis/motherboard/cpu3', 'value': True}}], 'rule_id': "
             "'read_sensors_rule'} is valid under each of {'required': "
             "['actions']}, {'required': ['rule_id']}");
     }
@@ -2700,7 +2700,7 @@
         configFile["chassis"][0]["devices"][1]["id"] = "vdd_regulator";
         configFile["chassis"][0]["devices"][1]["is_regulator"] = true;
         configFile["chassis"][0]["devices"][1]["fru"] =
-            "/system/chassis/motherboard/regulator1";
+            "system/chassis/motherboard/regulator1";
         configFile["chassis"][0]["devices"][1]["i2c_interface"]["bus"] = 2;
         configFile["chassis"][0]["devices"][1]["i2c_interface"]["address"] =
             "0x71";