George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame^] | 1 | #include "serialize.hpp" |
| 2 | |
| 3 | #include <filesystem> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | using namespace phosphor::led; |
| 8 | |
| 9 | TEST(SerializeTest, testStoreGroups) |
| 10 | { |
| 11 | namespace fs = std::filesystem; |
| 12 | |
| 13 | static constexpr auto& path = "config/led-save-group.json"; |
| 14 | static constexpr auto& bmcBooted = |
| 15 | "/xyz/openbmc_project/led/groups/bmc_booted"; |
| 16 | static constexpr auto& powerOn = "/xyz/openbmc_project/led/groups/power_on"; |
| 17 | static constexpr auto& enclosureIdentify = |
| 18 | "/xyz/openbmc_project/led/groups/EnclosureIdentify"; |
| 19 | |
| 20 | Serialize serialize(path); |
| 21 | |
| 22 | serialize.storeGroups(bmcBooted, true); |
| 23 | ASSERT_EQ(true, serialize.getGroupSavedState(bmcBooted)); |
| 24 | |
| 25 | serialize.storeGroups(powerOn, true); |
| 26 | ASSERT_EQ(true, serialize.getGroupSavedState(powerOn)); |
| 27 | |
| 28 | serialize.storeGroups(bmcBooted, false); |
| 29 | ASSERT_EQ(false, serialize.getGroupSavedState(bmcBooted)); |
| 30 | |
| 31 | serialize.storeGroups(enclosureIdentify, true); |
| 32 | ASSERT_EQ(true, serialize.getGroupSavedState(enclosureIdentify)); |
| 33 | |
| 34 | Serialize newSerial(path); |
| 35 | |
| 36 | ASSERT_EQ(true, newSerial.getGroupSavedState(powerOn)); |
| 37 | ASSERT_EQ(true, newSerial.getGroupSavedState(enclosureIdentify)); |
| 38 | |
| 39 | newSerial.storeGroups(powerOn, false); |
| 40 | ASSERT_EQ(false, newSerial.getGroupSavedState(powerOn)); |
| 41 | |
| 42 | newSerial.storeGroups(enclosureIdentify, false); |
| 43 | ASSERT_EQ(false, newSerial.getGroupSavedState(enclosureIdentify)); |
| 44 | } |