blob: a6ee783b4a2d34a531a8fc47054f794bdf8cc09e [file] [log] [blame]
Andrew Geisslerc74716e2021-02-09 15:11:10 -06001#include "config.h"
2
3#include <hypervisor_state_manager.hpp>
4#include <sdbusplus/bus.hpp>
5#include <sdeventplus/event.hpp>
6
7#include <gtest/gtest.h>
8
9namespace server = sdbusplus::xyz::openbmc_project::State::server;
10
11TEST(updateCurrentHostState, BasicPaths)
12{
13 auto bus = sdbusplus::bus::new_default();
14 auto event = sdeventplus::Event::get_default();
15 bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
16 auto objPathInst = std::string{HYPERVISOR_OBJPATH} + '0';
17
18 phosphor::state::manager::Hypervisor hypObj(bus, objPathInst.c_str());
19
20 std::string bootProgress = "Invalid.Boot.Progress";
21 hypObj.updateCurrentHostState(bootProgress);
22 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Off);
23
24 bootProgress = "xyz.openbmc_project.State.Boot.Progress."
25 "ProgressStages.SystemInitComplete";
26 hypObj.updateCurrentHostState(bootProgress);
27 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Standby);
28
29 bootProgress = "xyz.openbmc_project.State.Boot.Progress."
30 "ProgressStages.OSStart";
31 hypObj.updateCurrentHostState(bootProgress);
32 EXPECT_EQ(hypObj.currentHostState(),
33 server::Host::HostState::TransitioningToRunning);
34
35 bootProgress = "xyz.openbmc_project.State.Boot.Progress."
36 "ProgressStages.OSRunning";
37 hypObj.updateCurrentHostState(bootProgress);
38 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Running);
39}