Add storeGroups/restoreGroups method to LED Manager

Use CEREAL to storeGroup/restoreGroups the current state of
asserted groups.
Call storeGroups() when the request comes to add to(remove from)
asserted group.
Call restoreGroups() as part of starting LED Manager daemon.

Tested: Manually set the Asserted property of each group to true,
after rebooting, all property values tested with the busctl command
are still true.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ibeb1de5f51e3d67e98eeea34764e9efc6d6d8b35
diff --git a/test/utest-serialize.cpp b/test/utest-serialize.cpp
new file mode 100644
index 0000000..8c75031
--- /dev/null
+++ b/test/utest-serialize.cpp
@@ -0,0 +1,44 @@
+#include "serialize.hpp"
+
+#include <filesystem>
+
+#include <gtest/gtest.h>
+
+using namespace phosphor::led;
+
+TEST(SerializeTest, testStoreGroups)
+{
+    namespace fs = std::filesystem;
+
+    static constexpr auto& path = "config/led-save-group.json";
+    static constexpr auto& bmcBooted =
+        "/xyz/openbmc_project/led/groups/bmc_booted";
+    static constexpr auto& powerOn = "/xyz/openbmc_project/led/groups/power_on";
+    static constexpr auto& enclosureIdentify =
+        "/xyz/openbmc_project/led/groups/EnclosureIdentify";
+
+    Serialize serialize(path);
+
+    serialize.storeGroups(bmcBooted, true);
+    ASSERT_EQ(true, serialize.getGroupSavedState(bmcBooted));
+
+    serialize.storeGroups(powerOn, true);
+    ASSERT_EQ(true, serialize.getGroupSavedState(powerOn));
+
+    serialize.storeGroups(bmcBooted, false);
+    ASSERT_EQ(false, serialize.getGroupSavedState(bmcBooted));
+
+    serialize.storeGroups(enclosureIdentify, true);
+    ASSERT_EQ(true, serialize.getGroupSavedState(enclosureIdentify));
+
+    Serialize newSerial(path);
+
+    ASSERT_EQ(true, newSerial.getGroupSavedState(powerOn));
+    ASSERT_EQ(true, newSerial.getGroupSavedState(enclosureIdentify));
+
+    newSerial.storeGroups(powerOn, false);
+    ASSERT_EQ(false, newSerial.getGroupSavedState(powerOn));
+
+    newSerial.storeGroups(enclosureIdentify, false);
+    ASSERT_EQ(false, newSerial.getGroupSavedState(enclosureIdentify));
+}