1 #include "extensions/openpower-pels/data_interface.hpp" 2 3 #include <gtest/gtest.h> 4 5 using namespace openpower::pels; 6 7 TEST(DataInterfaceTest, ExtractConnectorLocCode) 8 { 9 { 10 auto [base, connector] = 11 DataInterface::extractConnectorFromLocCode("Ufcs-P0-C2-T11"); 12 13 EXPECT_EQ(base, "Ufcs-P0-C2"); 14 EXPECT_EQ(connector, "-T11"); 15 } 16 17 { 18 auto [base, connector] = 19 DataInterface::extractConnectorFromLocCode("Ufcs-P0-C2"); 20 21 EXPECT_EQ(base, "Ufcs-P0-C2"); 22 EXPECT_TRUE(connector.empty()); 23 } 24 } 25 26 TEST(DataInterfaceTest, ExtractUptime) 27 { 28 uint64_t seconds = 123456789; 29 std::string retUptime = "3y 332d 21h 33m 9s"; 30 31 auto bus = sdbusplus::bus::new_default(); 32 DataInterface dataIntf(bus); 33 std::string uptime = dataIntf.getBMCUptime(seconds); 34 35 EXPECT_EQ(uptime, retUptime); 36 } 37