blob: ea2eb8332e1e6762f77abeccf2ad9b1382262251 [file] [log] [blame]
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301#include "led-test-map.hpp"
Patrick Venture91ac8d32018-11-01 17:03:22 -07002#include "manager.hpp"
3
Patrick Venture91ac8d32018-11-01 17:03:22 -07004#include <sdbusplus/bus.hpp>
George Liua6c18f82020-06-22 10:50:04 +08005
6#include <algorithm>
Patrick Venture91ac8d32018-11-01 17:03:22 -07007#include <set>
8
9#include <gtest/gtest.h>
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053010using namespace phosphor::led;
11class LedTest : public ::testing::Test
12{
Patrick Venture91ac8d32018-11-01 17:03:22 -070013 public:
Patrick Williams3e073ba2022-07-22 19:26:52 -050014 sdbusplus::bus_t bus;
Patrick Venture91ac8d32018-11-01 17:03:22 -070015 LedTest() : bus(sdbusplus::bus::new_default())
16 {
17 // Nothing here
18 }
George Liuc8ddde62024-08-22 17:29:16 +080019 ~LedTest() override = default;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053020};
21
22/** @brief Assert Single LED to On */
23TEST_F(LedTest, assertSingleLedOn)
24{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053025 Manager manager(bus, singleLedOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053026 {
27 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050028 ActionSet ledsAssert{};
29 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053030
George Liu3d487512024-08-23 09:19:57 +080031 static constexpr auto group =
32 "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -040033 auto result =
34 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053035 EXPECT_EQ(true, result);
36
37 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050038 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -050039 {"One", phosphor::led::Layout::Action::On, 0, 0,
40 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053041 };
42 EXPECT_EQ(refAssert.size(), ledsAssert.size());
43 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053044
45 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -050046 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053047 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
48 refAssert.begin(), refAssert.end(),
49 std::inserter(temp, temp.begin()));
50 EXPECT_EQ(0, temp.size());
51 }
52}
53
54/** @brief Assert Single LED to Blink */
55TEST_F(LedTest, assertSingleLedBlink)
56{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053057 Manager manager(bus, singleLedBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053058 {
59 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050060 ActionSet ledsAssert{};
61 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053062
George Liu3d487512024-08-23 09:19:57 +080063 static constexpr auto group =
64 "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -040065 auto result =
66 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053067 EXPECT_EQ(true, result);
68
69 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -050070 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -050071 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
72 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053073 };
74 EXPECT_EQ(refAssert.size(), ledsAssert.size());
75 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053076
77 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -050078 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053079 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
80 refAssert.begin(), refAssert.end(),
81 std::inserter(temp, temp.begin()));
82 EXPECT_EQ(0, temp.size());
83 }
84}
85
86/** @brief Assert Single LED to On and Try Assert Again */
87TEST_F(LedTest, assertSingleLedOnAndreAssert)
88{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053089 Manager manager(bus, singleLedOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053090 {
91 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -050092 ActionSet ledsAssert{};
93 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053094
George Liu3d487512024-08-23 09:19:57 +080095 static constexpr auto group =
96 "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -040097 auto result =
98 manager.setGroupState(group, true, ledsAssert, 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
George Liu3d487512024-08-23 09:19:57 +0800121 static constexpr auto group =
122 "/xyz/openbmc_project/ledmanager/groups/SingleLed";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400123 auto result =
124 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530125 EXPECT_EQ(true, result);
126
127 EXPECT_EQ(0, ledsAssert.size());
128 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530129 }
130}
131
132/** @brief Assert Multiple LEDs to On */
133TEST_F(LedTest, assertMultipleLedOn)
134{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530135 Manager manager(bus, multipleLedsOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530136 {
137 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500138 ActionSet ledsAssert{};
139 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530140
George Liu3d487512024-08-23 09:19:57 +0800141 static constexpr auto group =
142 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400143 auto result =
144 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530145 EXPECT_EQ(true, result);
146
147 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500148 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500149 {"One", phosphor::led::Layout::Action::On, 0, 0,
150 phosphor::led::Layout::Action::On},
151 {"Two", phosphor::led::Layout::Action::On, 0, 0,
152 phosphor::led::Layout::Action::On},
153 {"Three", phosphor::led::Layout::Action::On, 0, 0,
154 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530155 };
156 EXPECT_EQ(refAssert.size(), ledsAssert.size());
157 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530158
159 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500160 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530161 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
162 refAssert.begin(), refAssert.end(),
163 std::inserter(temp, temp.begin()));
164 EXPECT_EQ(0, temp.size());
165 }
166}
167
168/** @brief Assert Multiple LEDs to Blink */
169TEST_F(LedTest, assertMultipleLedBlink)
170{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530171 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530172 {
173 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500174 ActionSet ledsAssert{};
175 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530176
George Liu3d487512024-08-23 09:19:57 +0800177 static constexpr auto group =
178 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400179 auto result =
180 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530181 EXPECT_EQ(true, result);
182
183 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500184 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500185 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
186 phosphor::led::Layout::Action::Blink},
187 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
188 phosphor::led::Layout::Action::Blink},
189 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
190 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530191 };
192 EXPECT_EQ(refAssert.size(), ledsAssert.size());
193 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530194
195 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500196 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530197 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
198 refAssert.begin(), refAssert.end(),
199 std::inserter(temp, temp.begin()));
200 EXPECT_EQ(0, temp.size());
201 }
202}
203
204/** @brief Assert Multiple LEDs to Blink, DeAssert */
205TEST_F(LedTest, assertMultipleLedBlinkAndDeAssert)
206{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530207 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530208 {
209 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500210 ActionSet ledsAssert{};
211 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530212
George Liu3d487512024-08-23 09:19:57 +0800213 static constexpr auto group =
214 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400215 auto result =
216 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530217 EXPECT_EQ(true, result);
218
219 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500220 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500221 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
222 phosphor::led::Layout::Action::Blink},
223 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
224 phosphor::led::Layout::Action::Blink},
225 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
226 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530227 };
228 EXPECT_EQ(refAssert.size(), ledsAssert.size());
229 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530230
231 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500232 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530233 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
234 refAssert.begin(), refAssert.end(),
235 std::inserter(temp, temp.begin()));
236 EXPECT_EQ(0, temp.size());
237 }
238 {
239 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500240 ActionSet ledsAssert{};
241 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530242
George Liu3d487512024-08-23 09:19:57 +0800243 static constexpr auto group =
244 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400245 auto result =
246 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530247 EXPECT_EQ(false, result);
248
249 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500250 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500251 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
252 phosphor::led::Layout::Action::Blink},
253 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
254 phosphor::led::Layout::Action::Blink},
255 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
256 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530257 };
258 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
259 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530260
261 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500262 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530263 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
264 refDeAssert.begin(), refDeAssert.end(),
265 std::inserter(temp, temp.begin()));
266 EXPECT_EQ(0, temp.size());
267 }
268}
269
270/** @brief Assert Multiple LEDs to Blink, DeAssert Twice */
271TEST_F(LedTest, assertMultipleLedBlinkAndDeAssertTwice)
272{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530273 Manager manager(bus, multipleLedsBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530274 {
275 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500276 ActionSet ledsAssert{};
277 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530278
George Liu3d487512024-08-23 09:19:57 +0800279 static constexpr auto group =
280 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400281 auto result =
282 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530283 EXPECT_EQ(true, result);
284
285 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500286 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500287 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
288 phosphor::led::Layout::Action::Blink},
289 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
290 phosphor::led::Layout::Action::Blink},
291 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
292 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530293 };
294 EXPECT_EQ(refAssert.size(), ledsAssert.size());
295 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530296
297 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500298 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530299 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
300 refAssert.begin(), refAssert.end(),
301 std::inserter(temp, temp.begin()));
302 EXPECT_EQ(0, temp.size());
303 }
304 {
305 // DeAssert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500306 ActionSet ledsAssert{};
307 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530308
George Liu3d487512024-08-23 09:19:57 +0800309 static constexpr auto group =
310 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400311 auto result =
312 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530313 EXPECT_EQ(false, result);
314
315 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500316 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500317 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
318 phosphor::led::Layout::Action::Blink},
319 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
320 phosphor::led::Layout::Action::Blink},
321 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
322 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530323 };
324 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
325 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530326
327 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500328 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530329 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
330 refDeAssert.begin(), refDeAssert.end(),
331 std::inserter(temp, temp.begin()));
332 EXPECT_EQ(0, temp.size());
333 }
334 {
335 // DeAssert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500336 ActionSet ledsAssert{};
337 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530338
George Liu3d487512024-08-23 09:19:57 +0800339 static constexpr auto group =
340 "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400341 auto result =
342 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530343 EXPECT_EQ(false, result);
344 EXPECT_EQ(0, ledsDeAssert.size());
345 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530346 }
347}
348
349/** @brief Assert Multiple LEDs to mix of On and Blink */
350TEST_F(LedTest, assertMultipleLedOnAndBlink)
351{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530352 Manager manager(bus, multipleLedsOnAndBlink);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530353 {
354 // Assert the LEDs.
Patrick Williams158b2c12022-03-17 05:57:44 -0500355 ActionSet ledsAssert{};
356 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530357
George Liu3d487512024-08-23 09:19:57 +0800358 static constexpr auto group =
359 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400360 auto result =
361 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530362 EXPECT_EQ(true, result);
363
364 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500365 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500366 {"One", phosphor::led::Layout::Action::Blink, 0, 0,
367 phosphor::led::Layout::Action::Blink},
368 {"Two", phosphor::led::Layout::Action::On, 0, 0,
369 phosphor::led::Layout::Action::Blink},
370 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
371 phosphor::led::Layout::Action::On},
372 {"Four", phosphor::led::Layout::Action::On, 0, 0,
373 phosphor::led::Layout::Action::Blink},
374 {"Five", phosphor::led::Layout::Action::On, 0, 0,
375 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530376 };
377 EXPECT_EQ(refAssert.size(), ledsAssert.size());
378 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530379
380 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500381 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530382 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
383 refAssert.begin(), refAssert.end(),
384 std::inserter(temp, temp.begin()));
385 EXPECT_EQ(0, temp.size());
386 }
387}
388
389/** @brief Assert 2 groups having distinct LEDs */
390TEST_F(LedTest, assertTwoGroupsOnWithDistinctLEDOn)
391{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530392 Manager manager(bus, twoGroupsWithDistinctLEDsOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530393 {
394 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500395 ActionSet ledsAssert{};
396 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530397
George Liu3d487512024-08-23 09:19:57 +0800398 static constexpr auto group =
399 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400400 auto result =
401 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530402 EXPECT_EQ(true, result);
403
404 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500405 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500406 {"One", phosphor::led::Layout::Action::On, 0, 0,
407 phosphor::led::Layout::Action::Blink},
408 {"Two", phosphor::led::Layout::Action::On, 0, 0,
409 phosphor::led::Layout::Action::On},
410 {"Three", phosphor::led::Layout::Action::On, 0, 0,
411 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530412 };
413 EXPECT_EQ(refAssert.size(), ledsAssert.size());
414 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530415
416 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500417 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530418 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
419 refAssert.begin(), refAssert.end(),
420 std::inserter(temp, temp.begin()));
421 EXPECT_EQ(0, temp.size());
422 }
423 {
424 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500425 ActionSet ledsAssert{};
426 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530427
George Liu3d487512024-08-23 09:19:57 +0800428 static constexpr auto group =
429 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400430 auto result =
431 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530432 EXPECT_EQ(true, result);
433
434 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500435 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500436 {"Four", phosphor::led::Layout::Action::On, 0, 0,
437 phosphor::led::Layout::Action::Blink},
438 {"Five", phosphor::led::Layout::Action::On, 0, 0,
439 phosphor::led::Layout::Action::Blink},
440 {"Six", phosphor::led::Layout::Action::On, 0, 0,
441 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530442 };
443 EXPECT_EQ(refAssert.size(), ledsAssert.size());
444 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530445
446 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500447 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530448 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
449 refAssert.begin(), refAssert.end(),
450 std::inserter(temp, temp.begin()));
451 EXPECT_EQ(0, temp.size());
452 }
453}
454
455/** @brief Assert 2 groups having one of the LEDs common */
456TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOn)
457{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530458 Manager manager(bus, twoGroupsWithOneComonLEDOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530459 {
460 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500461 ActionSet ledsAssert{};
462 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530463
George Liu3d487512024-08-23 09:19:57 +0800464 static constexpr auto group =
465 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400466 auto result =
467 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530468 EXPECT_EQ(true, result);
469
470 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500471 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500472 {"One", phosphor::led::Layout::Action::On, 0, 0,
473 phosphor::led::Layout::Action::On},
474 {"Two", phosphor::led::Layout::Action::On, 0, 0,
475 phosphor::led::Layout::Action::On},
476 {"Three", phosphor::led::Layout::Action::On, 0, 0,
477 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530478 };
479 EXPECT_EQ(refAssert.size(), ledsAssert.size());
480 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530481
482 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500483 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530484 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
485 refAssert.begin(), refAssert.end(),
486 std::inserter(temp, temp.begin()));
487 EXPECT_EQ(0, temp.size());
488 }
489 {
490 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500491 ActionSet ledsAssert{};
492 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530493
George Liu3d487512024-08-23 09:19:57 +0800494 static constexpr auto group =
495 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400496 auto result =
497 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530498 EXPECT_EQ(true, result);
499
500 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500501 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500502 {"Four", phosphor::led::Layout::Action::On, 0, 0,
503 phosphor::led::Layout::Action::On},
504 {"Six", phosphor::led::Layout::Action::On, 0, 0,
505 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530506 };
507 EXPECT_EQ(refAssert.size(), ledsAssert.size());
508 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530509
510 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500511 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530512 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
513 refAssert.begin(), refAssert.end(),
514 std::inserter(temp, temp.begin()));
515 EXPECT_EQ(0, temp.size());
516 }
517}
518
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530519/** @brief Assert 2 groups having one of the LEDs common but having Blink as
520 * priority and Deassert*/
521TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530522{
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530523 Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530524 {
525 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500526 ActionSet ledsAssert{};
527 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530528
George Liu3d487512024-08-23 09:19:57 +0800529 static constexpr auto group =
530 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400531 auto result =
532 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530533 EXPECT_EQ(true, result);
534
535 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500536 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500537 {"One", phosphor::led::Layout::Action::On, 0, 0,
538 phosphor::led::Layout::Action::On},
539 {"Two", phosphor::led::Layout::Action::On, 0, 0,
540 phosphor::led::Layout::Action::On},
541 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
542 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530543 };
544 EXPECT_EQ(refAssert.size(), ledsAssert.size());
545 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530546
547 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500548 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530549 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
550 refAssert.begin(), refAssert.end(),
551 std::inserter(temp, temp.begin()));
552 EXPECT_EQ(0, temp.size());
553 }
554 {
555 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500556 ActionSet ledsAssert{};
557 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530558
George Liu3d487512024-08-23 09:19:57 +0800559 static constexpr auto group =
560 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400561 auto result =
562 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530563 EXPECT_EQ(true, result);
564
565 // Need just the ledsAssserted populated with these.
566 // Does not action on [Three] since priority is [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500567 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500568 {"Four", phosphor::led::Layout::Action::On, 0, 0,
569 phosphor::led::Layout::Action::On},
570 {"Six", phosphor::led::Layout::Action::On, 0, 0,
571 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530572 };
573 EXPECT_EQ(refAssert.size(), ledsAssert.size());
574 EXPECT_EQ(0, ledsDeAssert.size());
575
576 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500577 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530578 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
579 refAssert.begin(), refAssert.end(),
580 std::inserter(temp, temp.begin()));
581 EXPECT_EQ(0, temp.size());
582 }
583 {
584 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500585 ActionSet ledsAssert{};
586 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530587
George Liu3d487512024-08-23 09:19:57 +0800588 static constexpr auto group =
589 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400590 auto result =
591 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530592 EXPECT_EQ(false, result);
593
594 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500595 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500596 {"Four", phosphor::led::Layout::Action::On, 0, 0,
597 phosphor::led::Layout::Action::On},
598 {"Six", phosphor::led::Layout::Action::On, 0, 0,
599 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530600 };
601 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
602 EXPECT_EQ(0, ledsAssert.size());
603
604 // difference of refDeAssert and ledsDeAssert must be null.
605 // [Three] is not touched since its already [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500606 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530607 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
608 refDeAssert.begin(), refDeAssert.end(),
609 std::inserter(temp, temp.begin()));
610 EXPECT_EQ(0, temp.size());
611 }
612}
613
614/** @brief Assert 2 groups having one of the LEDs common but having Blink as
615 * priority and Deassert A */
616TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA)
617{
618 Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
619 {
620 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500621 ActionSet ledsAssert{};
622 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530623
George Liu3d487512024-08-23 09:19:57 +0800624 static constexpr auto group =
625 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400626 auto result =
627 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530628 EXPECT_EQ(true, result);
629
630 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500631 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500632 {"One", phosphor::led::Layout::Action::On, 0, 0,
633 phosphor::led::Layout::Action::On},
634 {"Two", phosphor::led::Layout::Action::On, 0, 0,
635 phosphor::led::Layout::Action::On},
636 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
637 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530638 };
639 EXPECT_EQ(refAssert.size(), ledsAssert.size());
640 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530641
642 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500643 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530644 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
645 refAssert.begin(), refAssert.end(),
646 std::inserter(temp, temp.begin()));
647 EXPECT_EQ(0, temp.size());
648 }
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530649 {
650 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500651 ActionSet ledsAssert{};
652 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530653
George Liu3d487512024-08-23 09:19:57 +0800654 static constexpr auto group =
655 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400656 auto result =
657 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530658 EXPECT_EQ(true, result);
659
660 // Need just the ledsAssserted populated with these.
661 // [Three] does not get actioned since it has Blink priority
Patrick Williams158b2c12022-03-17 05:57:44 -0500662 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500663 {"Four", phosphor::led::Layout::Action::On, 0, 0,
664 phosphor::led::Layout::Action::On},
665 {"Six", phosphor::led::Layout::Action::On, 0, 0,
666 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530667 };
668 EXPECT_EQ(refAssert.size(), ledsAssert.size());
669 EXPECT_EQ(0, ledsDeAssert.size());
670
671 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500672 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530673 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
674 refAssert.begin(), refAssert.end(),
675 std::inserter(temp, temp.begin()));
676 EXPECT_EQ(0, temp.size());
677 }
678 {
679 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500680 ActionSet ledsAssert{};
681 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530682
George Liu3d487512024-08-23 09:19:57 +0800683 static constexpr auto group =
684 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400685 auto result =
686 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530687 EXPECT_EQ(false, result);
688
689 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500690 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500691 {"One", phosphor::led::Layout::Action::On, 0, 0,
692 phosphor::led::Layout::Action::On},
693 {"Two", phosphor::led::Layout::Action::On, 0, 0,
694 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530695 };
696 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
697
698 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500699 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530700 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
701 refDeAssert.begin(), refDeAssert.end(),
702 std::inserter(temp, temp.begin()));
703 EXPECT_EQ(0, temp.size());
704
705 // Need just the ledsAssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500706 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500707 {"Three", phosphor::led::Layout::Action::On, 0, 0,
708 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530709 };
710 EXPECT_EQ(refAssert.size(), ledsAssert.size());
711
712 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500713 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530714 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
715 refAssert.begin(), refAssert.end(),
716 std::inserter(temp1, temp1.begin()));
717 EXPECT_EQ(0, temp1.size());
718 }
719}
720
721/** @brief Assert 2 groups having one of the LEDs common but having ON as
722 * priority And Deassert A */
723TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA)
724{
725 Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
726 {
727 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500728 ActionSet ledsAssert{};
729 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530730
George Liu3d487512024-08-23 09:19:57 +0800731 static constexpr auto group =
732 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400733 auto result =
734 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530735 EXPECT_EQ(true, result);
736
737 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500738 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500739 {"One", phosphor::led::Layout::Action::On, 0, 0,
740 phosphor::led::Layout::Action::On},
741 {"Two", phosphor::led::Layout::Action::On, 0, 0,
742 phosphor::led::Layout::Action::On},
743 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
744 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530745 };
746 EXPECT_EQ(refAssert.size(), ledsAssert.size());
747 EXPECT_EQ(0, ledsDeAssert.size());
748
749 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500750 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530751 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
752 refAssert.begin(), refAssert.end(),
753 std::inserter(temp, temp.begin()));
754 EXPECT_EQ(0, temp.size());
755 }
756 {
757 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500758 ActionSet ledsAssert{};
759 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530760
George Liu3d487512024-08-23 09:19:57 +0800761 static constexpr auto group =
762 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400763 auto result =
764 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530765 EXPECT_EQ(true, result);
766
767 // Need just the ledsAssserted populated with these.
768 // Three is set to ON due to ON priority.
Patrick Williams158b2c12022-03-17 05:57:44 -0500769 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500770 {"Three", phosphor::led::Layout::Action::On, 0, 0,
771 phosphor::led::Layout::Action::On},
772 {"Four", phosphor::led::Layout::Action::On, 0, 0,
773 phosphor::led::Layout::Action::On},
774 {"Six", phosphor::led::Layout::Action::On, 0, 0,
775 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530776 };
777 EXPECT_EQ(refAssert.size(), ledsAssert.size());
778 EXPECT_EQ(0, ledsDeAssert.size());
779
780 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500781 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530782 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
783 refAssert.begin(), refAssert.end(),
784 std::inserter(temp, temp.begin()));
785 }
786 {
787 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500788 ActionSet ledsAssert{};
789 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530790
George Liu3d487512024-08-23 09:19:57 +0800791 static constexpr auto group =
792 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400793 auto result =
794 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530795 EXPECT_EQ(false, result);
796
797 // Need just the ledsDeAssserted populated with these.
798 // [Three] stays in [On] since [B] has it [On]
Patrick Williams158b2c12022-03-17 05:57:44 -0500799 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500800 {"One", phosphor::led::Layout::Action::On, 0, 0,
801 phosphor::led::Layout::Action::On},
802 {"Two", phosphor::led::Layout::Action::On, 0, 0,
803 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530804 };
805 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
806 EXPECT_EQ(0, ledsAssert.size());
807
808 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500809 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530810 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
811 refDeAssert.begin(), refDeAssert.end(),
812 std::inserter(temp, temp.begin()));
813 EXPECT_EQ(0, temp.size());
814 }
815}
816
817/** @brief Assert 2 groups having one of the LEDs common but having ON as
818 * priority And Deassert B */
819TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB)
820{
821 Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
822 {
823 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500824 ActionSet ledsAssert{};
825 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530826
George Liu3d487512024-08-23 09:19:57 +0800827 static constexpr auto group =
828 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400829 auto result =
830 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530831 EXPECT_EQ(true, result);
832
833 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500834 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500835 {"One", phosphor::led::Layout::Action::On, 0, 0,
836 phosphor::led::Layout::Action::On},
837 {"Two", phosphor::led::Layout::Action::On, 0, 0,
838 phosphor::led::Layout::Action::On},
839 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
840 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530841 };
842 EXPECT_EQ(refAssert.size(), ledsAssert.size());
843 EXPECT_EQ(0, ledsDeAssert.size());
844
845 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500846 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530847 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
848 refAssert.begin(), refAssert.end(),
849 std::inserter(temp, temp.begin()));
850 EXPECT_EQ(0, temp.size());
851 }
852 {
853 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500854 ActionSet ledsAssert{};
855 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530856
George Liu3d487512024-08-23 09:19:57 +0800857 static constexpr auto group =
858 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400859 auto result =
860 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530861 EXPECT_EQ(true, result);
862
863 // Need just the ledsAssserted populated with these.
864 // Three is set to ON due to ON priority.
Patrick Williams158b2c12022-03-17 05:57:44 -0500865 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500866 {"Three", phosphor::led::Layout::Action::On, 0, 0,
867 phosphor::led::Layout::Action::On},
868 {"Four", phosphor::led::Layout::Action::On, 0, 0,
869 phosphor::led::Layout::Action::On},
870 {"Six", phosphor::led::Layout::Action::On, 0, 0,
871 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530872 };
873 EXPECT_EQ(refAssert.size(), ledsAssert.size());
874 EXPECT_EQ(0, ledsDeAssert.size());
875
876 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500877 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530878 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
879 refAssert.begin(), refAssert.end(),
880 std::inserter(temp, temp.begin()));
881 }
882 {
883 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500884 ActionSet ledsAssert{};
885 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530886
George Liu3d487512024-08-23 09:19:57 +0800887 static constexpr auto group =
888 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400889 auto result =
890 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530891 EXPECT_EQ(false, result);
892
893 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500894 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500895 {"Four", phosphor::led::Layout::Action::On, 0, 0,
896 phosphor::led::Layout::Action::On},
897 {"Six", phosphor::led::Layout::Action::On, 0, 0,
898 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530899 };
900 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
901
902 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500903 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530904 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
905 refDeAssert.begin(), refDeAssert.end(),
906 std::inserter(temp, temp.begin()));
907 EXPECT_EQ(0, temp.size());
908
909 // Need just the ledsAssert populated with these.
910 // Since [Three] stood [On], need to go back to [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -0500911 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500912 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
913 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530914 };
915 EXPECT_EQ(refAssert.size(), ledsAssert.size());
916
917 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500918 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530919 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
920 refAssert.begin(), refAssert.end(),
921 std::inserter(temp, temp.begin()));
922 EXPECT_EQ(0, temp.size());
923 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530924}
925
926/** @brief Assert 2 groups having multiple common LEDs in Same State */
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530927TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530928{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +0530929 Manager manager(bus, twoGroupsWithMultiplComonLEDOn);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530930 {
931 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500932 ActionSet ledsAssert{};
933 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530934
George Liu3d487512024-08-23 09:19:57 +0800935 static constexpr auto group =
936 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400937 auto result =
938 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530939 EXPECT_EQ(true, result);
940
941 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500942 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500943 {"Two", phosphor::led::Layout::Action::On, 0, 0,
944 phosphor::led::Layout::Action::On},
945 {"Six", phosphor::led::Layout::Action::On, 0, 0,
946 phosphor::led::Layout::Action::On},
947 {"Three", phosphor::led::Layout::Action::On, 0, 0,
948 phosphor::led::Layout::Action::On},
949 {"Seven", phosphor::led::Layout::Action::On, 0, 0,
950 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530951 };
952 EXPECT_EQ(refAssert.size(), ledsAssert.size());
953 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530954
955 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500956 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530957 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
958 refAssert.begin(), refAssert.end(),
959 std::inserter(temp, temp.begin()));
960 EXPECT_EQ(0, temp.size());
961 }
962 {
963 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -0500964 ActionSet ledsAssert{};
965 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530966
George Liu3d487512024-08-23 09:19:57 +0800967 static constexpr auto group =
968 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400969 auto result =
970 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530971 EXPECT_EQ(true, result);
972
973 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -0500974 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -0500975 {"One", phosphor::led::Layout::Action::On, 0, 0,
976 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +0530977 };
978 EXPECT_EQ(refAssert.size(), ledsAssert.size());
979 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530980
981 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -0500982 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530983 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
984 refAssert.begin(), refAssert.end(),
985 std::inserter(temp, temp.begin()));
986 EXPECT_EQ(0, temp.size());
987 }
988 {
989 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -0500990 ActionSet ledsAssert{};
991 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530992
George Liu3d487512024-08-23 09:19:57 +0800993 static constexpr auto group =
994 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -0400995 auto result =
996 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +0530997 EXPECT_EQ(false, result);
998
999 // Need just the ledsDeAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001000 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001001 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1002 phosphor::led::Layout::Action::On},
1003 {"Seven", phosphor::led::Layout::Action::On, 0, 0,
1004 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301005 };
1006 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1007 EXPECT_EQ(0, ledsAssert.size());
1008
1009 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001010 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301011 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1012 refDeAssert.begin(), refDeAssert.end(),
1013 std::inserter(temp, temp.begin()));
1014 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301015 }
1016}
1017
1018/** @brief Assert 2 groups having multiple LEDs common in different state */
1019TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA)
1020{
1021 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
1022 {
1023 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001024 ActionSet ledsAssert{};
1025 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301026
George Liu3d487512024-08-23 09:19:57 +08001027 static constexpr auto group =
1028 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001029 auto result =
1030 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301031 EXPECT_EQ(true, result);
1032
1033 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001034 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001035 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1036 phosphor::led::Layout::Action::On},
1037 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1038 phosphor::led::Layout::Action::On},
1039 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1040 phosphor::led::Layout::Action::On},
1041 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1042 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301043 };
1044 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1045 EXPECT_EQ(0, ledsDeAssert.size());
1046
1047 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001048 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +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 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001056 ActionSet ledsAssert{};
1057 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301058
George Liu3d487512024-08-23 09:19:57 +08001059 static constexpr auto group =
1060 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001061 auto result =
1062 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301063 EXPECT_EQ(true, result);
1064
1065 // Need just the ledsAssserted populated with these
1066 // [Two] remains [On] due to higher priority.
1067 // [Three] remains [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001068 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001069 {"One", phosphor::led::Layout::Action::On, 0, 0,
1070 phosphor::led::Layout::Action::On},
1071 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1072 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301073 };
1074 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1075 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301076
1077 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001078 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301079 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1080 refAssert.begin(), refAssert.end(),
1081 std::inserter(temp, temp.begin()));
1082 EXPECT_EQ(0, temp.size());
1083 }
1084}
1085
1086/** @brief Assert 2 groups having multiple LEDs common in different state */
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301087TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301088{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +05301089 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301090 {
1091 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001092 ActionSet ledsAssert{};
1093 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301094
George Liu3d487512024-08-23 09:19:57 +08001095 static constexpr auto group =
1096 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001097 auto result =
1098 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301099 EXPECT_EQ(true, result);
1100
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301101 // Need just the ledsAssserted populated with these.'Two' gets to Blink
1102 // due to higher priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001103 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001104 {"One", phosphor::led::Layout::Action::On, 0, 0,
1105 phosphor::led::Layout::Action::On},
1106 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1107 phosphor::led::Layout::Action::On},
1108 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1109 phosphor::led::Layout::Action::On},
1110 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1111 phosphor::led::Layout::Action::On},
Vishwanatha 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 }
1123 {
1124 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001125 ActionSet ledsAssert{};
1126 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301127
George Liu3d487512024-08-23 09:19:57 +08001128 static constexpr auto group =
1129 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001130 auto result =
1131 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301132 EXPECT_EQ(true, result);
1133
1134 // Need just the ledsAssserted populated with these.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301135 // [Three] remains [Blink] from previous
1136 // [Two] moves to [On] from [Blink] due to [On] priority
Patrick Williams158b2c12022-03-17 05:57:44 -05001137 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001138 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1139 phosphor::led::Layout::Action::On},
1140 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1141 phosphor::led::Layout::Action::On},
1142 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1143 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301144 };
1145 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1146 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301147
1148 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001149 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301150 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1151 refAssert.begin(), refAssert.end(),
1152 std::inserter(temp, temp.begin()));
1153 EXPECT_EQ(0, temp.size());
1154 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301155}
1156
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301157/** @brief Assert 2 groups having multiple LEDs common in different state
1158 * DeAssert twice
1159 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001160TEST_F(LedTest,
1161 assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301162{
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +05301163 Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301164 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301165 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001166 ActionSet ledsAssert{};
1167 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301168
George Liu3d487512024-08-23 09:19:57 +08001169 static constexpr auto group =
1170 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001171 auto result =
1172 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301173 EXPECT_EQ(true, result);
1174
1175 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001176 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001177 {"One", phosphor::led::Layout::Action::On, 0, 0,
1178 phosphor::led::Layout::Action::On},
1179 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1180 phosphor::led::Layout::Action::On},
1181 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1182 phosphor::led::Layout::Action::On},
1183 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1184 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301185 };
1186 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1187 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301188
1189 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001190 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301191 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1192 refAssert.begin(), refAssert.end(),
1193 std::inserter(temp, temp.begin()));
1194 EXPECT_EQ(0, temp.size());
1195 }
1196 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301197 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001198 ActionSet ledsAssert{};
1199 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301200
George Liu3d487512024-08-23 09:19:57 +08001201 static constexpr auto group =
1202 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001203 auto result =
1204 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301205 EXPECT_EQ(true, result);
1206
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301207 // Need just the ledsAssserted populated with these.
1208 // [Two] turns [On] due to priority
1209 // [Three] remains [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001210 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001211 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1212 phosphor::led::Layout::Action::On},
1213 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1214 phosphor::led::Layout::Action::On},
1215 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1216 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301217 };
1218 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1219 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301220
1221 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001222 ActionSet temp{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301223 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1224 refAssert.begin(), refAssert.end(),
1225 std::inserter(temp, temp.begin()));
1226 EXPECT_EQ(0, temp.size());
1227 }
1228 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301229 // DeAssert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001230 ActionSet ledsAssert{};
1231 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301232
George Liu3d487512024-08-23 09:19:57 +08001233 static constexpr auto group =
1234 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001235 auto result =
1236 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301237 EXPECT_EQ(false, result);
1238
1239 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001240 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001241 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1242 phosphor::led::Layout::Action::On},
1243 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1244 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301245 };
1246 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1247
1248 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001249 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301250 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1251 refDeAssert.begin(), refDeAssert.end(),
1252 std::inserter(temp, temp.begin()));
1253 EXPECT_EQ(0, temp.size());
1254
1255 // Need just the ledsAssert populated with these.
1256 // [Two] will go back to [Blink] from [On]
Patrick Williams158b2c12022-03-17 05:57:44 -05001257 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001258 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1259 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301260 };
1261 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1262
1263 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001264 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301265 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1266 refAssert.begin(), refAssert.end(),
1267 std::inserter(temp1, temp1.begin()));
1268 EXPECT_EQ(0, temp1.size());
1269 }
1270 {
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301271 // DeAssert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001272 ActionSet ledsAssert{};
1273 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301274
George Liu3d487512024-08-23 09:19:57 +08001275 static constexpr auto group =
1276 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001277 auto result =
1278 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301279 EXPECT_EQ(false, result);
1280
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301281 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001282 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001283 {"One", phosphor::led::Layout::Action::On, 0, 0,
1284 phosphor::led::Layout::Action::On},
1285 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1286 phosphor::led::Layout::Action::On},
1287 {"Three", phosphor::led::Layout::Action::Blink, 0, 0,
1288 phosphor::led::Layout::Action::On},
1289 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1290 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301291 };
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301292 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301293 EXPECT_EQ(0, ledsAssert.size());
1294
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301295 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001296 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301297 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1298 refDeAssert.begin(), refDeAssert.end(),
1299 std::inserter(temp, temp.begin()));
1300 EXPECT_EQ(0, temp.size());
1301 }
1302 {
1303 // DeAssert Set-A again and make sure we get all empty
Patrick Williams158b2c12022-03-17 05:57:44 -05001304 ActionSet ledsAssert{};
1305 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301306
George Liu3d487512024-08-23 09:19:57 +08001307 static constexpr auto group =
1308 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001309 auto result =
1310 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301311 EXPECT_EQ(false, result);
1312 EXPECT_EQ(0, ledsDeAssert.size());
1313 EXPECT_EQ(0, ledsAssert.size());
1314 }
1315}
1316
1317/** @brief Assert 2 groups having multiple LEDs common in different state and
1318 * mixed priority. DeAssert-A
1319 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001320TEST_F(LedTest,
1321 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301322{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001323 Manager manager(bus,
1324 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301325 {
1326 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001327 ActionSet ledsAssert{};
1328 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301329
George Liu3d487512024-08-23 09:19:57 +08001330 static constexpr auto group =
1331 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001332 auto result =
1333 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301334 EXPECT_EQ(true, result);
1335
1336 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001337 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001338 {"One", phosphor::led::Layout::Action::On, 0, 0,
1339 phosphor::led::Layout::Action::On},
1340 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1341 phosphor::led::Layout::Action::On},
1342 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1343 phosphor::led::Layout::Action::Blink},
1344 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1345 phosphor::led::Layout::Action::On},
1346 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1347 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301348 };
1349 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1350 EXPECT_EQ(0, ledsDeAssert.size());
1351
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301352 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001353 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301354 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1355 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301356 std::inserter(temp, temp.begin()));
1357 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301358 }
1359 {
1360 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001361 ActionSet ledsAssert{};
1362 ActionSet ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301363
George Liu3d487512024-08-23 09:19:57 +08001364 static constexpr auto group =
1365 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001366 auto result =
1367 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301368 EXPECT_EQ(true, result);
1369
1370 // Need just the ledsAssserted populated with these.
1371 // [Two] gets to [ON] due to higher priority.
1372 // [Three] remains on since it never was in [Blink] before
1373 // [Ten] remains [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001374 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001375 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1376 phosphor::led::Layout::Action::On},
1377 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1378 phosphor::led::Layout::Action::On},
1379 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1380 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301381 };
1382 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1383 EXPECT_EQ(0, ledsDeAssert.size());
1384
1385 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001386 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301387 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1388 refAssert.begin(), refAssert.end(),
1389 std::inserter(temp, temp.begin()));
1390 EXPECT_EQ(0, temp.size());
1391 }
1392 {
1393 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001394 ActionSet ledsAssert{};
1395 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301396
George Liu3d487512024-08-23 09:19:57 +08001397 static constexpr auto group =
1398 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001399 auto result =
1400 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301401 EXPECT_EQ(false, result);
1402
1403 // Need just the ledsDeAsssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001404 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001405 {"One", phosphor::led::Layout::Action::On, 0, 0,
1406 phosphor::led::Layout::Action::On},
1407 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1408 phosphor::led::Layout::Action::On},
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301409 };
1410 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1411
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301412 // Need just the ledsAsssert populated with these.
1413 // [Ten] Moves to [On] since there is no prior [Blink]
1414 // [Three] remains [On] since it never changed state.
1415 // [Two] remains [On] since it did not go back
Patrick Williams158b2c12022-03-17 05:57:44 -05001416 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001417 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1418 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301419 };
1420 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1421
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301422 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001423 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301424 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1425 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301426 std::inserter(temp, temp.begin()));
1427 EXPECT_EQ(0, temp.size());
1428 }
1429}
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301430
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301431/** @brief Assert 2 groups having multiple LEDs common in different state and
1432 * mixed priority. DeAssert-B
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301433 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001434TEST_F(
1435 LedTest,
1436 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB)
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301437{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001438 Manager manager(bus,
1439 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301440 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301441 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001442 ActionSet ledsAssert{};
1443 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301444
George Liu3d487512024-08-23 09:19:57 +08001445 static constexpr auto group =
1446 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001447 auto result =
1448 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301449 EXPECT_EQ(true, result);
1450
1451 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001452 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001453 {"One", phosphor::led::Layout::Action::On, 0, 0,
1454 phosphor::led::Layout::Action::On},
1455 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1456 phosphor::led::Layout::Action::On},
1457 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1458 phosphor::led::Layout::Action::Blink},
1459 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1460 phosphor::led::Layout::Action::On},
1461 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1462 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301463 };
1464 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1465 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301466
1467 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001468 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301469 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1470 refAssert.begin(), refAssert.end(),
1471 std::inserter(temp, temp.begin()));
1472 EXPECT_EQ(0, temp.size());
1473 }
1474 {
1475 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001476 ActionSet ledsAssert{};
1477 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301478
George Liu3d487512024-08-23 09:19:57 +08001479 static constexpr auto group =
1480 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001481 auto result =
1482 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301483 EXPECT_EQ(true, result);
1484
1485 // Need just the ledsAssserted populated with these.
1486 // [Two] gets to [ON] due to higher priority.
1487 // [Three] remains on since it never was in [Blink] before
1488 // [Ten] remains [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001489 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001490 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1491 phosphor::led::Layout::Action::On},
1492 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1493 phosphor::led::Layout::Action::On},
1494 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1495 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301496 };
1497 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1498 EXPECT_EQ(0, ledsDeAssert.size());
1499
1500 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001501 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301502 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1503 refAssert.begin(), refAssert.end(),
1504 std::inserter(temp, temp.begin()));
1505 EXPECT_EQ(0, temp.size());
1506 }
1507 {
1508 // De-Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001509 ActionSet ledsAssert{};
1510 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301511
George Liu3d487512024-08-23 09:19:57 +08001512 static constexpr auto group =
1513 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001514 auto result =
1515 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301516 EXPECT_EQ(false, result);
1517
1518 // Need just the ledsDeAsssert populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001519 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001520 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1521 phosphor::led::Layout::Action::On},
1522 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1523 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301524 };
1525 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1526
1527 // Need just the ledsAsssert populated with these.
1528 // [Ten] remains [Blink] since it did not move to [On]
1529 // [Three] remains [On] since it never changed state.
1530 // [Two] moves to [Blink] since there is no prior [On]
Patrick Williams158b2c12022-03-17 05:57:44 -05001531 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001532 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1533 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301534 };
1535 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1536
1537 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001538 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +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
1546/** @brief Assert 2 groups having multiple LEDs common in different state and
1547 * mixed priority.
1548 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001549TEST_F(LedTest,
1550 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301551{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001552 Manager manager(bus,
1553 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301554 {
1555 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001556 ActionSet ledsAssert{};
1557 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301558
George Liu3d487512024-08-23 09:19:57 +08001559 static constexpr auto group =
1560 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001561 auto result =
1562 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301563 EXPECT_EQ(true, result);
1564
1565 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001566 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001567 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1568 phosphor::led::Layout::Action::On},
1569 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1570 phosphor::led::Layout::Action::Blink},
1571 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1572 phosphor::led::Layout::Action::On},
1573 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1574 phosphor::led::Layout::Action::On},
1575 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1576 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301577 };
1578 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1579 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301580
1581 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001582 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301583 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1584 refAssert.begin(), refAssert.end(),
1585 std::inserter(temp, temp.begin()));
1586 EXPECT_EQ(0, temp.size());
1587 }
1588 {
1589 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001590 ActionSet ledsAssert{};
1591 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301592
George Liu3d487512024-08-23 09:19:57 +08001593 static constexpr auto group =
1594 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001595 auto result =
1596 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301597 EXPECT_EQ(true, result);
1598
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301599 // Need just the ledsAssserted populated with these.
1600 // [Two] remains [ON] due to higher priority.
1601 // [Three] remains on since it never was in [Blink] before
1602 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001603 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001604 {"One", phosphor::led::Layout::Action::On, 0, 0,
1605 phosphor::led::Layout::Action::On},
1606 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1607 phosphor::led::Layout::Action::On},
1608 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1609 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301610 };
1611 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1612 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301613
1614 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001615 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301616 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1617 refAssert.begin(), refAssert.end(),
1618 std::inserter(temp, temp.begin()));
1619 EXPECT_EQ(0, temp.size());
1620 }
1621}
1622
1623/** @brief Assert 2 groups having multiple LEDs common in different state and
1624 * mixed priority and De-Assert-A
1625 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001626TEST_F(
1627 LedTest,
1628 assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301629{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001630 Manager manager(bus,
1631 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301632 {
1633 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001634 ActionSet ledsAssert{};
1635 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301636
George Liu3d487512024-08-23 09:19:57 +08001637 static constexpr auto group =
1638 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001639 auto result =
1640 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301641 EXPECT_EQ(true, result);
1642
1643 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001644 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001645 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1646 phosphor::led::Layout::Action::On},
1647 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1648 phosphor::led::Layout::Action::Blink},
1649 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1650 phosphor::led::Layout::Action::On},
1651 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1652 phosphor::led::Layout::Action::On},
1653 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1654 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301655 };
1656 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1657 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301658
1659 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001660 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301661 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1662 refAssert.begin(), refAssert.end(),
1663 std::inserter(temp, temp.begin()));
1664 EXPECT_EQ(0, temp.size());
1665 }
1666 {
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301667 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001668 ActionSet ledsAssert{};
1669 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301670
George Liu3d487512024-08-23 09:19:57 +08001671 static constexpr auto group =
1672 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001673 auto result =
1674 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301675 EXPECT_EQ(true, result);
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301676
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301677 // Need just the ledsAssserted populated with these.
1678 // [Two] remains [ON] due to higher priority.
1679 // [Three] remains on since it never was in [Blink] before
1680 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001681 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001682 {"One", phosphor::led::Layout::Action::On, 0, 0,
1683 phosphor::led::Layout::Action::On},
1684 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1685 phosphor::led::Layout::Action::On},
1686 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1687 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301688 };
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301689 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1690 EXPECT_EQ(0, ledsDeAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301691
1692 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001693 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301694 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1695 refAssert.begin(), refAssert.end(),
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301696 std::inserter(temp, temp.begin()));
1697 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301698 }
1699 {
1700 // De-Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001701 ActionSet ledsAssert{};
1702 ActionSet ledsDeAssert{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301703
George Liu3d487512024-08-23 09:19:57 +08001704 static constexpr auto group =
1705 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001706 auto result =
1707 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301708 EXPECT_EQ(false, result);
1709
1710 // Need just the ledsAssserted populated with these.
1711 // [Ten] remains [Blink] due to priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001712 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001713 {"One", phosphor::led::Layout::Action::On, 0, 0,
1714 phosphor::led::Layout::Action::On},
1715 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1716 phosphor::led::Layout::Action::On},
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301717 };
1718 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1719
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301720 // Need just the ledsAssserted populated with these.
1721 // [Two] remains [ON] due to higher priority.
1722 // [Three] remains [On] since it never was in [Blink] before
1723 // [Ten] moves to [On] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001724 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001725 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1726 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301727 };
1728 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1729
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301730 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001731 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301732 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1733 refAssert.begin(), refAssert.end(),
1734 std::inserter(temp, temp.begin()));
1735 EXPECT_EQ(0, temp.size());
1736 }
1737}
1738
1739/** @brief Assert 2 groups having multiple LEDs common in different state and
1740 * mixed priority and then DeAssert twice.
1741 */
Patrick Venture91ac8d32018-11-01 17:03:22 -07001742TEST_F(LedTest,
1743 assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA)
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301744{
Patrick Venture91ac8d32018-11-01 17:03:22 -07001745 Manager manager(bus,
1746 twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301747 {
1748 // Assert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001749 ActionSet ledsAssert{};
1750 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301751
George Liu3d487512024-08-23 09:19:57 +08001752 static constexpr auto group =
1753 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001754 auto result =
1755 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301756 EXPECT_EQ(true, result);
1757
1758 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001759 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001760 {"Two", phosphor::led::Layout::Action::On, 0, 0,
1761 phosphor::led::Layout::Action::On},
1762 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1763 phosphor::led::Layout::Action::Blink},
1764 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1765 phosphor::led::Layout::Action::On},
1766 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1767 phosphor::led::Layout::Action::On},
1768 {"Ten", phosphor::led::Layout::Action::On, 0, 0,
1769 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301770 };
1771 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1772 EXPECT_EQ(0, ledsDeAssert.size());
1773
1774 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001775 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301776 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1777 refAssert.begin(), refAssert.end(),
1778 std::inserter(temp, temp.begin()));
1779 EXPECT_EQ(0, temp.size());
1780 }
1781 {
1782 // Assert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001783 ActionSet ledsAssert{};
1784 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301785
George Liu3d487512024-08-23 09:19:57 +08001786 static constexpr auto group =
1787 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001788 auto result =
1789 manager.setGroupState(group, true, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301790 EXPECT_EQ(true, result);
1791
1792 // Need just the ledsAssserted populated with these.
1793 // [Two] remains [ON] due to higher priority.
1794 // [Three] remains on since it never was in [Blink] before
1795 // [Ten] moves to [Blink] due to priority: [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001796 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001797 {"One", phosphor::led::Layout::Action::On, 0, 0,
1798 phosphor::led::Layout::Action::On},
1799 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1800 phosphor::led::Layout::Action::On},
1801 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1802 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301803 };
1804 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1805 EXPECT_EQ(0, ledsDeAssert.size());
1806
1807 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001808 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301809 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1810 refAssert.begin(), refAssert.end(),
1811 std::inserter(temp, temp.begin()));
1812 EXPECT_EQ(0, temp.size());
1813 }
1814 {
1815 // DeAssert Set-B
Patrick Williams158b2c12022-03-17 05:57:44 -05001816 ActionSet ledsAssert{};
1817 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301818
George Liu3d487512024-08-23 09:19:57 +08001819 static constexpr auto group =
1820 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001821 auto result =
1822 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301823 EXPECT_EQ(false, result);
1824
1825 // Need just the ledsAssserted populated with these.
1826 // [Ten] remains [Blink] due to priority.
Patrick Williams158b2c12022-03-17 05:57:44 -05001827 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001828 {"Five", phosphor::led::Layout::Action::On, 0, 0,
1829 phosphor::led::Layout::Action::On},
1830 {"Six", phosphor::led::Layout::Action::On, 0, 0,
1831 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301832 };
1833 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1834
1835 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001836 ActionSet temp{};
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301837 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1838 refDeAssert.begin(), refDeAssert.end(),
1839 std::inserter(temp, temp.begin()));
1840 EXPECT_EQ(0, temp.size());
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301841
1842 // Need just the ledsAssert populated with these.
1843 // [Two] will move to [Blink]
Patrick Williams158b2c12022-03-17 05:57:44 -05001844 ActionSet refAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001845 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1846 phosphor::led::Layout::Action::On},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301847 };
1848 EXPECT_EQ(refAssert.size(), ledsAssert.size());
1849
1850 // difference of refAssert and ledsAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001851 ActionSet temp1{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301852 std::set_difference(ledsAssert.begin(), ledsAssert.end(),
1853 refAssert.begin(), refAssert.end(),
1854 std::inserter(temp1, temp1.begin()));
1855 EXPECT_EQ(0, temp1.size());
1856 }
1857 {
1858 // DeAssert Set-A
Patrick Williams158b2c12022-03-17 05:57:44 -05001859 ActionSet ledsAssert{};
1860 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301861
George Liu3d487512024-08-23 09:19:57 +08001862 static constexpr auto group =
1863 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001864 auto result =
1865 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301866 EXPECT_EQ(false, result);
1867
1868 // Need just the ledsAssserted populated with these.
Patrick Williams158b2c12022-03-17 05:57:44 -05001869 ActionSet refDeAssert = {
Patrick Williamsed80e882022-03-17 05:03:51 -05001870 {"One", phosphor::led::Layout::Action::On, 0, 0,
1871 phosphor::led::Layout::Action::On},
1872 {"Two", phosphor::led::Layout::Action::Blink, 0, 0,
1873 phosphor::led::Layout::Action::On},
1874 {"Three", phosphor::led::Layout::Action::On, 0, 0,
1875 phosphor::led::Layout::Action::Blink},
1876 {"Four", phosphor::led::Layout::Action::On, 0, 0,
1877 phosphor::led::Layout::Action::On},
1878 {"Ten", phosphor::led::Layout::Action::Blink, 0, 0,
1879 phosphor::led::Layout::Action::Blink},
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301880 };
1881 EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
1882 EXPECT_EQ(0, ledsAssert.size());
1883
1884 // difference of refDeAssert and ledsDeAssert must be null.
Patrick Williams158b2c12022-03-17 05:57:44 -05001885 ActionSet temp{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301886 std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
1887 refDeAssert.begin(), refDeAssert.end(),
1888 std::inserter(temp, temp.begin()));
1889 EXPECT_EQ(0, temp.size());
1890 }
1891 {
1892 // DeAssert Set-B again and make sure we get all empty
Patrick Williams158b2c12022-03-17 05:57:44 -05001893 ActionSet ledsAssert{};
1894 ActionSet ledsDeAssert{};
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301895
George Liu3d487512024-08-23 09:19:57 +08001896 static constexpr auto group =
1897 "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
Patrick Williams543ac9f2024-08-16 15:19:59 -04001898 auto result =
1899 manager.setGroupState(group, false, ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05301900 EXPECT_EQ(false, result);
1901 EXPECT_EQ(0, ledsDeAssert.size());
1902 EXPECT_EQ(0, ledsAssert.size());
Vishwanatha Subbannacd569d22017-05-03 12:46:14 +05301903 }
1904}