blob: a3ac54055d89fbf9b1f71bbe6428fdf4566be348 [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
Patrick Williams7e969cb2023-08-23 16:24:23 -05009namespace server = sdbusplus::server::xyz::openbmc_project::state;
Andrew Geisslerc74716e2021-02-09 15:11:10 -060010
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."
Andrew Geisslerc74716e2021-02-09 15:11:10 -060030 "ProgressStages.OSRunning";
31 hypObj.updateCurrentHostState(bootProgress);
32 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Running);
Andrew Geissler75f38ee2021-02-10 13:50:21 -060033
34 bootProgress = "xyz.openbmc_project.State.Boot.Progress."
35 "ProgressStages.Unspecified";
36 hypObj.updateCurrentHostState(bootProgress);
37 EXPECT_EQ(hypObj.currentHostState(), server::Host::HostState::Off);
Andrew Geisslerc74716e2021-02-09 15:11:10 -060038}