blob: 9508a1e423cc464abc623e9c62cfcfbdf158d255 [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 }
19 ~LedTest()
20 {
21 // Leaving up to auto cleanup.
22 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053023};
24
25/** @brief Assert Single LED to On */
26TEST_F(LedTest, assertSingleLedOn)
27{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053028 Manager manager(bus, singleLedOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053029 {
30 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050031 ActionSet ledsAssert{};
32 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053033
34 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams857da382023-05-10 07:50:20 -050035 auto result = manager.setGroupState(group, true, ledsAssert,
36 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053037 EXPECT_EQ(true, result);
38
39 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050040 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -050041 {"One", phosphor::led::Layout::Action::On, 0, 0,
42 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053043 };
44 EXPECT_EQ(refAssert.size(), ledsAssert.size());
45 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053046
47 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -050048 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053049 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
50 refAssert.begin(), refAssert.end(),
51 std::inserter(temp, temp.begin()));
52 EXPECT_EQ(0, temp.size());
53 }
54}
55
56/** @brief Assert Single LED to Blink */
57TEST_F(LedTest, assertSingleLedBlink)
58{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053059 Manager manager(bus, singleLedBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053060 {
61 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050062 ActionSet ledsAssert{};
63 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053064
65 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams857da382023-05-10 07:50:20 -050066 auto result = manager.setGroupState(group, true, ledsAssert,
67 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053068 EXPECT_EQ(true, result);
69
70 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050071 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -050072 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
73 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053074 };
75 EXPECT_EQ(refAssert.size(), ledsAssert.size());
76 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053077
78 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -050079 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053080 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
81 refAssert.begin(), refAssert.end(),
82 std::inserter(temp, temp.begin()));
83 EXPECT_EQ(0, temp.size());
84 }
85}
86
87/** @brief Assert Single LED to On and Try Assert Again */
88TEST_F(LedTest, assertSingleLedOnAndreAssert)
89{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053090 Manager manager(bus, singleLedOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053091 {
92 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050093 ActionSet ledsAssert{};
94 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053095
96 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams857da382023-05-10 07:50:20 -050097 auto result = manager.setGroupState(group, true, ledsAssert,
98 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053099 EXPECT_EQ(true, result);
100
101 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500102 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500103 {"One", phosphor::led::Layout::Action::On, 0, 0,
104 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530105 };
106 EXPECT_EQ(refAssert.size(), ledsAssert.size());
107 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530108
109 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500110 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530111 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
112 refAssert.begin(), refAssert.end(),
113 std::inserter(temp, temp.begin()));
114 EXPECT_EQ(0, temp.size());
115 }
116 {
117 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500118 ActionSet ledsAssert{};
119 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530120
121 auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams857da382023-05-10 07:50:20 -0500122 auto result = manager.setGroupState(group, true, ledsAssert,
123 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530124 EXPECT_EQ(true, result);
125
126 EXPECT_EQ(0, ledsAssert.size());
127 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530128 }
129}
130
131/** @brief Assert Multiple LEDs to On */
132TEST_F(LedTest, assertMultipleLedOn)
133{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530134 Manager manager(bus, multipleLedsOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530135 {
136 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500137 ActionSet ledsAssert{};
138 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530139
140 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500141 auto result = manager.setGroupState(group, true, ledsAssert,
142 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530143 EXPECT_EQ(true, result);
144
145 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500146 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500147 {"One", phosphor::led::Layout::Action::On, 0, 0,
148 phosphor::led::Layout::Action::On},
149 {"Two", phosphor::led::Layout::Action::On, 0, 0,
150 phosphor::led::Layout::Action::On},
151 {"Three", phosphor::led::Layout::Action::On, 0, 0,
152 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530153 };
154 EXPECT_EQ(refAssert.size(), ledsAssert.size());
155 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530156
157 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500158 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530159 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
160 refAssert.begin(), refAssert.end(),
161 std::inserter(temp, temp.begin()));
162 EXPECT_EQ(0, temp.size());
163 }
164}
165
166/** @brief Assert Multiple LEDs to Blink */
167TEST_F(LedTest, assertMultipleLedBlink)
168{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530169 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530170 {
171 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500172 ActionSet ledsAssert{};
173 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530174
175 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500176 auto result = manager.setGroupState(group, true, ledsAssert,
177 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530178 EXPECT_EQ(true, result);
179
180 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500181 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500182 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
183 phosphor::led::Layout::Action::Blink},
184 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
185 phosphor::led::Layout::Action::Blink},
186 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
187 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530188 };
189 EXPECT_EQ(refAssert.size(), ledsAssert.size());
190 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530191
192 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500193 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530194 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
195 refAssert.begin(), refAssert.end(),
196 std::inserter(temp, temp.begin()));
197 EXPECT_EQ(0, temp.size());
198 }
199}
200
201/** @brief Assert Multiple LEDs to Blink, DeAssert */
202TEST_F(LedTest, assertMultipleLedBlinkAndDeAssert)
203{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530204 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530205 {
206 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500207 ActionSet ledsAssert{};
208 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530209
210 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500211 auto result = manager.setGroupState(group, true, ledsAssert,
212 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530213 EXPECT_EQ(true, result);
214
215 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500216 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500217 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
218 phosphor::led::Layout::Action::Blink},
219 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
220 phosphor::led::Layout::Action::Blink},
221 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
222 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530223 };
224 EXPECT_EQ(refAssert.size(), ledsAssert.size());
225 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530226
227 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500228 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530229 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
230 refAssert.begin(), refAssert.end(),
231 std::inserter(temp, temp.begin()));
232 EXPECT_EQ(0, temp.size());
233 }
234 {
235 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500236 ActionSet ledsAssert{};
237 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530238
239 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500240 auto result = manager.setGroupState(group, false, ledsAssert,
241 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530242 EXPECT_EQ(false, result);
243
244 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500245 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500246 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
247 phosphor::led::Layout::Action::Blink},
248 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
249 phosphor::led::Layout::Action::Blink},
250 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
251 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530252 };
253 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
254 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530255
256 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500257 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530258 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
259 refDeAssert.begin(), refDeAssert.end(),
260 std::inserter(temp, temp.begin()));
261 EXPECT_EQ(0, temp.size());
262 }
263}
264
265/** @brief Assert Multiple LEDs to Blink, DeAssert Twice */
266TEST_F(LedTest, assertMultipleLedBlinkAndDeAssertTwice)
267{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530268 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530269 {
270 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500271 ActionSet ledsAssert{};
272 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530273
274 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500275 auto result = manager.setGroupState(group, true, ledsAssert,
276 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530277 EXPECT_EQ(true, result);
278
279 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500280 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500281 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
282 phosphor::led::Layout::Action::Blink},
283 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
284 phosphor::led::Layout::Action::Blink},
285 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
286 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530287 };
288 EXPECT_EQ(refAssert.size(), ledsAssert.size());
289 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530290
291 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500292 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530293 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
294 refAssert.begin(), refAssert.end(),
295 std::inserter(temp, temp.begin()));
296 EXPECT_EQ(0, temp.size());
297 }
298 {
299 // DeAssert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500300 ActionSet ledsAssert{};
301 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530302
303 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500304 auto result = manager.setGroupState(group, false, ledsAssert,
305 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530306 EXPECT_EQ(false, result);
307
308 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500309 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500310 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
311 phosphor::led::Layout::Action::Blink},
312 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
313 phosphor::led::Layout::Action::Blink},
314 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
315 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530316 };
317 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
318 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530319
320 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500321 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530322 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
323 refDeAssert.begin(), refDeAssert.end(),
324 std::inserter(temp, temp.begin()));
325 EXPECT_EQ(0, temp.size());
326 }
327 {
328 // DeAssert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500329 ActionSet ledsAssert{};
330 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530331
332 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams857da382023-05-10 07:50:20 -0500333 auto result = manager.setGroupState(group, false, ledsAssert,
334 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530335 EXPECT_EQ(false, result);
336 EXPECT_EQ(0, ledsDeAssert.size());
337 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530338 }
339}
340
341/** @brief Assert Multiple LEDs to mix of On and Blink */
342TEST_F(LedTest, assertMultipleLedOnAndBlink)
343{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530344 Manager manager(bus, multipleLedsOnAndBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530345 {
346 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500347 ActionSet ledsAssert{};
348 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530349
350 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix";
Patrick Williams857da382023-05-10 07:50:20 -0500351 auto result = manager.setGroupState(group, true, ledsAssert,
352 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530353 EXPECT_EQ(true, result);
354
355 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500356 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500357 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
358 phosphor::led::Layout::Action::Blink},
359 {"Two", phosphor::led::Layout::Action::On, 0, 0,
360 phosphor::led::Layout::Action::Blink},
361 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
362 phosphor::led::Layout::Action::On},
363 {"Four", phosphor::led::Layout::Action::On, 0, 0,
364 phosphor::led::Layout::Action::Blink},
365 {"Five", phosphor::led::Layout::Action::On, 0, 0,
366 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530367 };
368 EXPECT_EQ(refAssert.size(), ledsAssert.size());
369 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530370
371 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500372 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530373 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
374 refAssert.begin(), refAssert.end(),
375 std::inserter(temp, temp.begin()));
376 EXPECT_EQ(0, temp.size());
377 }
378}
379
380/** @brief Assert 2 groups having distinct LEDs */
381TEST_F(LedTest, assertTwoGroupsOnWithDistinctLEDOn)
382{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530383 Manager manager(bus, twoGroupsWithDistinctLEDsOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530384 {
385 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500386 ActionSet ledsAssert{};
387 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530388
Patrick Venture91ac8d32018-11-01 17:03:22 -0700389 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500390 auto result = manager.setGroupState(group, true, ledsAssert,
391 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530392 EXPECT_EQ(true, result);
393
394 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500395 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500396 {"One", phosphor::led::Layout::Action::On, 0, 0,
397 phosphor::led::Layout::Action::Blink},
398 {"Two", phosphor::led::Layout::Action::On, 0, 0,
399 phosphor::led::Layout::Action::On},
400 {"Three", phosphor::led::Layout::Action::On, 0, 0,
401 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530402 };
403 EXPECT_EQ(refAssert.size(), ledsAssert.size());
404 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530405
406 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500407 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530408 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
409 refAssert.begin(), refAssert.end(),
410 std::inserter(temp, temp.begin()));
411 EXPECT_EQ(0, temp.size());
412 }
413 {
414 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500415 ActionSet ledsAssert{};
416 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530417
Patrick Venture91ac8d32018-11-01 17:03:22 -0700418 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500419 auto result = manager.setGroupState(group, true, ledsAssert,
420 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530421 EXPECT_EQ(true, result);
422
423 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500424 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500425 {"Four", phosphor::led::Layout::Action::On, 0, 0,
426 phosphor::led::Layout::Action::Blink},
427 {"Five", phosphor::led::Layout::Action::On, 0, 0,
428 phosphor::led::Layout::Action::Blink},
429 {"Six", phosphor::led::Layout::Action::On, 0, 0,
430 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530431 };
432 EXPECT_EQ(refAssert.size(), ledsAssert.size());
433 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530434
435 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500436 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530437 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
438 refAssert.begin(), refAssert.end(),
439 std::inserter(temp, temp.begin()));
440 EXPECT_EQ(0, temp.size());
441 }
442}
443
444/** @brief Assert 2 groups having one of the LEDs common */
445TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOn)
446{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530447 Manager manager(bus, twoGroupsWithOneComonLEDOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530448 {
449 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500450 ActionSet ledsAssert{};
451 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530452
Patrick Venture91ac8d32018-11-01 17:03:22 -0700453 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500454 auto result = manager.setGroupState(group, true, ledsAssert,
455 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530456 EXPECT_EQ(true, result);
457
458 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500459 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500460 {"One", phosphor::led::Layout::Action::On, 0, 0,
461 phosphor::led::Layout::Action::On},
462 {"Two", phosphor::led::Layout::Action::On, 0, 0,
463 phosphor::led::Layout::Action::On},
464 {"Three", phosphor::led::Layout::Action::On, 0, 0,
465 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530466 };
467 EXPECT_EQ(refAssert.size(), ledsAssert.size());
468 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530469
470 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500471 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530472 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
473 refAssert.begin(), refAssert.end(),
474 std::inserter(temp, temp.begin()));
475 EXPECT_EQ(0, temp.size());
476 }
477 {
478 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500479 ActionSet ledsAssert{};
480 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530481
Patrick Venture91ac8d32018-11-01 17:03:22 -0700482 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500483 auto result = manager.setGroupState(group, true, ledsAssert,
484 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530485 EXPECT_EQ(true, result);
486
487 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500488 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500489 {"Four", phosphor::led::Layout::Action::On, 0, 0,
490 phosphor::led::Layout::Action::On},
491 {"Six", phosphor::led::Layout::Action::On, 0, 0,
492 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530493 };
494 EXPECT_EQ(refAssert.size(), ledsAssert.size());
495 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530496
497 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500498 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530499 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
500 refAssert.begin(), refAssert.end(),
501 std::inserter(temp, temp.begin()));
502 EXPECT_EQ(0, temp.size());
503 }
504}
505
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530506/** @brief Assert 2 groups having one of the LEDs common but having Blink as
507 * priority and Deassert*/
508TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530509{
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530510 Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530511 {
512 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500513 ActionSet ledsAssert{};
514 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530515
Patrick Venture91ac8d32018-11-01 17:03:22 -0700516 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500517 auto result = manager.setGroupState(group, true, ledsAssert,
518 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530519 EXPECT_EQ(true, result);
520
521 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500522 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500523 {"One", phosphor::led::Layout::Action::On, 0, 0,
524 phosphor::led::Layout::Action::On},
525 {"Two", phosphor::led::Layout::Action::On, 0, 0,
526 phosphor::led::Layout::Action::On},
527 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
528 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530529 };
530 EXPECT_EQ(refAssert.size(), ledsAssert.size());
531 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530532
533 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500534 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530535 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
536 refAssert.begin(), refAssert.end(),
537 std::inserter(temp, temp.begin()));
538 EXPECT_EQ(0, temp.size());
539 }
540 {
541 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500542 ActionSet ledsAssert{};
543 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530544
Patrick Venture91ac8d32018-11-01 17:03:22 -0700545 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500546 auto result = manager.setGroupState(group, true, ledsAssert,
547 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530548 EXPECT_EQ(true, result);
549
550 // Need just the ledsAssserted populated with these.
551 // Does not action on [Three] since priority is [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500552 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500553 {"Four", phosphor::led::Layout::Action::On, 0, 0,
554 phosphor::led::Layout::Action::On},
555 {"Six", phosphor::led::Layout::Action::On, 0, 0,
556 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530557 };
558 EXPECT_EQ(refAssert.size(), ledsAssert.size());
559 EXPECT_EQ(0, ledsDeAssert.size());
560
561 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500562 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530563 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
564 refAssert.begin(), refAssert.end(),
565 std::inserter(temp, temp.begin()));
566 EXPECT_EQ(0, temp.size());
567 }
568 {
569 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500570 ActionSet ledsAssert{};
571 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530572
Patrick Venture91ac8d32018-11-01 17:03:22 -0700573 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500574 auto result = manager.setGroupState(group, false, ledsAssert,
575 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530576 EXPECT_EQ(false, result);
577
578 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500579 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500580 {"Four", phosphor::led::Layout::Action::On, 0, 0,
581 phosphor::led::Layout::Action::On},
582 {"Six", phosphor::led::Layout::Action::On, 0, 0,
583 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530584 };
585 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
586 EXPECT_EQ(0, ledsAssert.size());
587
588 // difference of refDeAssert and ledsDeAssert must be null.
589 // [Three] is not touched since its already [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500590 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530591 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
592 refDeAssert.begin(), refDeAssert.end(),
593 std::inserter(temp, temp.begin()));
594 EXPECT_EQ(0, temp.size());
595 }
596}
597
598/** @brief Assert 2 groups having one of the LEDs common but having Blink as
599 * priority and Deassert A */
600TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA)
601{
602 Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
603 {
604 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500605 ActionSet ledsAssert{};
606 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530607
Patrick Venture91ac8d32018-11-01 17:03:22 -0700608 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500609 auto result = manager.setGroupState(group, true, ledsAssert,
610 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530611 EXPECT_EQ(true, result);
612
613 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500614 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500615 {"One", phosphor::led::Layout::Action::On, 0, 0,
616 phosphor::led::Layout::Action::On},
617 {"Two", phosphor::led::Layout::Action::On, 0, 0,
618 phosphor::led::Layout::Action::On},
619 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
620 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530621 };
622 EXPECT_EQ(refAssert.size(), ledsAssert.size());
623 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530624
625 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500626 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530627 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
628 refAssert.begin(), refAssert.end(),
629 std::inserter(temp, temp.begin()));
630 EXPECT_EQ(0, temp.size());
631 }
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530632 {
633 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500634 ActionSet ledsAssert{};
635 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530636
Patrick Venture91ac8d32018-11-01 17:03:22 -0700637 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500638 auto result = manager.setGroupState(group, true, ledsAssert,
639 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530640 EXPECT_EQ(true, result);
641
642 // Need just the ledsAssserted populated with these.
643 // [Three] does not get actioned since it has Blink priority
Patrick Williams158b2c12022-03-17 05:57:44 -0500644 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500645 {"Four", phosphor::led::Layout::Action::On, 0, 0,
646 phosphor::led::Layout::Action::On},
647 {"Six", phosphor::led::Layout::Action::On, 0, 0,
648 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530649 };
650 EXPECT_EQ(refAssert.size(), ledsAssert.size());
651 EXPECT_EQ(0, ledsDeAssert.size());
652
653 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500654 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530655 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
656 refAssert.begin(), refAssert.end(),
657 std::inserter(temp, temp.begin()));
658 EXPECT_EQ(0, temp.size());
659 }
660 {
661 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500662 ActionSet ledsAssert{};
663 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530664
Patrick Venture91ac8d32018-11-01 17:03:22 -0700665 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500666 auto result = manager.setGroupState(group, false, ledsAssert,
667 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530668 EXPECT_EQ(false, result);
669
670 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500671 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500672 {"One", phosphor::led::Layout::Action::On, 0, 0,
673 phosphor::led::Layout::Action::On},
674 {"Two", phosphor::led::Layout::Action::On, 0, 0,
675 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530676 };
677 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
678
679 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500680 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530681 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
682 refDeAssert.begin(), refDeAssert.end(),
683 std::inserter(temp, temp.begin()));
684 EXPECT_EQ(0, temp.size());
685
686 // Need just the ledsAssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500687 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500688 {"Three", phosphor::led::Layout::Action::On, 0, 0,
689 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530690 };
691 EXPECT_EQ(refAssert.size(), ledsAssert.size());
692
693 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500694 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530695 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
696 refAssert.begin(), refAssert.end(),
697 std::inserter(temp1, temp1.begin()));
698 EXPECT_EQ(0, temp1.size());
699 }
700}
701
702/** @brief Assert 2 groups having one of the LEDs common but having ON as
703 * priority And Deassert A */
704TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA)
705{
706 Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
707 {
708 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500709 ActionSet ledsAssert{};
710 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530711
Patrick Venture91ac8d32018-11-01 17:03:22 -0700712 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500713 auto result = manager.setGroupState(group, true, ledsAssert,
714 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530715 EXPECT_EQ(true, result);
716
717 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500718 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500719 {"One", phosphor::led::Layout::Action::On, 0, 0,
720 phosphor::led::Layout::Action::On},
721 {"Two", phosphor::led::Layout::Action::On, 0, 0,
722 phosphor::led::Layout::Action::On},
723 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
724 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530725 };
726 EXPECT_EQ(refAssert.size(), ledsAssert.size());
727 EXPECT_EQ(0, ledsDeAssert.size());
728
729 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500730 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530731 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
732 refAssert.begin(), refAssert.end(),
733 std::inserter(temp, temp.begin()));
734 EXPECT_EQ(0, temp.size());
735 }
736 {
737 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500738 ActionSet ledsAssert{};
739 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530740
Patrick Venture91ac8d32018-11-01 17:03:22 -0700741 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500742 auto result = manager.setGroupState(group, true, ledsAssert,
743 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530744 EXPECT_EQ(true, result);
745
746 // Need just the ledsAssserted populated with these.
747 // Three is set to ON due to ON priority.
Patrick Williams158b2c12022-03-17 05:57:44 -0500748 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500749 {"Three", phosphor::led::Layout::Action::On, 0, 0,
750 phosphor::led::Layout::Action::On},
751 {"Four", phosphor::led::Layout::Action::On, 0, 0,
752 phosphor::led::Layout::Action::On},
753 {"Six", phosphor::led::Layout::Action::On, 0, 0,
754 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530755 };
756 EXPECT_EQ(refAssert.size(), ledsAssert.size());
757 EXPECT_EQ(0, ledsDeAssert.size());
758
759 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500760 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530761 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
762 refAssert.begin(), refAssert.end(),
763 std::inserter(temp, temp.begin()));
764 }
765 {
766 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500767 ActionSet ledsAssert{};
768 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530769
Patrick Venture91ac8d32018-11-01 17:03:22 -0700770 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500771 auto result = manager.setGroupState(group, false, ledsAssert,
772 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530773 EXPECT_EQ(false, result);
774
775 // Need just the ledsDeAssserted populated with these.
776 // [Three] stays in [On] since [B] has it [On]
Patrick Williams158b2c12022-03-17 05:57:44 -0500777 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500778 {"One", phosphor::led::Layout::Action::On, 0, 0,
779 phosphor::led::Layout::Action::On},
780 {"Two", phosphor::led::Layout::Action::On, 0, 0,
781 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530782 };
783 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
784 EXPECT_EQ(0, ledsAssert.size());
785
786 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500787 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530788 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
789 refDeAssert.begin(), refDeAssert.end(),
790 std::inserter(temp, temp.begin()));
791 EXPECT_EQ(0, temp.size());
792 }
793}
794
795/** @brief Assert 2 groups having one of the LEDs common but having ON as
796 * priority And Deassert B */
797TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB)
798{
799 Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
800 {
801 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500802 ActionSet ledsAssert{};
803 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530804
Patrick Venture91ac8d32018-11-01 17:03:22 -0700805 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500806 auto result = manager.setGroupState(group, true, ledsAssert,
807 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530808 EXPECT_EQ(true, result);
809
810 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500811 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500812 {"One", phosphor::led::Layout::Action::On, 0, 0,
813 phosphor::led::Layout::Action::On},
814 {"Two", phosphor::led::Layout::Action::On, 0, 0,
815 phosphor::led::Layout::Action::On},
816 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
817 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530818 };
819 EXPECT_EQ(refAssert.size(), ledsAssert.size());
820 EXPECT_EQ(0, ledsDeAssert.size());
821
822 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500823 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530824 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
825 refAssert.begin(), refAssert.end(),
826 std::inserter(temp, temp.begin()));
827 EXPECT_EQ(0, temp.size());
828 }
829 {
830 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500831 ActionSet ledsAssert{};
832 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530833
Patrick Venture91ac8d32018-11-01 17:03:22 -0700834 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500835 auto result = manager.setGroupState(group, true, ledsAssert,
836 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530837 EXPECT_EQ(true, result);
838
839 // Need just the ledsAssserted populated with these.
840 // Three is set to ON due to ON priority.
Patrick Williams158b2c12022-03-17 05:57:44 -0500841 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500842 {"Three", phosphor::led::Layout::Action::On, 0, 0,
843 phosphor::led::Layout::Action::On},
844 {"Four", phosphor::led::Layout::Action::On, 0, 0,
845 phosphor::led::Layout::Action::On},
846 {"Six", phosphor::led::Layout::Action::On, 0, 0,
847 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530848 };
849 EXPECT_EQ(refAssert.size(), ledsAssert.size());
850 EXPECT_EQ(0, ledsDeAssert.size());
851
852 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500853 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530854 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
855 refAssert.begin(), refAssert.end(),
856 std::inserter(temp, temp.begin()));
857 }
858 {
859 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500860 ActionSet ledsAssert{};
861 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530862
Patrick Venture91ac8d32018-11-01 17:03:22 -0700863 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500864 auto result = manager.setGroupState(group, false, ledsAssert,
865 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530866 EXPECT_EQ(false, result);
867
868 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500869 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500870 {"Four", phosphor::led::Layout::Action::On, 0, 0,
871 phosphor::led::Layout::Action::On},
872 {"Six", phosphor::led::Layout::Action::On, 0, 0,
873 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530874 };
875 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
876
877 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500878 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530879 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
880 refDeAssert.begin(), refDeAssert.end(),
881 std::inserter(temp, temp.begin()));
882 EXPECT_EQ(0, temp.size());
883
884 // Need just the ledsAssert populated with these.
885 // Since [Three] stood [On], need to go back to [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500886 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500887 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
888 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530889 };
890 EXPECT_EQ(refAssert.size(), ledsAssert.size());
891
892 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500893 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530894 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
895 refAssert.begin(), refAssert.end(),
896 std::inserter(temp, temp.begin()));
897 EXPECT_EQ(0, temp.size());
898 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530899}
900
901/** @brief Assert 2 groups having multiple common LEDs in Same State */
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530902TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530903{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530904 Manager manager(bus, twoGroupsWithMultiplComonLEDOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530905 {
906 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500907 ActionSet ledsAssert{};
908 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530909
Patrick Venture91ac8d32018-11-01 17:03:22 -0700910 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500911 auto result = manager.setGroupState(group, true, ledsAssert,
912 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530913 EXPECT_EQ(true, result);
914
915 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500916 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500917 {"Two", phosphor::led::Layout::Action::On, 0, 0,
918 phosphor::led::Layout::Action::On},
919 {"Six", phosphor::led::Layout::Action::On, 0, 0,
920 phosphor::led::Layout::Action::On},
921 {"Three", phosphor::led::Layout::Action::On, 0, 0,
922 phosphor::led::Layout::Action::On},
923 {"Seven", phosphor::led::Layout::Action::On, 0, 0,
924 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530925 };
926 EXPECT_EQ(refAssert.size(), ledsAssert.size());
927 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530928
929 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500930 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530931 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
932 refAssert.begin(), refAssert.end(),
933 std::inserter(temp, temp.begin()));
934 EXPECT_EQ(0, temp.size());
935 }
936 {
937 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500938 ActionSet ledsAssert{};
939 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530940
Patrick Venture91ac8d32018-11-01 17:03:22 -0700941 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -0500942 auto result = manager.setGroupState(group, true, ledsAssert,
943 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530944 EXPECT_EQ(true, result);
945
946 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500947 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500948 {"One", phosphor::led::Layout::Action::On, 0, 0,
949 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530950 };
951 EXPECT_EQ(refAssert.size(), ledsAssert.size());
952 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530953
954 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500955 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530956 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
957 refAssert.begin(), refAssert.end(),
958 std::inserter(temp, temp.begin()));
959 EXPECT_EQ(0, temp.size());
960 }
961 {
962 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500963 ActionSet ledsAssert{};
964 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530965
Patrick Venture91ac8d32018-11-01 17:03:22 -0700966 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -0500967 auto result = manager.setGroupState(group, false, ledsAssert,
968 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530969 EXPECT_EQ(false, result);
970
971 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500972 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500973 {"Six", phosphor::led::Layout::Action::On, 0, 0,
974 phosphor::led::Layout::Action::On},
975 {"Seven", phosphor::led::Layout::Action::On, 0, 0,
976 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530977 };
978 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
979 EXPECT_EQ(0, ledsAssert.size());
980
981 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500982 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530983 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
984 refDeAssert.begin(), refDeAssert.end(),
985 std::inserter(temp, temp.begin()));
986 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530987 }
988}
989
990/** @brief Assert 2 groups having multiple LEDs common in different state */
991TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA)
992{
993 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
994 {
995 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500996 ActionSet ledsAssert{};
997 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530998
Patrick Venture91ac8d32018-11-01 17:03:22 -0700999 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001000 auto result = manager.setGroupState(group, true, ledsAssert,
1001 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301002 EXPECT_EQ(true, result);
1003
1004 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001005 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001006 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1007 phosphor::led::Layout::Action::On},
1008 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1009 phosphor::led::Layout::Action::On},
1010 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1011 phosphor::led::Layout::Action::On},
1012 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1013 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301014 };
1015 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1016 EXPECT_EQ(0, ledsDeAssert.size());
1017
1018 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001019 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301020 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1021 refAssert.begin(), refAssert.end(),
1022 std::inserter(temp, temp.begin()));
1023 EXPECT_EQ(0, temp.size());
1024 }
1025 {
1026 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001027 ActionSet ledsAssert{};
1028 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301029
Patrick Venture91ac8d32018-11-01 17:03:22 -07001030 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001031 auto result = manager.setGroupState(group, true, ledsAssert,
1032 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301033 EXPECT_EQ(true, result);
1034
1035 // Need just the ledsAssserted populated with these
1036 // [Two] remains [On] due to higher priority.
1037 // [Three] remains [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001038 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001039 {"One", phosphor::led::Layout::Action::On, 0, 0,
1040 phosphor::led::Layout::Action::On},
1041 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1042 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301043 };
1044 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1045 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301046
1047 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001048 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301049 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1050 refAssert.begin(), refAssert.end(),
1051 std::inserter(temp, temp.begin()));
1052 EXPECT_EQ(0, temp.size());
1053 }
1054}
1055
1056/** @brief Assert 2 groups having multiple LEDs common in different state */
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301057TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301058{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +05301059 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301060 {
1061 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001062 ActionSet ledsAssert{};
1063 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301064
Patrick Venture91ac8d32018-11-01 17:03:22 -07001065 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001066 auto result = manager.setGroupState(group, true, ledsAssert,
1067 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301068 EXPECT_EQ(true, result);
1069
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301070 // Need just the ledsAssserted populated with these.'Two' gets to Blink
1071 // due to higher priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001072 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001073 {"One", phosphor::led::Layout::Action::On, 0, 0,
1074 phosphor::led::Layout::Action::On},
1075 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1076 phosphor::led::Layout::Action::On},
1077 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1078 phosphor::led::Layout::Action::On},
1079 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1080 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301081 };
1082 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1083 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301084
1085 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001086 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301087 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1088 refAssert.begin(), refAssert.end(),
1089 std::inserter(temp, temp.begin()));
1090 EXPECT_EQ(0, temp.size());
1091 }
1092 {
1093 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001094 ActionSet ledsAssert{};
1095 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301096
Patrick Venture91ac8d32018-11-01 17:03:22 -07001097 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001098 auto result = manager.setGroupState(group, true, ledsAssert,
1099 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301100 EXPECT_EQ(true, result);
1101
1102 // Need just the ledsAssserted populated with these.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301103 // [Three] remains [Blink] from previous
1104 // [Two] moves to [On] from [Blink] due to [On] priority
Patrick Williams158b2c12022-03-17 05:57:44 -05001105 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001106 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1107 phosphor::led::Layout::Action::On},
1108 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1109 phosphor::led::Layout::Action::On},
1110 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1111 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301112 };
1113 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1114 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301115
1116 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001117 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301118 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1119 refAssert.begin(), refAssert.end(),
1120 std::inserter(temp, temp.begin()));
1121 EXPECT_EQ(0, temp.size());
1122 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301123}
1124
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301125/** @brief Assert 2 groups having multiple LEDs common in different state
1126 * DeAssert twice
1127 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001128TEST_F(LedTest,
1129 assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301130{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +05301131 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301132 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301133 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001134 ActionSet ledsAssert{};
1135 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301136
Patrick Venture91ac8d32018-11-01 17:03:22 -07001137 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001138 auto result = manager.setGroupState(group, true, ledsAssert,
1139 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301140 EXPECT_EQ(true, result);
1141
1142 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001143 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001144 {"One", phosphor::led::Layout::Action::On, 0, 0,
1145 phosphor::led::Layout::Action::On},
1146 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1147 phosphor::led::Layout::Action::On},
1148 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1149 phosphor::led::Layout::Action::On},
1150 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1151 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301152 };
1153 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1154 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301155
1156 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001157 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301158 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1159 refAssert.begin(), refAssert.end(),
1160 std::inserter(temp, temp.begin()));
1161 EXPECT_EQ(0, temp.size());
1162 }
1163 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301164 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001165 ActionSet ledsAssert{};
1166 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301167
Patrick Venture91ac8d32018-11-01 17:03:22 -07001168 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001169 auto result = manager.setGroupState(group, true, ledsAssert,
1170 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301171 EXPECT_EQ(true, result);
1172
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301173 // Need just the ledsAssserted populated with these.
1174 // [Two] turns [On] due to priority
1175 // [Three] remains [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001176 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001177 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1178 phosphor::led::Layout::Action::On},
1179 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1180 phosphor::led::Layout::Action::On},
1181 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1182 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301183 };
1184 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1185 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301186
1187 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001188 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301189 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1190 refAssert.begin(), refAssert.end(),
1191 std::inserter(temp, temp.begin()));
1192 EXPECT_EQ(0, temp.size());
1193 }
1194 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301195 // DeAssert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001196 ActionSet ledsAssert{};
1197 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301198
Patrick Venture91ac8d32018-11-01 17:03:22 -07001199 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001200 auto result = manager.setGroupState(group, false, ledsAssert,
1201 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301202 EXPECT_EQ(false, result);
1203
1204 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001205 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001206 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1207 phosphor::led::Layout::Action::On},
1208 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1209 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301210 };
1211 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1212
1213 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001214 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301215 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1216 refDeAssert.begin(), refDeAssert.end(),
1217 std::inserter(temp, temp.begin()));
1218 EXPECT_EQ(0, temp.size());
1219
1220 // Need just the ledsAssert populated with these.
1221 // [Two] will go back to [Blink] from [On]
Patrick Williams158b2c12022-03-17 05:57:44 -05001222 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001223 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1224 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301225 };
1226 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1227
1228 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001229 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301230 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1231 refAssert.begin(), refAssert.end(),
1232 std::inserter(temp1, temp1.begin()));
1233 EXPECT_EQ(0, temp1.size());
1234 }
1235 {
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301236 // DeAssert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001237 ActionSet ledsAssert{};
1238 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301239
Patrick Venture91ac8d32018-11-01 17:03:22 -07001240 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001241 auto result = manager.setGroupState(group, false, ledsAssert,
1242 ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301243 EXPECT_EQ(false, result);
1244
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301245 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001246 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001247 {"One", phosphor::led::Layout::Action::On, 0, 0,
1248 phosphor::led::Layout::Action::On},
1249 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1250 phosphor::led::Layout::Action::On},
1251 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1252 phosphor::led::Layout::Action::On},
1253 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1254 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301255 };
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301256 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301257 EXPECT_EQ(0, ledsAssert.size());
1258
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301259 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001260 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301261 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1262 refDeAssert.begin(), refDeAssert.end(),
1263 std::inserter(temp, temp.begin()));
1264 EXPECT_EQ(0, temp.size());
1265 }
1266 {
1267 // DeAssert Set-A again and make sure we get all empty
Patrick Williams158b2c12022-03-17 05:57:44 -05001268 ActionSet ledsAssert{};
1269 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301270
Patrick Venture91ac8d32018-11-01 17:03:22 -07001271 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001272 auto result = manager.setGroupState(group, false, ledsAssert,
1273 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301274 EXPECT_EQ(false, result);
1275 EXPECT_EQ(0, ledsDeAssert.size());
1276 EXPECT_EQ(0, ledsAssert.size());
1277 }
1278}
1279
1280/** @brief Assert 2 groups having multiple LEDs common in different state and
1281 * mixed priority. DeAssert-A
1282 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001283TEST_F(LedTest,
1284 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301285{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001286 Manager manager(bus,
1287 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301288 {
1289 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001290 ActionSet ledsAssert{};
1291 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301292
Patrick Venture91ac8d32018-11-01 17:03:22 -07001293 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001294 auto result = manager.setGroupState(group, true, ledsAssert,
1295 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301296 EXPECT_EQ(true, result);
1297
1298 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001299 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001300 {"One", phosphor::led::Layout::Action::On, 0, 0,
1301 phosphor::led::Layout::Action::On},
1302 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1303 phosphor::led::Layout::Action::On},
1304 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1305 phosphor::led::Layout::Action::Blink},
1306 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1307 phosphor::led::Layout::Action::On},
1308 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1309 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301310 };
1311 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1312 EXPECT_EQ(0, ledsDeAssert.size());
1313
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301314 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001315 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301316 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1317 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301318 std::inserter(temp, temp.begin()));
1319 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301320 }
1321 {
1322 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001323 ActionSet ledsAssert{};
1324 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301325
Patrick Venture91ac8d32018-11-01 17:03:22 -07001326 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001327 auto result = manager.setGroupState(group, true, ledsAssert,
1328 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301329 EXPECT_EQ(true, result);
1330
1331 // Need just the ledsAssserted populated with these.
1332 // [Two] gets to [ON] due to higher priority.
1333 // [Three] remains on since it never was in [Blink] before
1334 // [Ten] remains [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001335 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001336 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1337 phosphor::led::Layout::Action::On},
1338 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1339 phosphor::led::Layout::Action::On},
1340 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1341 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301342 };
1343 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1344 EXPECT_EQ(0, ledsDeAssert.size());
1345
1346 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001347 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301348 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1349 refAssert.begin(), refAssert.end(),
1350 std::inserter(temp, temp.begin()));
1351 EXPECT_EQ(0, temp.size());
1352 }
1353 {
1354 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001355 ActionSet ledsAssert{};
1356 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301357
Patrick Venture91ac8d32018-11-01 17:03:22 -07001358 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001359 auto result = manager.setGroupState(group, false, ledsAssert,
1360 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301361 EXPECT_EQ(false, result);
1362
1363 // Need just the ledsDeAsssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001364 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001365 {"One", phosphor::led::Layout::Action::On, 0, 0,
1366 phosphor::led::Layout::Action::On},
1367 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1368 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301369 };
1370 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1371
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301372 // Need just the ledsAsssert populated with these.
1373 // [Ten] Moves to [On] since there is no prior [Blink]
1374 // [Three] remains [On] since it never changed state.
1375 // [Two] remains [On] since it did not go back
Patrick Williams158b2c12022-03-17 05:57:44 -05001376 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001377 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1378 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301379 };
1380 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1381
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301382 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001383 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301384 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1385 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301386 std::inserter(temp, temp.begin()));
1387 EXPECT_EQ(0, temp.size());
1388 }
1389}
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301390
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301391/** @brief Assert 2 groups having multiple LEDs common in different state and
1392 * mixed priority. DeAssert-B
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301393 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001394TEST_F(
1395 LedTest,
1396 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB)
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301397{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001398 Manager manager(bus,
1399 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301400 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301401 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001402 ActionSet ledsAssert{};
1403 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301404
Patrick Venture91ac8d32018-11-01 17:03:22 -07001405 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001406 auto result = manager.setGroupState(group, true, ledsAssert,
1407 ledsDeAssert);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301408 EXPECT_EQ(true, result);
1409
1410 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001411 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001412 {"One", phosphor::led::Layout::Action::On, 0, 0,
1413 phosphor::led::Layout::Action::On},
1414 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1415 phosphor::led::Layout::Action::On},
1416 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1417 phosphor::led::Layout::Action::Blink},
1418 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1419 phosphor::led::Layout::Action::On},
1420 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1421 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301422 };
1423 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1424 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301425
1426 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001427 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301428 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1429 refAssert.begin(), refAssert.end(),
1430 std::inserter(temp, temp.begin()));
1431 EXPECT_EQ(0, temp.size());
1432 }
1433 {
1434 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001435 ActionSet ledsAssert{};
1436 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301437
Patrick Venture91ac8d32018-11-01 17:03:22 -07001438 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001439 auto result = manager.setGroupState(group, true, ledsAssert,
1440 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301441 EXPECT_EQ(true, result);
1442
1443 // Need just the ledsAssserted populated with these.
1444 // [Two] gets to [ON] due to higher priority.
1445 // [Three] remains on since it never was in [Blink] before
1446 // [Ten] remains [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001447 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001448 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1449 phosphor::led::Layout::Action::On},
1450 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1451 phosphor::led::Layout::Action::On},
1452 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1453 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301454 };
1455 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1456 EXPECT_EQ(0, ledsDeAssert.size());
1457
1458 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001459 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301460 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1461 refAssert.begin(), refAssert.end(),
1462 std::inserter(temp, temp.begin()));
1463 EXPECT_EQ(0, temp.size());
1464 }
1465 {
1466 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001467 ActionSet ledsAssert{};
1468 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301469
Patrick Venture91ac8d32018-11-01 17:03:22 -07001470 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001471 auto result = manager.setGroupState(group, false, ledsAssert,
1472 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301473 EXPECT_EQ(false, result);
1474
1475 // Need just the ledsDeAsssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001476 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001477 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1478 phosphor::led::Layout::Action::On},
1479 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1480 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301481 };
1482 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1483
1484 // Need just the ledsAsssert populated with these.
1485 // [Ten] remains [Blink] since it did not move to [On]
1486 // [Three] remains [On] since it never changed state.
1487 // [Two] moves to [Blink] since there is no prior [On]
Patrick Williams158b2c12022-03-17 05:57:44 -05001488 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001489 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1490 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301491 };
1492 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1493
1494 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001495 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301496 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1497 refAssert.begin(), refAssert.end(),
1498 std::inserter(temp, temp.begin()));
1499 EXPECT_EQ(0, temp.size());
1500 }
1501}
1502
1503/** @brief Assert 2 groups having multiple LEDs common in different state and
1504 * mixed priority.
1505 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001506TEST_F(LedTest,
1507 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301508{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001509 Manager manager(bus,
1510 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301511 {
1512 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001513 ActionSet ledsAssert{};
1514 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301515
Patrick Venture91ac8d32018-11-01 17:03:22 -07001516 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001517 auto result = manager.setGroupState(group, true, ledsAssert,
1518 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301519 EXPECT_EQ(true, result);
1520
1521 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001522 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001523 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1524 phosphor::led::Layout::Action::On},
1525 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1526 phosphor::led::Layout::Action::Blink},
1527 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1528 phosphor::led::Layout::Action::On},
1529 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1530 phosphor::led::Layout::Action::On},
1531 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1532 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301533 };
1534 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1535 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301536
1537 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001538 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301539 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1540 refAssert.begin(), refAssert.end(),
1541 std::inserter(temp, temp.begin()));
1542 EXPECT_EQ(0, temp.size());
1543 }
1544 {
1545 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001546 ActionSet ledsAssert{};
1547 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301548
Patrick Venture91ac8d32018-11-01 17:03:22 -07001549 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001550 auto result = manager.setGroupState(group, true, ledsAssert,
1551 ledsDeAssert);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301552 EXPECT_EQ(true, result);
1553
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301554 // Need just the ledsAssserted populated with these.
1555 // [Two] remains [ON] due to higher priority.
1556 // [Three] remains on since it never was in [Blink] before
1557 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001558 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001559 {"One", phosphor::led::Layout::Action::On, 0, 0,
1560 phosphor::led::Layout::Action::On},
1561 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1562 phosphor::led::Layout::Action::On},
1563 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1564 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301565 };
1566 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1567 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301568
1569 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001570 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301571 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1572 refAssert.begin(), refAssert.end(),
1573 std::inserter(temp, temp.begin()));
1574 EXPECT_EQ(0, temp.size());
1575 }
1576}
1577
1578/** @brief Assert 2 groups having multiple LEDs common in different state and
1579 * mixed priority and De-Assert-A
1580 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001581TEST_F(
1582 LedTest,
1583 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301584{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001585 Manager manager(bus,
1586 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301587 {
1588 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001589 ActionSet ledsAssert{};
1590 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301591
Patrick Venture91ac8d32018-11-01 17:03:22 -07001592 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001593 auto result = manager.setGroupState(group, true, ledsAssert,
1594 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301595 EXPECT_EQ(true, result);
1596
1597 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001598 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001599 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1600 phosphor::led::Layout::Action::On},
1601 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1602 phosphor::led::Layout::Action::Blink},
1603 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1604 phosphor::led::Layout::Action::On},
1605 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1606 phosphor::led::Layout::Action::On},
1607 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1608 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301609 };
1610 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1611 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301612
1613 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001614 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301615 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1616 refAssert.begin(), refAssert.end(),
1617 std::inserter(temp, temp.begin()));
1618 EXPECT_EQ(0, temp.size());
1619 }
1620 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301621 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001622 ActionSet ledsAssert{};
1623 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301624
Patrick Venture91ac8d32018-11-01 17:03:22 -07001625 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001626 auto result = manager.setGroupState(group, true, ledsAssert,
1627 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301628 EXPECT_EQ(true, result);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301629
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301630 // Need just the ledsAssserted populated with these.
1631 // [Two] remains [ON] due to higher priority.
1632 // [Three] remains on since it never was in [Blink] before
1633 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001634 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001635 {"One", phosphor::led::Layout::Action::On, 0, 0,
1636 phosphor::led::Layout::Action::On},
1637 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1638 phosphor::led::Layout::Action::On},
1639 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1640 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301641 };
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301642 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1643 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301644
1645 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001646 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301647 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1648 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301649 std::inserter(temp, temp.begin()));
1650 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301651 }
1652 {
1653 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001654 ActionSet ledsAssert{};
1655 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301656
Patrick Venture91ac8d32018-11-01 17:03:22 -07001657 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001658 auto result = manager.setGroupState(group, false, ledsAssert,
1659 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301660 EXPECT_EQ(false, result);
1661
1662 // Need just the ledsAssserted populated with these.
1663 // [Ten] remains [Blink] due to priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001664 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001665 {"One", phosphor::led::Layout::Action::On, 0, 0,
1666 phosphor::led::Layout::Action::On},
1667 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1668 phosphor::led::Layout::Action::On},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301669 };
1670 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1671
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301672 // Need just the ledsAssserted populated with these.
1673 // [Two] remains [ON] due to higher priority.
1674 // [Three] remains [On] since it never was in [Blink] before
1675 // [Ten] moves to [On] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001676 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001677 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1678 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301679 };
1680 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1681
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301682 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001683 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301684 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1685 refAssert.begin(), refAssert.end(),
1686 std::inserter(temp, temp.begin()));
1687 EXPECT_EQ(0, temp.size());
1688 }
1689}
1690
1691/** @brief Assert 2 groups having multiple LEDs common in different state and
1692 * mixed priority and then DeAssert twice.
1693 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001694TEST_F(LedTest,
1695 assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301696{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001697 Manager manager(bus,
1698 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301699 {
1700 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001701 ActionSet ledsAssert{};
1702 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301703
Patrick Venture91ac8d32018-11-01 17:03:22 -07001704 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001705 auto result = manager.setGroupState(group, true, ledsAssert,
1706 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301707 EXPECT_EQ(true, result);
1708
1709 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001710 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001711 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1712 phosphor::led::Layout::Action::On},
1713 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1714 phosphor::led::Layout::Action::Blink},
1715 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1716 phosphor::led::Layout::Action::On},
1717 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1718 phosphor::led::Layout::Action::On},
1719 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1720 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301721 };
1722 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1723 EXPECT_EQ(0, ledsDeAssert.size());
1724
1725 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001726 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301727 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1728 refAssert.begin(), refAssert.end(),
1729 std::inserter(temp, temp.begin()));
1730 EXPECT_EQ(0, temp.size());
1731 }
1732 {
1733 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001734 ActionSet ledsAssert{};
1735 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301736
Patrick Venture91ac8d32018-11-01 17:03:22 -07001737 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001738 auto result = manager.setGroupState(group, true, ledsAssert,
1739 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301740 EXPECT_EQ(true, result);
1741
1742 // Need just the ledsAssserted populated with these.
1743 // [Two] remains [ON] due to higher priority.
1744 // [Three] remains on since it never was in [Blink] before
1745 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001746 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001747 {"One", phosphor::led::Layout::Action::On, 0, 0,
1748 phosphor::led::Layout::Action::On},
1749 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1750 phosphor::led::Layout::Action::On},
1751 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1752 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301753 };
1754 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1755 EXPECT_EQ(0, ledsDeAssert.size());
1756
1757 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001758 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301759 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1760 refAssert.begin(), refAssert.end(),
1761 std::inserter(temp, temp.begin()));
1762 EXPECT_EQ(0, temp.size());
1763 }
1764 {
1765 // DeAssert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001766 ActionSet ledsAssert{};
1767 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301768
Patrick Venture91ac8d32018-11-01 17:03:22 -07001769 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001770 auto result = manager.setGroupState(group, false, ledsAssert,
1771 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301772 EXPECT_EQ(false, result);
1773
1774 // Need just the ledsAssserted populated with these.
1775 // [Ten] remains [Blink] due to priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001776 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001777 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1778 phosphor::led::Layout::Action::On},
1779 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1780 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301781 };
1782 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1783
1784 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001785 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301786 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1787 refDeAssert.begin(), refDeAssert.end(),
1788 std::inserter(temp, temp.begin()));
1789 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301790
1791 // Need just the ledsAssert populated with these.
1792 // [Two] will move to [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001793 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001794 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1795 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301796 };
1797 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1798
1799 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001800 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301801 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1802 refAssert.begin(), refAssert.end(),
1803 std::inserter(temp1, temp1.begin()));
1804 EXPECT_EQ(0, temp1.size());
1805 }
1806 {
1807 // DeAssert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001808 ActionSet ledsAssert{};
1809 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301810
Patrick Venture91ac8d32018-11-01 17:03:22 -07001811 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams857da382023-05-10 07:50:20 -05001812 auto result = manager.setGroupState(group, false, ledsAssert,
1813 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301814 EXPECT_EQ(false, result);
1815
1816 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001817 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001818 {"One", phosphor::led::Layout::Action::On, 0, 0,
1819 phosphor::led::Layout::Action::On},
1820 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1821 phosphor::led::Layout::Action::On},
1822 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1823 phosphor::led::Layout::Action::Blink},
1824 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1825 phosphor::led::Layout::Action::On},
1826 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1827 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301828 };
1829 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1830 EXPECT_EQ(0, ledsAssert.size());
1831
1832 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001833 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301834 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1835 refDeAssert.begin(), refDeAssert.end(),
1836 std::inserter(temp, temp.begin()));
1837 EXPECT_EQ(0, temp.size());
1838 }
1839 {
1840 // DeAssert Set-B again and make sure we get all empty
Patrick Williams158b2c12022-03-17 05:57:44 -05001841 ActionSet ledsAssert{};
1842 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301843
Patrick Venture91ac8d32018-11-01 17:03:22 -07001844 auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams857da382023-05-10 07:50:20 -05001845 auto result = manager.setGroupState(group, false, ledsAssert,
1846 ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301847 EXPECT_EQ(false, result);
1848 EXPECT_EQ(0, ledsDeAssert.size());
1849 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301850 }
1851}