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