xref: /openbmc/phosphor-led-manager/test/utest-led-yaml-empty-group.cpp (revision f2669fabb9a9e4803fdd1d2648b9897f9e7c4fb8)
1 #include "config-validator.hpp"
2 #include "group.hpp"
3 #include "ledlayout.hpp"
4 #include "test-empty-group.hpp"
5 
6 #include <gtest/gtest.h>
7 
8 using namespace phosphor::led;
9 
10 // systemLedMap is generated code
11 // static const GroupMap systemLedMap = {};
12 
13 const std::string basePath = "/xyz/openbmc_project/led/groups/";
14 
TEST(YamlEmptyGroupTest,assertEmptyGroupExists)15 TEST(YamlEmptyGroupTest, assertEmptyGroupExists)
16 {
17     /* Empty led groups are supported since some boards may
18      * not have the required leds to fill the expected groups.
19      * Other software in openbmc (e.g bmcweb, led-manager itself)
20      * expects certain groups and unintended error messages can result
21      * if they are not present.
22      */
23 
24     const std::string emptyGroupPath = basePath + "emptygroup";
25     const std::string nonEmptyGroupPath = basePath + "nonemptygroup";
26 
27     EXPECT_EQ(systemLedMap.contains(emptyGroupPath), true);
28     EXPECT_EQ(systemLedMap.contains(nonEmptyGroupPath), true);
29 
30     const Layout::GroupLayout& emptyGroup = systemLedMap.at(emptyGroupPath);
31     const Layout::GroupLayout& nonEmptyGroup =
32         systemLedMap.at(nonEmptyGroupPath);
33 
34     EXPECT_EQ(emptyGroup.actionSet.size(), 0);
35     EXPECT_EQ(nonEmptyGroup.actionSet.size(), 1);
36 
37     // this should not throw
38     phosphor::led::validateConfigV1(systemLedMap);
39 }
40