yaml: add back support for empty LED groups
The old script had support for empty LED groups. I tried removing the
empty "bmc_booted" LED group, but that caused systemd to never "finish"
booting (systemctl is-system-running returned "starting" because it was
blocked waiting for the "bmc_booted" LED service to start).
This adds back support for empty LED groups.
Tested:
Confirmed that with an empty "bmc_booted" LED group, the firmware will
build successfully and systemd doesn't get blocked waiting for the
"bmc_booted" LED service.
Change-Id: I11d7c50696cd50d989a4eaef28f8e5c43473ce6e
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/test/utest-led-yaml-empty-group.cpp b/test/utest-led-yaml-empty-group.cpp
new file mode 100644
index 0000000..7055053
--- /dev/null
+++ b/test/utest-led-yaml-empty-group.cpp
@@ -0,0 +1,39 @@
+#include "config-validator.hpp"
+#include "group.hpp"
+#include "ledlayout.hpp"
+#include "test-empty-group.hpp"
+
+#include <gtest/gtest.h>
+
+using namespace phosphor::led;
+
+// systemLedMap is generated code
+// static const GroupMap systemLedMap = {};
+
+const std::string basePath = "/xyz/openbmc_project/led/groups/";
+
+TEST(YamlEmptyGroupTest, assertEmptyGroupExists)
+{
+ /* Empty led groups are supported since some boards may
+ * not have the required leds to fill the expected groups.
+ * Other software in openbmc (e.g bmcweb, led-manager itself)
+ * expects certain groups and unintended error messages can result
+ * if they are not present.
+ */
+
+ const std::string emptyGroupPath = basePath + "emptygroup";
+ const std::string nonEmptyGroupPath = basePath + "nonemptygroup";
+
+ EXPECT_EQ(systemLedMap.contains(emptyGroupPath), true);
+ EXPECT_EQ(systemLedMap.contains(nonEmptyGroupPath), true);
+
+ const Layout::GroupLayout& emptyGroup = systemLedMap.at(emptyGroupPath);
+ const Layout::GroupLayout& nonEmptyGroup =
+ systemLedMap.at(nonEmptyGroupPath);
+
+ EXPECT_EQ(emptyGroup.actionSet.size(), 0);
+ EXPECT_EQ(nonEmptyGroup.actionSet.size(), 1);
+
+ // this should not throw
+ phosphor::led::validateConfigV1(systemLedMap);
+}