Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1 | #include "led-test-map.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 2 | #include "manager.hpp" |
| 3 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
George Liu | a6c18f8 | 2020-06-22 10:50:04 +0800 | [diff] [blame] | 5 | |
| 6 | #include <algorithm> |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 7 | #include <set> |
| 8 | |
| 9 | #include <gtest/gtest.h> |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 10 | using namespace phosphor::led; |
| 11 | class LedTest : public ::testing::Test |
| 12 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 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 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | /** @brief Assert Single LED to On */ |
| 26 | TEST_F(LedTest, assertSingleLedOn) |
| 27 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 28 | Manager manager(bus, singleLedOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 29 | { |
| 30 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 31 | Manager::group ledsAssert{}; |
| 32 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 33 | |
| 34 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 35 | auto result = |
| 36 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 37 | EXPECT_EQ(true, result); |
| 38 | |
| 39 | // Need just the ledsAssserted populated with these. |
| 40 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 41 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 42 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 43 | }; |
| 44 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 45 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 46 | |
| 47 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 48 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 59 | Manager manager(bus, singleLedBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 60 | { |
| 61 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 62 | Manager::group ledsAssert{}; |
| 63 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 64 | |
| 65 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 66 | auto result = |
| 67 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 68 | EXPECT_EQ(true, result); |
| 69 | |
| 70 | // Need just the ledsAssserted populated with these. |
| 71 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 72 | {"One", phosphor::led::Layout::Action::Blink, 0, 0, |
| 73 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 74 | }; |
| 75 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 76 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 77 | |
| 78 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 79 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 90 | Manager manager(bus, singleLedOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 91 | { |
| 92 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 93 | Manager::group ledsAssert{}; |
| 94 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 95 | |
| 96 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 97 | auto result = |
| 98 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 99 | EXPECT_EQ(true, result); |
| 100 | |
| 101 | // Need just the ledsAssserted populated with these. |
| 102 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 103 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 104 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 105 | }; |
| 106 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 107 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 108 | |
| 109 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 110 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 118 | Manager::group ledsAssert{}; |
| 119 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 120 | |
| 121 | auto group = "/xyz/openbmc_project/ledmanager/groups/SingleLed"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 122 | auto result = |
| 123 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 124 | EXPECT_EQ(true, result); |
| 125 | |
| 126 | EXPECT_EQ(0, ledsAssert.size()); |
| 127 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
| 131 | /** @brief Assert Multiple LEDs to On */ |
| 132 | TEST_F(LedTest, assertMultipleLedOn) |
| 133 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 134 | Manager manager(bus, multipleLedsOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 135 | { |
| 136 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 137 | Manager::group ledsAssert{}; |
| 138 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 139 | |
| 140 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 141 | auto result = |
| 142 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 143 | EXPECT_EQ(true, result); |
| 144 | |
| 145 | // Need just the ledsAssserted populated with these. |
| 146 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 153 | }; |
| 154 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 155 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 156 | |
| 157 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 158 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 169 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 170 | { |
| 171 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 172 | Manager::group ledsAssert{}; |
| 173 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 174 | |
| 175 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 176 | auto result = |
| 177 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 178 | EXPECT_EQ(true, result); |
| 179 | |
| 180 | // Need just the ledsAssserted populated with these. |
| 181 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 188 | }; |
| 189 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 190 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 191 | |
| 192 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 193 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 204 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 205 | { |
| 206 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 207 | Manager::group ledsAssert{}; |
| 208 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 209 | |
| 210 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 211 | auto result = |
| 212 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 213 | EXPECT_EQ(true, result); |
| 214 | |
| 215 | // Need just the ledsAssserted populated with these. |
| 216 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 223 | }; |
| 224 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 225 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 226 | |
| 227 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 228 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 236 | Manager::group ledsAssert{}; |
| 237 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 238 | |
| 239 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 240 | auto result = |
| 241 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 242 | EXPECT_EQ(false, result); |
| 243 | |
| 244 | // Need just the ledsAssserted populated with these. |
| 245 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 252 | }; |
| 253 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 254 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 255 | |
| 256 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 257 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 268 | Manager manager(bus, multipleLedsBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 269 | { |
| 270 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 271 | Manager::group ledsAssert{}; |
| 272 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 273 | |
| 274 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 275 | auto result = |
| 276 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 277 | EXPECT_EQ(true, result); |
| 278 | |
| 279 | // Need just the ledsAssserted populated with these. |
| 280 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 287 | }; |
| 288 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 289 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 290 | |
| 291 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 292 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 300 | Manager::group ledsAssert{}; |
| 301 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 302 | |
| 303 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 304 | auto result = |
| 305 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 306 | EXPECT_EQ(false, result); |
| 307 | |
| 308 | // Need just the ledsAssserted populated with these. |
| 309 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 316 | }; |
| 317 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 318 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 319 | |
| 320 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 321 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 329 | Manager::group ledsAssert{}; |
| 330 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 331 | |
| 332 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLeds"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 333 | auto result = |
| 334 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 335 | EXPECT_EQ(false, result); |
| 336 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 337 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | |
| 341 | /** @brief Assert Multiple LEDs to mix of On and Blink */ |
| 342 | TEST_F(LedTest, assertMultipleLedOnAndBlink) |
| 343 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 344 | Manager manager(bus, multipleLedsOnAndBlink); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 345 | { |
| 346 | // Assert the LEDs. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 347 | Manager::group ledsAssert{}; |
| 348 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 349 | |
| 350 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsMix"; |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 351 | auto result = |
| 352 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 353 | EXPECT_EQ(true, result); |
| 354 | |
| 355 | // Need just the ledsAssserted populated with these. |
| 356 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 367 | }; |
| 368 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 369 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 370 | |
| 371 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 372 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 383 | Manager manager(bus, twoGroupsWithDistinctLEDsOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 384 | { |
| 385 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 386 | Manager::group ledsAssert{}; |
| 387 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 388 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 389 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 390 | auto result = |
| 391 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 392 | EXPECT_EQ(true, result); |
| 393 | |
| 394 | // Need just the ledsAssserted populated with these. |
| 395 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 402 | }; |
| 403 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 404 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 405 | |
| 406 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 407 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 415 | Manager::group ledsAssert{}; |
| 416 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 417 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 418 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 419 | auto result = |
| 420 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 421 | EXPECT_EQ(true, result); |
| 422 | |
| 423 | // Need just the ledsAssserted populated with these. |
| 424 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 431 | }; |
| 432 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 433 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 434 | |
| 435 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 436 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 447 | Manager manager(bus, twoGroupsWithOneComonLEDOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 448 | { |
| 449 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 450 | Manager::group ledsAssert{}; |
| 451 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 452 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 453 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 454 | auto result = |
| 455 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 456 | EXPECT_EQ(true, result); |
| 457 | |
| 458 | // Need just the ledsAssserted populated with these. |
| 459 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 466 | }; |
| 467 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 468 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 469 | |
| 470 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 471 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 479 | Manager::group ledsAssert{}; |
| 480 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 481 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 482 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 483 | auto result = |
| 484 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 485 | EXPECT_EQ(true, result); |
| 486 | |
| 487 | // Need just the ledsAssserted populated with these. |
| 488 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 493 | }; |
| 494 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 495 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 496 | |
| 497 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 498 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 506 | /** @brief Assert 2 groups having one of the LEDs common but having Blink as |
| 507 | * priority and Deassert*/ |
| 508 | TEST_F(LedTest, asserttwoGroupsWithOneComonLEDOnOneLEDBlinkPriorityAndDeAssertB) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 509 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 510 | Manager manager(bus, twoGroupsWithOneComonLEDOnOneLEDBlinkPriority); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 511 | { |
| 512 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 513 | Manager::group ledsAssert{}; |
| 514 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 515 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 516 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 517 | auto result = |
| 518 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 519 | EXPECT_EQ(true, result); |
| 520 | |
| 521 | // Need just the ledsAssserted populated with these. |
| 522 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 529 | }; |
| 530 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 531 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 532 | |
| 533 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 534 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 542 | Manager::group ledsAssert{}; |
| 543 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 544 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 545 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 546 | auto result = |
| 547 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 557 | }; |
| 558 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 559 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 560 | |
| 561 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 562 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 570 | Manager::group ledsAssert{}; |
| 571 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 572 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 573 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 574 | auto result = |
| 575 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 576 | EXPECT_EQ(false, result); |
| 577 | |
| 578 | // Need just the ledsDeAssserted populated with these. |
| 579 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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] |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 590 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 605 | Manager::group ledsAssert{}; |
| 606 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 607 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 608 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 609 | auto result = |
| 610 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 611 | EXPECT_EQ(true, result); |
| 612 | |
| 613 | // Need just the ledsAssserted populated with these. |
| 614 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 621 | }; |
| 622 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 623 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 624 | |
| 625 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 626 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | } |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 632 | { |
| 633 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 634 | Manager::group ledsAssert{}; |
| 635 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 636 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 637 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 638 | auto result = |
| 639 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 649 | }; |
| 650 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 651 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 652 | |
| 653 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 654 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 662 | Manager::group ledsAssert{}; |
| 663 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 664 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 665 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 666 | auto result = |
| 667 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 668 | EXPECT_EQ(false, result); |
| 669 | |
| 670 | // Need just the ledsDeAssserted populated with these. |
| 671 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 676 | }; |
| 677 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 678 | |
| 679 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 680 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 688 | {"Three", phosphor::led::Layout::Action::On, 0, 0, |
| 689 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 690 | }; |
| 691 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 692 | |
| 693 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 694 | Manager::group temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 709 | Manager::group ledsAssert{}; |
| 710 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 711 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 712 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 713 | auto result = |
| 714 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 715 | EXPECT_EQ(true, result); |
| 716 | |
| 717 | // Need just the ledsAssserted populated with these. |
| 718 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 725 | }; |
| 726 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 727 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 728 | |
| 729 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 730 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 738 | Manager::group ledsAssert{}; |
| 739 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 740 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 741 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 742 | auto result = |
| 743 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 755 | }; |
| 756 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 757 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 758 | |
| 759 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 760 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 767 | Manager::group ledsAssert{}; |
| 768 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 769 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 770 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 771 | auto result = |
| 772 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 782 | }; |
| 783 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 784 | EXPECT_EQ(0, ledsAssert.size()); |
| 785 | |
| 786 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 787 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 802 | Manager::group ledsAssert{}; |
| 803 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 804 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 805 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 806 | auto result = |
| 807 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 808 | EXPECT_EQ(true, result); |
| 809 | |
| 810 | // Need just the ledsAssserted populated with these. |
| 811 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 818 | }; |
| 819 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 820 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 821 | |
| 822 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 823 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 831 | Manager::group ledsAssert{}; |
| 832 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 833 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 834 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 835 | auto result = |
| 836 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 848 | }; |
| 849 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 850 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 851 | |
| 852 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 853 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 860 | Manager::group ledsAssert{}; |
| 861 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 862 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 863 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 864 | auto result = |
| 865 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 866 | EXPECT_EQ(false, result); |
| 867 | |
| 868 | // Need just the ledsDeAssserted populated with these. |
| 869 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 874 | }; |
| 875 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 876 | |
| 877 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 878 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 887 | {"Three", phosphor::led::Layout::Action::Blink, 0, 0, |
| 888 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 889 | }; |
| 890 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 891 | |
| 892 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 893 | Manager::group temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | /** @brief Assert 2 groups having multiple common LEDs in Same State */ |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 902 | TEST_F(LedTest, assertTwoGroupsWithMultiplComonLEDOnAndDeAssert) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 903 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 904 | Manager manager(bus, twoGroupsWithMultiplComonLEDOn); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 905 | { |
| 906 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 907 | Manager::group ledsAssert{}; |
| 908 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 909 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 910 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 911 | auto result = |
| 912 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 913 | EXPECT_EQ(true, result); |
| 914 | |
| 915 | // Need just the ledsAssserted populated with these. |
| 916 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 925 | }; |
| 926 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 927 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 928 | |
| 929 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 930 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 938 | Manager::group ledsAssert{}; |
| 939 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 940 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 941 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 942 | auto result = |
| 943 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 944 | EXPECT_EQ(true, result); |
| 945 | |
| 946 | // Need just the ledsAssserted populated with these. |
| 947 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 948 | {"One", phosphor::led::Layout::Action::On, 0, 0, |
| 949 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 950 | }; |
| 951 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 952 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 953 | |
| 954 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 955 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 963 | Manager::group ledsAssert{}; |
| 964 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 965 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 966 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 967 | auto result = |
| 968 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 969 | EXPECT_EQ(false, result); |
| 970 | |
| 971 | // Need just the ledsDeAssserted populated with these. |
| 972 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 977 | }; |
| 978 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 979 | EXPECT_EQ(0, ledsAssert.size()); |
| 980 | |
| 981 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 982 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 996 | Manager::group ledsAssert{}; |
| 997 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 998 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 999 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1000 | auto result = |
| 1001 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1002 | EXPECT_EQ(true, result); |
| 1003 | |
| 1004 | // Need just the ledsAssserted populated with these. |
| 1005 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1014 | }; |
| 1015 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1016 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1017 | |
| 1018 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1019 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1027 | Manager::group ledsAssert{}; |
| 1028 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1029 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1030 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1031 | auto result = |
| 1032 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1043 | }; |
| 1044 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1045 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1046 | |
| 1047 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1048 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 */ |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1057 | TEST_F(LedTest, assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoB) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1058 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 1059 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1060 | { |
| 1061 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1062 | Manager::group ledsAssert{}; |
| 1063 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1064 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1065 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1066 | auto result = |
| 1067 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1068 | EXPECT_EQ(true, result); |
| 1069 | |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1070 | // Need just the ledsAssserted populated with these.'Two' gets to Blink |
| 1071 | // due to higher priority. |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1072 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1081 | }; |
| 1082 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1083 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1084 | |
| 1085 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1086 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1094 | Manager::group ledsAssert{}; |
| 1095 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1096 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1097 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1098 | auto result = |
| 1099 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1100 | EXPECT_EQ(true, result); |
| 1101 | |
| 1102 | // Need just the ledsAssserted populated with these. |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1103 | // [Three] remains [Blink] from previous |
| 1104 | // [Two] moves to [On] from [Blink] due to [On] priority |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1105 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1112 | }; |
| 1113 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1114 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1115 | |
| 1116 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1117 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1123 | } |
| 1124 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1125 | /** @brief Assert 2 groups having multiple LEDs common in different state |
| 1126 | * DeAssert twice |
| 1127 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1128 | TEST_F(LedTest, |
| 1129 | assertTwoGroupsWithMultipleComonLEDInDifferentStateAtoBDeAssertTwice) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1130 | { |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 1131 | Manager manager(bus, twoGroupsWithMultipleComonLEDInDifferentState); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1132 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1133 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1134 | Manager::group ledsAssert{}; |
| 1135 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1136 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1137 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1138 | auto result = |
| 1139 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1140 | EXPECT_EQ(true, result); |
| 1141 | |
| 1142 | // Need just the ledsAssserted populated with these. |
| 1143 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1152 | }; |
| 1153 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1154 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1155 | |
| 1156 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1157 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1164 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1165 | Manager::group ledsAssert{}; |
| 1166 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1167 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1168 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1169 | auto result = |
| 1170 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1171 | EXPECT_EQ(true, result); |
| 1172 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1173 | // Need just the ledsAssserted populated with these. |
| 1174 | // [Two] turns [On] due to priority |
| 1175 | // [Three] remains [Blink] |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1176 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1183 | }; |
| 1184 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1185 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1186 | |
| 1187 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1188 | Manager::group temp{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1195 | // DeAssert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1196 | Manager::group ledsAssert{}; |
| 1197 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1198 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1199 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1200 | auto result = |
| 1201 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1202 | EXPECT_EQ(false, result); |
| 1203 | |
| 1204 | // Need just the ledsAssserted populated with these. |
| 1205 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1210 | }; |
| 1211 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1212 | |
| 1213 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1214 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 1223 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1224 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1225 | }; |
| 1226 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1227 | |
| 1228 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1229 | Manager::group temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1236 | // DeAssert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1237 | Manager::group ledsAssert{}; |
| 1238 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1239 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1240 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1241 | auto result = |
| 1242 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1243 | EXPECT_EQ(false, result); |
| 1244 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1245 | // Need just the ledsAssserted populated with these. |
| 1246 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1255 | }; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1256 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1257 | EXPECT_EQ(0, ledsAssert.size()); |
| 1258 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1259 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1260 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1268 | Manager::group ledsAssert{}; |
| 1269 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1270 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1271 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1272 | auto result = |
| 1273 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1283 | TEST_F(LedTest, |
| 1284 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandB) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1285 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1286 | Manager manager(bus, |
| 1287 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1288 | { |
| 1289 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1290 | Manager::group ledsAssert{}; |
| 1291 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1292 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1293 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1294 | auto result = |
| 1295 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1296 | EXPECT_EQ(true, result); |
| 1297 | |
| 1298 | // Need just the ledsAssserted populated with these. |
| 1299 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1310 | }; |
| 1311 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1312 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1313 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1314 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1315 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1316 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1317 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1318 | std::inserter(temp, temp.begin())); |
| 1319 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1320 | } |
| 1321 | { |
| 1322 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1323 | Manager::group ledsAssert{}; |
| 1324 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1325 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1326 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1327 | auto result = |
| 1328 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1342 | }; |
| 1343 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1344 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1345 | |
| 1346 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1347 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1355 | Manager::group ledsAssert{}; |
| 1356 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1357 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1358 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1359 | auto result = |
| 1360 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1361 | EXPECT_EQ(false, result); |
| 1362 | |
| 1363 | // Need just the ledsDeAsssert populated with these. |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1364 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1369 | }; |
| 1370 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1371 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 1377 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1378 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1379 | }; |
| 1380 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1381 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1382 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1383 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1384 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1385 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1386 | std::inserter(temp, temp.begin())); |
| 1387 | EXPECT_EQ(0, temp.size()); |
| 1388 | } |
| 1389 | } |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1390 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1391 | /** @brief Assert 2 groups having multiple LEDs common in different state and |
| 1392 | * mixed priority. DeAssert-B |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1393 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1394 | TEST_F( |
| 1395 | LedTest, |
| 1396 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityAandBDeAssertB) |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1397 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1398 | Manager manager(bus, |
| 1399 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1400 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1401 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1402 | Manager::group ledsAssert{}; |
| 1403 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1404 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1405 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1406 | auto result = |
| 1407 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1408 | EXPECT_EQ(true, result); |
| 1409 | |
| 1410 | // Need just the ledsAssserted populated with these. |
| 1411 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1422 | }; |
| 1423 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1424 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1425 | |
| 1426 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1427 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1435 | Manager::group ledsAssert{}; |
| 1436 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1437 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1438 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1439 | auto result = |
| 1440 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1454 | }; |
| 1455 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1456 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1457 | |
| 1458 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1459 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1467 | Manager::group ledsAssert{}; |
| 1468 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1469 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1470 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1471 | auto result = |
| 1472 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1473 | EXPECT_EQ(false, result); |
| 1474 | |
| 1475 | // Need just the ledsDeAsssert populated with these. |
| 1476 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 1489 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1490 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1491 | }; |
| 1492 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1493 | |
| 1494 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1495 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1506 | TEST_F(LedTest, |
| 1507 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1508 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1509 | Manager manager(bus, |
| 1510 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1511 | { |
| 1512 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1513 | Manager::group ledsAssert{}; |
| 1514 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1515 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1516 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1517 | auto result = |
| 1518 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1519 | EXPECT_EQ(true, result); |
| 1520 | |
| 1521 | // Need just the ledsAssserted populated with these. |
| 1522 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1533 | }; |
| 1534 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1535 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1536 | |
| 1537 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1538 | Manager::group temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1546 | Manager::group ledsAssert{}; |
| 1547 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1548 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1549 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1550 | auto result = |
| 1551 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1552 | EXPECT_EQ(true, result); |
| 1553 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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] |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1558 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1565 | }; |
| 1566 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1567 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1568 | |
| 1569 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1570 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1581 | TEST_F( |
| 1582 | LedTest, |
| 1583 | assertTwoGroupsWithMultipleComonLEDInDifferentStateDiffPriorityBandADeAssertA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1584 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1585 | Manager manager(bus, |
| 1586 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1587 | { |
| 1588 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1589 | Manager::group ledsAssert{}; |
| 1590 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1591 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1592 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1593 | auto result = |
| 1594 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1595 | EXPECT_EQ(true, result); |
| 1596 | |
| 1597 | // Need just the ledsAssserted populated with these. |
| 1598 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1609 | }; |
| 1610 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1611 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1612 | |
| 1613 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1614 | Manager::group temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 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 | { |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1621 | // Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1622 | Manager::group ledsAssert{}; |
| 1623 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1624 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1625 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1626 | auto result = |
| 1627 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1628 | EXPECT_EQ(true, result); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1629 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1641 | }; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1642 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1643 | EXPECT_EQ(0, ledsDeAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1644 | |
| 1645 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1646 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1647 | std::set_difference(ledsAssert.begin(), ledsAssert.end(), |
| 1648 | refAssert.begin(), refAssert.end(), |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1649 | std::inserter(temp, temp.begin())); |
| 1650 | EXPECT_EQ(0, temp.size()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1651 | } |
| 1652 | { |
| 1653 | // De-Assert Set-A |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1654 | Manager::group ledsAssert{}; |
| 1655 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1656 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1657 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1658 | auto result = |
| 1659 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1660 | EXPECT_EQ(false, result); |
| 1661 | |
| 1662 | // Need just the ledsAssserted populated with these. |
| 1663 | // [Ten] remains [Blink] due to priority. |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1664 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1669 | }; |
| 1670 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1671 | |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 1677 | {"Ten", phosphor::led::Layout::Action::On, 0, 0, |
| 1678 | phosphor::led::Layout::Action::Blink}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1679 | }; |
| 1680 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1681 | |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1682 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1683 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1694 | TEST_F(LedTest, |
| 1695 | assertTwoGroupsWithMultipleComonLEDInDifferentStateOnBlinkPriorityBandA) |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1696 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1697 | Manager manager(bus, |
| 1698 | twoGroupsWithMultipleComonLEDInDifferentStateDiffPriority); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1699 | { |
| 1700 | // Assert Set-B |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1701 | Manager::group ledsAssert{}; |
| 1702 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1703 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1704 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1705 | auto result = |
| 1706 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1707 | EXPECT_EQ(true, result); |
| 1708 | |
| 1709 | // Need just the ledsAssserted populated with these. |
| 1710 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1721 | }; |
| 1722 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1723 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1724 | |
| 1725 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1726 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1734 | Manager::group ledsAssert{}; |
| 1735 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1736 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1737 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1738 | auto result = |
| 1739 | manager.setGroupState(group, true, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1753 | }; |
| 1754 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1755 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1756 | |
| 1757 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1758 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1766 | Manager::group ledsAssert{}; |
| 1767 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1768 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1769 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1770 | auto result = |
| 1771 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1772 | EXPECT_EQ(false, result); |
| 1773 | |
| 1774 | // Need just the ledsAssserted populated with these. |
| 1775 | // [Ten] remains [Blink] due to priority. |
| 1776 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1781 | }; |
| 1782 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1783 | |
| 1784 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1785 | Manager::group temp{}; |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 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()); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1790 | |
| 1791 | // Need just the ledsAssert populated with these. |
| 1792 | // [Two] will move to [Blink] |
| 1793 | std::set<Layout::LedAction> refAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 1794 | {"Two", phosphor::led::Layout::Action::Blink, 0, 0, |
| 1795 | phosphor::led::Layout::Action::On}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1796 | }; |
| 1797 | EXPECT_EQ(refAssert.size(), ledsAssert.size()); |
| 1798 | |
| 1799 | // difference of refAssert and ledsAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1800 | Manager::group temp1{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1808 | Manager::group ledsAssert{}; |
| 1809 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1810 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1811 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsASet"; |
| 1812 | auto result = |
| 1813 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1814 | EXPECT_EQ(false, result); |
| 1815 | |
| 1816 | // Need just the ledsAssserted populated with these. |
| 1817 | std::set<Layout::LedAction> refDeAssert = { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame^] | 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}, |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1828 | }; |
| 1829 | EXPECT_EQ(refDeAssert.size(), ledsDeAssert.size()); |
| 1830 | EXPECT_EQ(0, ledsAssert.size()); |
| 1831 | |
| 1832 | // difference of refDeAssert and ledsDeAssert must be null. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1833 | Manager::group temp{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 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 |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1841 | Manager::group ledsAssert{}; |
| 1842 | Manager::group ledsDeAssert{}; |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1843 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1844 | auto group = "/xyz/openbmc_project/ledmanager/groups/MultipleLedsBSet"; |
| 1845 | auto result = |
| 1846 | manager.setGroupState(group, false, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 1847 | EXPECT_EQ(false, result); |
| 1848 | EXPECT_EQ(0, ledsDeAssert.size()); |
| 1849 | EXPECT_EQ(0, ledsAssert.size()); |
Vishwanatha Subbanna | cd569d2 | 2017-05-03 12:46:14 +0530 | [diff] [blame] | 1850 | } |
| 1851 | } |