PEL: Use the real system names property

There is now a 'Names' property on the new
xyz.openbmc_project.Configuration.IBMCompatibleSystem interface that the
DataInterface::getSystemNames function will read.  The existing code was
mostly a placeholder until the actual interface showed up on D-Bus.

Since the path that holds the interface is system specific, and the PEL
code should only rarely need this, the code was changed to read it on
demand instead of at caching it startup.

Since getSystemNames() no longer returns a cached value, the signature
was changed slightly to remove the reference from the returned
std::vector<std::string> value.

The UserHeader constructor used to make a call to getSystemNames every
time, and that was changed to only call it when actually necessary,
which is when there is a severity value defined in the message registry
that depends on the system name.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1d4f307ef38287b631f94dae2b8929307d129029
diff --git a/test/openpower-pels/mocks.hpp b/test/openpower-pels/mocks.hpp
index e9d9fdf..510974c 100644
--- a/test/openpower-pels/mocks.hpp
+++ b/test/openpower-pels/mocks.hpp
@@ -34,8 +34,7 @@
                 (const override));
     MOCK_METHOD(std::string, getLocationCode, (const std::string&),
                 (const override));
-    MOCK_METHOD(const std::vector<std::string>&, getSystemNames, (),
-                (const override));
+    MOCK_METHOD(std::vector<std::string>, getSystemNames, (), (const override));
     MOCK_METHOD(std::string, expandLocationCode, (const std::string&, uint16_t),
                 (const override));
     MOCK_METHOD(std::string, getInventoryFromLocCode,
diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp
index 2247a71..3112a16 100644
--- a/test/openpower-pels/pel_manager_test.cpp
+++ b/test/openpower-pels/pel_manager_test.cpp
@@ -30,7 +30,6 @@
 
 using ::testing::NiceMock;
 using ::testing::Return;
-using ::testing::ReturnRef;
 
 class TestLogger
 {
@@ -883,7 +882,7 @@
         std::vector<std::string> names{"systemA"};
         EXPECT_CALL(*mockIface, getSystemNames)
             .Times(1)
-            .WillOnce(ReturnRef(names));
+            .WillOnce(Return(names));
 
         EXPECT_CALL(*mockIface, expandLocationCode("P42-C23", 0))
             .WillOnce(Return("U42-P42-C23"));
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index e1697ac..3631b50 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -29,7 +29,6 @@
 using ::testing::_;
 using ::testing::NiceMock;
 using ::testing::Return;
-using ::testing::ReturnRef;
 using ::testing::SetArgReferee;
 
 class PELTest : public CleanLogID
@@ -823,7 +822,7 @@
     std::vector<std::string> names{"systemA"};
     EXPECT_CALL(dataIface, getSystemNames)
         .Times(2)
-        .WillRepeatedly(ReturnRef(names));
+        .WillRepeatedly(Return(names));
 
     EXPECT_CALL(dataIface,
                 getLocationCode(
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index f439bfc..1f0db2a 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -26,7 +26,6 @@
 using ::testing::InvokeWithoutArgs;
 using ::testing::NiceMock;
 using ::testing::Return;
-using ::testing::ReturnRef;
 using ::testing::SetArgReferee;
 using ::testing::Throw;
 namespace fs = std::filesystem;
@@ -537,7 +536,7 @@
         NiceMock<MockDataInterface> dataIface;
         std::vector<std::string> names{"systemA"};
 
-        EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
+        EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
 
         SRC src{entry, ad, dataIface};
 
@@ -574,7 +573,7 @@
         std::vector<std::string> names{"systemB"};
 
         EXPECT_CALL(dataIface, expandLocationCode).WillOnce(Return("P0-C8"));
-        EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
+        EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
 
         SRC src{entry, ad, dataIface};
 
@@ -611,7 +610,7 @@
         NiceMock<MockDataInterface> dataIface;
         std::vector<std::string> names{"systemC"};
 
-        EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
+        EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
 
         EXPECT_CALL(dataIface, expandLocationCode("P0-C8", 0))
             .WillOnce(Return("UXXX-P0-C8"));
@@ -707,7 +706,7 @@
         NiceMock<MockDataInterface> dataIface;
         std::vector<std::string> names{"systemA"};
 
-        EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
+        EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
 
         EXPECT_CALL(dataIface, getLocationCode("motherboard"))
             .Times(1)
@@ -760,7 +759,7 @@
         NiceMock<MockDataInterface> dataIface;
         std::vector<std::string> names{"systemA"};
 
-        EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
+        EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
 
         SRC src{entry, ad, dataIface};
 
@@ -825,7 +824,7 @@
 
     EXPECT_CALL(dataIface, getSystemNames)
         .Times(5)
-        .WillRepeatedly(ReturnRef(names));
+        .WillRepeatedly(Return(names));
 
     EXPECT_CALL(dataIface, getInventoryFromLocCode("P1-C40", 0, false))
         .Times(3)
diff --git a/test/openpower-pels/user_header_test.cpp b/test/openpower-pels/user_header_test.cpp
index 526a59e..b7b6583 100644
--- a/test/openpower-pels/user_header_test.cpp
+++ b/test/openpower-pels/user_header_test.cpp
@@ -24,7 +24,6 @@
 
 using namespace openpower::pels;
 using ::testing::Return;
-using ::testing::ReturnRef;
 
 TEST(UserHeaderTest, SizeTest)
 {
@@ -113,9 +112,6 @@
         regEntry.eventScope = 2;
 
         MockDataInterface dataIface;
-        std::vector<std::string> names{"systemA"};
-
-        EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
 
         UserHeader uh(regEntry, phosphor::logging::Entry::Level::Error,
                       dataIface);
@@ -140,8 +136,6 @@
             // The same thing, but as if the action flags weren't specified
             // in the registry so they are a nullopt.  The object should
             // then set them to 0xFFFF.
-            EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
-
             regEntry.actionFlags = std::nullopt;
 
             UserHeader uh(regEntry, phosphor::logging::Entry::Level::Error,
@@ -164,9 +158,9 @@
         std::vector<std::string> names3{"systemC"};
 
         EXPECT_CALL(dataIface, getSystemNames)
-            .WillOnce(ReturnRef(names1))
-            .WillOnce(ReturnRef(names2))
-            .WillOnce(ReturnRef(names3));
+            .WillOnce(Return(names1))
+            .WillOnce(Return(names2))
+            .WillOnce(Return(names3));
 
         {
             UserHeader uh(regEntry, phosphor::logging::Entry::Level::Error,
@@ -224,9 +218,6 @@
 
     MockDataInterface dataIface;
 
-    std::vector<std::string> names{"systemA"};
-    EXPECT_CALL(dataIface, getSystemNames).WillOnce(ReturnRef(names));
-
     UserHeader uh(regEntry, phosphor::logging::Entry::Level::Error, dataIface);
 
     ASSERT_EQ(uh.eventType(), 0);