xref: /openbmc/phosphor-led-manager/test/utest.cpp (revision c8ddde644bcb304f6386c33ce485640cff291261)
1 #include "led-test-map.hpp"
2 #include "manager.hpp"
3 
4 #include <sdbusplus/bus.hpp>
5 
6 #include <algorithm>
7 #include <set>
8 
9 #include <gtest/gtest.h>
10 using namespace phosphor::led;
11 class LedTest : public ::testing::Test
12 {
13   public:
14     sdbusplus::bus_t bus;
15     LedTest() : bus(sdbusplus::bus::new_default())
16     {
17         // Nothing here
18     }
19     ~LedTest() override = default;
20 };
21 
22 /** @brief Assert Single LED to On */
23 TEST_F(LedTest, assertSingleLedOn)
24 {
25     Manager manager(bus, singleLedOn);
26     {
27         // Assert the LEDs.
28         ActionSet ledsAssert{};
29         ActionSet ledsDeAssert{};
30 
31         auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
32         auto result =
33             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
34         EXPECT_EQ(true, result);
35 
36         // Need just the ledsAssserted populated with these.
37         ActionSet refAssert = {
38             {"One", phosphor::led::Layout::Action::On, 0, 0,
39              phosphor::led::Layout::Action::Blink},
40         };
41         EXPECT_EQ(refAssert.size(), ledsAssert.size());
42         EXPECT_EQ(0, ledsDeAssert.size());
43 
44         // difference of refAssert and ledsAssert must be null.
45         ActionSet temp{};
46         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 */
54 TEST_F(LedTest, assertSingleLedBlink)
55 {
56     Manager manager(bus, singleLedBlink);
57     {
58         // Assert the LEDs.
59         ActionSet ledsAssert{};
60         ActionSet ledsDeAssert{};
61 
62         auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
63         auto result =
64             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
65         EXPECT_EQ(true, result);
66 
67         // Need just the ledsAssserted populated with these.
68         ActionSet refAssert = {
69             {"One", phosphor::led::Layout::Action::Blink, 0, 0,
70              phosphor::led::Layout::Action::Blink},
71         };
72         EXPECT_EQ(refAssert.size(), ledsAssert.size());
73         EXPECT_EQ(0, ledsDeAssert.size());
74 
75         // difference of refAssert and ledsAssert must be null.
76         ActionSet temp{};
77         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 */
85 TEST_F(LedTest, assertSingleLedOnAndreAssert)
86 {
87     Manager manager(bus, singleLedOn);
88     {
89         // Assert the LEDs.
90         ActionSet ledsAssert{};
91         ActionSet ledsDeAssert{};
92 
93         auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
94         auto result =
95             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
96         EXPECT_EQ(true, result);
97 
98         // Need just the ledsAssserted populated with these.
99         ActionSet refAssert = {
100             {"One", phosphor::led::Layout::Action::On, 0, 0,
101              phosphor::led::Layout::Action::Blink},
102         };
103         EXPECT_EQ(refAssert.size(), ledsAssert.size());
104         EXPECT_EQ(0, ledsDeAssert.size());
105 
106         // difference of refAssert and ledsAssert must be null.
107         ActionSet temp{};
108         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.
115         ActionSet ledsAssert{};
116         ActionSet ledsDeAssert{};
117 
118         auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
119         auto result =
120             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
121         EXPECT_EQ(true, result);
122 
123         EXPECT_EQ(0, ledsAssert.size());
124         EXPECT_EQ(0, ledsDeAssert.size());
125     }
126 }
127 
128 /** @brief Assert Multiple LEDs to On */
129 TEST_F(LedTest, assertMultipleLedOn)
130 {
131     Manager manager(bus, multipleLedsOn);
132     {
133         // Assert the LEDs.
134         ActionSet ledsAssert{};
135         ActionSet ledsDeAssert{};
136 
137         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
138         auto result =
139             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
140         EXPECT_EQ(true, result);
141 
142         // Need just the ledsAssserted populated with these.
143         ActionSet refAssert = {
144             {"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},
150         };
151         EXPECT_EQ(refAssert.size(), ledsAssert.size());
152         EXPECT_EQ(0, ledsDeAssert.size());
153 
154         // difference of refAssert and ledsAssert must be null.
155         ActionSet temp{};
156         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 */
164 TEST_F(LedTest, assertMultipleLedBlink)
165 {
166     Manager manager(bus, multipleLedsBlink);
167     {
168         // Assert the LEDs.
169         ActionSet ledsAssert{};
170         ActionSet ledsDeAssert{};
171 
172         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
173         auto result =
174             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
175         EXPECT_EQ(true, result);
176 
177         // Need just the ledsAssserted populated with these.
178         ActionSet refAssert = {
179             {"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},
185         };
186         EXPECT_EQ(refAssert.size(), ledsAssert.size());
187         EXPECT_EQ(0, ledsDeAssert.size());
188 
189         // difference of refAssert and ledsAssert must be null.
190         ActionSet temp{};
191         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 */
199 TEST_F(LedTest, assertMultipleLedBlinkAndDeAssert)
200 {
201     Manager manager(bus, multipleLedsBlink);
202     {
203         // Assert the LEDs.
204         ActionSet ledsAssert{};
205         ActionSet ledsDeAssert{};
206 
207         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
208         auto result =
209             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
210         EXPECT_EQ(true, result);
211 
212         // Need just the ledsAssserted populated with these.
213         ActionSet refAssert = {
214             {"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},
220         };
221         EXPECT_EQ(refAssert.size(), ledsAssert.size());
222         EXPECT_EQ(0, ledsDeAssert.size());
223 
224         // difference of refAssert and ledsAssert must be null.
225         ActionSet temp{};
226         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.
233         ActionSet ledsAssert{};
234         ActionSet ledsDeAssert{};
235 
236         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
237         auto result =
238             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
239         EXPECT_EQ(false, result);
240 
241         // Need just the ledsAssserted populated with these.
242         ActionSet refDeAssert = {
243             {"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},
249         };
250         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
251         EXPECT_EQ(0, ledsAssert.size());
252 
253         // difference of refDeAssert and ledsDeAssert must be null.
254         ActionSet temp{};
255         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 */
263 TEST_F(LedTest, assertMultipleLedBlinkAndDeAssertTwice)
264 {
265     Manager manager(bus, multipleLedsBlink);
266     {
267         // Assert the LEDs.
268         ActionSet ledsAssert{};
269         ActionSet ledsDeAssert{};
270 
271         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
272         auto result =
273             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
274         EXPECT_EQ(true, result);
275 
276         // Need just the ledsAssserted populated with these.
277         ActionSet refAssert = {
278             {"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},
284         };
285         EXPECT_EQ(refAssert.size(), ledsAssert.size());
286         EXPECT_EQ(0, ledsDeAssert.size());
287 
288         // difference of refAssert and ledsAssert must be null.
289         ActionSet temp{};
290         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.
297         ActionSet ledsAssert{};
298         ActionSet ledsDeAssert{};
299 
300         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
301         auto result =
302             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
303         EXPECT_EQ(false, result);
304 
305         // Need just the ledsAssserted populated with these.
306         ActionSet refDeAssert = {
307             {"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},
313         };
314         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
315         EXPECT_EQ(0, ledsAssert.size());
316 
317         // difference of refDeAssert and ledsDeAssert must be null.
318         ActionSet temp{};
319         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.
326         ActionSet ledsAssert{};
327         ActionSet ledsDeAssert{};
328 
329         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
330         auto result =
331             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
332         EXPECT_EQ(false, result);
333         EXPECT_EQ(0, ledsDeAssert.size());
334         EXPECT_EQ(0, ledsAssert.size());
335     }
336 }
337 
338 /** @brief Assert Multiple LEDs to mix of On and Blink */
339 TEST_F(LedTest, assertMultipleLedOnAndBlink)
340 {
341     Manager manager(bus, multipleLedsOnAndBlink);
342     {
343         // Assert the LEDs.
344         ActionSet ledsAssert{};
345         ActionSet ledsDeAssert{};
346 
347         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix";
348         auto result =
349             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
350         EXPECT_EQ(true, result);
351 
352         // Need just the ledsAssserted populated with these.
353         ActionSet refAssert = {
354             {"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},
364         };
365         EXPECT_EQ(refAssert.size(), ledsAssert.size());
366         EXPECT_EQ(0, ledsDeAssert.size());
367 
368         // difference of refAssert and ledsAssert must be null.
369         ActionSet temp{};
370         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 */
378 TEST_F(LedTest, assertTwoGroupsOnWithDistinctLEDOn)
379 {
380     Manager manager(bus, twoGroupsWithDistinctLEDsOn);
381     {
382         // Assert Set-A
383         ActionSet ledsAssert{};
384         ActionSet ledsDeAssert{};
385 
386         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
387         auto result =
388             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
389         EXPECT_EQ(true, result);
390 
391         // Need just the ledsAssserted populated with these.
392         ActionSet refAssert = {
393             {"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},
399         };
400         EXPECT_EQ(refAssert.size(), ledsAssert.size());
401         EXPECT_EQ(0, ledsDeAssert.size());
402 
403         // difference of refAssert and ledsAssert must be null.
404         ActionSet temp{};
405         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
412         ActionSet ledsAssert{};
413         ActionSet ledsDeAssert{};
414 
415         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
416         auto result =
417             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
418         EXPECT_EQ(true, result);
419 
420         // Need just the ledsAssserted populated with these.
421         ActionSet refAssert = {
422             {"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},
428         };
429         EXPECT_EQ(refAssert.size(), ledsAssert.size());
430         EXPECT_EQ(0, ledsDeAssert.size());
431 
432         // difference of refAssert and ledsAssert must be null.
433         ActionSet temp{};
434         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 */
442 TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOn)
443 {
444     Manager manager(bus, twoGroupsWithOneComonLEDOn);
445     {
446         // Assert Set-A
447         ActionSet ledsAssert{};
448         ActionSet ledsDeAssert{};
449 
450         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
451         auto result =
452             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
453         EXPECT_EQ(true, result);
454 
455         // Need just the ledsAssserted populated with these.
456         ActionSet refAssert = {
457             {"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},
463         };
464         EXPECT_EQ(refAssert.size(), ledsAssert.size());
465         EXPECT_EQ(0, ledsDeAssert.size());
466 
467         // difference of refAssert and ledsAssert must be null.
468         ActionSet temp{};
469         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
476         ActionSet ledsAssert{};
477         ActionSet ledsDeAssert{};
478 
479         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
480         auto result =
481             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
482         EXPECT_EQ(true, result);
483 
484         // Need just the ledsAssserted populated with these.
485         ActionSet refAssert = {
486             {"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},
490         };
491         EXPECT_EQ(refAssert.size(), ledsAssert.size());
492         EXPECT_EQ(0, ledsDeAssert.size());
493 
494         // difference of refAssert and ledsAssert must be null.
495         ActionSet temp{};
496         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 
503 /** @brief Assert 2 groups having one of the LEDs common but having Blink as
504  * priority and Deassert*/
505 TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB)
506 {
507     Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
508     {
509         // Assert Set-A
510         ActionSet ledsAssert{};
511         ActionSet ledsDeAssert{};
512 
513         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
514         auto result =
515             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
516         EXPECT_EQ(true, result);
517 
518         // Need just the ledsAssserted populated with these.
519         ActionSet refAssert = {
520             {"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},
526         };
527         EXPECT_EQ(refAssert.size(), ledsAssert.size());
528         EXPECT_EQ(0, ledsDeAssert.size());
529 
530         // difference of refAssert and ledsAssert must be null.
531         ActionSet temp{};
532         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
539         ActionSet ledsAssert{};
540         ActionSet ledsDeAssert{};
541 
542         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
543         auto result =
544             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
545         EXPECT_EQ(true, result);
546 
547         // Need just the ledsAssserted populated with these.
548         // Does not action on [Three] since  priority is [Blink]
549         ActionSet refAssert = {
550             {"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},
554         };
555         EXPECT_EQ(refAssert.size(), ledsAssert.size());
556         EXPECT_EQ(0, ledsDeAssert.size());
557 
558         // difference of refAssert and ledsAssert must be null.
559         ActionSet temp{};
560         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
567         ActionSet ledsAssert{};
568         ActionSet ledsDeAssert{};
569 
570         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
571         auto result =
572             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
573         EXPECT_EQ(false, result);
574 
575         // Need just the ledsDeAssserted populated with these.
576         ActionSet refDeAssert = {
577             {"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},
581         };
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]
587         ActionSet temp{};
588         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 */
597 TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA)
598 {
599     Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
600     {
601         // Assert Set-A
602         ActionSet ledsAssert{};
603         ActionSet ledsDeAssert{};
604 
605         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
606         auto result =
607             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
608         EXPECT_EQ(true, result);
609 
610         // Need just the ledsAssserted populated with these.
611         ActionSet refAssert = {
612             {"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},
618         };
619         EXPECT_EQ(refAssert.size(), ledsAssert.size());
620         EXPECT_EQ(0, ledsDeAssert.size());
621 
622         // difference of refAssert and ledsAssert must be null.
623         ActionSet temp{};
624         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     }
629     {
630         // Assert Set-B
631         ActionSet ledsAssert{};
632         ActionSet ledsDeAssert{};
633 
634         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
635         auto result =
636             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
637         EXPECT_EQ(true, result);
638 
639         // Need just the ledsAssserted populated with these.
640         // [Three] does not get actioned since it has Blink priority
641         ActionSet refAssert = {
642             {"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},
646         };
647         EXPECT_EQ(refAssert.size(), ledsAssert.size());
648         EXPECT_EQ(0, ledsDeAssert.size());
649 
650         // difference of refAssert and ledsAssert must be null.
651         ActionSet temp{};
652         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
659         ActionSet ledsAssert{};
660         ActionSet ledsDeAssert{};
661 
662         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
663         auto result =
664             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
665         EXPECT_EQ(false, result);
666 
667         // Need just the ledsDeAssserted populated with these.
668         ActionSet refDeAssert = {
669             {"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},
673         };
674         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
675 
676         // difference of refDeAssert and ledsDeAssert must be null.
677         ActionSet temp{};
678         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.
684         ActionSet refAssert = {
685             {"Three", phosphor::led::Layout::Action::On, 0, 0,
686              phosphor::led::Layout::Action::Blink},
687         };
688         EXPECT_EQ(refAssert.size(), ledsAssert.size());
689 
690         // difference of refAssert and ledsAssert must be null.
691         ActionSet temp1{};
692         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 */
701 TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA)
702 {
703     Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
704     {
705         // Assert Set-A
706         ActionSet ledsAssert{};
707         ActionSet ledsDeAssert{};
708 
709         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
710         auto result =
711             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
712         EXPECT_EQ(true, result);
713 
714         // Need just the ledsAssserted populated with these.
715         ActionSet refAssert = {
716             {"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},
722         };
723         EXPECT_EQ(refAssert.size(), ledsAssert.size());
724         EXPECT_EQ(0, ledsDeAssert.size());
725 
726         // difference of refAssert and ledsAssert must be null.
727         ActionSet temp{};
728         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
735         ActionSet ledsAssert{};
736         ActionSet ledsDeAssert{};
737 
738         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
739         auto result =
740             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
741         EXPECT_EQ(true, result);
742 
743         // Need just the ledsAssserted populated with these.
744         // Three is set to ON due to ON priority.
745         ActionSet refAssert = {
746             {"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},
752         };
753         EXPECT_EQ(refAssert.size(), ledsAssert.size());
754         EXPECT_EQ(0, ledsDeAssert.size());
755 
756         // difference of refAssert and ledsAssert must be null.
757         ActionSet temp{};
758         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
764         ActionSet ledsAssert{};
765         ActionSet ledsDeAssert{};
766 
767         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
768         auto result =
769             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
770         EXPECT_EQ(false, result);
771 
772         // Need just the ledsDeAssserted populated with these.
773         // [Three] stays in [On] since [B] has it [On]
774         ActionSet refDeAssert = {
775             {"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},
779         };
780         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
781         EXPECT_EQ(0, ledsAssert.size());
782 
783         // difference of refDeAssert and ledsDeAssert must be null.
784         ActionSet temp{};
785         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 */
794 TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB)
795 {
796     Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
797     {
798         // Assert Set-A
799         ActionSet ledsAssert{};
800         ActionSet ledsDeAssert{};
801 
802         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
803         auto result =
804             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
805         EXPECT_EQ(true, result);
806 
807         // Need just the ledsAssserted populated with these.
808         ActionSet refAssert = {
809             {"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},
815         };
816         EXPECT_EQ(refAssert.size(), ledsAssert.size());
817         EXPECT_EQ(0, ledsDeAssert.size());
818 
819         // difference of refAssert and ledsAssert must be null.
820         ActionSet temp{};
821         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
828         ActionSet ledsAssert{};
829         ActionSet ledsDeAssert{};
830 
831         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
832         auto result =
833             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
834         EXPECT_EQ(true, result);
835 
836         // Need just the ledsAssserted populated with these.
837         // Three is set to ON due to ON priority.
838         ActionSet refAssert = {
839             {"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},
845         };
846         EXPECT_EQ(refAssert.size(), ledsAssert.size());
847         EXPECT_EQ(0, ledsDeAssert.size());
848 
849         // difference of refAssert and ledsAssert must be null.
850         ActionSet temp{};
851         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
857         ActionSet ledsAssert{};
858         ActionSet ledsDeAssert{};
859 
860         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
861         auto result =
862             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
863         EXPECT_EQ(false, result);
864 
865         // Need just the ledsDeAssserted populated with these.
866         ActionSet refDeAssert = {
867             {"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},
871         };
872         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
873 
874         // difference of refDeAssert and ledsDeAssert must be null.
875         ActionSet temp{};
876         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]
883         ActionSet refAssert = {
884             {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
885              phosphor::led::Layout::Action::On},
886         };
887         EXPECT_EQ(refAssert.size(), ledsAssert.size());
888 
889         // difference of refAssert and ledsAssert must be null.
890         ActionSet temp1{};
891         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     }
896 }
897 
898 /** @brief Assert 2 groups having multiple common LEDs in Same State */
899 TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert)
900 {
901     Manager manager(bus, twoGroupsWithMultiplComonLEDOn);
902     {
903         // Assert Set-B
904         ActionSet ledsAssert{};
905         ActionSet ledsDeAssert{};
906 
907         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
908         auto result =
909             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
910         EXPECT_EQ(true, result);
911 
912         // Need just the ledsAssserted populated with these.
913         ActionSet refAssert = {
914             {"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},
922         };
923         EXPECT_EQ(refAssert.size(), ledsAssert.size());
924         EXPECT_EQ(0, ledsDeAssert.size());
925 
926         // difference of refAssert and ledsAssert must be null.
927         ActionSet temp{};
928         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
935         ActionSet ledsAssert{};
936         ActionSet ledsDeAssert{};
937 
938         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
939         auto result =
940             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
941         EXPECT_EQ(true, result);
942 
943         // Need just the ledsAssserted populated with these.
944         ActionSet refAssert = {
945             {"One", phosphor::led::Layout::Action::On, 0, 0,
946              phosphor::led::Layout::Action::On},
947         };
948         EXPECT_EQ(refAssert.size(), ledsAssert.size());
949         EXPECT_EQ(0, ledsDeAssert.size());
950 
951         // difference of refAssert and ledsAssert must be null.
952         ActionSet temp{};
953         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
960         ActionSet ledsAssert{};
961         ActionSet ledsDeAssert{};
962 
963         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
964         auto result =
965             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
966         EXPECT_EQ(false, result);
967 
968         // Need just the ledsDeAssserted populated with these.
969         ActionSet refDeAssert = {
970             {"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},
974         };
975         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
976         EXPECT_EQ(0, ledsAssert.size());
977 
978         // difference of refDeAssert and ledsDeAssert must be null.
979         ActionSet temp{};
980         std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
981                             refDeAssert.begin(), refDeAssert.end(),
982                             std::inserter(temp, temp.begin()));
983         EXPECT_EQ(0, temp.size());
984     }
985 }
986 
987 /** @brief Assert 2 groups having multiple LEDs common in different state */
988 TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA)
989 {
990     Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
991     {
992         // Assert Set-B
993         ActionSet ledsAssert{};
994         ActionSet ledsDeAssert{};
995 
996         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
997         auto result =
998             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
999         EXPECT_EQ(true, result);
1000 
1001         // Need just the ledsAssserted populated with these.
1002         ActionSet refAssert = {
1003             {"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},
1011         };
1012         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1013         EXPECT_EQ(0, ledsDeAssert.size());
1014 
1015         // difference of refAssert and ledsAssert must be null.
1016         ActionSet temp{};
1017         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
1024         ActionSet ledsAssert{};
1025         ActionSet ledsDeAssert{};
1026 
1027         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1028         auto result =
1029             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1030         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]
1035         ActionSet refAssert = {
1036             {"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},
1040         };
1041         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1042         EXPECT_EQ(0, ledsDeAssert.size());
1043 
1044         // difference of refAssert and ledsAssert must be null.
1045         ActionSet temp{};
1046         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 */
1054 TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB)
1055 {
1056     Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
1057     {
1058         // Assert Set-A
1059         ActionSet ledsAssert{};
1060         ActionSet ledsDeAssert{};
1061 
1062         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1063         auto result =
1064             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1065         EXPECT_EQ(true, result);
1066 
1067         // Need just the ledsAssserted populated with these.'Two' gets to Blink
1068         // due to higher priority.
1069         ActionSet refAssert = {
1070             {"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},
1078         };
1079         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1080         EXPECT_EQ(0, ledsDeAssert.size());
1081 
1082         // difference of refAssert and ledsAssert must be null.
1083         ActionSet temp{};
1084         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
1091         ActionSet ledsAssert{};
1092         ActionSet ledsDeAssert{};
1093 
1094         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1095         auto result =
1096             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1097         EXPECT_EQ(true, result);
1098 
1099         // Need just the ledsAssserted populated with these.
1100         // [Three] remains [Blink] from previous
1101         // [Two] moves to [On] from [Blink] due to [On] priority
1102         ActionSet refAssert = {
1103             {"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},
1109         };
1110         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1111         EXPECT_EQ(0, ledsDeAssert.size());
1112 
1113         // difference of refAssert and ledsAssert must be null.
1114         ActionSet temp{};
1115         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     }
1120 }
1121 
1122 /** @brief Assert 2 groups having multiple LEDs common in different state
1123  *  DeAssert twice
1124  */
1125 TEST_F(LedTest,
1126        assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice)
1127 {
1128     Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
1129     {
1130         // Assert Set-A
1131         ActionSet ledsAssert{};
1132         ActionSet ledsDeAssert{};
1133 
1134         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1135         auto result =
1136             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1137         EXPECT_EQ(true, result);
1138 
1139         // Need just the ledsAssserted populated with these.
1140         ActionSet refAssert = {
1141             {"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},
1149         };
1150         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1151         EXPECT_EQ(0, ledsDeAssert.size());
1152 
1153         // difference of refAssert and ledsAssert must be null.
1154         ActionSet temp{};
1155         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     {
1161         // Assert Set-B
1162         ActionSet ledsAssert{};
1163         ActionSet ledsDeAssert{};
1164 
1165         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1166         auto result =
1167             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1168         EXPECT_EQ(true, result);
1169 
1170         // Need just the ledsAssserted populated with these.
1171         // [Two] turns [On] due to priority
1172         // [Three] remains [Blink]
1173         ActionSet refAssert = {
1174             {"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},
1180         };
1181         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1182         EXPECT_EQ(0, ledsDeAssert.size());
1183 
1184         // difference of refAssert and ledsAssert must be null.
1185         ActionSet temp{};
1186         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     {
1192         // DeAssert Set-B
1193         ActionSet ledsAssert{};
1194         ActionSet ledsDeAssert{};
1195 
1196         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1197         auto result =
1198             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1199         EXPECT_EQ(false, result);
1200 
1201         // Need just the ledsAssserted populated with these.
1202         ActionSet refDeAssert = {
1203             {"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},
1207         };
1208         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1209 
1210         // difference of refDeAssert and ledsDeAssert must be null.
1211         ActionSet temp{};
1212         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]
1219         ActionSet refAssert = {
1220             {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1221              phosphor::led::Layout::Action::On},
1222         };
1223         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1224 
1225         // difference of refAssert and ledsAssert must be null.
1226         ActionSet temp1{};
1227         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     {
1233         // DeAssert Set-A
1234         ActionSet ledsAssert{};
1235         ActionSet ledsDeAssert{};
1236 
1237         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1238         auto result =
1239             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1240         EXPECT_EQ(false, result);
1241 
1242         // Need just the ledsAssserted populated with these.
1243         ActionSet refDeAssert = {
1244             {"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},
1252         };
1253         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1254         EXPECT_EQ(0, ledsAssert.size());
1255 
1256         // difference of refDeAssert and ledsDeAssert must be null.
1257         ActionSet temp{};
1258         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
1265         ActionSet ledsAssert{};
1266         ActionSet ledsDeAssert{};
1267 
1268         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1269         auto result =
1270             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1271         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  */
1280 TEST_F(LedTest,
1281        assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB)
1282 {
1283     Manager manager(bus,
1284                     twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
1285     {
1286         // Assert Set-A
1287         ActionSet ledsAssert{};
1288         ActionSet ledsDeAssert{};
1289 
1290         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1291         auto result =
1292             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1293         EXPECT_EQ(true, result);
1294 
1295         // Need just the ledsAssserted populated with these.
1296         ActionSet refAssert = {
1297             {"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},
1307         };
1308         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1309         EXPECT_EQ(0, ledsDeAssert.size());
1310 
1311         // difference of refAssert and ledsAssert must be null.
1312         ActionSet temp{};
1313         std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1314                             refAssert.begin(), refAssert.end(),
1315                             std::inserter(temp, temp.begin()));
1316         EXPECT_EQ(0, temp.size());
1317     }
1318     {
1319         // Assert Set-B
1320         ActionSet ledsAssert{};
1321         ActionSet ledsDeAssert{};
1322 
1323         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1324         auto result =
1325             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1326         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]
1332         ActionSet refAssert = {
1333             {"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},
1339         };
1340         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1341         EXPECT_EQ(0, ledsDeAssert.size());
1342 
1343         // difference of refAssert and ledsAssert must be null.
1344         ActionSet temp{};
1345         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
1352         ActionSet ledsAssert{};
1353         ActionSet ledsDeAssert{};
1354 
1355         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1356         auto result =
1357             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1358         EXPECT_EQ(false, result);
1359 
1360         // Need just the ledsDeAsssert populated with these.
1361         ActionSet refDeAssert = {
1362             {"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},
1366         };
1367         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1368 
1369         // 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
1373         ActionSet refAssert = {
1374             {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1375              phosphor::led::Layout::Action::Blink},
1376         };
1377         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1378 
1379         // difference of refAssert and ledsAssert must be null.
1380         ActionSet temp{};
1381         std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1382                             refAssert.begin(), refAssert.end(),
1383                             std::inserter(temp, temp.begin()));
1384         EXPECT_EQ(0, temp.size());
1385     }
1386 }
1387 
1388 /** @brief Assert 2 groups having multiple LEDs common in different state and
1389  *  mixed priority. DeAssert-B
1390  */
1391 TEST_F(
1392     LedTest,
1393     assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB)
1394 {
1395     Manager manager(bus,
1396                     twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
1397     {
1398         // Assert Set-A
1399         ActionSet ledsAssert{};
1400         ActionSet ledsDeAssert{};
1401 
1402         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1403         auto result =
1404             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1405         EXPECT_EQ(true, result);
1406 
1407         // Need just the ledsAssserted populated with these.
1408         ActionSet refAssert = {
1409             {"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},
1419         };
1420         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1421         EXPECT_EQ(0, ledsDeAssert.size());
1422 
1423         // difference of refAssert and ledsAssert must be null.
1424         ActionSet temp{};
1425         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
1432         ActionSet ledsAssert{};
1433         ActionSet ledsDeAssert{};
1434 
1435         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1436         auto result =
1437             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1438         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]
1444         ActionSet refAssert = {
1445             {"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},
1451         };
1452         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1453         EXPECT_EQ(0, ledsDeAssert.size());
1454 
1455         // difference of refAssert and ledsAssert must be null.
1456         ActionSet temp{};
1457         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
1464         ActionSet ledsAssert{};
1465         ActionSet ledsDeAssert{};
1466 
1467         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1468         auto result =
1469             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1470         EXPECT_EQ(false, result);
1471 
1472         // Need just the ledsDeAsssert populated with these.
1473         ActionSet refDeAssert = {
1474             {"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},
1478         };
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]
1485         ActionSet refAssert = {
1486             {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1487              phosphor::led::Layout::Action::On},
1488         };
1489         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1490 
1491         // difference of refAssert and ledsAssert must be null.
1492         ActionSet temp{};
1493         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  */
1503 TEST_F(LedTest,
1504        assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA)
1505 {
1506     Manager manager(bus,
1507                     twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
1508     {
1509         // Assert Set-B
1510         ActionSet ledsAssert{};
1511         ActionSet ledsDeAssert{};
1512 
1513         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1514         auto result =
1515             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1516         EXPECT_EQ(true, result);
1517 
1518         // Need just the ledsAssserted populated with these.
1519         ActionSet refAssert = {
1520             {"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},
1530         };
1531         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1532         EXPECT_EQ(0, ledsDeAssert.size());
1533 
1534         // difference of refAssert and ledsAssert must be null.
1535         ActionSet temp{};
1536         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
1543         ActionSet ledsAssert{};
1544         ActionSet ledsDeAssert{};
1545 
1546         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1547         auto result =
1548             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1549         EXPECT_EQ(true, result);
1550 
1551         // 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]
1555         ActionSet refAssert = {
1556             {"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},
1562         };
1563         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1564         EXPECT_EQ(0, ledsDeAssert.size());
1565 
1566         // difference of refAssert and ledsAssert must be null.
1567         ActionSet temp{};
1568         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  */
1578 TEST_F(
1579     LedTest,
1580     assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA)
1581 {
1582     Manager manager(bus,
1583                     twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
1584     {
1585         // Assert Set-B
1586         ActionSet ledsAssert{};
1587         ActionSet ledsDeAssert{};
1588 
1589         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1590         auto result =
1591             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1592         EXPECT_EQ(true, result);
1593 
1594         // Need just the ledsAssserted populated with these.
1595         ActionSet refAssert = {
1596             {"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},
1606         };
1607         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1608         EXPECT_EQ(0, ledsDeAssert.size());
1609 
1610         // difference of refAssert and ledsAssert must be null.
1611         ActionSet temp{};
1612         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     {
1618         // Assert Set-A
1619         ActionSet ledsAssert{};
1620         ActionSet ledsDeAssert{};
1621 
1622         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1623         auto result =
1624             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1625         EXPECT_EQ(true, result);
1626 
1627         // 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]
1631         ActionSet refAssert = {
1632             {"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},
1638         };
1639         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1640         EXPECT_EQ(0, ledsDeAssert.size());
1641 
1642         // difference of refAssert and ledsAssert must be null.
1643         ActionSet temp{};
1644         std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1645                             refAssert.begin(), refAssert.end(),
1646                             std::inserter(temp, temp.begin()));
1647         EXPECT_EQ(0, temp.size());
1648     }
1649     {
1650         // De-Assert Set-A
1651         ActionSet ledsAssert{};
1652         ActionSet ledsDeAssert{};
1653 
1654         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1655         auto result =
1656             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1657         EXPECT_EQ(false, result);
1658 
1659         // Need just the ledsAssserted populated with these.
1660         // [Ten] remains [Blink] due to priority.
1661         ActionSet refDeAssert = {
1662             {"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},
1666         };
1667         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1668 
1669         // 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]
1673         ActionSet refAssert = {
1674             {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1675              phosphor::led::Layout::Action::Blink},
1676         };
1677         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1678 
1679         // difference of refAssert and ledsAssert must be null.
1680         ActionSet temp{};
1681         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  */
1691 TEST_F(LedTest,
1692        assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA)
1693 {
1694     Manager manager(bus,
1695                     twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
1696     {
1697         // Assert Set-B
1698         ActionSet ledsAssert{};
1699         ActionSet ledsDeAssert{};
1700 
1701         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1702         auto result =
1703             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1704         EXPECT_EQ(true, result);
1705 
1706         // Need just the ledsAssserted populated with these.
1707         ActionSet refAssert = {
1708             {"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},
1718         };
1719         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1720         EXPECT_EQ(0, ledsDeAssert.size());
1721 
1722         // difference of refAssert and ledsAssert must be null.
1723         ActionSet temp{};
1724         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
1731         ActionSet ledsAssert{};
1732         ActionSet ledsDeAssert{};
1733 
1734         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1735         auto result =
1736             manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
1737         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]
1743         ActionSet refAssert = {
1744             {"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},
1750         };
1751         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1752         EXPECT_EQ(0, ledsDeAssert.size());
1753 
1754         // difference of refAssert and ledsAssert must be null.
1755         ActionSet temp{};
1756         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
1763         ActionSet ledsAssert{};
1764         ActionSet ledsDeAssert{};
1765 
1766         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1767         auto result =
1768             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1769         EXPECT_EQ(false, result);
1770 
1771         // Need just the ledsAssserted populated with these.
1772         // [Ten] remains [Blink] due to priority.
1773         ActionSet refDeAssert = {
1774             {"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},
1778         };
1779         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1780 
1781         // difference of refDeAssert and ledsDeAssert must be null.
1782         ActionSet temp{};
1783         std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1784                             refDeAssert.begin(), refDeAssert.end(),
1785                             std::inserter(temp, temp.begin()));
1786         EXPECT_EQ(0, temp.size());
1787 
1788         // Need just the ledsAssert populated with these.
1789         // [Two] will move to [Blink]
1790         ActionSet refAssert = {
1791             {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1792              phosphor::led::Layout::Action::On},
1793         };
1794         EXPECT_EQ(refAssert.size(), ledsAssert.size());
1795 
1796         // difference of refAssert and ledsAssert must be null.
1797         ActionSet temp1{};
1798         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
1805         ActionSet ledsAssert{};
1806         ActionSet ledsDeAssert{};
1807 
1808         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
1809         auto result =
1810             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1811         EXPECT_EQ(false, result);
1812 
1813         // Need just the ledsAssserted populated with these.
1814         ActionSet refDeAssert = {
1815             {"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},
1825         };
1826         EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1827         EXPECT_EQ(0, ledsAssert.size());
1828 
1829         // difference of refDeAssert and ledsDeAssert must be null.
1830         ActionSet temp{};
1831         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
1838         ActionSet ledsAssert{};
1839         ActionSet ledsDeAssert{};
1840 
1841         auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
1842         auto result =
1843             manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
1844         EXPECT_EQ(false, result);
1845         EXPECT_EQ(0, ledsDeAssert.size());
1846         EXPECT_EQ(0, ledsAssert.size());
1847     }
1848 }
1849