1 #include "json-parser.hpp"
2
3 #include <gtest/gtest.h>
4
TEST(loadJsonConfig,testGoodPath)5 TEST(loadJsonConfig, testGoodPath)
6 {
7 static constexpr auto jsonPath = "config/led-group-config.json";
8 auto ledMap = loadJsonConfig(jsonPath);
9
10 std::string objPath = "/xyz/openbmc_project/led/groups";
11 std::string bmcBooted = objPath + "/bmc_booted";
12 std::string powerOn = objPath + "/power_on";
13 std::string powerOff = objPath + "/power_off";
14 std::string enclosureIdentify = objPath + "/enclosure_identify";
15
16 ASSERT_EQ(ledMap.contains(bmcBooted), true);
17 ASSERT_EQ(ledMap.contains(powerOn), true);
18 ASSERT_EQ(ledMap.contains(powerOff), true);
19 ASSERT_EQ(ledMap.contains(enclosureIdentify), true);
20
21 auto& bmcBootedActions = ledMap.at(bmcBooted).actionSet;
22 auto& powerOnActions = ledMap.at(powerOn).actionSet;
23 auto& powerOffActions = ledMap.at(powerOff).actionSet;
24 auto& enclosureIdentifyActions = ledMap.at(enclosureIdentify).actionSet;
25
26 for (const auto& group : bmcBootedActions)
27 {
28 ASSERT_EQ(group.name, "heartbeat");
29 ASSERT_EQ(group.action, phosphor::led::Layout::Action::On);
30 ASSERT_EQ(group.dutyOn, 50);
31 ASSERT_EQ(group.period, 0);
32 ASSERT_EQ(group.priority, phosphor::led::Layout::Action::Blink);
33 }
34
35 for (const auto& group : powerOnActions)
36 {
37 ASSERT_EQ(group.name, "power");
38 ASSERT_EQ(group.action, phosphor::led::Layout::Action::On);
39 ASSERT_EQ(group.dutyOn, 50);
40 ASSERT_EQ(group.period, 0);
41 ASSERT_EQ(group.priority, phosphor::led::Layout::Action::On);
42 }
43 for (const auto& group : powerOffActions)
44 {
45 ASSERT_EQ(group.name, "power_off_led");
46 ASSERT_EQ(group.action, phosphor::led::Layout::Action::Off);
47 ASSERT_EQ(group.priority, phosphor::led::Layout::Action::Off);
48 }
49
50 for (const auto& group : enclosureIdentifyActions)
51 {
52 if (group.name == "front_id")
53 {
54 ASSERT_EQ(group.action, phosphor::led::Layout::Action::Blink);
55 ASSERT_EQ(group.dutyOn, 50);
56 ASSERT_EQ(group.period, 1000);
57 ASSERT_EQ(group.priority, phosphor::led::Layout::Action::Blink);
58 }
59 else if (group.name == "rear_id")
60 {
61 ASSERT_EQ(group.action, phosphor::led::Layout::Action::Blink);
62 ASSERT_EQ(group.dutyOn, 50);
63 ASSERT_EQ(group.period, 1000);
64 ASSERT_EQ(group.priority, phosphor::led::Layout::Action::Blink);
65 }
66 else
67 {
68 ASSERT_TRUE(false);
69 }
70 }
71 }
72