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::server::xyz::openbmc_project::state; 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.OSRunning"; 31 hypObj.updateCurrentHostState(bootProgress); 32 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Running); 33 34 bootProgress = "xyz.openbmc_project.State.Boot.Progress." 35 "ProgressStages.Unspecified"; 36 hypObj.updateCurrentHostState(bootProgress); 37 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Off); 38 } 39