Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1 | #include "led-test-map.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 2 | #include "manager.hpp" |
| 3 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
George Liu | a6c18f8 | 2020-06-22 10:50:04 +0800 | [diff] [blame] | 5 | |
| 6 | #include <algorithm> |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 7 | #include <set> |
| 8 | |
| 9 | #include <gtest/gtest.h> |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 10 | using namespace phosphor::led; |
| 11 | class LedTest : public ::testing::Test |
| 12 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 13 | public: |
Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 14 | sdbusplus::bus_t bus; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 15 | LedTest() : bus(sdbusplus::bus::new_default()) |
| 16 | { |
| 17 | // Nothing here |
| 18 | } |
George Liu | c8ddde6 | 2024-08-22 17:29:16 +0800 | [diff] [blame] | 19 | ~LedTest() override = default; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | /** @brief Assert Single LED to On */ |
| 23 | TEST_F(LedTest, assertSingleLedOn) |
| 24 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 25 | Manager manager(bus, singleLedOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 26 | { |
| 27 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 28 | ActionSet ledsAssert{}; |
| 29 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 30 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 31 | static constexpr auto group = |
| 32 | "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 33 | auto result = |
| 34 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 35 | EXPECT_EQ(true, result); |
| 36 | |
| 37 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 38 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 39 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 40 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 41 | }; |
| 42 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 43 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 44 | |
| 45 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 46 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 47 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 48 | refAssert.begin(), refAssert.end(), |
| 49 | std::inserter(temp, temp.begin())); |
| 50 | EXPECT_EQ(0, temp.size()); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /** @brief Assert Single LED to Blink */ |
| 55 | TEST_F(LedTest, assertSingleLedBlink) |
| 56 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 57 | Manager manager(bus, singleLedBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 58 | { |
| 59 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 60 | ActionSet ledsAssert{}; |
| 61 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 62 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 63 | static constexpr auto group = |
| 64 | "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 65 | auto result = |
| 66 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 67 | EXPECT_EQ(true, result); |
| 68 | |
| 69 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 70 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 71 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 72 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 73 | }; |
| 74 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 75 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 76 | |
| 77 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 78 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 79 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 80 | refAssert.begin(), refAssert.end(), |
| 81 | std::inserter(temp, temp.begin())); |
| 82 | EXPECT_EQ(0, temp.size()); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** @brief Assert Single LED to On and Try Assert Again */ |
| 87 | TEST_F(LedTest, assertSingleLedOnAndreAssert) |
| 88 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 89 | Manager manager(bus, singleLedOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 90 | { |
| 91 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 92 | ActionSet ledsAssert{}; |
| 93 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 94 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 95 | static constexpr auto group = |
| 96 | "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 97 | auto result = |
| 98 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 99 | EXPECT_EQ(true, result); |
| 100 | |
| 101 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 102 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 103 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 104 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 105 | }; |
| 106 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 107 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 108 | |
| 109 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 110 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 111 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 112 | refAssert.begin(), refAssert.end(), |
| 113 | std::inserter(temp, temp.begin())); |
| 114 | EXPECT_EQ(0, temp.size()); |
| 115 | } |
| 116 | { |
| 117 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 118 | ActionSet ledsAssert{}; |
| 119 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 120 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 121 | static constexpr auto group = |
| 122 | "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 123 | auto result = |
| 124 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 125 | EXPECT_EQ(true, result); |
| 126 | |
| 127 | EXPECT_EQ(0, ledsAssert.size()); |
| 128 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | |
| 132 | /** @brief Assert Multiple LEDs to On */ |
| 133 | TEST_F(LedTest, assertMultipleLedOn) |
| 134 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 135 | Manager manager(bus, multipleLedsOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 136 | { |
| 137 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 138 | ActionSet ledsAssert{}; |
| 139 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 140 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 141 | static constexpr auto group = |
| 142 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 143 | auto result = |
| 144 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 145 | EXPECT_EQ(true, result); |
| 146 | |
| 147 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 148 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 149 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 150 | phosphor::led::Layout::Action::On}, |
| 151 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 152 | phosphor::led::Layout::Action::On}, |
| 153 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 154 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 155 | }; |
| 156 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 157 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 158 | |
| 159 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 160 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 161 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 162 | refAssert.begin(), refAssert.end(), |
| 163 | std::inserter(temp, temp.begin())); |
| 164 | EXPECT_EQ(0, temp.size()); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /** @brief Assert Multiple LEDs to Blink */ |
| 169 | TEST_F(LedTest, assertMultipleLedBlink) |
| 170 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 171 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 172 | { |
| 173 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 174 | ActionSet ledsAssert{}; |
| 175 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 176 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 177 | static constexpr auto group = |
| 178 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 179 | auto result = |
| 180 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 181 | EXPECT_EQ(true, result); |
| 182 | |
| 183 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 184 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 185 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 186 | phosphor::led::Layout::Action::Blink}, |
| 187 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 188 | phosphor::led::Layout::Action::Blink}, |
| 189 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 190 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 191 | }; |
| 192 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 193 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 194 | |
| 195 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 196 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 197 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 198 | refAssert.begin(), refAssert.end(), |
| 199 | std::inserter(temp, temp.begin())); |
| 200 | EXPECT_EQ(0, temp.size()); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** @brief Assert Multiple LEDs to Blink, DeAssert */ |
| 205 | TEST_F(LedTest, assertMultipleLedBlinkAndDeAssert) |
| 206 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 207 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 208 | { |
| 209 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 210 | ActionSet ledsAssert{}; |
| 211 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 212 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 213 | static constexpr auto group = |
| 214 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 215 | auto result = |
| 216 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 217 | EXPECT_EQ(true, result); |
| 218 | |
| 219 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 220 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 221 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 222 | phosphor::led::Layout::Action::Blink}, |
| 223 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 224 | phosphor::led::Layout::Action::Blink}, |
| 225 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 226 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 227 | }; |
| 228 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 229 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 230 | |
| 231 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 232 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 233 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 234 | refAssert.begin(), refAssert.end(), |
| 235 | std::inserter(temp, temp.begin())); |
| 236 | EXPECT_EQ(0, temp.size()); |
| 237 | } |
| 238 | { |
| 239 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 240 | ActionSet ledsAssert{}; |
| 241 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 242 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 243 | static constexpr auto group = |
| 244 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 245 | auto result = |
| 246 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 247 | EXPECT_EQ(false, result); |
| 248 | |
| 249 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 250 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 251 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 252 | phosphor::led::Layout::Action::Blink}, |
| 253 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 254 | phosphor::led::Layout::Action::Blink}, |
| 255 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 256 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 257 | }; |
| 258 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 259 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 260 | |
| 261 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 262 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 263 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 264 | refDeAssert.begin(), refDeAssert.end(), |
| 265 | std::inserter(temp, temp.begin())); |
| 266 | EXPECT_EQ(0, temp.size()); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /** @brief Assert Multiple LEDs to Blink, DeAssert Twice */ |
| 271 | TEST_F(LedTest, assertMultipleLedBlinkAndDeAssertTwice) |
| 272 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 273 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 274 | { |
| 275 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 276 | ActionSet ledsAssert{}; |
| 277 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 278 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 279 | static constexpr auto group = |
| 280 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 281 | auto result = |
| 282 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 283 | EXPECT_EQ(true, result); |
| 284 | |
| 285 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 286 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 287 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 288 | phosphor::led::Layout::Action::Blink}, |
| 289 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 290 | phosphor::led::Layout::Action::Blink}, |
| 291 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 292 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 293 | }; |
| 294 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 295 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 296 | |
| 297 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 298 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 299 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 300 | refAssert.begin(), refAssert.end(), |
| 301 | std::inserter(temp, temp.begin())); |
| 302 | EXPECT_EQ(0, temp.size()); |
| 303 | } |
| 304 | { |
| 305 | // DeAssert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 306 | ActionSet ledsAssert{}; |
| 307 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 308 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 309 | static constexpr auto group = |
| 310 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 311 | auto result = |
| 312 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 313 | EXPECT_EQ(false, result); |
| 314 | |
| 315 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 316 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 317 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 318 | phosphor::led::Layout::Action::Blink}, |
| 319 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 320 | phosphor::led::Layout::Action::Blink}, |
| 321 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 322 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 323 | }; |
| 324 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 325 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 326 | |
| 327 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 328 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 329 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 330 | refDeAssert.begin(), refDeAssert.end(), |
| 331 | std::inserter(temp, temp.begin())); |
| 332 | EXPECT_EQ(0, temp.size()); |
| 333 | } |
| 334 | { |
| 335 | // DeAssert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 336 | ActionSet ledsAssert{}; |
| 337 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 338 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 339 | static constexpr auto group = |
| 340 | "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 341 | auto result = |
| 342 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 343 | EXPECT_EQ(false, result); |
| 344 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 345 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | |
| 349 | /** @brief Assert Multiple LEDs to mix of On and Blink */ |
| 350 | TEST_F(LedTest, assertMultipleLedOnAndBlink) |
| 351 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 352 | Manager manager(bus, multipleLedsOnAndBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 353 | { |
| 354 | // Assert the LEDs. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 355 | ActionSet ledsAssert{}; |
| 356 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 357 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 358 | static constexpr auto group = |
| 359 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 360 | auto result = |
| 361 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 362 | EXPECT_EQ(true, result); |
| 363 | |
| 364 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 365 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 366 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 367 | phosphor::led::Layout::Action::Blink}, |
| 368 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 369 | phosphor::led::Layout::Action::Blink}, |
| 370 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 371 | phosphor::led::Layout::Action::On}, |
| 372 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 373 | phosphor::led::Layout::Action::Blink}, |
| 374 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 375 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 376 | }; |
| 377 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 378 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 379 | |
| 380 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 381 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 382 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 383 | refAssert.begin(), refAssert.end(), |
| 384 | std::inserter(temp, temp.begin())); |
| 385 | EXPECT_EQ(0, temp.size()); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | /** @brief Assert 2 groups having distinct LEDs */ |
| 390 | TEST_F(LedTest, assertTwoGroupsOnWithDistinctLEDOn) |
| 391 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 392 | Manager manager(bus, twoGroupsWithDistinctLEDsOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 393 | { |
| 394 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 395 | ActionSet ledsAssert{}; |
| 396 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 397 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 398 | static constexpr auto group = |
| 399 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 400 | auto result = |
| 401 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 402 | EXPECT_EQ(true, result); |
| 403 | |
| 404 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 405 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 406 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 407 | phosphor::led::Layout::Action::Blink}, |
| 408 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 409 | phosphor::led::Layout::Action::On}, |
| 410 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 411 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 412 | }; |
| 413 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 414 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 415 | |
| 416 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 417 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 418 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 419 | refAssert.begin(), refAssert.end(), |
| 420 | std::inserter(temp, temp.begin())); |
| 421 | EXPECT_EQ(0, temp.size()); |
| 422 | } |
| 423 | { |
| 424 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 425 | ActionSet ledsAssert{}; |
| 426 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 427 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 428 | static constexpr auto group = |
| 429 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 430 | auto result = |
| 431 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 432 | EXPECT_EQ(true, result); |
| 433 | |
| 434 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 435 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 436 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 437 | phosphor::led::Layout::Action::Blink}, |
| 438 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 439 | phosphor::led::Layout::Action::Blink}, |
| 440 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 441 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 442 | }; |
| 443 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 444 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 445 | |
| 446 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 447 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 448 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 449 | refAssert.begin(), refAssert.end(), |
| 450 | std::inserter(temp, temp.begin())); |
| 451 | EXPECT_EQ(0, temp.size()); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | /** @brief Assert 2 groups having one of the LEDs common */ |
| 456 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOn) |
| 457 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 458 | Manager manager(bus, twoGroupsWithOneComonLEDOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 459 | { |
| 460 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 461 | ActionSet ledsAssert{}; |
| 462 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 463 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 464 | static constexpr auto group = |
| 465 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 466 | auto result = |
| 467 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 468 | EXPECT_EQ(true, result); |
| 469 | |
| 470 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 471 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 472 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 473 | phosphor::led::Layout::Action::On}, |
| 474 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 475 | phosphor::led::Layout::Action::On}, |
| 476 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 477 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 478 | }; |
| 479 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 480 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 481 | |
| 482 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 483 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 484 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 485 | refAssert.begin(), refAssert.end(), |
| 486 | std::inserter(temp, temp.begin())); |
| 487 | EXPECT_EQ(0, temp.size()); |
| 488 | } |
| 489 | { |
| 490 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 491 | ActionSet ledsAssert{}; |
| 492 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 493 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 494 | static constexpr auto group = |
| 495 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 496 | auto result = |
| 497 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 498 | EXPECT_EQ(true, result); |
| 499 | |
| 500 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 501 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 502 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 503 | phosphor::led::Layout::Action::On}, |
| 504 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 505 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 506 | }; |
| 507 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 508 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 509 | |
| 510 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 511 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 512 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 513 | refAssert.begin(), refAssert.end(), |
| 514 | std::inserter(temp, temp.begin())); |
| 515 | EXPECT_EQ(0, temp.size()); |
| 516 | } |
| 517 | } |
| 518 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 519 | /** @brief Assert 2 groups having one of the LEDs common but having Blink as |
| 520 | * priority and Deassert*/ |
| 521 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 522 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 523 | Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 524 | { |
| 525 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 526 | ActionSet ledsAssert{}; |
| 527 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 528 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 529 | static constexpr auto group = |
| 530 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 531 | auto result = |
| 532 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 533 | EXPECT_EQ(true, result); |
| 534 | |
| 535 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 536 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 537 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 538 | phosphor::led::Layout::Action::On}, |
| 539 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 540 | phosphor::led::Layout::Action::On}, |
| 541 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 542 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 543 | }; |
| 544 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 545 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 546 | |
| 547 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 548 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 549 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 550 | refAssert.begin(), refAssert.end(), |
| 551 | std::inserter(temp, temp.begin())); |
| 552 | EXPECT_EQ(0, temp.size()); |
| 553 | } |
| 554 | { |
| 555 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 556 | ActionSet ledsAssert{}; |
| 557 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 558 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 559 | static constexpr auto group = |
| 560 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 561 | auto result = |
| 562 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 563 | EXPECT_EQ(true, result); |
| 564 | |
| 565 | // Need just the ledsAssserted populated with these. |
| 566 | // Does not action on [Three] since priority is [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 567 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 568 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 569 | phosphor::led::Layout::Action::On}, |
| 570 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 571 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 572 | }; |
| 573 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 574 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 575 | |
| 576 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 577 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 578 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 579 | refAssert.begin(), refAssert.end(), |
| 580 | std::inserter(temp, temp.begin())); |
| 581 | EXPECT_EQ(0, temp.size()); |
| 582 | } |
| 583 | { |
| 584 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 585 | ActionSet ledsAssert{}; |
| 586 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 587 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 588 | static constexpr auto group = |
| 589 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 590 | auto result = |
| 591 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 592 | EXPECT_EQ(false, result); |
| 593 | |
| 594 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 595 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 596 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 597 | phosphor::led::Layout::Action::On}, |
| 598 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 599 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 600 | }; |
| 601 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 602 | EXPECT_EQ(0, ledsAssert.size()); |
| 603 | |
| 604 | // difference of refDeAssert and ledsDeAssert must be null. |
| 605 | // [Three] is not touched since its already [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 606 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 607 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 608 | refDeAssert.begin(), refDeAssert.end(), |
| 609 | std::inserter(temp, temp.begin())); |
| 610 | EXPECT_EQ(0, temp.size()); |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | /** @brief Assert 2 groups having one of the LEDs common but having Blink as |
| 615 | * priority and Deassert A */ |
| 616 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA) |
| 617 | { |
| 618 | Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority); |
| 619 | { |
| 620 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 621 | ActionSet ledsAssert{}; |
| 622 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 623 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 624 | static constexpr auto group = |
| 625 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 626 | auto result = |
| 627 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 628 | EXPECT_EQ(true, result); |
| 629 | |
| 630 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 631 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 632 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 633 | phosphor::led::Layout::Action::On}, |
| 634 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 635 | phosphor::led::Layout::Action::On}, |
| 636 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 637 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 638 | }; |
| 639 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 640 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 641 | |
| 642 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 643 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 644 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 645 | refAssert.begin(), refAssert.end(), |
| 646 | std::inserter(temp, temp.begin())); |
| 647 | EXPECT_EQ(0, temp.size()); |
| 648 | } |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 649 | { |
| 650 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 651 | ActionSet ledsAssert{}; |
| 652 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 653 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 654 | static constexpr auto group = |
| 655 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 656 | auto result = |
| 657 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 658 | EXPECT_EQ(true, result); |
| 659 | |
| 660 | // Need just the ledsAssserted populated with these. |
| 661 | // [Three] does not get actioned since it has Blink priority |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 662 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 663 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 664 | phosphor::led::Layout::Action::On}, |
| 665 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 666 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 667 | }; |
| 668 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 669 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 670 | |
| 671 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 672 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 673 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 674 | refAssert.begin(), refAssert.end(), |
| 675 | std::inserter(temp, temp.begin())); |
| 676 | EXPECT_EQ(0, temp.size()); |
| 677 | } |
| 678 | { |
| 679 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 680 | ActionSet ledsAssert{}; |
| 681 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 682 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 683 | static constexpr auto group = |
| 684 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 685 | auto result = |
| 686 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 687 | EXPECT_EQ(false, result); |
| 688 | |
| 689 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 690 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 691 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 692 | phosphor::led::Layout::Action::On}, |
| 693 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 694 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 695 | }; |
| 696 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 697 | |
| 698 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 699 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 700 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 701 | refDeAssert.begin(), refDeAssert.end(), |
| 702 | std::inserter(temp, temp.begin())); |
| 703 | EXPECT_EQ(0, temp.size()); |
| 704 | |
| 705 | // Need just the ledsAssert populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 706 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 707 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 708 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 709 | }; |
| 710 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 711 | |
| 712 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 713 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 714 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 715 | refAssert.begin(), refAssert.end(), |
| 716 | std::inserter(temp1, temp1.begin())); |
| 717 | EXPECT_EQ(0, temp1.size()); |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | /** @brief Assert 2 groups having one of the LEDs common but having ON as |
| 722 | * priority And Deassert A */ |
| 723 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA) |
| 724 | { |
| 725 | Manager manager(bus, twoGroupsWithOneComonLEDOnPriority); |
| 726 | { |
| 727 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 728 | ActionSet ledsAssert{}; |
| 729 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 730 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 731 | static constexpr auto group = |
| 732 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 733 | auto result = |
| 734 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 735 | EXPECT_EQ(true, result); |
| 736 | |
| 737 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 738 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 739 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 740 | phosphor::led::Layout::Action::On}, |
| 741 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 742 | phosphor::led::Layout::Action::On}, |
| 743 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 744 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 745 | }; |
| 746 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 747 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 748 | |
| 749 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 750 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 751 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 752 | refAssert.begin(), refAssert.end(), |
| 753 | std::inserter(temp, temp.begin())); |
| 754 | EXPECT_EQ(0, temp.size()); |
| 755 | } |
| 756 | { |
| 757 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 758 | ActionSet ledsAssert{}; |
| 759 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 760 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 761 | static constexpr auto group = |
| 762 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 763 | auto result = |
| 764 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 765 | EXPECT_EQ(true, result); |
| 766 | |
| 767 | // Need just the ledsAssserted populated with these. |
| 768 | // Three is set to ON due to ON priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 769 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 770 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 771 | phosphor::led::Layout::Action::On}, |
| 772 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 773 | phosphor::led::Layout::Action::On}, |
| 774 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 775 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 776 | }; |
| 777 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 778 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 779 | |
| 780 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 781 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 782 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 783 | refAssert.begin(), refAssert.end(), |
| 784 | std::inserter(temp, temp.begin())); |
| 785 | } |
| 786 | { |
| 787 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 788 | ActionSet ledsAssert{}; |
| 789 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 790 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 791 | static constexpr auto group = |
| 792 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 793 | auto result = |
| 794 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 795 | EXPECT_EQ(false, result); |
| 796 | |
| 797 | // Need just the ledsDeAssserted populated with these. |
| 798 | // [Three] stays in [On] since [B] has it [On] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 799 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 800 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 801 | phosphor::led::Layout::Action::On}, |
| 802 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 803 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 804 | }; |
| 805 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 806 | EXPECT_EQ(0, ledsAssert.size()); |
| 807 | |
| 808 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 809 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 810 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 811 | refDeAssert.begin(), refDeAssert.end(), |
| 812 | std::inserter(temp, temp.begin())); |
| 813 | EXPECT_EQ(0, temp.size()); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | /** @brief Assert 2 groups having one of the LEDs common but having ON as |
| 818 | * priority And Deassert B */ |
| 819 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB) |
| 820 | { |
| 821 | Manager manager(bus, twoGroupsWithOneComonLEDOnPriority); |
| 822 | { |
| 823 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 824 | ActionSet ledsAssert{}; |
| 825 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 826 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 827 | static constexpr auto group = |
| 828 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 829 | auto result = |
| 830 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 831 | EXPECT_EQ(true, result); |
| 832 | |
| 833 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 834 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 835 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 836 | phosphor::led::Layout::Action::On}, |
| 837 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 838 | phosphor::led::Layout::Action::On}, |
| 839 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 840 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 841 | }; |
| 842 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 843 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 844 | |
| 845 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 846 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 847 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 848 | refAssert.begin(), refAssert.end(), |
| 849 | std::inserter(temp, temp.begin())); |
| 850 | EXPECT_EQ(0, temp.size()); |
| 851 | } |
| 852 | { |
| 853 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 854 | ActionSet ledsAssert{}; |
| 855 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 856 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 857 | static constexpr auto group = |
| 858 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 859 | auto result = |
| 860 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 861 | EXPECT_EQ(true, result); |
| 862 | |
| 863 | // Need just the ledsAssserted populated with these. |
| 864 | // Three is set to ON due to ON priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 865 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 866 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 867 | phosphor::led::Layout::Action::On}, |
| 868 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 869 | phosphor::led::Layout::Action::On}, |
| 870 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 871 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 872 | }; |
| 873 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 874 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 875 | |
| 876 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 877 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 878 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 879 | refAssert.begin(), refAssert.end(), |
| 880 | std::inserter(temp, temp.begin())); |
| 881 | } |
| 882 | { |
| 883 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 884 | ActionSet ledsAssert{}; |
| 885 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 886 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 887 | static constexpr auto group = |
| 888 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 889 | auto result = |
| 890 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 891 | EXPECT_EQ(false, result); |
| 892 | |
| 893 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 894 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 895 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 896 | phosphor::led::Layout::Action::On}, |
| 897 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 898 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 899 | }; |
| 900 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 901 | |
| 902 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 903 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 904 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 905 | refDeAssert.begin(), refDeAssert.end(), |
| 906 | std::inserter(temp, temp.begin())); |
| 907 | EXPECT_EQ(0, temp.size()); |
| 908 | |
| 909 | // Need just the ledsAssert populated with these. |
| 910 | // Since [Three] stood [On], need to go back to [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 911 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 912 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 913 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 914 | }; |
| 915 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 916 | |
| 917 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 918 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 919 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 920 | refAssert.begin(), refAssert.end(), |
| 921 | std::inserter(temp, temp.begin())); |
| 922 | EXPECT_EQ(0, temp.size()); |
| 923 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | /** @brief Assert 2 groups having multiple common LEDs in Same State */ |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 927 | TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 928 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 929 | Manager manager(bus, twoGroupsWithMultiplComonLEDOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 930 | { |
| 931 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 932 | ActionSet ledsAssert{}; |
| 933 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 934 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 935 | static constexpr auto group = |
| 936 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 937 | auto result = |
| 938 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 939 | EXPECT_EQ(true, result); |
| 940 | |
| 941 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 942 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 943 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 944 | phosphor::led::Layout::Action::On}, |
| 945 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 946 | phosphor::led::Layout::Action::On}, |
| 947 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 948 | phosphor::led::Layout::Action::On}, |
| 949 | {"Seven", phosphor::led::Layout::Action::On, 0, 0, |
| 950 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 951 | }; |
| 952 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 953 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 954 | |
| 955 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 956 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 957 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 958 | refAssert.begin(), refAssert.end(), |
| 959 | std::inserter(temp, temp.begin())); |
| 960 | EXPECT_EQ(0, temp.size()); |
| 961 | } |
| 962 | { |
| 963 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 964 | ActionSet ledsAssert{}; |
| 965 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 966 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 967 | static constexpr auto group = |
| 968 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 969 | auto result = |
| 970 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 971 | EXPECT_EQ(true, result); |
| 972 | |
| 973 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 974 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 975 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 976 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 977 | }; |
| 978 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 979 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 980 | |
| 981 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 982 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 983 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 984 | refAssert.begin(), refAssert.end(), |
| 985 | std::inserter(temp, temp.begin())); |
| 986 | EXPECT_EQ(0, temp.size()); |
| 987 | } |
| 988 | { |
| 989 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 990 | ActionSet ledsAssert{}; |
| 991 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 992 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 993 | static constexpr auto group = |
| 994 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 995 | auto result = |
| 996 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 997 | EXPECT_EQ(false, result); |
| 998 | |
| 999 | // Need just the ledsDeAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1000 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1001 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1002 | phosphor::led::Layout::Action::On}, |
| 1003 | {"Seven", phosphor::led::Layout::Action::On, 0, 0, |
| 1004 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1005 | }; |
| 1006 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1007 | EXPECT_EQ(0, ledsAssert.size()); |
| 1008 | |
| 1009 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1010 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1011 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1012 | refDeAssert.begin(), refDeAssert.end(), |
| 1013 | std::inserter(temp, temp.begin())); |
| 1014 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | /** @brief Assert 2 groups having multiple LEDs common in different state */ |
| 1019 | TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA) |
| 1020 | { |
| 1021 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
| 1022 | { |
| 1023 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1024 | ActionSet ledsAssert{}; |
| 1025 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1026 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1027 | static constexpr auto group = |
| 1028 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1029 | auto result = |
| 1030 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1031 | EXPECT_EQ(true, result); |
| 1032 | |
| 1033 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1034 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1035 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1036 | phosphor::led::Layout::Action::On}, |
| 1037 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1038 | phosphor::led::Layout::Action::On}, |
| 1039 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1040 | phosphor::led::Layout::Action::On}, |
| 1041 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1042 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1043 | }; |
| 1044 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1045 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1046 | |
| 1047 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1048 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1049 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1050 | refAssert.begin(), refAssert.end(), |
| 1051 | std::inserter(temp, temp.begin())); |
| 1052 | EXPECT_EQ(0, temp.size()); |
| 1053 | } |
| 1054 | { |
| 1055 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1056 | ActionSet ledsAssert{}; |
| 1057 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1058 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1059 | static constexpr auto group = |
| 1060 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1061 | auto result = |
| 1062 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1063 | EXPECT_EQ(true, result); |
| 1064 | |
| 1065 | // Need just the ledsAssserted populated with these |
| 1066 | // [Two] remains [On] due to higher priority. |
| 1067 | // [Three] remains [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1068 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1069 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1070 | phosphor::led::Layout::Action::On}, |
| 1071 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1072 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1073 | }; |
| 1074 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1075 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1076 | |
| 1077 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1078 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1079 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1080 | refAssert.begin(), refAssert.end(), |
| 1081 | std::inserter(temp, temp.begin())); |
| 1082 | EXPECT_EQ(0, temp.size()); |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | /** @brief Assert 2 groups having multiple LEDs common in different state */ |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1087 | TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1088 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 1089 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1090 | { |
| 1091 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1092 | ActionSet ledsAssert{}; |
| 1093 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1094 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1095 | static constexpr auto group = |
| 1096 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1097 | auto result = |
| 1098 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1099 | EXPECT_EQ(true, result); |
| 1100 | |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1101 | // Need just the ledsAssserted populated with these.'Two' gets to Blink |
| 1102 | // due to higher priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1103 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1104 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1105 | phosphor::led::Layout::Action::On}, |
| 1106 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1107 | phosphor::led::Layout::Action::On}, |
| 1108 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1109 | phosphor::led::Layout::Action::On}, |
| 1110 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1111 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1112 | }; |
| 1113 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1114 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1115 | |
| 1116 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1117 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1118 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1119 | refAssert.begin(), refAssert.end(), |
| 1120 | std::inserter(temp, temp.begin())); |
| 1121 | EXPECT_EQ(0, temp.size()); |
| 1122 | } |
| 1123 | { |
| 1124 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1125 | ActionSet ledsAssert{}; |
| 1126 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1127 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1128 | static constexpr auto group = |
| 1129 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1130 | auto result = |
| 1131 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1132 | EXPECT_EQ(true, result); |
| 1133 | |
| 1134 | // Need just the ledsAssserted populated with these. |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1135 | // [Three] remains [Blink] from previous |
| 1136 | // [Two] moves to [On] from [Blink] due to [On] priority |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1137 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1138 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1139 | phosphor::led::Layout::Action::On}, |
| 1140 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1141 | phosphor::led::Layout::Action::On}, |
| 1142 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1143 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1144 | }; |
| 1145 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1146 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1147 | |
| 1148 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1149 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1150 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1151 | refAssert.begin(), refAssert.end(), |
| 1152 | std::inserter(temp, temp.begin())); |
| 1153 | EXPECT_EQ(0, temp.size()); |
| 1154 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1155 | } |
| 1156 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1157 | /** @brief Assert 2 groups having multiple LEDs common in different state |
| 1158 | * DeAssert twice |
| 1159 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1160 | TEST_F(LedTest, |
| 1161 | assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1162 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 1163 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1164 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1165 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1166 | ActionSet ledsAssert{}; |
| 1167 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1168 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1169 | static constexpr auto group = |
| 1170 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1171 | auto result = |
| 1172 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1173 | EXPECT_EQ(true, result); |
| 1174 | |
| 1175 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1176 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1177 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1178 | phosphor::led::Layout::Action::On}, |
| 1179 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1180 | phosphor::led::Layout::Action::On}, |
| 1181 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1182 | phosphor::led::Layout::Action::On}, |
| 1183 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1184 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1185 | }; |
| 1186 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1187 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1188 | |
| 1189 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1190 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1191 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1192 | refAssert.begin(), refAssert.end(), |
| 1193 | std::inserter(temp, temp.begin())); |
| 1194 | EXPECT_EQ(0, temp.size()); |
| 1195 | } |
| 1196 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1197 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1198 | ActionSet ledsAssert{}; |
| 1199 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1200 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1201 | static constexpr auto group = |
| 1202 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1203 | auto result = |
| 1204 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1205 | EXPECT_EQ(true, result); |
| 1206 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1207 | // Need just the ledsAssserted populated with these. |
| 1208 | // [Two] turns [On] due to priority |
| 1209 | // [Three] remains [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1210 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1211 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1212 | phosphor::led::Layout::Action::On}, |
| 1213 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1214 | phosphor::led::Layout::Action::On}, |
| 1215 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1216 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1217 | }; |
| 1218 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1219 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1220 | |
| 1221 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1222 | ActionSet temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1223 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1224 | refAssert.begin(), refAssert.end(), |
| 1225 | std::inserter(temp, temp.begin())); |
| 1226 | EXPECT_EQ(0, temp.size()); |
| 1227 | } |
| 1228 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1229 | // DeAssert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1230 | ActionSet ledsAssert{}; |
| 1231 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1232 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1233 | static constexpr auto group = |
| 1234 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1235 | auto result = |
| 1236 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1237 | EXPECT_EQ(false, result); |
| 1238 | |
| 1239 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1240 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1241 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1242 | phosphor::led::Layout::Action::On}, |
| 1243 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1244 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1245 | }; |
| 1246 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1247 | |
| 1248 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1249 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1250 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1251 | refDeAssert.begin(), refDeAssert.end(), |
| 1252 | std::inserter(temp, temp.begin())); |
| 1253 | EXPECT_EQ(0, temp.size()); |
| 1254 | |
| 1255 | // Need just the ledsAssert populated with these. |
| 1256 | // [Two] will go back to [Blink] from [On] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1257 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1258 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1259 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1260 | }; |
| 1261 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1262 | |
| 1263 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1264 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1265 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1266 | refAssert.begin(), refAssert.end(), |
| 1267 | std::inserter(temp1, temp1.begin())); |
| 1268 | EXPECT_EQ(0, temp1.size()); |
| 1269 | } |
| 1270 | { |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1271 | // DeAssert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1272 | ActionSet ledsAssert{}; |
| 1273 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1274 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1275 | static constexpr auto group = |
| 1276 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1277 | auto result = |
| 1278 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1279 | EXPECT_EQ(false, result); |
| 1280 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1281 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1282 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1283 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1284 | phosphor::led::Layout::Action::On}, |
| 1285 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1286 | phosphor::led::Layout::Action::On}, |
| 1287 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1288 | phosphor::led::Layout::Action::On}, |
| 1289 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1290 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1291 | }; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1292 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1293 | EXPECT_EQ(0, ledsAssert.size()); |
| 1294 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1295 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1296 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1297 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1298 | refDeAssert.begin(), refDeAssert.end(), |
| 1299 | std::inserter(temp, temp.begin())); |
| 1300 | EXPECT_EQ(0, temp.size()); |
| 1301 | } |
| 1302 | { |
| 1303 | // DeAssert Set-A again and make sure we get all empty |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1304 | ActionSet ledsAssert{}; |
| 1305 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1306 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1307 | static constexpr auto group = |
| 1308 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1309 | auto result = |
| 1310 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1311 | EXPECT_EQ(false, result); |
| 1312 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1313 | EXPECT_EQ(0, ledsAssert.size()); |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1318 | * mixed priority. DeAssert-A |
| 1319 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1320 | TEST_F(LedTest, |
| 1321 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1322 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1323 | Manager manager(bus, |
| 1324 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1325 | { |
| 1326 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1327 | ActionSet ledsAssert{}; |
| 1328 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1329 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1330 | static constexpr auto group = |
| 1331 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1332 | auto result = |
| 1333 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1334 | EXPECT_EQ(true, result); |
| 1335 | |
| 1336 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1337 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1338 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1339 | phosphor::led::Layout::Action::On}, |
| 1340 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1341 | phosphor::led::Layout::Action::On}, |
| 1342 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1343 | phosphor::led::Layout::Action::Blink}, |
| 1344 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1345 | phosphor::led::Layout::Action::On}, |
| 1346 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1347 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1348 | }; |
| 1349 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1350 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1351 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1352 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1353 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1354 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1355 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1356 | std::inserter(temp, temp.begin())); |
| 1357 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1358 | } |
| 1359 | { |
| 1360 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1361 | ActionSet ledsAssert{}; |
| 1362 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1363 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1364 | static constexpr auto group = |
| 1365 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1366 | auto result = |
| 1367 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1368 | EXPECT_EQ(true, result); |
| 1369 | |
| 1370 | // Need just the ledsAssserted populated with these. |
| 1371 | // [Two] gets to [ON] due to higher priority. |
| 1372 | // [Three] remains on since it never was in [Blink] before |
| 1373 | // [Ten] remains [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1374 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1375 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1376 | phosphor::led::Layout::Action::On}, |
| 1377 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1378 | phosphor::led::Layout::Action::On}, |
| 1379 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1380 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1381 | }; |
| 1382 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1383 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1384 | |
| 1385 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1386 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1387 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1388 | refAssert.begin(), refAssert.end(), |
| 1389 | std::inserter(temp, temp.begin())); |
| 1390 | EXPECT_EQ(0, temp.size()); |
| 1391 | } |
| 1392 | { |
| 1393 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1394 | ActionSet ledsAssert{}; |
| 1395 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1396 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1397 | static constexpr auto group = |
| 1398 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1399 | auto result = |
| 1400 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1401 | EXPECT_EQ(false, result); |
| 1402 | |
| 1403 | // Need just the ledsDeAsssert populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1404 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1405 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1406 | phosphor::led::Layout::Action::On}, |
| 1407 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1408 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1409 | }; |
| 1410 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1411 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1412 | // Need just the ledsAsssert populated with these. |
| 1413 | // [Ten] Moves to [On] since there is no prior [Blink] |
| 1414 | // [Three] remains [On] since it never changed state. |
| 1415 | // [Two] remains [On] since it did not go back |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1416 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1417 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1418 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1419 | }; |
| 1420 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1421 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1422 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1423 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1424 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1425 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1426 | std::inserter(temp, temp.begin())); |
| 1427 | EXPECT_EQ(0, temp.size()); |
| 1428 | } |
| 1429 | } |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1430 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1431 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1432 | * mixed priority. DeAssert-B |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1433 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1434 | TEST_F( |
| 1435 | LedTest, |
| 1436 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB) |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1437 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1438 | Manager manager(bus, |
| 1439 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1440 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1441 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1442 | ActionSet ledsAssert{}; |
| 1443 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1444 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1445 | static constexpr auto group = |
| 1446 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1447 | auto result = |
| 1448 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1449 | EXPECT_EQ(true, result); |
| 1450 | |
| 1451 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1452 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1453 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1454 | phosphor::led::Layout::Action::On}, |
| 1455 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1456 | phosphor::led::Layout::Action::On}, |
| 1457 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1458 | phosphor::led::Layout::Action::Blink}, |
| 1459 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1460 | phosphor::led::Layout::Action::On}, |
| 1461 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1462 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1463 | }; |
| 1464 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1465 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1466 | |
| 1467 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1468 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1469 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1470 | refAssert.begin(), refAssert.end(), |
| 1471 | std::inserter(temp, temp.begin())); |
| 1472 | EXPECT_EQ(0, temp.size()); |
| 1473 | } |
| 1474 | { |
| 1475 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1476 | ActionSet ledsAssert{}; |
| 1477 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1478 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1479 | static constexpr auto group = |
| 1480 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1481 | auto result = |
| 1482 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1483 | EXPECT_EQ(true, result); |
| 1484 | |
| 1485 | // Need just the ledsAssserted populated with these. |
| 1486 | // [Two] gets to [ON] due to higher priority. |
| 1487 | // [Three] remains on since it never was in [Blink] before |
| 1488 | // [Ten] remains [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1489 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1490 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1491 | phosphor::led::Layout::Action::On}, |
| 1492 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1493 | phosphor::led::Layout::Action::On}, |
| 1494 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1495 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1496 | }; |
| 1497 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1498 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1499 | |
| 1500 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1501 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1502 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1503 | refAssert.begin(), refAssert.end(), |
| 1504 | std::inserter(temp, temp.begin())); |
| 1505 | EXPECT_EQ(0, temp.size()); |
| 1506 | } |
| 1507 | { |
| 1508 | // De-Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1509 | ActionSet ledsAssert{}; |
| 1510 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1511 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1512 | static constexpr auto group = |
| 1513 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1514 | auto result = |
| 1515 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1516 | EXPECT_EQ(false, result); |
| 1517 | |
| 1518 | // Need just the ledsDeAsssert populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1519 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1520 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1521 | phosphor::led::Layout::Action::On}, |
| 1522 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1523 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1524 | }; |
| 1525 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1526 | |
| 1527 | // Need just the ledsAsssert populated with these. |
| 1528 | // [Ten] remains [Blink] since it did not move to [On] |
| 1529 | // [Three] remains [On] since it never changed state. |
| 1530 | // [Two] moves to [Blink] since there is no prior [On] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1531 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1532 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1533 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1534 | }; |
| 1535 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1536 | |
| 1537 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1538 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1539 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1540 | refAssert.begin(), refAssert.end(), |
| 1541 | std::inserter(temp, temp.begin())); |
| 1542 | EXPECT_EQ(0, temp.size()); |
| 1543 | } |
| 1544 | } |
| 1545 | |
| 1546 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1547 | * mixed priority. |
| 1548 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1549 | TEST_F(LedTest, |
| 1550 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1551 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1552 | Manager manager(bus, |
| 1553 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1554 | { |
| 1555 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1556 | ActionSet ledsAssert{}; |
| 1557 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1558 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1559 | static constexpr auto group = |
| 1560 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1561 | auto result = |
| 1562 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1563 | EXPECT_EQ(true, result); |
| 1564 | |
| 1565 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1566 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1567 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1568 | phosphor::led::Layout::Action::On}, |
| 1569 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1570 | phosphor::led::Layout::Action::Blink}, |
| 1571 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1572 | phosphor::led::Layout::Action::On}, |
| 1573 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1574 | phosphor::led::Layout::Action::On}, |
| 1575 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1576 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1577 | }; |
| 1578 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1579 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1580 | |
| 1581 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1582 | ActionSet temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1583 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1584 | refAssert.begin(), refAssert.end(), |
| 1585 | std::inserter(temp, temp.begin())); |
| 1586 | EXPECT_EQ(0, temp.size()); |
| 1587 | } |
| 1588 | { |
| 1589 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1590 | ActionSet ledsAssert{}; |
| 1591 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1592 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1593 | static constexpr auto group = |
| 1594 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1595 | auto result = |
| 1596 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1597 | EXPECT_EQ(true, result); |
| 1598 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1599 | // Need just the ledsAssserted populated with these. |
| 1600 | // [Two] remains [ON] due to higher priority. |
| 1601 | // [Three] remains on since it never was in [Blink] before |
| 1602 | // [Ten] moves to [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1603 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1604 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1605 | phosphor::led::Layout::Action::On}, |
| 1606 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1607 | phosphor::led::Layout::Action::On}, |
| 1608 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1609 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1610 | }; |
| 1611 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1612 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1613 | |
| 1614 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1615 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1616 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1617 | refAssert.begin(), refAssert.end(), |
| 1618 | std::inserter(temp, temp.begin())); |
| 1619 | EXPECT_EQ(0, temp.size()); |
| 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1624 | * mixed priority and De-Assert-A |
| 1625 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1626 | TEST_F( |
| 1627 | LedTest, |
| 1628 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1629 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1630 | Manager manager(bus, |
| 1631 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1632 | { |
| 1633 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1634 | ActionSet ledsAssert{}; |
| 1635 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1636 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1637 | static constexpr auto group = |
| 1638 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1639 | auto result = |
| 1640 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1641 | EXPECT_EQ(true, result); |
| 1642 | |
| 1643 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1644 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1645 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1646 | phosphor::led::Layout::Action::On}, |
| 1647 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1648 | phosphor::led::Layout::Action::Blink}, |
| 1649 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1650 | phosphor::led::Layout::Action::On}, |
| 1651 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1652 | phosphor::led::Layout::Action::On}, |
| 1653 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1654 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1655 | }; |
| 1656 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1657 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1658 | |
| 1659 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1660 | ActionSet temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1661 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1662 | refAssert.begin(), refAssert.end(), |
| 1663 | std::inserter(temp, temp.begin())); |
| 1664 | EXPECT_EQ(0, temp.size()); |
| 1665 | } |
| 1666 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1667 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1668 | ActionSet ledsAssert{}; |
| 1669 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1670 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1671 | static constexpr auto group = |
| 1672 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1673 | auto result = |
| 1674 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1675 | EXPECT_EQ(true, result); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1676 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1677 | // Need just the ledsAssserted populated with these. |
| 1678 | // [Two] remains [ON] due to higher priority. |
| 1679 | // [Three] remains on since it never was in [Blink] before |
| 1680 | // [Ten] moves to [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1681 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1682 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1683 | phosphor::led::Layout::Action::On}, |
| 1684 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1685 | phosphor::led::Layout::Action::On}, |
| 1686 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1687 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1688 | }; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1689 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1690 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1691 | |
| 1692 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1693 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1694 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1695 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1696 | std::inserter(temp, temp.begin())); |
| 1697 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1698 | } |
| 1699 | { |
| 1700 | // De-Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1701 | ActionSet ledsAssert{}; |
| 1702 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1703 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1704 | static constexpr auto group = |
| 1705 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1706 | auto result = |
| 1707 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1708 | EXPECT_EQ(false, result); |
| 1709 | |
| 1710 | // Need just the ledsAssserted populated with these. |
| 1711 | // [Ten] remains [Blink] due to priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1712 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1713 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1714 | phosphor::led::Layout::Action::On}, |
| 1715 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1716 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1717 | }; |
| 1718 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1719 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1720 | // Need just the ledsAssserted populated with these. |
| 1721 | // [Two] remains [ON] due to higher priority. |
| 1722 | // [Three] remains [On] since it never was in [Blink] before |
| 1723 | // [Ten] moves to [On] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1724 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1725 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1726 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1727 | }; |
| 1728 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1729 | |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1730 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1731 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1732 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1733 | refAssert.begin(), refAssert.end(), |
| 1734 | std::inserter(temp, temp.begin())); |
| 1735 | EXPECT_EQ(0, temp.size()); |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1740 | * mixed priority and then DeAssert twice. |
| 1741 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1742 | TEST_F(LedTest, |
| 1743 | assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1744 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1745 | Manager manager(bus, |
| 1746 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1747 | { |
| 1748 | // Assert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1749 | ActionSet ledsAssert{}; |
| 1750 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1751 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1752 | static constexpr auto group = |
| 1753 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1754 | auto result = |
| 1755 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1756 | EXPECT_EQ(true, result); |
| 1757 | |
| 1758 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1759 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1760 | {"Two", phosphor::led::Layout::Action::On, 0, 0, |
| 1761 | phosphor::led::Layout::Action::On}, |
| 1762 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1763 | phosphor::led::Layout::Action::Blink}, |
| 1764 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1765 | phosphor::led::Layout::Action::On}, |
| 1766 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1767 | phosphor::led::Layout::Action::On}, |
| 1768 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1769 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1770 | }; |
| 1771 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1772 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1773 | |
| 1774 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1775 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1776 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1777 | refAssert.begin(), refAssert.end(), |
| 1778 | std::inserter(temp, temp.begin())); |
| 1779 | EXPECT_EQ(0, temp.size()); |
| 1780 | } |
| 1781 | { |
| 1782 | // Assert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1783 | ActionSet ledsAssert{}; |
| 1784 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1785 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1786 | static constexpr auto group = |
| 1787 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1788 | auto result = |
| 1789 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1790 | EXPECT_EQ(true, result); |
| 1791 | |
| 1792 | // Need just the ledsAssserted populated with these. |
| 1793 | // [Two] remains [ON] due to higher priority. |
| 1794 | // [Three] remains on since it never was in [Blink] before |
| 1795 | // [Ten] moves to [Blink] due to priority: [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1796 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1797 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1798 | phosphor::led::Layout::Action::On}, |
| 1799 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1800 | phosphor::led::Layout::Action::On}, |
| 1801 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1802 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1803 | }; |
| 1804 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1805 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1806 | |
| 1807 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1808 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1809 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1810 | refAssert.begin(), refAssert.end(), |
| 1811 | std::inserter(temp, temp.begin())); |
| 1812 | EXPECT_EQ(0, temp.size()); |
| 1813 | } |
| 1814 | { |
| 1815 | // DeAssert Set-B |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1816 | ActionSet ledsAssert{}; |
| 1817 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1818 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1819 | static constexpr auto group = |
| 1820 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1821 | auto result = |
| 1822 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1823 | EXPECT_EQ(false, result); |
| 1824 | |
| 1825 | // Need just the ledsAssserted populated with these. |
| 1826 | // [Ten] remains [Blink] due to priority. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1827 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1828 | {"Five", phosphor::led::Layout::Action::On, 0, 0, |
| 1829 | phosphor::led::Layout::Action::On}, |
| 1830 | {"Six", phosphor::led::Layout::Action::On, 0, 0, |
| 1831 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1832 | }; |
| 1833 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1834 | |
| 1835 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1836 | ActionSet temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1837 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1838 | refDeAssert.begin(), refDeAssert.end(), |
| 1839 | std::inserter(temp, temp.begin())); |
| 1840 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1841 | |
| 1842 | // Need just the ledsAssert populated with these. |
| 1843 | // [Two] will move to [Blink] |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1844 | ActionSet refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1845 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1846 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1847 | }; |
| 1848 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1849 | |
| 1850 | // difference of refAssert and ledsAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1851 | ActionSet temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1852 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1853 | refAssert.begin(), refAssert.end(), |
| 1854 | std::inserter(temp1, temp1.begin())); |
| 1855 | EXPECT_EQ(0, temp1.size()); |
| 1856 | } |
| 1857 | { |
| 1858 | // DeAssert Set-A |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1859 | ActionSet ledsAssert{}; |
| 1860 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1861 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1862 | static constexpr auto group = |
| 1863 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1864 | auto result = |
| 1865 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1866 | EXPECT_EQ(false, result); |
| 1867 | |
| 1868 | // Need just the ledsAssserted populated with these. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1869 | ActionSet refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 1870 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 1871 | phosphor::led::Layout::Action::On}, |
| 1872 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1873 | phosphor::led::Layout::Action::On}, |
| 1874 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 1875 | phosphor::led::Layout::Action::Blink}, |
| 1876 | {"Four", phosphor::led::Layout::Action::On, 0, 0, |
| 1877 | phosphor::led::Layout::Action::On}, |
| 1878 | {"Ten", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1879 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1880 | }; |
| 1881 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1882 | EXPECT_EQ(0, ledsAssert.size()); |
| 1883 | |
| 1884 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1885 | ActionSet temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1886 | std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(), |
| 1887 | refDeAssert.begin(), refDeAssert.end(), |
| 1888 | std::inserter(temp, temp.begin())); |
| 1889 | EXPECT_EQ(0, temp.size()); |
| 1890 | } |
| 1891 | { |
| 1892 | // DeAssert Set-B again and make sure we get all empty |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 1893 | ActionSet ledsAssert{}; |
| 1894 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1895 | |
George Liu | 3d48751 | 2024-08-23 09:19:57 +0800 | [diff] [blame] | 1896 | static constexpr auto group = |
| 1897 | "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
Patrick Williams | 543ac9f | 2024-08-16 15:19:59 -0400 | [diff] [blame] | 1898 | auto result = |
| 1899 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1900 | EXPECT_EQ(false, result); |
| 1901 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1902 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1903 | } |
| 1904 | } |