blob: 361e9c706f6051b1a65db42edae541bbb61edfc4 [file] [log] [blame]
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301#include "led-test-map.hpp"
Patrick Venture91ac8d32018-11-01 17:03:22 -07002#include "manager.hpp"
3
Patrick Venture91ac8d32018-11-01 17:03:22 -07004#include <sdbusplus/bus.hpp>
George Liua6c18f82020-06-22 10:50:04 +08005
6#include <algorithm>
Patrick Venture91ac8d32018-11-01 17:03:22 -07007#include <set>
8
9#include <gtest/gtest.h>
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053010using namespace phosphor::led;
11class LedTest : public ::testing::Test
12{
Patrick Venture91ac8d32018-11-01 17:03:22 -070013 public:
Patrick Williams3e073ba2022-07-22 19:26:52 -050014 sdbusplus::bus_t bus;
Patrick Venture91ac8d32018-11-01 17:03:22 -070015 LedTest() : bus(sdbusplus::bus::new_default())
16 {
17 // Nothing here
18 }
George Liucc1de722024-08-22 16:47:14 +080019 ~LedTest() = default;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053020};
21
22/** @brief Assert Single LED to On */
23TEST_F(LedTest, assertSingleLedOn)
24{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053025 Manager manager(bus, singleLedOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053026 {
27 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050028 ActionSet ledsAssert{};
29 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053030
31 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -040032 auto result =
33 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053034 EXPECT_EQ(true, result);
35
36 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050037 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -050038 {"One", phosphor::led::Layout::Action::On, 0, 0,
39 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053040 };
41 EXPECT_EQ(refAssert.size(), ledsAssert.size());
42 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053043
44 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -050045 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053046 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
47 refAssert.begin(), refAssert.end(),
48 std::inserter(temp, temp.begin()));
49 EXPECT_EQ(0, temp.size());
50 }
51}
52
53/** @brief Assert Single LED to Blink */
54TEST_F(LedTest, assertSingleLedBlink)
55{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053056 Manager manager(bus, singleLedBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053057 {
58 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050059 ActionSet ledsAssert{};
60 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053061
62 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -040063 auto result =
64 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053065 EXPECT_EQ(true, result);
66
67 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050068 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -050069 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
70 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053071 };
72 EXPECT_EQ(refAssert.size(), ledsAssert.size());
73 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053074
75 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -050076 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053077 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
78 refAssert.begin(), refAssert.end(),
79 std::inserter(temp, temp.begin()));
80 EXPECT_EQ(0, temp.size());
81 }
82}
83
84/** @brief Assert Single LED to On and Try Assert Again */
85TEST_F(LedTest, assertSingleLedOnAndreAssert)
86{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053087 Manager manager(bus, singleLedOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053088 {
89 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050090 ActionSet ledsAssert{};
91 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053092
93 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -040094 auto result =
95 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053096 EXPECT_EQ(true, result);
97
98 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050099 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500100 {"One", phosphor::led::Layout::Action::On, 0, 0,
101 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530102 };
103 EXPECT_EQ(refAssert.size(), ledsAssert.size());
104 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530105
106 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500107 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530108 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
109 refAssert.begin(), refAssert.end(),
110 std::inserter(temp, temp.begin()));
111 EXPECT_EQ(0, temp.size());
112 }
113 {
114 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500115 ActionSet ledsAssert{};
116 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530117
118 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400119 auto result =
120 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530121 EXPECT_EQ(true, result);
122
123 EXPECT_EQ(0, ledsAssert.size());
124 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530125 }
126}
127
128/** @brief Assert Multiple LEDs to On */
129TEST_F(LedTest, assertMultipleLedOn)
130{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530131 Manager manager(bus, multipleLedsOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530132 {
133 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500134 ActionSet ledsAssert{};
135 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530136
137 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400138 auto result =
139 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530140 EXPECT_EQ(true, result);
141
142 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500143 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500144 {"One", phosphor::led::Layout::Action::On, 0, 0,
145 phosphor::led::Layout::Action::On},
146 {"Two", phosphor::led::Layout::Action::On, 0, 0,
147 phosphor::led::Layout::Action::On},
148 {"Three", phosphor::led::Layout::Action::On, 0, 0,
149 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530150 };
151 EXPECT_EQ(refAssert.size(), ledsAssert.size());
152 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530153
154 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500155 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530156 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
157 refAssert.begin(), refAssert.end(),
158 std::inserter(temp, temp.begin()));
159 EXPECT_EQ(0, temp.size());
160 }
161}
162
163/** @brief Assert Multiple LEDs to Blink */
164TEST_F(LedTest, assertMultipleLedBlink)
165{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530166 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530167 {
168 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500169 ActionSet ledsAssert{};
170 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530171
172 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400173 auto result =
174 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530175 EXPECT_EQ(true, result);
176
177 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500178 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500179 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
180 phosphor::led::Layout::Action::Blink},
181 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
182 phosphor::led::Layout::Action::Blink},
183 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
184 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530185 };
186 EXPECT_EQ(refAssert.size(), ledsAssert.size());
187 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530188
189 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500190 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530191 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
192 refAssert.begin(), refAssert.end(),
193 std::inserter(temp, temp.begin()));
194 EXPECT_EQ(0, temp.size());
195 }
196}
197
198/** @brief Assert Multiple LEDs to Blink, DeAssert */
199TEST_F(LedTest, assertMultipleLedBlinkAndDeAssert)
200{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530201 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530202 {
203 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500204 ActionSet ledsAssert{};
205 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530206
207 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400208 auto result =
209 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530210 EXPECT_EQ(true, result);
211
212 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500213 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500214 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
215 phosphor::led::Layout::Action::Blink},
216 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
217 phosphor::led::Layout::Action::Blink},
218 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
219 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530220 };
221 EXPECT_EQ(refAssert.size(), ledsAssert.size());
222 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530223
224 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500225 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530226 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
227 refAssert.begin(), refAssert.end(),
228 std::inserter(temp, temp.begin()));
229 EXPECT_EQ(0, temp.size());
230 }
231 {
232 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500233 ActionSet ledsAssert{};
234 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530235
236 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400237 auto result =
238 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530239 EXPECT_EQ(false, result);
240
241 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500242 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500243 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
244 phosphor::led::Layout::Action::Blink},
245 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
246 phosphor::led::Layout::Action::Blink},
247 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
248 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530249 };
250 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
251 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530252
253 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500254 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530255 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
256 refDeAssert.begin(), refDeAssert.end(),
257 std::inserter(temp, temp.begin()));
258 EXPECT_EQ(0, temp.size());
259 }
260}
261
262/** @brief Assert Multiple LEDs to Blink, DeAssert Twice */
263TEST_F(LedTest, assertMultipleLedBlinkAndDeAssertTwice)
264{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530265 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530266 {
267 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500268 ActionSet ledsAssert{};
269 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530270
271 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400272 auto result =
273 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530274 EXPECT_EQ(true, result);
275
276 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500277 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500278 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
279 phosphor::led::Layout::Action::Blink},
280 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
281 phosphor::led::Layout::Action::Blink},
282 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
283 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530284 };
285 EXPECT_EQ(refAssert.size(), ledsAssert.size());
286 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530287
288 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500289 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530290 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
291 refAssert.begin(), refAssert.end(),
292 std::inserter(temp, temp.begin()));
293 EXPECT_EQ(0, temp.size());
294 }
295 {
296 // DeAssert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500297 ActionSet ledsAssert{};
298 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530299
300 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400301 auto result =
302 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530303 EXPECT_EQ(false, result);
304
305 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500306 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500307 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
308 phosphor::led::Layout::Action::Blink},
309 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
310 phosphor::led::Layout::Action::Blink},
311 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
312 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530313 };
314 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
315 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530316
317 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500318 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530319 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
320 refDeAssert.begin(), refDeAssert.end(),
321 std::inserter(temp, temp.begin()));
322 EXPECT_EQ(0, temp.size());
323 }
324 {
325 // DeAssert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500326 ActionSet ledsAssert{};
327 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530328
329 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400330 auto result =
331 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530332 EXPECT_EQ(false, result);
333 EXPECT_EQ(0, ledsDeAssert.size());
334 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530335 }
336}
337
338/** @brief Assert Multiple LEDs to mix of On and Blink */
339TEST_F(LedTest, assertMultipleLedOnAndBlink)
340{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530341 Manager manager(bus, multipleLedsOnAndBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530342 {
343 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500344 ActionSet ledsAssert{};
345 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530346
347 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400348 auto result =
349 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530350 EXPECT_EQ(true, result);
351
352 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500353 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500354 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
355 phosphor::led::Layout::Action::Blink},
356 {"Two", phosphor::led::Layout::Action::On, 0, 0,
357 phosphor::led::Layout::Action::Blink},
358 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
359 phosphor::led::Layout::Action::On},
360 {"Four", phosphor::led::Layout::Action::On, 0, 0,
361 phosphor::led::Layout::Action::Blink},
362 {"Five", phosphor::led::Layout::Action::On, 0, 0,
363 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530364 };
365 EXPECT_EQ(refAssert.size(), ledsAssert.size());
366 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530367
368 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500369 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530370 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
371 refAssert.begin(), refAssert.end(),
372 std::inserter(temp, temp.begin()));
373 EXPECT_EQ(0, temp.size());
374 }
375}
376
377/** @brief Assert 2 groups having distinct LEDs */
378TEST_F(LedTest, assertTwoGroupsOnWithDistinctLEDOn)
379{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530380 Manager manager(bus, twoGroupsWithDistinctLEDsOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530381 {
382 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500383 ActionSet ledsAssert{};
384 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530385
Patrick Venture91ac8d32018-11-01 17:03:22 -0700386 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400387 auto result =
388 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530389 EXPECT_EQ(true, result);
390
391 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500392 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500393 {"One", phosphor::led::Layout::Action::On, 0, 0,
394 phosphor::led::Layout::Action::Blink},
395 {"Two", phosphor::led::Layout::Action::On, 0, 0,
396 phosphor::led::Layout::Action::On},
397 {"Three", phosphor::led::Layout::Action::On, 0, 0,
398 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530399 };
400 EXPECT_EQ(refAssert.size(), ledsAssert.size());
401 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530402
403 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500404 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530405 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
406 refAssert.begin(), refAssert.end(),
407 std::inserter(temp, temp.begin()));
408 EXPECT_EQ(0, temp.size());
409 }
410 {
411 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500412 ActionSet ledsAssert{};
413 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530414
Patrick Venture91ac8d32018-11-01 17:03:22 -0700415 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400416 auto result =
417 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530418 EXPECT_EQ(true, result);
419
420 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500421 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500422 {"Four", phosphor::led::Layout::Action::On, 0, 0,
423 phosphor::led::Layout::Action::Blink},
424 {"Five", phosphor::led::Layout::Action::On, 0, 0,
425 phosphor::led::Layout::Action::Blink},
426 {"Six", phosphor::led::Layout::Action::On, 0, 0,
427 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530428 };
429 EXPECT_EQ(refAssert.size(), ledsAssert.size());
430 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530431
432 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500433 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530434 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
435 refAssert.begin(), refAssert.end(),
436 std::inserter(temp, temp.begin()));
437 EXPECT_EQ(0, temp.size());
438 }
439}
440
441/** @brief Assert 2 groups having one of the LEDs common */
442TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOn)
443{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530444 Manager manager(bus, twoGroupsWithOneComonLEDOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530445 {
446 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500447 ActionSet ledsAssert{};
448 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530449
Patrick Venture91ac8d32018-11-01 17:03:22 -0700450 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400451 auto result =
452 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530453 EXPECT_EQ(true, result);
454
455 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500456 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500457 {"One", phosphor::led::Layout::Action::On, 0, 0,
458 phosphor::led::Layout::Action::On},
459 {"Two", phosphor::led::Layout::Action::On, 0, 0,
460 phosphor::led::Layout::Action::On},
461 {"Three", phosphor::led::Layout::Action::On, 0, 0,
462 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530463 };
464 EXPECT_EQ(refAssert.size(), ledsAssert.size());
465 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530466
467 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500468 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530469 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
470 refAssert.begin(), refAssert.end(),
471 std::inserter(temp, temp.begin()));
472 EXPECT_EQ(0, temp.size());
473 }
474 {
475 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500476 ActionSet ledsAssert{};
477 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530478
Patrick Venture91ac8d32018-11-01 17:03:22 -0700479 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400480 auto result =
481 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530482 EXPECT_EQ(true, result);
483
484 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500485 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500486 {"Four", phosphor::led::Layout::Action::On, 0, 0,
487 phosphor::led::Layout::Action::On},
488 {"Six", phosphor::led::Layout::Action::On, 0, 0,
489 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530490 };
491 EXPECT_EQ(refAssert.size(), ledsAssert.size());
492 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530493
494 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500495 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530496 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
497 refAssert.begin(), refAssert.end(),
498 std::inserter(temp, temp.begin()));
499 EXPECT_EQ(0, temp.size());
500 }
501}
502
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530503/** @brief Assert 2 groups having one of the LEDs common but having Blink as
504 * priority and Deassert*/
505TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530506{
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530507 Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530508 {
509 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500510 ActionSet ledsAssert{};
511 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530512
Patrick Venture91ac8d32018-11-01 17:03:22 -0700513 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400514 auto result =
515 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530516 EXPECT_EQ(true, result);
517
518 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500519 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500520 {"One", phosphor::led::Layout::Action::On, 0, 0,
521 phosphor::led::Layout::Action::On},
522 {"Two", phosphor::led::Layout::Action::On, 0, 0,
523 phosphor::led::Layout::Action::On},
524 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
525 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530526 };
527 EXPECT_EQ(refAssert.size(), ledsAssert.size());
528 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530529
530 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500531 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530532 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
533 refAssert.begin(), refAssert.end(),
534 std::inserter(temp, temp.begin()));
535 EXPECT_EQ(0, temp.size());
536 }
537 {
538 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500539 ActionSet ledsAssert{};
540 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530541
Patrick Venture91ac8d32018-11-01 17:03:22 -0700542 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400543 auto result =
544 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530545 EXPECT_EQ(true, result);
546
547 // Need just the ledsAssserted populated with these.
548 // Does not action on [Three] since priority is [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500549 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500550 {"Four", phosphor::led::Layout::Action::On, 0, 0,
551 phosphor::led::Layout::Action::On},
552 {"Six", phosphor::led::Layout::Action::On, 0, 0,
553 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530554 };
555 EXPECT_EQ(refAssert.size(), ledsAssert.size());
556 EXPECT_EQ(0, ledsDeAssert.size());
557
558 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500559 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530560 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
561 refAssert.begin(), refAssert.end(),
562 std::inserter(temp, temp.begin()));
563 EXPECT_EQ(0, temp.size());
564 }
565 {
566 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500567 ActionSet ledsAssert{};
568 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530569
Patrick Venture91ac8d32018-11-01 17:03:22 -0700570 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400571 auto result =
572 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530573 EXPECT_EQ(false, result);
574
575 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500576 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500577 {"Four", phosphor::led::Layout::Action::On, 0, 0,
578 phosphor::led::Layout::Action::On},
579 {"Six", phosphor::led::Layout::Action::On, 0, 0,
580 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530581 };
582 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
583 EXPECT_EQ(0, ledsAssert.size());
584
585 // difference of refDeAssert and ledsDeAssert must be null.
586 // [Three] is not touched since its already [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500587 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530588 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
589 refDeAssert.begin(), refDeAssert.end(),
590 std::inserter(temp, temp.begin()));
591 EXPECT_EQ(0, temp.size());
592 }
593}
594
595/** @brief Assert 2 groups having one of the LEDs common but having Blink as
596 * priority and Deassert A */
597TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA)
598{
599 Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
600 {
601 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500602 ActionSet ledsAssert{};
603 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530604
Patrick Venture91ac8d32018-11-01 17:03:22 -0700605 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400606 auto result =
607 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530608 EXPECT_EQ(true, result);
609
610 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500611 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500612 {"One", phosphor::led::Layout::Action::On, 0, 0,
613 phosphor::led::Layout::Action::On},
614 {"Two", phosphor::led::Layout::Action::On, 0, 0,
615 phosphor::led::Layout::Action::On},
616 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
617 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530618 };
619 EXPECT_EQ(refAssert.size(), ledsAssert.size());
620 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530621
622 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500623 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530624 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
625 refAssert.begin(), refAssert.end(),
626 std::inserter(temp, temp.begin()));
627 EXPECT_EQ(0, temp.size());
628 }
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530629 {
630 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500631 ActionSet ledsAssert{};
632 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530633
Patrick Venture91ac8d32018-11-01 17:03:22 -0700634 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400635 auto result =
636 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530637 EXPECT_EQ(true, result);
638
639 // Need just the ledsAssserted populated with these.
640 // [Three] does not get actioned since it has Blink priority
Patrick Williams158b2c12022-03-17 05:57:44 -0500641 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500642 {"Four", phosphor::led::Layout::Action::On, 0, 0,
643 phosphor::led::Layout::Action::On},
644 {"Six", phosphor::led::Layout::Action::On, 0, 0,
645 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530646 };
647 EXPECT_EQ(refAssert.size(), ledsAssert.size());
648 EXPECT_EQ(0, ledsDeAssert.size());
649
650 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500651 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530652 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
653 refAssert.begin(), refAssert.end(),
654 std::inserter(temp, temp.begin()));
655 EXPECT_EQ(0, temp.size());
656 }
657 {
658 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500659 ActionSet ledsAssert{};
660 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530661
Patrick Venture91ac8d32018-11-01 17:03:22 -0700662 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400663 auto result =
664 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530665 EXPECT_EQ(false, result);
666
667 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500668 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500669 {"One", phosphor::led::Layout::Action::On, 0, 0,
670 phosphor::led::Layout::Action::On},
671 {"Two", phosphor::led::Layout::Action::On, 0, 0,
672 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530673 };
674 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
675
676 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500677 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530678 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
679 refDeAssert.begin(), refDeAssert.end(),
680 std::inserter(temp, temp.begin()));
681 EXPECT_EQ(0, temp.size());
682
683 // Need just the ledsAssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500684 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500685 {"Three", phosphor::led::Layout::Action::On, 0, 0,
686 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530687 };
688 EXPECT_EQ(refAssert.size(), ledsAssert.size());
689
690 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500691 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530692 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
693 refAssert.begin(), refAssert.end(),
694 std::inserter(temp1, temp1.begin()));
695 EXPECT_EQ(0, temp1.size());
696 }
697}
698
699/** @brief Assert 2 groups having one of the LEDs common but having ON as
700 * priority And Deassert A */
701TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA)
702{
703 Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
704 {
705 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500706 ActionSet ledsAssert{};
707 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530708
Patrick Venture91ac8d32018-11-01 17:03:22 -0700709 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400710 auto result =
711 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530712 EXPECT_EQ(true, result);
713
714 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500715 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500716 {"One", phosphor::led::Layout::Action::On, 0, 0,
717 phosphor::led::Layout::Action::On},
718 {"Two", phosphor::led::Layout::Action::On, 0, 0,
719 phosphor::led::Layout::Action::On},
720 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
721 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530722 };
723 EXPECT_EQ(refAssert.size(), ledsAssert.size());
724 EXPECT_EQ(0, ledsDeAssert.size());
725
726 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500727 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530728 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
729 refAssert.begin(), refAssert.end(),
730 std::inserter(temp, temp.begin()));
731 EXPECT_EQ(0, temp.size());
732 }
733 {
734 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500735 ActionSet ledsAssert{};
736 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530737
Patrick Venture91ac8d32018-11-01 17:03:22 -0700738 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400739 auto result =
740 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530741 EXPECT_EQ(true, result);
742
743 // Need just the ledsAssserted populated with these.
744 // Three is set to ON due to ON priority.
Patrick Williams158b2c12022-03-17 05:57:44 -0500745 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500746 {"Three", phosphor::led::Layout::Action::On, 0, 0,
747 phosphor::led::Layout::Action::On},
748 {"Four", phosphor::led::Layout::Action::On, 0, 0,
749 phosphor::led::Layout::Action::On},
750 {"Six", phosphor::led::Layout::Action::On, 0, 0,
751 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530752 };
753 EXPECT_EQ(refAssert.size(), ledsAssert.size());
754 EXPECT_EQ(0, ledsDeAssert.size());
755
756 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500757 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530758 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
759 refAssert.begin(), refAssert.end(),
760 std::inserter(temp, temp.begin()));
761 }
762 {
763 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500764 ActionSet ledsAssert{};
765 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530766
Patrick Venture91ac8d32018-11-01 17:03:22 -0700767 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400768 auto result =
769 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530770 EXPECT_EQ(false, result);
771
772 // Need just the ledsDeAssserted populated with these.
773 // [Three] stays in [On] since [B] has it [On]
Patrick Williams158b2c12022-03-17 05:57:44 -0500774 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500775 {"One", phosphor::led::Layout::Action::On, 0, 0,
776 phosphor::led::Layout::Action::On},
777 {"Two", phosphor::led::Layout::Action::On, 0, 0,
778 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530779 };
780 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
781 EXPECT_EQ(0, ledsAssert.size());
782
783 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500784 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530785 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
786 refDeAssert.begin(), refDeAssert.end(),
787 std::inserter(temp, temp.begin()));
788 EXPECT_EQ(0, temp.size());
789 }
790}
791
792/** @brief Assert 2 groups having one of the LEDs common but having ON as
793 * priority And Deassert B */
794TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB)
795{
796 Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
797 {
798 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500799 ActionSet ledsAssert{};
800 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530801
Patrick Venture91ac8d32018-11-01 17:03:22 -0700802 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400803 auto result =
804 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530805 EXPECT_EQ(true, result);
806
807 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500808 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500809 {"One", phosphor::led::Layout::Action::On, 0, 0,
810 phosphor::led::Layout::Action::On},
811 {"Two", phosphor::led::Layout::Action::On, 0, 0,
812 phosphor::led::Layout::Action::On},
813 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
814 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530815 };
816 EXPECT_EQ(refAssert.size(), ledsAssert.size());
817 EXPECT_EQ(0, ledsDeAssert.size());
818
819 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500820 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530821 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
822 refAssert.begin(), refAssert.end(),
823 std::inserter(temp, temp.begin()));
824 EXPECT_EQ(0, temp.size());
825 }
826 {
827 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500828 ActionSet ledsAssert{};
829 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530830
Patrick Venture91ac8d32018-11-01 17:03:22 -0700831 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400832 auto result =
833 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530834 EXPECT_EQ(true, result);
835
836 // Need just the ledsAssserted populated with these.
837 // Three is set to ON due to ON priority.
Patrick Williams158b2c12022-03-17 05:57:44 -0500838 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500839 {"Three", phosphor::led::Layout::Action::On, 0, 0,
840 phosphor::led::Layout::Action::On},
841 {"Four", phosphor::led::Layout::Action::On, 0, 0,
842 phosphor::led::Layout::Action::On},
843 {"Six", phosphor::led::Layout::Action::On, 0, 0,
844 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530845 };
846 EXPECT_EQ(refAssert.size(), ledsAssert.size());
847 EXPECT_EQ(0, ledsDeAssert.size());
848
849 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500850 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530851 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
852 refAssert.begin(), refAssert.end(),
853 std::inserter(temp, temp.begin()));
854 }
855 {
856 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500857 ActionSet ledsAssert{};
858 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530859
Patrick Venture91ac8d32018-11-01 17:03:22 -0700860 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400861 auto result =
862 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530863 EXPECT_EQ(false, result);
864
865 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500866 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500867 {"Four", phosphor::led::Layout::Action::On, 0, 0,
868 phosphor::led::Layout::Action::On},
869 {"Six", phosphor::led::Layout::Action::On, 0, 0,
870 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530871 };
872 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
873
874 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500875 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530876 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
877 refDeAssert.begin(), refDeAssert.end(),
878 std::inserter(temp, temp.begin()));
879 EXPECT_EQ(0, temp.size());
880
881 // Need just the ledsAssert populated with these.
882 // Since [Three] stood [On], need to go back to [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500883 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500884 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
885 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530886 };
887 EXPECT_EQ(refAssert.size(), ledsAssert.size());
888
889 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500890 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530891 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
892 refAssert.begin(), refAssert.end(),
893 std::inserter(temp, temp.begin()));
894 EXPECT_EQ(0, temp.size());
895 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530896}
897
898/** @brief Assert 2 groups having multiple common LEDs in Same State */
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530899TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530900{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530901 Manager manager(bus, twoGroupsWithMultiplComonLEDOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530902 {
903 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500904 ActionSet ledsAssert{};
905 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530906
Patrick Venture91ac8d32018-11-01 17:03:22 -0700907 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400908 auto result =
909 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530910 EXPECT_EQ(true, result);
911
912 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500913 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500914 {"Two", phosphor::led::Layout::Action::On, 0, 0,
915 phosphor::led::Layout::Action::On},
916 {"Six", phosphor::led::Layout::Action::On, 0, 0,
917 phosphor::led::Layout::Action::On},
918 {"Three", phosphor::led::Layout::Action::On, 0, 0,
919 phosphor::led::Layout::Action::On},
920 {"Seven", phosphor::led::Layout::Action::On, 0, 0,
921 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530922 };
923 EXPECT_EQ(refAssert.size(), ledsAssert.size());
924 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530925
926 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500927 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530928 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
929 refAssert.begin(), refAssert.end(),
930 std::inserter(temp, temp.begin()));
931 EXPECT_EQ(0, temp.size());
932 }
933 {
934 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500935 ActionSet ledsAssert{};
936 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530937
Patrick Venture91ac8d32018-11-01 17:03:22 -0700938 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400939 auto result =
940 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530941 EXPECT_EQ(true, result);
942
943 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500944 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500945 {"One", phosphor::led::Layout::Action::On, 0, 0,
946 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530947 };
948 EXPECT_EQ(refAssert.size(), ledsAssert.size());
949 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530950
951 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500952 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530953 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
954 refAssert.begin(), refAssert.end(),
955 std::inserter(temp, temp.begin()));
956 EXPECT_EQ(0, temp.size());
957 }
958 {
959 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500960 ActionSet ledsAssert{};
961 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530962
Patrick Venture91ac8d32018-11-01 17:03:22 -0700963 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400964 auto result =
965 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530966 EXPECT_EQ(false, result);
967
968 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500969 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500970 {"Six", phosphor::led::Layout::Action::On, 0, 0,
971 phosphor::led::Layout::Action::On},
972 {"Seven", phosphor::led::Layout::Action::On, 0, 0,
973 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530974 };
975 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
976 EXPECT_EQ(0, ledsAssert.size());
977
978 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500979 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530980 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
981 refDeAssert.begin(), refDeAssert.end(),
982 std::inserter(temp, temp.begin()));
983 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530984 }
985}
986
987/** @brief Assert 2 groups having multiple LEDs common in different state */
988TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA)
989{
990 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
991 {
992 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500993 ActionSet ledsAssert{};
994 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530995
Patrick Venture91ac8d32018-11-01 17:03:22 -0700996 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400997 auto result =
998 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530999 EXPECT_EQ(true, result);
1000
1001 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001002 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001003 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1004 phosphor::led::Layout::Action::On},
1005 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1006 phosphor::led::Layout::Action::On},
1007 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1008 phosphor::led::Layout::Action::On},
1009 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1010 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301011 };
1012 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1013 EXPECT_EQ(0, ledsDeAssert.size());
1014
1015 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001016 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301017 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1018 refAssert.begin(), refAssert.end(),
1019 std::inserter(temp, temp.begin()));
1020 EXPECT_EQ(0, temp.size());
1021 }
1022 {
1023 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001024 ActionSet ledsAssert{};
1025 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301026
Patrick Venture91ac8d32018-11-01 17:03:22 -07001027 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001028 auto result =
1029 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301030 EXPECT_EQ(true, result);
1031
1032 // Need just the ledsAssserted populated with these
1033 // [Two] remains [On] due to higher priority.
1034 // [Three] remains [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001035 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001036 {"One", phosphor::led::Layout::Action::On, 0, 0,
1037 phosphor::led::Layout::Action::On},
1038 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1039 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301040 };
1041 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1042 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301043
1044 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001045 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301046 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1047 refAssert.begin(), refAssert.end(),
1048 std::inserter(temp, temp.begin()));
1049 EXPECT_EQ(0, temp.size());
1050 }
1051}
1052
1053/** @brief Assert 2 groups having multiple LEDs common in different state */
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301054TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301055{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +05301056 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301057 {
1058 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001059 ActionSet ledsAssert{};
1060 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301061
Patrick Venture91ac8d32018-11-01 17:03:22 -07001062 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001063 auto result =
1064 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301065 EXPECT_EQ(true, result);
1066
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301067 // Need just the ledsAssserted populated with these.'Two' gets to Blink
1068 // due to higher priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001069 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001070 {"One", phosphor::led::Layout::Action::On, 0, 0,
1071 phosphor::led::Layout::Action::On},
1072 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1073 phosphor::led::Layout::Action::On},
1074 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1075 phosphor::led::Layout::Action::On},
1076 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1077 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301078 };
1079 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1080 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301081
1082 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001083 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301084 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1085 refAssert.begin(), refAssert.end(),
1086 std::inserter(temp, temp.begin()));
1087 EXPECT_EQ(0, temp.size());
1088 }
1089 {
1090 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001091 ActionSet ledsAssert{};
1092 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301093
Patrick Venture91ac8d32018-11-01 17:03:22 -07001094 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001095 auto result =
1096 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301097 EXPECT_EQ(true, result);
1098
1099 // Need just the ledsAssserted populated with these.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301100 // [Three] remains [Blink] from previous
1101 // [Two] moves to [On] from [Blink] due to [On] priority
Patrick Williams158b2c12022-03-17 05:57:44 -05001102 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001103 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1104 phosphor::led::Layout::Action::On},
1105 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1106 phosphor::led::Layout::Action::On},
1107 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1108 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301109 };
1110 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1111 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301112
1113 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001114 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301115 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1116 refAssert.begin(), refAssert.end(),
1117 std::inserter(temp, temp.begin()));
1118 EXPECT_EQ(0, temp.size());
1119 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301120}
1121
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301122/** @brief Assert 2 groups having multiple LEDs common in different state
1123 * DeAssert twice
1124 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001125TEST_F(LedTest,
1126 assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301127{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +05301128 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301129 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301130 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001131 ActionSet ledsAssert{};
1132 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301133
Patrick Venture91ac8d32018-11-01 17:03:22 -07001134 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001135 auto result =
1136 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301137 EXPECT_EQ(true, result);
1138
1139 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001140 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001141 {"One", phosphor::led::Layout::Action::On, 0, 0,
1142 phosphor::led::Layout::Action::On},
1143 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1144 phosphor::led::Layout::Action::On},
1145 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1146 phosphor::led::Layout::Action::On},
1147 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1148 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301149 };
1150 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1151 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301152
1153 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001154 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301155 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1156 refAssert.begin(), refAssert.end(),
1157 std::inserter(temp, temp.begin()));
1158 EXPECT_EQ(0, temp.size());
1159 }
1160 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301161 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001162 ActionSet ledsAssert{};
1163 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301164
Patrick Venture91ac8d32018-11-01 17:03:22 -07001165 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001166 auto result =
1167 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301168 EXPECT_EQ(true, result);
1169
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301170 // Need just the ledsAssserted populated with these.
1171 // [Two] turns [On] due to priority
1172 // [Three] remains [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001173 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001174 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1175 phosphor::led::Layout::Action::On},
1176 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1177 phosphor::led::Layout::Action::On},
1178 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1179 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301180 };
1181 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1182 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301183
1184 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001185 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301186 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1187 refAssert.begin(), refAssert.end(),
1188 std::inserter(temp, temp.begin()));
1189 EXPECT_EQ(0, temp.size());
1190 }
1191 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301192 // DeAssert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001193 ActionSet ledsAssert{};
1194 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301195
Patrick Venture91ac8d32018-11-01 17:03:22 -07001196 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001197 auto result =
1198 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301199 EXPECT_EQ(false, result);
1200
1201 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001202 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001203 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1204 phosphor::led::Layout::Action::On},
1205 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1206 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301207 };
1208 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1209
1210 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001211 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301212 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1213 refDeAssert.begin(), refDeAssert.end(),
1214 std::inserter(temp, temp.begin()));
1215 EXPECT_EQ(0, temp.size());
1216
1217 // Need just the ledsAssert populated with these.
1218 // [Two] will go back to [Blink] from [On]
Patrick Williams158b2c12022-03-17 05:57:44 -05001219 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001220 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1221 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301222 };
1223 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1224
1225 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001226 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301227 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1228 refAssert.begin(), refAssert.end(),
1229 std::inserter(temp1, temp1.begin()));
1230 EXPECT_EQ(0, temp1.size());
1231 }
1232 {
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301233 // DeAssert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001234 ActionSet ledsAssert{};
1235 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301236
Patrick Venture91ac8d32018-11-01 17:03:22 -07001237 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001238 auto result =
1239 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301240 EXPECT_EQ(false, result);
1241
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301242 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001243 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001244 {"One", phosphor::led::Layout::Action::On, 0, 0,
1245 phosphor::led::Layout::Action::On},
1246 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1247 phosphor::led::Layout::Action::On},
1248 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1249 phosphor::led::Layout::Action::On},
1250 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1251 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301252 };
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301253 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301254 EXPECT_EQ(0, ledsAssert.size());
1255
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301256 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001257 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301258 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1259 refDeAssert.begin(), refDeAssert.end(),
1260 std::inserter(temp, temp.begin()));
1261 EXPECT_EQ(0, temp.size());
1262 }
1263 {
1264 // DeAssert Set-A again and make sure we get all empty
Patrick Williams158b2c12022-03-17 05:57:44 -05001265 ActionSet ledsAssert{};
1266 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301267
Patrick Venture91ac8d32018-11-01 17:03:22 -07001268 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001269 auto result =
1270 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301271 EXPECT_EQ(false, result);
1272 EXPECT_EQ(0, ledsDeAssert.size());
1273 EXPECT_EQ(0, ledsAssert.size());
1274 }
1275}
1276
1277/** @brief Assert 2 groups having multiple LEDs common in different state and
1278 * mixed priority. DeAssert-A
1279 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001280TEST_F(LedTest,
1281 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301282{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001283 Manager manager(bus,
1284 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301285 {
1286 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001287 ActionSet ledsAssert{};
1288 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301289
Patrick Venture91ac8d32018-11-01 17:03:22 -07001290 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001291 auto result =
1292 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301293 EXPECT_EQ(true, result);
1294
1295 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001296 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001297 {"One", phosphor::led::Layout::Action::On, 0, 0,
1298 phosphor::led::Layout::Action::On},
1299 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1300 phosphor::led::Layout::Action::On},
1301 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1302 phosphor::led::Layout::Action::Blink},
1303 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1304 phosphor::led::Layout::Action::On},
1305 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1306 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301307 };
1308 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1309 EXPECT_EQ(0, ledsDeAssert.size());
1310
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301311 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001312 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301313 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1314 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301315 std::inserter(temp, temp.begin()));
1316 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301317 }
1318 {
1319 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001320 ActionSet ledsAssert{};
1321 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301322
Patrick Venture91ac8d32018-11-01 17:03:22 -07001323 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001324 auto result =
1325 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301326 EXPECT_EQ(true, result);
1327
1328 // Need just the ledsAssserted populated with these.
1329 // [Two] gets to [ON] due to higher priority.
1330 // [Three] remains on since it never was in [Blink] before
1331 // [Ten] remains [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001332 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001333 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1334 phosphor::led::Layout::Action::On},
1335 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1336 phosphor::led::Layout::Action::On},
1337 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1338 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301339 };
1340 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1341 EXPECT_EQ(0, ledsDeAssert.size());
1342
1343 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001344 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301345 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1346 refAssert.begin(), refAssert.end(),
1347 std::inserter(temp, temp.begin()));
1348 EXPECT_EQ(0, temp.size());
1349 }
1350 {
1351 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001352 ActionSet ledsAssert{};
1353 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301354
Patrick Venture91ac8d32018-11-01 17:03:22 -07001355 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001356 auto result =
1357 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301358 EXPECT_EQ(false, result);
1359
1360 // Need just the ledsDeAsssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001361 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001362 {"One", phosphor::led::Layout::Action::On, 0, 0,
1363 phosphor::led::Layout::Action::On},
1364 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1365 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301366 };
1367 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1368
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301369 // Need just the ledsAsssert populated with these.
1370 // [Ten] Moves to [On] since there is no prior [Blink]
1371 // [Three] remains [On] since it never changed state.
1372 // [Two] remains [On] since it did not go back
Patrick Williams158b2c12022-03-17 05:57:44 -05001373 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001374 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1375 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301376 };
1377 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1378
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301379 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001380 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301381 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1382 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301383 std::inserter(temp, temp.begin()));
1384 EXPECT_EQ(0, temp.size());
1385 }
1386}
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301387
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301388/** @brief Assert 2 groups having multiple LEDs common in different state and
1389 * mixed priority. DeAssert-B
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301390 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001391TEST_F(
1392 LedTest,
1393 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB)
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301394{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001395 Manager manager(bus,
1396 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301397 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301398 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001399 ActionSet ledsAssert{};
1400 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301401
Patrick Venture91ac8d32018-11-01 17:03:22 -07001402 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001403 auto result =
1404 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301405 EXPECT_EQ(true, result);
1406
1407 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001408 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001409 {"One", phosphor::led::Layout::Action::On, 0, 0,
1410 phosphor::led::Layout::Action::On},
1411 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1412 phosphor::led::Layout::Action::On},
1413 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1414 phosphor::led::Layout::Action::Blink},
1415 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1416 phosphor::led::Layout::Action::On},
1417 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1418 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301419 };
1420 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1421 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301422
1423 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001424 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301425 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1426 refAssert.begin(), refAssert.end(),
1427 std::inserter(temp, temp.begin()));
1428 EXPECT_EQ(0, temp.size());
1429 }
1430 {
1431 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001432 ActionSet ledsAssert{};
1433 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301434
Patrick Venture91ac8d32018-11-01 17:03:22 -07001435 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001436 auto result =
1437 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301438 EXPECT_EQ(true, result);
1439
1440 // Need just the ledsAssserted populated with these.
1441 // [Two] gets to [ON] due to higher priority.
1442 // [Three] remains on since it never was in [Blink] before
1443 // [Ten] remains [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001444 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001445 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1446 phosphor::led::Layout::Action::On},
1447 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1448 phosphor::led::Layout::Action::On},
1449 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1450 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301451 };
1452 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1453 EXPECT_EQ(0, ledsDeAssert.size());
1454
1455 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001456 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301457 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1458 refAssert.begin(), refAssert.end(),
1459 std::inserter(temp, temp.begin()));
1460 EXPECT_EQ(0, temp.size());
1461 }
1462 {
1463 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001464 ActionSet ledsAssert{};
1465 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301466
Patrick Venture91ac8d32018-11-01 17:03:22 -07001467 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001468 auto result =
1469 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301470 EXPECT_EQ(false, result);
1471
1472 // Need just the ledsDeAsssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001473 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001474 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1475 phosphor::led::Layout::Action::On},
1476 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1477 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301478 };
1479 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1480
1481 // Need just the ledsAsssert populated with these.
1482 // [Ten] remains [Blink] since it did not move to [On]
1483 // [Three] remains [On] since it never changed state.
1484 // [Two] moves to [Blink] since there is no prior [On]
Patrick Williams158b2c12022-03-17 05:57:44 -05001485 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001486 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1487 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301488 };
1489 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1490
1491 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001492 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301493 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1494 refAssert.begin(), refAssert.end(),
1495 std::inserter(temp, temp.begin()));
1496 EXPECT_EQ(0, temp.size());
1497 }
1498}
1499
1500/** @brief Assert 2 groups having multiple LEDs common in different state and
1501 * mixed priority.
1502 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001503TEST_F(LedTest,
1504 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301505{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001506 Manager manager(bus,
1507 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301508 {
1509 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001510 ActionSet ledsAssert{};
1511 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301512
Patrick Venture91ac8d32018-11-01 17:03:22 -07001513 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001514 auto result =
1515 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301516 EXPECT_EQ(true, result);
1517
1518 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001519 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001520 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1521 phosphor::led::Layout::Action::On},
1522 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1523 phosphor::led::Layout::Action::Blink},
1524 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1525 phosphor::led::Layout::Action::On},
1526 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1527 phosphor::led::Layout::Action::On},
1528 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1529 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301530 };
1531 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1532 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301533
1534 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001535 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301536 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1537 refAssert.begin(), refAssert.end(),
1538 std::inserter(temp, temp.begin()));
1539 EXPECT_EQ(0, temp.size());
1540 }
1541 {
1542 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001543 ActionSet ledsAssert{};
1544 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301545
Patrick Venture91ac8d32018-11-01 17:03:22 -07001546 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001547 auto result =
1548 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301549 EXPECT_EQ(true, result);
1550
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301551 // Need just the ledsAssserted populated with these.
1552 // [Two] remains [ON] due to higher priority.
1553 // [Three] remains on since it never was in [Blink] before
1554 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001555 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001556 {"One", phosphor::led::Layout::Action::On, 0, 0,
1557 phosphor::led::Layout::Action::On},
1558 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1559 phosphor::led::Layout::Action::On},
1560 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1561 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301562 };
1563 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1564 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301565
1566 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001567 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301568 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1569 refAssert.begin(), refAssert.end(),
1570 std::inserter(temp, temp.begin()));
1571 EXPECT_EQ(0, temp.size());
1572 }
1573}
1574
1575/** @brief Assert 2 groups having multiple LEDs common in different state and
1576 * mixed priority and De-Assert-A
1577 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001578TEST_F(
1579 LedTest,
1580 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301581{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001582 Manager manager(bus,
1583 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301584 {
1585 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001586 ActionSet ledsAssert{};
1587 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301588
Patrick Venture91ac8d32018-11-01 17:03:22 -07001589 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001590 auto result =
1591 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301592 EXPECT_EQ(true, result);
1593
1594 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001595 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001596 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1597 phosphor::led::Layout::Action::On},
1598 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1599 phosphor::led::Layout::Action::Blink},
1600 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1601 phosphor::led::Layout::Action::On},
1602 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1603 phosphor::led::Layout::Action::On},
1604 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1605 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301606 };
1607 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1608 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301609
1610 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001611 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301612 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1613 refAssert.begin(), refAssert.end(),
1614 std::inserter(temp, temp.begin()));
1615 EXPECT_EQ(0, temp.size());
1616 }
1617 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301618 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001619 ActionSet ledsAssert{};
1620 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301621
Patrick Venture91ac8d32018-11-01 17:03:22 -07001622 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001623 auto result =
1624 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301625 EXPECT_EQ(true, result);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301626
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301627 // Need just the ledsAssserted populated with these.
1628 // [Two] remains [ON] due to higher priority.
1629 // [Three] remains on since it never was in [Blink] before
1630 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001631 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001632 {"One", phosphor::led::Layout::Action::On, 0, 0,
1633 phosphor::led::Layout::Action::On},
1634 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1635 phosphor::led::Layout::Action::On},
1636 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1637 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301638 };
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301639 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1640 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301641
1642 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001643 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301644 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1645 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301646 std::inserter(temp, temp.begin()));
1647 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301648 }
1649 {
1650 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001651 ActionSet ledsAssert{};
1652 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301653
Patrick Venture91ac8d32018-11-01 17:03:22 -07001654 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001655 auto result =
1656 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301657 EXPECT_EQ(false, result);
1658
1659 // Need just the ledsAssserted populated with these.
1660 // [Ten] remains [Blink] due to priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001661 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001662 {"One", phosphor::led::Layout::Action::On, 0, 0,
1663 phosphor::led::Layout::Action::On},
1664 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1665 phosphor::led::Layout::Action::On},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301666 };
1667 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1668
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301669 // Need just the ledsAssserted populated with these.
1670 // [Two] remains [ON] due to higher priority.
1671 // [Three] remains [On] since it never was in [Blink] before
1672 // [Ten] moves to [On] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001673 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001674 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1675 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301676 };
1677 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1678
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301679 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001680 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301681 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1682 refAssert.begin(), refAssert.end(),
1683 std::inserter(temp, temp.begin()));
1684 EXPECT_EQ(0, temp.size());
1685 }
1686}
1687
1688/** @brief Assert 2 groups having multiple LEDs common in different state and
1689 * mixed priority and then DeAssert twice.
1690 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001691TEST_F(LedTest,
1692 assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301693{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001694 Manager manager(bus,
1695 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301696 {
1697 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001698 ActionSet ledsAssert{};
1699 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301700
Patrick Venture91ac8d32018-11-01 17:03:22 -07001701 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001702 auto result =
1703 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301704 EXPECT_EQ(true, result);
1705
1706 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001707 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001708 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1709 phosphor::led::Layout::Action::On},
1710 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1711 phosphor::led::Layout::Action::Blink},
1712 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1713 phosphor::led::Layout::Action::On},
1714 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1715 phosphor::led::Layout::Action::On},
1716 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1717 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301718 };
1719 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1720 EXPECT_EQ(0, ledsDeAssert.size());
1721
1722 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001723 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301724 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1725 refAssert.begin(), refAssert.end(),
1726 std::inserter(temp, temp.begin()));
1727 EXPECT_EQ(0, temp.size());
1728 }
1729 {
1730 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001731 ActionSet ledsAssert{};
1732 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301733
Patrick Venture91ac8d32018-11-01 17:03:22 -07001734 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001735 auto result =
1736 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301737 EXPECT_EQ(true, result);
1738
1739 // Need just the ledsAssserted populated with these.
1740 // [Two] remains [ON] due to higher priority.
1741 // [Three] remains on since it never was in [Blink] before
1742 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001743 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001744 {"One", phosphor::led::Layout::Action::On, 0, 0,
1745 phosphor::led::Layout::Action::On},
1746 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1747 phosphor::led::Layout::Action::On},
1748 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1749 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301750 };
1751 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1752 EXPECT_EQ(0, ledsDeAssert.size());
1753
1754 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001755 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301756 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1757 refAssert.begin(), refAssert.end(),
1758 std::inserter(temp, temp.begin()));
1759 EXPECT_EQ(0, temp.size());
1760 }
1761 {
1762 // DeAssert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001763 ActionSet ledsAssert{};
1764 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301765
Patrick Venture91ac8d32018-11-01 17:03:22 -07001766 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001767 auto result =
1768 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301769 EXPECT_EQ(false, result);
1770
1771 // Need just the ledsAssserted populated with these.
1772 // [Ten] remains [Blink] due to priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001773 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001774 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1775 phosphor::led::Layout::Action::On},
1776 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1777 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301778 };
1779 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1780
1781 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001782 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301783 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1784 refDeAssert.begin(), refDeAssert.end(),
1785 std::inserter(temp, temp.begin()));
1786 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301787
1788 // Need just the ledsAssert populated with these.
1789 // [Two] will move to [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001790 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001791 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1792 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301793 };
1794 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1795
1796 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001797 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301798 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1799 refAssert.begin(), refAssert.end(),
1800 std::inserter(temp1, temp1.begin()));
1801 EXPECT_EQ(0, temp1.size());
1802 }
1803 {
1804 // DeAssert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001805 ActionSet ledsAssert{};
1806 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301807
Patrick Venture91ac8d32018-11-01 17:03:22 -07001808 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001809 auto result =
1810 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301811 EXPECT_EQ(false, result);
1812
1813 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001814 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001815 {"One", phosphor::led::Layout::Action::On, 0, 0,
1816 phosphor::led::Layout::Action::On},
1817 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1818 phosphor::led::Layout::Action::On},
1819 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1820 phosphor::led::Layout::Action::Blink},
1821 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1822 phosphor::led::Layout::Action::On},
1823 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1824 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301825 };
1826 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1827 EXPECT_EQ(0, ledsAssert.size());
1828
1829 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001830 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301831 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1832 refDeAssert.begin(), refDeAssert.end(),
1833 std::inserter(temp, temp.begin()));
1834 EXPECT_EQ(0, temp.size());
1835 }
1836 {
1837 // DeAssert Set-B again and make sure we get all empty
Patrick Williams158b2c12022-03-17 05:57:44 -05001838 ActionSet ledsAssert{};
1839 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301840
Patrick Venture91ac8d32018-11-01 17:03:22 -07001841 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001842 auto result =
1843 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301844 EXPECT_EQ(false, result);
1845 EXPECT_EQ(0, ledsDeAssert.size());
1846 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301847 }
1848}