Intialize new phosphor-time-manager

phosphor-time-manager will be refactored to use sdbusplus interfaces.
This is a initial commit that EpochBase is implemented based on dbus
interface xyz/openbmc_project/Time/EpochTime.interface.yaml.

EpochBase is the base class that wraps EpochTime interface, and is
initialized with time mode and owner from settingsd.

An initial unit test case is added.

Change-Id: Ic944b70f63ec3c0329762cc8874f0f57b09ddce3
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/test/TestEpochBase.cpp b/test/TestEpochBase.cpp
new file mode 100644
index 0000000..c3ca7e1
--- /dev/null
+++ b/test/TestEpochBase.cpp
@@ -0,0 +1,64 @@
+#include <sdbusplus/bus.hpp>
+#include <gtest/gtest.h>
+
+#include "epoch_base.hpp"
+
+namespace phosphor
+{
+namespace time
+{
+
+class TestEpochBase : public testing::Test
+{
+    public:
+        using Mode = EpochBase::Mode;
+        using Owner = EpochBase::Owner;
+
+        sdbusplus::bus::bus bus;
+        EpochBase epochBase;
+
+        TestEpochBase()
+            : bus(sdbusplus::bus::new_default()),
+              epochBase(bus, "")
+        {
+            // Empty
+        }
+
+        // Proxies for EpochBase's private members and functions
+        Mode convertToMode(const std::string& mode)
+        {
+            return EpochBase::convertToMode(mode);
+        }
+        Owner convertToOwner(const std::string& owner)
+        {
+            return EpochBase::convertToOwner(owner);
+        }
+};
+
+TEST_F(TestEpochBase, convertToMode)
+{
+    EXPECT_EQ(Mode::NTP, convertToMode("NTP"));
+    EXPECT_EQ(Mode::MANUAL, convertToMode("MANUAL"));
+
+    // All unrecognized strings are mapped to Ntp
+    EXPECT_EQ(Mode::NTP, convertToMode(""));
+    EXPECT_EQ(Mode::NTP, convertToMode("Manual"));
+    EXPECT_EQ(Mode::NTP, convertToMode("whatever"));
+}
+
+
+TEST_F(TestEpochBase, convertToOwner)
+{
+    EXPECT_EQ(Owner::BMC, convertToOwner("BMC"));
+    EXPECT_EQ(Owner::HOST, convertToOwner("HOST"));
+    EXPECT_EQ(Owner::SPLIT, convertToOwner("SPLIT"));
+    EXPECT_EQ(Owner::BOTH, convertToOwner("BOTH"));
+
+    // All unrecognized strings are mapped to Bmc
+    EXPECT_EQ(Owner::BMC, convertToOwner(""));
+    EXPECT_EQ(Owner::BMC, convertToOwner("Split"));
+    EXPECT_EQ(Owner::BMC, convertToOwner("xyz"));
+}
+
+}
+}