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