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