regulators: Add configure support to System class

Implemented the configure() method in the System class.  This method
configures the regulator devices in all chassis in the system.

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ie78aeb2b44bcb60da74f641743af34911cc13dd6
diff --git a/phosphor-regulators/src/system.cpp b/phosphor-regulators/src/system.cpp
index edaa1ed..57df6ef 100644
--- a/phosphor-regulators/src/system.cpp
+++ b/phosphor-regulators/src/system.cpp
@@ -34,4 +34,13 @@
     }
 }
 
+void System::configure()
+{
+    // Configure devices in each chassis
+    for (std::unique_ptr<Chassis>& oneChassis : chassis)
+    {
+        oneChassis->configure(*this);
+    }
+}
+
 } // namespace phosphor::power::regulators
diff --git a/phosphor-regulators/src/system.hpp b/phosphor-regulators/src/system.hpp
index b0346ac..16e55b4 100644
--- a/phosphor-regulators/src/system.hpp
+++ b/phosphor-regulators/src/system.hpp
@@ -60,6 +60,14 @@
     }
 
     /**
+     * Configure the regulator devices in the system.
+     *
+     * This method should be called during the boot before regulators are
+     * enabled.
+     */
+    void configure();
+
+    /**
      * Returns the chassis in the system.
      *
      * @return chassis
diff --git a/phosphor-regulators/test/system_tests.cpp b/phosphor-regulators/test/system_tests.cpp
index 0e5b8db..85a1da6 100644
--- a/phosphor-regulators/test/system_tests.cpp
+++ b/phosphor-regulators/test/system_tests.cpp
@@ -16,6 +16,8 @@
 #include "chassis.hpp"
 #include "device.hpp"
 #include "id_map.hpp"
+#include "journal.hpp"
+#include "mock_journal.hpp"
 #include "rail.hpp"
 #include "rule.hpp"
 #include "system.hpp"
@@ -23,6 +25,7 @@
 
 #include <memory>
 #include <stdexcept>
+#include <string>
 #include <utility>
 #include <vector>
 
@@ -55,6 +58,29 @@
     EXPECT_EQ(system.getRules()[0]->getID(), "set_voltage_rule");
 }
 
+TEST(SystemTests, Configure)
+{
+    // Specify an empty rules vector
+    std::vector<std::unique_ptr<Rule>> rules{};
+
+    // Create Chassis
+    std::vector<std::unique_ptr<Chassis>> chassis{};
+    chassis.emplace_back(std::make_unique<Chassis>(1));
+    chassis.emplace_back(std::make_unique<Chassis>(3));
+
+    // Create System
+    System system{std::move(rules), std::move(chassis)};
+
+    // Call configure()
+    journal::clear();
+    system.configure();
+    EXPECT_EQ(journal::getDebugMessages().size(), 0);
+    EXPECT_EQ(journal::getErrMessages().size(), 0);
+    std::vector<std::string> expectedInfoMessages{"Configuring chassis 1",
+                                                  "Configuring chassis 3"};
+    EXPECT_EQ(journal::getInfoMessages(), expectedInfoMessages);
+}
+
 TEST(SystemTests, GetChassis)
 {
     // Specify an empty rules vector