blob: 3041bc27ee2407b601f260086b18dad50384efbe [file] [log] [blame]
Matt Spinler0d92b522021-06-16 13:28:17 -06001#include "extensions/openpower-pels/data_interface.hpp"
2
3#include <gtest/gtest.h>
4
5using namespace openpower::pels;
6
7TEST(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}
George Liu9ac0d9b2022-07-15 10:57:38 +080025
26TEST(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}