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