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