blob: 7a7188bbb2d5acce172276b7ec163c5e3a4da3b1 [file] [log] [blame]
George Liu2098aa62020-05-09 11:26:35 +08001#include "serialize.hpp"
2
3#include <filesystem>
4
5#include <gtest/gtest.h>
6
7using namespace phosphor::led;
8
9TEST(SerializeTest, testStoreGroups)
10{
11 namespace fs = std::filesystem;
12
George Liu3d487512024-08-23 09:19:57 +080013 static constexpr auto path = "config/led-save-group.json";
14 static constexpr auto bmcBooted =
George Liu2098aa62020-05-09 11:26:35 +080015 "/xyz/openbmc_project/led/groups/bmc_booted";
George Liu3d487512024-08-23 09:19:57 +080016 static constexpr auto powerOn = "/xyz/openbmc_project/led/groups/power_on";
17 static constexpr auto enclosureIdentify =
George Liu2098aa62020-05-09 11:26:35 +080018 "/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}