blob: 9136c83717e28e1a0c3c723670101c3c2e0bf842 [file] [log] [blame]
#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);
bootProgress = "xyz.openbmc_project.State.Boot.Progress."
"ProgressStages.Unspecified";
hypObj.updateCurrentHostState(bootProgress);
EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Off);
}