Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame^] | 1 | #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 | |
| 9 | namespace server = sdbusplus::xyz::openbmc_project::State::server; |
| 10 | |
| 11 | TEST(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 | } |