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