hypervisor: monitor boot progress

The BootProgress property will be tracked to set the hypervisor state as
appropriate

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I5aa5d95893222169bc5abed6b851e795f2ad5ff0
diff --git a/test/hypervisor_state.cpp b/test/hypervisor_state.cpp
new file mode 100644
index 0000000..a6ee783
--- /dev/null
+++ b/test/hypervisor_state.cpp
@@ -0,0 +1,39 @@
+#include "config.h"
+
+#include <hypervisor_state_manager.hpp>
+#include <sdbusplus/bus.hpp>
+#include <sdeventplus/event.hpp>
+
+#include <gtest/gtest.h>
+
+namespace server = sdbusplus::xyz::openbmc_project::State::server;
+
+TEST(updateCurrentHostState, BasicPaths)
+{
+    auto bus = sdbusplus::bus::new_default();
+    auto event = sdeventplus::Event::get_default();
+    bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
+    auto objPathInst = std::string{HYPERVISOR_OBJPATH} + '0';
+
+    phosphor::state::manager::Hypervisor hypObj(bus, objPathInst.c_str());
+
+    std::string bootProgress = "Invalid.Boot.Progress";
+    hypObj.updateCurrentHostState(bootProgress);
+    EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Off);
+
+    bootProgress = "xyz.openbmc_project.State.Boot.Progress."
+                   "ProgressStages.SystemInitComplete";
+    hypObj.updateCurrentHostState(bootProgress);
+    EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Standby);
+
+    bootProgress = "xyz.openbmc_project.State.Boot.Progress."
+                   "ProgressStages.OSStart";
+    hypObj.updateCurrentHostState(bootProgress);
+    EXPECT_EQ(hypObj.currentHostState(),
+              server::Host::HostState::TransitioningToRunning);
+
+    bootProgress = "xyz.openbmc_project.State.Boot.Progress."
+                   "ProgressStages.OSRunning";
+    hypObj.updateCurrentHostState(bootProgress);
+    EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Running);
+}