LEDS: Provide support to override the default Blink priority
In some cases, it is needed that the Solid-ON action over rules
Blink and this patch adds that support.
Change-Id: Ib0a88b11142ccef3e39ef0a7c6eb3a037c878bc2
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/test/utest.cpp b/test/utest.cpp
index 19c54a2..ea08ea0 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -27,20 +27,19 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -59,20 +58,19 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::Blink},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -91,20 +89,19 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -117,16 +114,14 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
EXPECT_EQ(0, ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
}
}
@@ -138,22 +133,23 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -172,22 +168,23 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::Blink},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -206,22 +203,23 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::Blink},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -234,22 +232,23 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, false, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(false, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refDeAssert = {
- {"One",phosphor::led::Layout::Blink},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
EXPECT_EQ(0, ledsAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refDeAssert and ledsDeAssert must be null.
Manager::group temp {};
@@ -268,22 +267,23 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::Blink},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -296,22 +296,23 @@
// DeAssert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, false, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(false, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refDeAssert = {
- {"One",phosphor::led::Layout::Blink},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
EXPECT_EQ(0, ledsAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refDeAssert and ledsDeAssert must be null.
Manager::group temp {};
@@ -324,15 +325,13 @@
// DeAssert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds";
auto result = manager.setGroupState(group, false, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(false, result);
EXPECT_EQ(0, ledsDeAssert.size());
EXPECT_EQ(0, ledsAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
}
}
@@ -344,24 +343,27 @@
// Assert the LEDs.
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::Blink},
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::Blink},
- {"Four",phosphor::led::Layout::On},
- {"Five",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::On,
+ 0, phosphor::led::Layout::Blink},
+ {"Three",phosphor::led::Layout::Blink,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On,
+ 0, phosphor::led::Layout::Blink},
+ {"Five",phosphor::led::Layout::On,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -380,22 +382,23 @@
// Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -408,22 +411,23 @@
// Assert Set-B
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"Four",phosphor::led::Layout::On},
- {"Five",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -442,22 +446,23 @@
// Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -470,21 +475,21 @@
// Assert Set-B
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"Four",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -495,30 +500,32 @@
}
}
-/** @brief Assert 2 groups having one of the LEDs common in different state */
-TEST_F(LedTest, assertTwoGroupsWithOneComonLEDInDifferentState)
+/** @brief Assert 2 groups having one of the LEDs common but having Blink as
+ * priority and Deassert*/
+TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB)
{
- Manager manager(bus, twoGroupsWithOneComonLEDInDifferentState);
+ Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
{
// Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -531,23 +538,86 @@
// Assert Set-B
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // Does not action on [Three] since priority is [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // De-Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+ EXPECT_EQ(0, ledsAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ // [Three] is not touched since its already [Blink]
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+}
+
+/** @brief Assert 2 groups having one of the LEDs common but having Blink as
+ * priority and Deassert A */
+TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertA)
+{
+ Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority);
+ {
+ // Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"Two",phosphor::led::Layout::Blink},
- {"Four",phosphor::led::Layout::On},
- {"Five",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -556,33 +626,302 @@
std::inserter(temp, temp.begin()));
EXPECT_EQ(0, temp.size());
}
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // [Three] does not get actioned since it has Blink priority
+ std::set<Layout::LedAction> refAssert = {
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // De-Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+
+ // Need just the ledsAssert populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp1 {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp1, temp1.begin()));
+ EXPECT_EQ(0, temp1.size());
+ }
+}
+
+/** @brief Assert 2 groups having one of the LEDs common but having ON as
+ * priority And Deassert A */
+TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertA)
+{
+ Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
+ {
+ // Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, true,
+ ledsAssert, ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // Three is set to ON due to ON priority.
+ std::set<Layout::LedAction> refAssert = {
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ }
+ {
+ // De-Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAssserted populated with these.
+ // [Three] stays in [On] since [B] has it [On]
+ std::set<Layout::LedAction> refDeAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+ EXPECT_EQ(0, ledsAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+}
+
+/** @brief Assert 2 groups having one of the LEDs common but having ON as
+ * priority And Deassert B */
+TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDOnPriorityAndDeAssertB)
+{
+ Manager manager(bus, twoGroupsWithOneComonLEDOnPriority);
+ {
+ // Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // Three is set to ON due to ON priority.
+ std::set<Layout::LedAction> refAssert = {
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ }
+ {
+ // De-Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+
+ // Need just the ledsAssert populated with these.
+ // Since [Three] stood [On], need to go back to [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp1 {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
}
/** @brief Assert 2 groups having multiple common LEDs in Same State */
-TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOn)
+TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert)
{
Manager manager(bus, twoGroupsWithMultiplComonLEDOn);
{
// Assert Set-B
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"Two",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::On},
- {"Seven",phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Seven",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -595,20 +934,113 @@
// Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // De-Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Seven",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+ EXPECT_EQ(0, ledsAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+
+ }
+}
+
+/** @brief Assert 2 groups having multiple LEDs common in different state */
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateBandA)
+{
+ Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these
+ // [Two] remains [On] due to higher priority.
+ // [Three] remains [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -620,96 +1052,33 @@
}
/** @brief Assert 2 groups having multiple LEDs common in different state */
-TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStates)
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB)
{
Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
{
// Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
- EXPECT_EQ(true, result);
-
- // Need just the ledsAssserted populated with these.
- std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::On},
- {"Four",phosphor::led::Layout::On},
- };
- EXPECT_EQ(refAssert.size(), ledsAssert.size());
- EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
-
- // difference of refAssert and ledsAssert must be null.
- Manager::group temp {};
- std::set_difference(ledsAssert.begin(), ledsAssert.end(),
- refAssert.begin(), refAssert.end(),
- std::inserter(temp, temp.begin()));
- EXPECT_EQ(0, temp.size());
- }
- {
- // Assert Set-B
- Manager::group ledsAssert {};
- Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
-
- auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
- auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.'Two' gets to Blink
// due to higher priority.
std::set<Layout::LedAction> refAssert = {
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
- {"Five",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
-
- // difference of refAssert and ledsAssert must be null.
- Manager::group temp {};
- std::set_difference(ledsAssert.begin(), ledsAssert.end(),
- refAssert.begin(), refAssert.end(),
- std::inserter(temp, temp.begin()));
- EXPECT_EQ(0, temp.size());
- }
-}
-
-/** @brief Assert 2 groups having multiple LEDs common in Same State
- * and then De-Assert One
- */
-TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDAndDeAssertOne)
-{
- Manager manager(bus, twoGroupsWithMultiplComonLEDOn);
- {
- // Assert Set-A
- Manager::group ledsAssert {};
- Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
-
- auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
- auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
- EXPECT_EQ(true, result);
-
- // Need just the ledsAssserted populated with these.
- std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::On},
- };
- EXPECT_EQ(refAssert.size(), ledsAssert.size());
- EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -722,21 +1091,25 @@
// Assert Set-B
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
+ // [Three] remains [Blink] from previous
+ // [Two] moves to [On] from [Blink] due to [On] priority
std::set<Layout::LedAction> refAssert = {
- {"Six",phosphor::led::Layout::On},
- {"Seven",phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -745,60 +1118,37 @@
std::inserter(temp, temp.begin()));
EXPECT_EQ(0, temp.size());
}
- {
- // DeAssert Set-A
- Manager::group ledsAssert {};
- Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
-
- auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
- auto result = manager.setGroupState(group, false, ledsAssert,
- ledsDeAssert, ledsUpdate);
- EXPECT_EQ(false, result);
-
- // Need just the ledsAssserted populated with these.
- std::set<Layout::LedAction> refDeAssert = {
- {"One",phosphor::led::Layout::On},
- };
- EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
- EXPECT_EQ(0, ledsAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
-
- // difference of refAssert and ledsAssert must be null.
- Manager::group temp {};
- std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
- refDeAssert.begin(), refDeAssert.end(),
- std::inserter(temp, temp.begin()));
- EXPECT_EQ(0, temp.size());
- }
}
-/** @brief Assert 2 groups having multiple LEDs common but in
- * different state and De-Assert one*/
-TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateDeAssertOne)
+/** @brief Assert 2 groups having multiple LEDs common in different state
+ * DeAssert twice
+ */
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice)
{
Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState);
{
- // Assert Set-B
+ // Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
- auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::Blink},
- {"Five",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -808,27 +1158,28 @@
EXPECT_EQ(0, temp.size());
}
{
- // Assert Set-A
+ // Assert Set-B
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
- auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
- // Need just the ledsAssserted populated with these. 'Three` remains at
- // Blink due to increased priority.
+ // Need just the ledsAssserted populated with these.
+ // [Two] turns [On] due to priority
+ // [Three] remains [Blink]
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
- {"Four",phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -838,75 +1189,340 @@
EXPECT_EQ(0, temp.size());
}
{
+ // DeAssert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+
+ // Need just the ledsAssert populated with these.
+ // [Two] will go back to [Blink] from [On]
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp1 {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp1, temp1.begin()));
+ EXPECT_EQ(0, temp1.size());
+ }
+ {
// DeAssert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, false, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(false, result);
- // Need just the ledsUpdated populated with these.
- std::set<Layout::LedAction> refUpdate = {
- {"Two",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::Blink},
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
- EXPECT_EQ(refUpdate.size(), ledsUpdate.size());
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
EXPECT_EQ(0, ledsAssert.size());
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // DeAssert Set-A again and make sure we get all empty
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+ EXPECT_EQ(0, ledsDeAssert.size());
+ EXPECT_EQ(0, ledsAssert.size());
+ }
+}
+
+/** @brief Assert 2 groups having multiple LEDs common in different state and
+ * mixed priority. DeAssert-A
+ */
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB)
+{
+ Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
+ {
+ // Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
- std::set_difference(ledsUpdate.begin(), ledsUpdate.end(),
- refUpdate.begin(), refUpdate.end(),
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
std::inserter(temp, temp.begin()));
EXPECT_EQ(0, temp.size());
+ }
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
- // Need just the ledsDeAsserted populated with these.
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // [Two] gets to [ON] due to higher priority.
+ // [Three] remains on since it never was in [Blink] before
+ // [Ten] remains [Blink] due to priority: [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // De-Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAsssert populated with these.
std::set<Layout::LedAction> refDeAssert = {
- {"One",phosphor::led::Layout::On},
- {"Four",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+ // Need just the ledsAsssert populated with these.
+ // [Ten] Moves to [On] since there is no prior [Blink]
+ // [Three] remains [On] since it never changed state.
+ // [Two] remains [On] since it did not go back
+ std::set<Layout::LedAction> refAssert = {
+ {"Ten",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
// difference of refAssert and ledsAssert must be null.
- temp.clear();
- std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
- refDeAssert.begin(), refDeAssert.end(),
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
std::inserter(temp, temp.begin()));
EXPECT_EQ(0, temp.size());
}
}
-/** @brief Assert 2 groups having multiple LEDs common but in
- * different state and De-Assert one and make sure the
- * state is changed back to Blink
+/** @brief Assert 2 groups having multiple LEDs common in different state and
+ * mixed priority. DeAssert-B
*/
-TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateDeAssertOneGetBlink)
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB)
{
- Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentStateBlinkAgain);
+ Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
{
- // Assert Set-B
+ // Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
- auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
// Need just the ledsAssserted populated with these.
std::set<Layout::LedAction> refAssert = {
- {"Two",phosphor::led::Layout::Blink},
- {"Three",phosphor::led::Layout::Blink},
- {"Five",phosphor::led::Layout::On},
- {"Six",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // [Two] gets to [ON] due to higher priority.
+ // [Three] remains on since it never was in [Blink] before
+ // [Ten] remains [Blink] due to priority: [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // De-Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsDeAsssert populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+
+ // Need just the ledsAsssert populated with these.
+ // [Ten] remains [Blink] since it did not move to [On]
+ // [Three] remains [On] since it never changed state.
+ // [Two] moves to [Blink] since there is no prior [On]
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+}
+
+/** @brief Assert 2 groups having multiple LEDs common in different state and
+ * mixed priority.
+ */
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA)
+{
+ Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -919,24 +1535,67 @@
// Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
auto result = manager.setGroupState(group, true, ledsAssert,
- ledsDeAssert, ledsUpdate);
+ ledsDeAssert);
EXPECT_EQ(true, result);
- // Need just the ledsAssserted populated with these. 'Three` remains at
- // Blink due to increased priority. Two is already in asserted state and
- // it wont be asserted again.
+ // Need just the ledsAssserted populated with these.
+ // [Two] remains [ON] due to higher priority.
+ // [Three] remains on since it never was in [Blink] before
+ // [Ten] moves to [Blink] due to priority: [Blink]
std::set<Layout::LedAction> refAssert = {
- {"One",phosphor::led::Layout::On},
- {"Three",phosphor::led::Layout::Blink},
- {"Four",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
EXPECT_EQ(refAssert.size(), ledsAssert.size());
EXPECT_EQ(0, ledsDeAssert.size());
- EXPECT_EQ(0, ledsUpdate.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+}
+
+/** @brief Assert 2 groups having multiple LEDs common in different state and
+ * mixed priority and De-Assert-A
+ */
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA)
+{
+ Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
@@ -946,42 +1605,232 @@
EXPECT_EQ(0, temp.size());
}
{
- // DeAssert Set-A
+ // Assert Set-A
Manager::group ledsAssert {};
Manager::group ledsDeAssert {};
- Manager::group ledsUpdate {};
auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
- auto result = manager.setGroupState(group, false, ledsAssert,
- ledsDeAssert, ledsUpdate);
- EXPECT_EQ(false, result);
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
- // Need just the ledsUpdated populated with these.
- std::set<Layout::LedAction> refUpdate = {
- {"Three",phosphor::led::Layout::Blink},
+ // Need just the ledsAssserted populated with these.
+ // [Two] remains [ON] due to higher priority.
+ // [Three] remains on since it never was in [Blink] before
+ // [Ten] moves to [Blink] due to priority: [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
};
- EXPECT_EQ(refUpdate.size(), ledsUpdate.size());
- EXPECT_EQ(0, ledsAssert.size());
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
// difference of refAssert and ledsAssert must be null.
Manager::group temp {};
- std::set_difference(ledsUpdate.begin(), ledsUpdate.end(),
- refUpdate.begin(), refUpdate.end(),
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
std::inserter(temp, temp.begin()));
EXPECT_EQ(0, temp.size());
+ }
+ {
+ // De-Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
- // Need just the ledsDeAsserted populated with these.
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsAssserted populated with these.
+ // [Ten] remains [Blink] due to priority.
std::set<Layout::LedAction> refDeAssert = {
- {"One",phosphor::led::Layout::On},
- {"Four",phosphor::led::Layout::On},
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
};
EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+ // Need just the ledsAssserted populated with these.
+ // [Two] remains [ON] due to higher priority.
+ // [Three] remains [On] since it never was in [Blink] before
+ // [Ten] moves to [On] due to priority: [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"Ten",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
// difference of refAssert and ledsAssert must be null.
- temp.clear();
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+}
+
+/** @brief Assert 2 groups having multiple LEDs common in different state and
+ * mixed priority and then DeAssert twice.
+ */
+TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA)
+{
+ Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority);
+ {
+ // Assert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // Assert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, true, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(true, result);
+
+ // Need just the ledsAssserted populated with these.
+ // [Two] remains [ON] due to higher priority.
+ // [Three] remains on since it never was in [Blink] before
+ // [Ten] moves to [Blink] due to priority: [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+ EXPECT_EQ(0, ledsDeAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // DeAssert Set-B
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsAssserted populated with these.
+ // [Ten] remains [Blink] due to priority.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"Five",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Six",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
refDeAssert.begin(), refDeAssert.end(),
std::inserter(temp, temp.begin()));
EXPECT_EQ(0, temp.size());
+
+ // Need just the ledsAssert populated with these.
+ // [Two] will move to [Blink]
+ std::set<Layout::LedAction> refAssert = {
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ };
+ EXPECT_EQ(refAssert.size(), ledsAssert.size());
+
+ // difference of refAssert and ledsAssert must be null.
+ Manager::group temp1 {};
+ std::set_difference(ledsAssert.begin(), ledsAssert.end(),
+ refAssert.begin(), refAssert.end(),
+ std::inserter(temp1, temp1.begin()));
+ EXPECT_EQ(0, temp1.size());
+ }
+ {
+ // DeAssert Set-A
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+
+ // Need just the ledsAssserted populated with these.
+ std::set<Layout::LedAction> refDeAssert = {
+ {"One",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Two",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::On},
+ {"Three",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::Blink},
+ {"Four",phosphor::led::Layout::On, 0,
+ 0, phosphor::led::Layout::On},
+ {"Ten",phosphor::led::Layout::Blink, 0,
+ 0, phosphor::led::Layout::Blink},
+ };
+ EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size());
+ EXPECT_EQ(0, ledsAssert.size());
+
+ // difference of refDeAssert and ledsDeAssert must be null.
+ Manager::group temp {};
+ std::set_difference(ledsDeAssert.begin(), ledsDeAssert.end(),
+ refDeAssert.begin(), refDeAssert.end(),
+ std::inserter(temp, temp.begin()));
+ EXPECT_EQ(0, temp.size());
+ }
+ {
+ // DeAssert Set-B again and make sure we get all empty
+ Manager::group ledsAssert {};
+ Manager::group ledsDeAssert {};
+
+ auto group ="/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet";
+ auto result = manager.setGroupState(group, false, ledsAssert,
+ ledsDeAssert);
+ EXPECT_EQ(false, result);
+ EXPECT_EQ(0, ledsDeAssert.size());
+ EXPECT_EQ(0, ledsAssert.size());
}
}